diff --git a/assets/AgentLogos-j-Qekw7T.js b/assets/AgentLogos-xoTIu0NB.js similarity index 99% rename from assets/AgentLogos-j-Qekw7T.js rename to assets/AgentLogos-xoTIu0NB.js index 419afe23ed61aefb0de35cd00fd33a38babb344f..8e3fce7c22d7ffffc7337c1109dd3e557409b6d4 100644 --- a/assets/AgentLogos-j-Qekw7T.js +++ b/assets/AgentLogos-xoTIu0NB.js @@ -1 +1 @@ -import{j as e}from"./index-DyXq7-Tg.js";const s="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='256'%20height='257'%20preserveAspectRatio='xMidYMid'%20viewBox='0%200%20256%20257'%3e%3cpath%20fill='%23D97757'%20d='m50.228%20170.321%2050.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0%20125.796l.583-3.759%205.12-3.434%207.324.648%2016.202%201.101%2024.304%201.685%2017.629%201.037%2026.118%202.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758%207-7.713%209.397.649%202.398.648%209.527%207.323%2020.35%2015.75L94.817%2091.9l3.889%203.24%201.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42%200%2082.05%201.426l4.472%203.888%206.61%2015.101%2010.694%2023.786%2016.591%2032.34%204.861%209.592%202.592%208.879.973%202.722h1.685v-1.556l1.36-18.211%202.528-22.36%202.463-28.776.843-8.1%204.018-9.722%207.971-5.25%206.222%202.981%205.12%207.324-.713%204.73-3.046%2019.768-5.962%2030.98-3.889%2020.739h2.268l2.593-2.593%2010.499-13.934%2017.628-22.036%207.778-8.749%209.073-9.657%205.833-4.601h11.018l8.1%2012.055-3.628%2012.443-11.342%2014.388-9.398%2012.184-13.48%2018.147-8.426%2014.518.778%201.166%202.01-.194%2030.46-6.481%2016.462-2.982%2019.637-3.37%208.88%204.148.971%204.213-3.5%208.62-20.998%205.184-24.628%204.926-36.682%208.685-.454.324.519.648%2016.526%201.555%207.065.389h17.304l32.21%202.398%208.426%205.574%205.055%206.805-.843%205.184-12.962%206.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666%2011.406%2021.387%2019.314%2026.767%2024.887%201.36%206.157-3.434%204.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73%206.935%2025.017%2037.59%201.296%2011.536-1.814%203.76-6.481%202.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194%2077.448-3.37%203.953-7.778%202.981-6.48-4.925-3.436-7.972%203.435-15.749%204.148-20.544%203.37-16.333%203.046-20.285%201.815-6.74-.13-.454-1.49.194-15.295%2020.999-23.267%2031.433-18.406%2019.702-4.407%201.75-7.648-3.954.713-7.064%204.277-6.286%2025.47-32.405%2015.36-20.092%209.917-11.6-.065-1.686h-.583L44.07%20198.125l-12.055%201.555-5.185-4.86.648-7.972%202.463-2.593%2020.35-13.999-.064.065Z'/%3e%3c/svg%3e",a="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='256'%20height='257'%20preserveAspectRatio='xMidYMid'%20viewBox='0%200%20256%20257'%3e%3cpath%20fill='%23D97757'%20d='m50.228%20170.321%2050.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0%20125.796l.583-3.759%205.12-3.434%207.324.648%2016.202%201.101%2024.304%201.685%2017.629%201.037%2026.118%202.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758%207-7.713%209.397.649%202.398.648%209.527%207.323%2020.35%2015.75L94.817%2091.9l3.889%203.24%201.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42%200%2082.05%201.426l4.472%203.888%206.61%2015.101%2010.694%2023.786%2016.591%2032.34%204.861%209.592%202.592%208.879.973%202.722h1.685v-1.556l1.36-18.211%202.528-22.36%202.463-28.776.843-8.1%204.018-9.722%207.971-5.25%206.222%202.981%205.12%207.324-.713%204.73-3.046%2019.768-5.962%2030.98-3.889%2020.739h2.268l2.593-2.593%2010.499-13.934%2017.628-22.036%207.778-8.749%209.073-9.657%205.833-4.601h11.018l8.1%2012.055-3.628%2012.443-11.342%2014.388-9.398%2012.184-13.48%2018.147-8.426%2014.518.778%201.166%202.01-.194%2030.46-6.481%2016.462-2.982%2019.637-3.37%208.88%204.148.971%204.213-3.5%208.62-20.998%205.184-24.628%204.926-36.682%208.685-.454.324.519.648%2016.526%201.555%207.065.389h17.304l32.21%202.398%208.426%205.574%205.055%206.805-.843%205.184-12.962%206.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666%2011.406%2021.387%2019.314%2026.767%2024.887%201.36%206.157-3.434%204.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73%206.935%2025.017%2037.59%201.296%2011.536-1.814%203.76-6.481%202.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194%2077.448-3.37%203.953-7.778%202.981-6.48-4.925-3.436-7.972%203.435-15.749%204.148-20.544%203.37-16.333%203.046-20.285%201.815-6.74-.13-.454-1.49.194-15.295%2020.999-23.267%2031.433-18.406%2019.702-4.407%201.75-7.648-3.954.713-7.064%204.277-6.286%2025.47-32.405%2015.36-20.092%209.917-11.6-.065-1.686h-.583L44.07%20198.125l-12.055%201.555-5.185-4.86.648-7.972%202.463-2.593%2020.35-13.999-.064.065Z'/%3e%3c/svg%3e",h="data:image/svg+xml,%3csvg%20fill='%23111'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M8.086.457a6.105%206.105%200%20013.046-.415c1.333.153%202.521.72%203.564%201.7a.117.117%200%2000.107.029c1.408-.346%202.762-.224%204.061.366l.063.03.154.076c1.357.703%202.33%201.77%202.918%203.198.278.679.418%201.388.421%202.126a5.655%205.655%200%2001-.18%201.631.167.167%200%2000.04.155%205.982%205.982%200%20011.578%202.891c.385%201.901-.01%203.615-1.183%205.14l-.182.22a6.063%206.063%200%2001-2.934%201.851.162.162%200%2000-.108.102c-.255.736-.511%201.364-.987%201.992-1.199%201.582-2.962%202.462-4.948%202.451-1.583-.008-2.986-.587-4.21-1.736a.145.145%200%2000-.14-.032c-.518.167-1.04.191-1.604.185a5.924%205.924%200%2001-2.595-.622%206.058%206.058%200%2001-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74%207.74%200%2001-.495-1.283%206.11%206.11%200%2001-.017-3.064.166.166%200%2000.008-.074.115.115%200%2000-.037-.064%205.958%205.958%200%2001-1.38-2.202%205.196%205.196%200%2001-.333-1.589%206.915%206.915%200%2001.188-2.132c.45-1.484%201.309-2.648%202.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129%200%2000.087-.087A6.016%206.016%200%20015.635%202.31C6.315%201.464%207.132.846%208.086.457zm-.804%207.85a.848.848%200%2000-1.473.842l1.694%202.965-1.688%202.848a.849.849%200%20001.46.864l1.94-3.272a.849.849%200%2000.007-.854l-1.94-3.393zm5.446%206.24a.849.849%200%20000%201.695h4.848a.849.849%200%20000-1.696h-4.848z'%3e%3c/path%3e%3c/svg%3e",o="data:image/svg+xml,%3csvg%20fill='%23fff'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M8.086.457a6.105%206.105%200%20013.046-.415c1.333.153%202.521.72%203.564%201.7a.117.117%200%2000.107.029c1.408-.346%202.762-.224%204.061.366l.063.03.154.076c1.357.703%202.33%201.77%202.918%203.198.278.679.418%201.388.421%202.126a5.655%205.655%200%2001-.18%201.631.167.167%200%2000.04.155%205.982%205.982%200%20011.578%202.891c.385%201.901-.01%203.615-1.183%205.14l-.182.22a6.063%206.063%200%2001-2.934%201.851.162.162%200%2000-.108.102c-.255.736-.511%201.364-.987%201.992-1.199%201.582-2.962%202.462-4.948%202.451-1.583-.008-2.986-.587-4.21-1.736a.145.145%200%2000-.14-.032c-.518.167-1.04.191-1.604.185a5.924%205.924%200%2001-2.595-.622%206.058%206.058%200%2001-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74%207.74%200%2001-.495-1.283%206.11%206.11%200%2001-.017-3.064.166.166%200%2000.008-.074.115.115%200%2000-.037-.064%205.958%205.958%200%2001-1.38-2.202%205.196%205.196%200%2001-.333-1.589%206.915%206.915%200%2001.188-2.132c.45-1.484%201.309-2.648%202.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129%200%2000.087-.087A6.016%206.016%200%20015.635%202.31C6.315%201.464%207.132.846%208.086.457zm-.804%207.85a.848.848%200%2000-1.473.842l1.694%202.965-1.688%202.848a.849.849%200%20001.46.864l1.94-3.272a.849.849%200%2000.007-.854l-1.94-3.393zm5.446%206.24a.849.849%200%20000%201.695h4.848a.849.849%200%20000-1.696h-4.848z'%3e%3c/path%3e%3c/svg%3e",r="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='cursor_light__Ebene_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20466.73%20532.09'%3e%3c!--Generator:%20Adobe%20Illustrator%2029.6.1,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%209)--%3e%3cdefs%3e%3cstyle%3e.cursor_light__st0{fill:%2326251e}%3c/style%3e%3c/defs%3e%3cpath%20class='cursor_light__st0'%20d='M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z'/%3e%3c/svg%3e",d="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='cursor_dark__Ebene_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20466.73%20532.09'%3e%3c!--Generator:%20Adobe%20Illustrator%2029.6.1,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%209)--%3e%3cdefs%3e%3cstyle%3e.cursor_dark__st0{fill:%23edecec}%3c/style%3e%3c/defs%3e%3cpath%20class='cursor_dark__st0'%20d='M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z'/%3e%3c/svg%3e",n="data:image/svg+xml,%3csvg%20width='512'%20height='512'%20viewBox='0%200%20512%20512'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='512'%20height='512'%20fill='%23FDFCFC'/%3e%3cpath%20d='M320%20224V352H192V224H320Z'%20fill='%23E6E5E6'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M384%20416H128V96H384V416ZM320%20160H192V352H320V160Z'%20fill='%2317181C'/%3e%3c/svg%3e",g="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='512'%20height='512'%3e%3csvg%20width='512'%20height='512'%20viewBox='0%200%20512%20512'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='512'%20height='512'%20fill='%23131010'%3e%3c/rect%3e%3cpath%20d='M320%20224V352H192V224H320Z'%20fill='%235A5858'%3e%3c/path%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M384%20416H128V96H384V416ZM320%20160H192V352H320V160Z'%20fill='white'%3e%3c/path%3e%3c/svg%3e%3cstyle%3e@media%20(prefers-color-scheme:%20light)%20{%20:root%20{%20filter:%20none;%20}%20}%20@media%20(prefers-color-scheme:%20dark)%20{%20:root%20{%20filter:%20none;%20}%20}%20%3c/style%3e%3c/svg%3e",i=[{name:"Claude",light:s,dark:a},{name:"Codex",light:h,dark:o},{name:"Cursor",light:r,dark:d},{name:"OpenCode",light:n,dark:g}];function w(){return e.jsx("span",{className:"ml-1 inline-flex shrink-0 items-center gap-1.5","aria-hidden":"true",children:i.map(({name:l,light:t,dark:c})=>e.jsxs("span",{title:l,className:"inline-flex h-[18px] w-[18px]",children:[e.jsx("img",{src:t,alt:"",width:18,height:18,className:"h-full w-full object-contain dark:hidden"}),e.jsx("img",{src:c,alt:"",width:18,height:18,className:"hidden h-full w-full object-contain dark:block"})]},l))})}function m(){return e.jsx("ul",{className:"flex flex-wrap gap-2","aria-label":"Supported coding agents",children:i.map(({name:l,light:t,dark:c})=>e.jsxs("li",{className:"inline-flex items-center gap-2 rounded-full border px-3 py-1 text-sm",children:[e.jsx("img",{src:t,alt:"",width:18,height:18,className:"h-[18px] w-[18px] object-contain dark:hidden"}),e.jsx("img",{src:c,alt:"",width:18,height:18,className:"hidden h-[18px] w-[18px] object-contain dark:block"}),l]},l))})}export{w as A,m as a}; +import{j as e}from"./index-CjdUkE4w.js";const s="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='256'%20height='257'%20preserveAspectRatio='xMidYMid'%20viewBox='0%200%20256%20257'%3e%3cpath%20fill='%23D97757'%20d='m50.228%20170.321%2050.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0%20125.796l.583-3.759%205.12-3.434%207.324.648%2016.202%201.101%2024.304%201.685%2017.629%201.037%2026.118%202.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758%207-7.713%209.397.649%202.398.648%209.527%207.323%2020.35%2015.75L94.817%2091.9l3.889%203.24%201.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42%200%2082.05%201.426l4.472%203.888%206.61%2015.101%2010.694%2023.786%2016.591%2032.34%204.861%209.592%202.592%208.879.973%202.722h1.685v-1.556l1.36-18.211%202.528-22.36%202.463-28.776.843-8.1%204.018-9.722%207.971-5.25%206.222%202.981%205.12%207.324-.713%204.73-3.046%2019.768-5.962%2030.98-3.889%2020.739h2.268l2.593-2.593%2010.499-13.934%2017.628-22.036%207.778-8.749%209.073-9.657%205.833-4.601h11.018l8.1%2012.055-3.628%2012.443-11.342%2014.388-9.398%2012.184-13.48%2018.147-8.426%2014.518.778%201.166%202.01-.194%2030.46-6.481%2016.462-2.982%2019.637-3.37%208.88%204.148.971%204.213-3.5%208.62-20.998%205.184-24.628%204.926-36.682%208.685-.454.324.519.648%2016.526%201.555%207.065.389h17.304l32.21%202.398%208.426%205.574%205.055%206.805-.843%205.184-12.962%206.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666%2011.406%2021.387%2019.314%2026.767%2024.887%201.36%206.157-3.434%204.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73%206.935%2025.017%2037.59%201.296%2011.536-1.814%203.76-6.481%202.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194%2077.448-3.37%203.953-7.778%202.981-6.48-4.925-3.436-7.972%203.435-15.749%204.148-20.544%203.37-16.333%203.046-20.285%201.815-6.74-.13-.454-1.49.194-15.295%2020.999-23.267%2031.433-18.406%2019.702-4.407%201.75-7.648-3.954.713-7.064%204.277-6.286%2025.47-32.405%2015.36-20.092%209.917-11.6-.065-1.686h-.583L44.07%20198.125l-12.055%201.555-5.185-4.86.648-7.972%202.463-2.593%2020.35-13.999-.064.065Z'/%3e%3c/svg%3e",a="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='256'%20height='257'%20preserveAspectRatio='xMidYMid'%20viewBox='0%200%20256%20257'%3e%3cpath%20fill='%23D97757'%20d='m50.228%20170.321%2050.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0%20125.796l.583-3.759%205.12-3.434%207.324.648%2016.202%201.101%2024.304%201.685%2017.629%201.037%2026.118%202.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758%207-7.713%209.397.649%202.398.648%209.527%207.323%2020.35%2015.75L94.817%2091.9l3.889%203.24%201.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42%200%2082.05%201.426l4.472%203.888%206.61%2015.101%2010.694%2023.786%2016.591%2032.34%204.861%209.592%202.592%208.879.973%202.722h1.685v-1.556l1.36-18.211%202.528-22.36%202.463-28.776.843-8.1%204.018-9.722%207.971-5.25%206.222%202.981%205.12%207.324-.713%204.73-3.046%2019.768-5.962%2030.98-3.889%2020.739h2.268l2.593-2.593%2010.499-13.934%2017.628-22.036%207.778-8.749%209.073-9.657%205.833-4.601h11.018l8.1%2012.055-3.628%2012.443-11.342%2014.388-9.398%2012.184-13.48%2018.147-8.426%2014.518.778%201.166%202.01-.194%2030.46-6.481%2016.462-2.982%2019.637-3.37%208.88%204.148.971%204.213-3.5%208.62-20.998%205.184-24.628%204.926-36.682%208.685-.454.324.519.648%2016.526%201.555%207.065.389h17.304l32.21%202.398%208.426%205.574%205.055%206.805-.843%205.184-12.962%206.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666%2011.406%2021.387%2019.314%2026.767%2024.887%201.36%206.157-3.434%204.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73%206.935%2025.017%2037.59%201.296%2011.536-1.814%203.76-6.481%202.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194%2077.448-3.37%203.953-7.778%202.981-6.48-4.925-3.436-7.972%203.435-15.749%204.148-20.544%203.37-16.333%203.046-20.285%201.815-6.74-.13-.454-1.49.194-15.295%2020.999-23.267%2031.433-18.406%2019.702-4.407%201.75-7.648-3.954.713-7.064%204.277-6.286%2025.47-32.405%2015.36-20.092%209.917-11.6-.065-1.686h-.583L44.07%20198.125l-12.055%201.555-5.185-4.86.648-7.972%202.463-2.593%2020.35-13.999-.064.065Z'/%3e%3c/svg%3e",h="data:image/svg+xml,%3csvg%20fill='%23111'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M8.086.457a6.105%206.105%200%20013.046-.415c1.333.153%202.521.72%203.564%201.7a.117.117%200%2000.107.029c1.408-.346%202.762-.224%204.061.366l.063.03.154.076c1.357.703%202.33%201.77%202.918%203.198.278.679.418%201.388.421%202.126a5.655%205.655%200%2001-.18%201.631.167.167%200%2000.04.155%205.982%205.982%200%20011.578%202.891c.385%201.901-.01%203.615-1.183%205.14l-.182.22a6.063%206.063%200%2001-2.934%201.851.162.162%200%2000-.108.102c-.255.736-.511%201.364-.987%201.992-1.199%201.582-2.962%202.462-4.948%202.451-1.583-.008-2.986-.587-4.21-1.736a.145.145%200%2000-.14-.032c-.518.167-1.04.191-1.604.185a5.924%205.924%200%2001-2.595-.622%206.058%206.058%200%2001-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74%207.74%200%2001-.495-1.283%206.11%206.11%200%2001-.017-3.064.166.166%200%2000.008-.074.115.115%200%2000-.037-.064%205.958%205.958%200%2001-1.38-2.202%205.196%205.196%200%2001-.333-1.589%206.915%206.915%200%2001.188-2.132c.45-1.484%201.309-2.648%202.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129%200%2000.087-.087A6.016%206.016%200%20015.635%202.31C6.315%201.464%207.132.846%208.086.457zm-.804%207.85a.848.848%200%2000-1.473.842l1.694%202.965-1.688%202.848a.849.849%200%20001.46.864l1.94-3.272a.849.849%200%2000.007-.854l-1.94-3.393zm5.446%206.24a.849.849%200%20000%201.695h4.848a.849.849%200%20000-1.696h-4.848z'%3e%3c/path%3e%3c/svg%3e",o="data:image/svg+xml,%3csvg%20fill='%23fff'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M8.086.457a6.105%206.105%200%20013.046-.415c1.333.153%202.521.72%203.564%201.7a.117.117%200%2000.107.029c1.408-.346%202.762-.224%204.061.366l.063.03.154.076c1.357.703%202.33%201.77%202.918%203.198.278.679.418%201.388.421%202.126a5.655%205.655%200%2001-.18%201.631.167.167%200%2000.04.155%205.982%205.982%200%20011.578%202.891c.385%201.901-.01%203.615-1.183%205.14l-.182.22a6.063%206.063%200%2001-2.934%201.851.162.162%200%2000-.108.102c-.255.736-.511%201.364-.987%201.992-1.199%201.582-2.962%202.462-4.948%202.451-1.583-.008-2.986-.587-4.21-1.736a.145.145%200%2000-.14-.032c-.518.167-1.04.191-1.604.185a5.924%205.924%200%2001-2.595-.622%206.058%206.058%200%2001-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74%207.74%200%2001-.495-1.283%206.11%206.11%200%2001-.017-3.064.166.166%200%2000.008-.074.115.115%200%2000-.037-.064%205.958%205.958%200%2001-1.38-2.202%205.196%205.196%200%2001-.333-1.589%206.915%206.915%200%2001.188-2.132c.45-1.484%201.309-2.648%202.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129%200%2000.087-.087A6.016%206.016%200%20015.635%202.31C6.315%201.464%207.132.846%208.086.457zm-.804%207.85a.848.848%200%2000-1.473.842l1.694%202.965-1.688%202.848a.849.849%200%20001.46.864l1.94-3.272a.849.849%200%2000.007-.854l-1.94-3.393zm5.446%206.24a.849.849%200%20000%201.695h4.848a.849.849%200%20000-1.696h-4.848z'%3e%3c/path%3e%3c/svg%3e",r="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='cursor_light__Ebene_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20466.73%20532.09'%3e%3c!--Generator:%20Adobe%20Illustrator%2029.6.1,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%209)--%3e%3cdefs%3e%3cstyle%3e.cursor_light__st0{fill:%2326251e}%3c/style%3e%3c/defs%3e%3cpath%20class='cursor_light__st0'%20d='M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z'/%3e%3c/svg%3e",d="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='cursor_dark__Ebene_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20466.73%20532.09'%3e%3c!--Generator:%20Adobe%20Illustrator%2029.6.1,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%209)--%3e%3cdefs%3e%3cstyle%3e.cursor_dark__st0{fill:%23edecec}%3c/style%3e%3c/defs%3e%3cpath%20class='cursor_dark__st0'%20d='M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z'/%3e%3c/svg%3e",n="data:image/svg+xml,%3csvg%20width='512'%20height='512'%20viewBox='0%200%20512%20512'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='512'%20height='512'%20fill='%23FDFCFC'/%3e%3cpath%20d='M320%20224V352H192V224H320Z'%20fill='%23E6E5E6'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M384%20416H128V96H384V416ZM320%20160H192V352H320V160Z'%20fill='%2317181C'/%3e%3c/svg%3e",g="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='512'%20height='512'%3e%3csvg%20width='512'%20height='512'%20viewBox='0%200%20512%20512'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='512'%20height='512'%20fill='%23131010'%3e%3c/rect%3e%3cpath%20d='M320%20224V352H192V224H320Z'%20fill='%235A5858'%3e%3c/path%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M384%20416H128V96H384V416ZM320%20160H192V352H320V160Z'%20fill='white'%3e%3c/path%3e%3c/svg%3e%3cstyle%3e@media%20(prefers-color-scheme:%20light)%20{%20:root%20{%20filter:%20none;%20}%20}%20@media%20(prefers-color-scheme:%20dark)%20{%20:root%20{%20filter:%20none;%20}%20}%20%3c/style%3e%3c/svg%3e",i=[{name:"Claude",light:s,dark:a},{name:"Codex",light:h,dark:o},{name:"Cursor",light:r,dark:d},{name:"OpenCode",light:n,dark:g}];function w(){return e.jsx("span",{className:"ml-1 inline-flex shrink-0 items-center gap-1.5","aria-hidden":"true",children:i.map(({name:l,light:t,dark:c})=>e.jsxs("span",{title:l,className:"inline-flex h-[18px] w-[18px]",children:[e.jsx("img",{src:t,alt:"",width:18,height:18,className:"h-full w-full object-contain dark:hidden"}),e.jsx("img",{src:c,alt:"",width:18,height:18,className:"hidden h-full w-full object-contain dark:block"})]},l))})}function m(){return e.jsx("ul",{className:"flex flex-wrap gap-2","aria-label":"Supported coding agents",children:i.map(({name:l,light:t,dark:c})=>e.jsxs("li",{className:"inline-flex items-center gap-2 rounded-full border px-3 py-1 text-sm",children:[e.jsx("img",{src:t,alt:"",width:18,height:18,className:"h-[18px] w-[18px] object-contain dark:hidden"}),e.jsx("img",{src:c,alt:"",width:18,height:18,className:"hidden h-[18px] w-[18px] object-contain dark:block"}),l]},l))})}export{w as A,m as a}; diff --git a/assets/AiDeadlinesView--bEB1R4q.js b/assets/AiDeadlinesView-Dh-TYdum.js similarity index 96% rename from assets/AiDeadlinesView--bEB1R4q.js rename to assets/AiDeadlinesView-Dh-TYdum.js index ce5c4c9a01bf7c81c75de7d1fda1b2f2a8695ec0..2bad95ac432488e0d7c63fc1e3d9e9de6e02dba6 100644 --- a/assets/AiDeadlinesView--bEB1R4q.js +++ b/assets/AiDeadlinesView-Dh-TYdum.js @@ -1,3 +1,3 @@ -import{d as g,j as t,b as R,T as A}from"./index-DyXq7-Tg.js";import{c as L}from"./catalog-CRar2olQ.js";import{S as B}from"./switch-nfvTohnt.js";import{S as U}from"./skeleton-C3IIzpSL.js";import{A as W,a as M}from"./alert-gbJBhAVE.js";import{s as $}from"./safeExternalHref-CkBrsh84.js";import{D as O,a as V,c as P,b as G,d as H}from"./dialog-CfM0Uql2.js";import{s as K,n as S,f as _,p as Y,u as N,l as k,a as I,c as b,D as q,b as z,d as Q}from"./deadlines-BH32v7D1.js";import"./index-C041TDos.js";const w={fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--ink-faint)"},J=(e,l)=>{const s=Math.ceil((e-l)/q);return s<=0?"passed":`${s} ${s===1?"day":"days"}`},F=(e,l)=>{const s=_(e.start_date,e.end_date),r=e.venue||[e.city,e.country].filter(Boolean).join(", ");return[`${l.label||l.type||"Deadline"} for ${e.name}`,s?`Dates: ${s}`:null,r?`Location: ${r}`:null,e.url?`Website: ${e.url}`:null].filter(Boolean).join(` +import{d as g,j as t,b as R,T as A}from"./index-CjdUkE4w.js";import{c as L}from"./catalog-qXcKve0z.js";import{S as B}from"./switch-hcLL2FH0.js";import{S as U}from"./skeleton-DTWi7Ctg.js";import{A as W,a as M}from"./alert-BM9Xfuyy.js";import{s as $}from"./safeExternalHref-CkBrsh84.js";import{D as O,a as V,c as P,b as G,d as H}from"./dialog-BzX9PD3v.js";import{s as K,n as S,f as _,p as Y,u as N,l as k,a as I,c as b,D as q,b as z,d as Q}from"./deadlines-BH32v7D1.js";import"./index-BxR27SAB.js";const w={fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--ink-faint)"},J=(e,l)=>{const s=Math.ceil((e-l)/q);return s<=0?"passed":`${s} ${s===1?"day":"days"}`},F=(e,l)=>{const s=_(e.start_date,e.end_date),r=e.venue||[e.city,e.country].filter(Boolean).join(", ");return[`${l.label||l.type||"Deadline"} for ${e.name}`,s?`Dates: ${s}`:null,r?`Location: ${r}`:null,e.url?`Website: ${e.url}`:null].filter(Boolean).join(` `)},C=e=>e.toISOString().replace(/[-:]/g,"").replace(/\.\d{3}/,""),X=(e,l)=>{const s=new Date(l.deadline_at),r=new Date(s.getTime()+60*60*1e3),o=`${e.short_name||e.name} ${l.label||l.type||"deadline"}`,h=e.venue||[e.city,e.country].filter(Boolean).join(", "),n=`https://calendar.google.com/calendar/render?action=TEMPLATE&text=${encodeURIComponent(o)}&dates=${C(s)}/${C(r)}&details=${encodeURIComponent(F(e,l))}&location=${encodeURIComponent(h)}`,p=$(n);p&&window.open(p,"_blank","noopener,noreferrer")},Z=(e,l)=>{const s=new Date(l.deadline_at),r=new Date(s.getTime()+60*60*1e3),o=`${e.short_name||e.name} ${l.label||l.type||"deadline"}`,h=e.venue||[e.city,e.country].filter(Boolean).join(", "),n=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",e.url?`URL:${e.url}`:null,`DTSTART:${C(s)}`,`DTEND:${C(r)}`,`SUMMARY:${o}`,`DESCRIPTION:${F(e,l).replace(/\n/g,"\\n")}`,h?`LOCATION:${h}`:null,"END:VEVENT","END:VCALENDAR"].filter(Boolean).join(` `),p=new Blob([n],{type:"text/calendar;charset=utf-8"}),d=document.createElement("a");d.href=URL.createObjectURL(p),d.download=`${(e.short_name||e.name).toLowerCase().replace(/\s+/g,"-")}-deadline.ics`,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(d.href)},ee=({conf:e,open:l,onOpenChange:s})=>{const[r,o]=g.useState(()=>Date.now());g.useEffect(()=>{if(!l)return;o(Date.now());const i=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(i)},[l]);const h=g.useMemo(()=>e?K(e):[],[e]),n=g.useMemo(()=>e?S(e,r):null,[e,r]),p=e?_(e.start_date,e.end_date):null,d=e?e.venue||[e.city,e.country].filter(Boolean).join(", ")||e.location:null,m=n?new Date(n.deadline_at).getTime():null;return t.jsx(O,{open:l,onOpenChange:s,children:t.jsx(V,{className:"max-w-xl",style:{background:"var(--bg-elevated)",maxHeight:"85vh",overflowY:"auto"},children:e&&t.jsxs(t.Fragment,{children:[t.jsxs(P,{children:[t.jsx(G,{asChild:!0,children:t.jsx("h2",{style:{fontFamily:"var(--serif)",fontSize:26,fontWeight:500,letterSpacing:"-0.01em",margin:0},children:e.short_name?`${e.short_name} ${e.year??""}`.trim():e.name})}),e.short_name&&e.name||e.description?t.jsx(H,{asChild:!0,children:t.jsx("span",{style:{fontFamily:"var(--serif)",fontSize:14,color:"var(--ink-soft)"},children:e.short_name?e.name:e.description})}):null]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20,marginTop:4},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:24},children:[p&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsx("span",{style:w,children:"Dates"}),t.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:13,color:"var(--ink-soft)"},children:p})]}),d&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsx("span",{style:w,children:"Venue"}),t.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:13,color:"var(--ink-soft)"},children:d})]})]}),m!=null&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"12px 14px",borderRadius:8,background:"var(--bg-subtle)",border:"1px solid var(--hairline)"},children:[t.jsx("span",{style:w,children:"Next deadline in"}),t.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:22,fontWeight:600,color:N(m,r)},children:Y(m,r)})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("span",{style:w,children:"Important deadlines"}),h.length===0?t.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:13,color:"var(--ink-faint)"},children:"No deadlines listed"}):h.map((i,c)=>{const y=new Date(i.deadline_at).getTime(),a=n!=null&&i.deadline_at===n.deadline_at&&i.type===n.type,u=y<=r;return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,padding:"8px 12px",borderRadius:6,background:a?"var(--accent-soft)":"transparent",border:a?"1px solid var(--hairline-strong)":"1px solid var(--hairline)",opacity:u&&!a?.55:1},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:13,color:"var(--ink)",fontWeight:a?600:400},children:[i.label||k(i.type||"deadline"),a&&t.jsx("span",{style:{...w,marginLeft:8},children:"Next"})]}),t.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:12,color:"var(--ink-faint)"},children:[I(i.deadline_at),i.timezone?` · ${i.timezone}`:""]})]}),t.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:12,fontWeight:600,whiteSpace:"nowrap",color:N(u?null:y,r)},children:J(y,r)})]},`${i.type??"deadline"}-${c}`)})]}),b(e).length>0&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:b(e).map(i=>t.jsx("span",{className:"tag-chip",style:{background:"var(--bg-subtle)",color:"var(--ink-soft)"},children:k(i)},i))}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:16,paddingTop:12,borderTop:"1px solid var(--hairline)"},children:[e.url&&t.jsx("a",{href:$(e.url)??void 0,target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"var(--mono)",fontSize:12,color:"var(--accent-text)"},children:"Visit website ↗"}),n&&t.jsxs("div",{style:{display:"flex",gap:12,marginLeft:"auto"},children:[t.jsx("button",{type:"button",className:"tag-chip",onClick:()=>X(e,n),style:{background:"var(--bg-subtle)",color:"var(--ink-soft)"},children:"+ Google Calendar"}),t.jsx("button",{type:"button",className:"tag-chip",onClick:()=>Z(e,n),style:{background:"var(--bg-subtle)",color:"var(--ink-soft)"},children:"+ Apple / .ics"})]})]})]})]})})})},E=({id:e,label:l,checked:s,onChange:r})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--mono)",fontSize:12,color:"var(--ink-soft)"},children:[t.jsx(B,{id:e,checked:s,onCheckedChange:r}),t.jsx("label",{htmlFor:e,style:{cursor:"pointer"},children:l})]}),te=({conf:e,now:l,selectedDomains:s,onToggleDomain:r,onOpen:o})=>{const h=S(e,l),n=h??z(e),p=n?new Date(n.deadline_at).getTime():null,d=N(h?p:null,l),m=_(e.start_date,e.end_date),i=[e.city??null,e.country??null].filter(Boolean).join(", ");return t.jsxs("div",{role:"button",tabIndex:0,onClick:()=>o(e),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),o(e))},style:{border:"1px solid var(--hairline)",borderRadius:8,padding:20,background:"var(--bg-elevated)",display:"flex",flexDirection:"column",gap:12,cursor:"pointer"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:12},children:[t.jsx("h3",{style:{fontFamily:"var(--serif)",fontSize:20,fontWeight:500,letterSpacing:"-0.01em",margin:0},children:e.short_name?`${e.short_name} ${e.year??""}`.trim():e.name}),e.url&&t.jsx("a",{href:$(e.url)??void 0,target:"_blank",rel:"noopener noreferrer",onClick:c=>c.stopPropagation(),style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--accent-text)",whiteSpace:"nowrap"},children:"website ↗"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,paddingBottom:12,borderBottom:"1px solid var(--hairline)"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink-faint)"},children:(n==null?void 0:n.label)||(n==null?void 0:n.type)||"Deadline"}),t.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:12,color:"var(--ink-soft)"},children:n?`${I(n.deadline_at)}${n.timezone?` · ${n.timezone}`:""}`:"TBD"})]}),t.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:14,fontWeight:600,color:d,whiteSpace:"nowrap"},children:p!=null?Q(p,l):"TBD"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,fontFamily:"var(--mono)",fontSize:11,color:"var(--ink-faint)"},children:[m&&t.jsx("span",{children:m}),i&&t.jsx("span",{children:i})]}),b(e).length>0&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:b(e).map(c=>{const y=s.has(c);return t.jsx("button",{className:"tag-chip",onClick:a=>{a.stopPropagation(),r(c)},style:{background:y?"var(--ink)":"var(--bg-subtle)",color:y?"var(--bg)":"var(--ink-soft)"},children:k(c)},c)})})]})},pe=()=>{const[e,l]=g.useState(!0),[s,r]=g.useState(!1),[o,h]=g.useState(new Set),[n,p]=g.useState(null),d=g.useMemo(()=>Date.now(),[]),m=R({queryKey:["conference-deadlines"],queryFn:()=>L.conferenceDeadlines(),staleTime:A}),i=a=>{h(u=>{const x=new Set(u);return x.has(a)?x.delete(a):x.add(a),x})},c=g.useMemo(()=>{var u;const a=new Map;return(u=m.data)==null||u.results.forEach(x=>{b(x).forEach(j=>a.set(j,(a.get(j)??0)+1))}),Array.from(a.entries()).sort((x,j)=>j[1]-x[1]).map(([x])=>x)},[m.data]),y=g.useMemo(()=>{var j;const u=(((j=m.data)==null?void 0:j.results)??[]).filter(f=>!(e&&f.tier!=="a"||o.size>0&&!b(f).some(v=>o.has(v))||!s&&!S(f,d))),x=f=>{const D=S(f,d);if(D)return{group:0,time:new Date(D.deadline_at).getTime()};const v=z(f);return{group:1,time:-(v?new Date(v.deadline_at).getTime():0)}};return[...u].sort((f,D)=>{const v=x(f),T=x(D);return v.group!==T.group?v.group-T.group:v.time-T.time})},[m.data,e,s,o,d]);return m.error?t.jsx("div",{className:"page",children:t.jsx(W,{variant:"destructive",children:t.jsx(M,{children:"Failed to load conference deadlines. Please try again."})})}):t.jsxs("div",{className:"page",children:[t.jsx("div",{className:"feed-header",children:t.jsxs("div",{children:[t.jsxs("h1",{className:"feed-title",children:["AI Conference ",t.jsx("em",{children:"Deadlines"})]}),t.jsx("div",{className:"feed-subtitle",children:"Upcoming submission deadlines for major AI conferences, counting down."})]})}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:20,padding:"16px 0",borderBottom:"1px solid var(--hairline)",marginBottom:24},children:[t.jsx(E,{id:"top-tier-only",label:"Top tier only",checked:e,onChange:l}),t.jsx(E,{id:"show-past",label:"Show past conferences",checked:s,onChange:r})]}),c.length>0&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:24},children:[c.map(a=>{const u=o.has(a);return t.jsx("button",{className:"tag-chip",onClick:()=>i(a),style:{background:u?"var(--ink)":"var(--bg-subtle)",color:u?"var(--bg)":"var(--ink-soft)"},children:k(a)},a)}),o.size>0&&t.jsx("button",{className:"tag-chip",onClick:()=>h(new Set),style:{background:"transparent",color:"var(--ink-faint)"},children:"Clear ✕"})]}),t.jsx("div",{className:"sort-bar",children:t.jsx("div",{className:"results-count",children:m.isLoading?"…":`${y.length} conferences`})}),m.isLoading?t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))",gap:16},children:Array.from({length:6}).map((a,u)=>t.jsx(U,{className:"h-44"},u))}):y.length===0?t.jsxs("div",{className:"no-results",children:["No conferences match these filters",s?".":" — try enabling “Show past conferences”."]}):t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))",gap:16},children:y.map(a=>t.jsx(te,{conf:a,now:d,selectedDomains:o,onToggleDomain:i,onOpen:p},a.id))}),t.jsx(ee,{conf:n,open:n!==null,onOpenChange:a=>{a||p(null)}})]})};export{pe as default}; diff --git a/assets/ApiDocsView-DhYUFS5g.js b/assets/ApiDocsView-LwSN2FTa.js similarity index 98% rename from assets/ApiDocsView-DhYUFS5g.js rename to assets/ApiDocsView-LwSN2FTa.js index c96d217d4e40a5eb00f89b97fa569fc0d4300433..4c338ebb04c991f63646e59d6f879ba94f872259 100644 --- a/assets/ApiDocsView-DhYUFS5g.js +++ b/assets/ApiDocsView-LwSN2FTa.js @@ -1,4 +1,4 @@ -import{ac as m,b as f,d as h,j as e}from"./index-DyXq7-Tg.js";import{u as g}from"./useDocumentTitle-DcxM2Zv_.js";import{M as y}from"./index-mCi_y_l3.js";const b={queryKey:["public-api-schema"],queryFn:()=>m("/openapi.json",{credentials:"omit"}),staleTime:5*60*1e3};function w(s,r){const n=new URLSearchParams;for(const[a,t]of Object.entries(r["x-example-parameters"]))s.includes(`{${a}}`)?s=s.replace(`{${a}}`,encodeURIComponent(String(t))):n.append(a,String(t));return`https://paperswithcode.co${s}${n.size?`?${n}`:""}`}function v(s,r){return r==="Python"?`import requests +import{ac as m,b as f,d as h,j as e}from"./index-CjdUkE4w.js";import{u as g}from"./useDocumentTitle-2Ho8_KfW.js";import{M as y}from"./index-tLcwYp0U.js";const b={queryKey:["public-api-schema"],queryFn:()=>m("/openapi.json",{credentials:"omit"}),staleTime:5*60*1e3};function w(s,r){const n=new URLSearchParams;for(const[a,t]of Object.entries(r["x-example-parameters"]))s.includes(`{${a}}`)?s=s.replace(`{${a}}`,encodeURIComponent(String(t))):n.append(a,String(t));return`https://paperswithcode.co${s}${n.size?`?${n}`:""}`}function v(s,r){return r==="Python"?`import requests response = requests.get(${JSON.stringify(s)}, timeout=30) response.raise_for_status() diff --git a/assets/AreaSection-BxnKzNK0.js b/assets/AreaSection-iYSRoy6-.js similarity index 88% rename from assets/AreaSection-BxnKzNK0.js rename to assets/AreaSection-iYSRoy6-.js index 21ed214b45723ad2fad82a3661b75f75269b3d30..64bb5dce39e759dc6da1b86239882af8245795da 100644 --- a/assets/AreaSection-BxnKzNK0.js +++ b/assets/AreaSection-iYSRoy6-.js @@ -1 +1 @@ -import{j as s}from"./index-DyXq7-Tg.js";import{S as l}from"./skeleton-C3IIzpSL.js";const m=({id:t,title:a,description:e,meta:r,style:c,children:i})=>s.jsxs("section",{id:t,className:"area-section",style:c,children:[s.jsxs("div",{className:"area-section-head",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"area-section-title",children:a}),e&&s.jsx("div",{className:"area-section-description",children:e})]}),s.jsx("div",{className:"area-section-meta",children:r})]}),s.jsx("div",{className:"tag-grid",children:i})]}),h=({sections:t=4,tiles:a,tileClassName:e})=>s.jsx("div",{className:"area-directory-skeleton",children:Array.from({length:t}).map((r,c)=>s.jsxs("div",{children:[s.jsx(l,{className:"h-8 w-1/3 mb-4"}),s.jsx("div",{className:"tag-grid",children:Array.from({length:a}).map((i,n)=>s.jsx(l,{className:e},n))})]},c))}),x=({areas:t})=>{const a=t.filter(r=>r.tasks.length>0),e=a.reduce((r,c)=>r+c.tasks.length,0);return e===0?null:s.jsxs("div",{className:"area-directory-footer",children:[e," tasks across ",a.length," areas."]})};export{h as A,m as a,x as b}; +import{j as s}from"./index-CjdUkE4w.js";import{S as l}from"./skeleton-DTWi7Ctg.js";const m=({id:t,title:a,description:e,meta:r,style:c,children:i})=>s.jsxs("section",{id:t,className:"area-section",style:c,children:[s.jsxs("div",{className:"area-section-head",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"area-section-title",children:a}),e&&s.jsx("div",{className:"area-section-description",children:e})]}),s.jsx("div",{className:"area-section-meta",children:r})]}),s.jsx("div",{className:"tag-grid",children:i})]}),h=({sections:t=4,tiles:a,tileClassName:e})=>s.jsx("div",{className:"area-directory-skeleton",children:Array.from({length:t}).map((r,c)=>s.jsxs("div",{children:[s.jsx(l,{className:"h-8 w-1/3 mb-4"}),s.jsx("div",{className:"tag-grid",children:Array.from({length:a}).map((i,n)=>s.jsx(l,{className:e},n))})]},c))}),x=({areas:t})=>{const a=t.filter(r=>r.tasks.length>0),e=a.reduce((r,c)=>r+c.tasks.length,0);return e===0?null:s.jsxs("div",{className:"area-directory-footer",children:[e," tasks across ",a.length," areas."]})};export{h as A,m as a,x as b}; diff --git a/assets/ArtifactWorkspace-Ya79_F5k.js b/assets/ArtifactWorkspace-Ya79_F5k.js deleted file mode 100644 index 8d5cb0c67f0801c49b88c3e7f53a4a35a39d38e1..0000000000000000000000000000000000000000 --- a/assets/ArtifactWorkspace-Ya79_F5k.js +++ /dev/null @@ -1,163 +0,0 @@ -var TL=Object.defineProperty;var yA=n=>{throw TypeError(n)};var PL=(n,e,t)=>e in n?TL(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var oe=(n,e,t)=>PL(n,typeof e!="symbol"?e+"":e,t),av=(n,e,t)=>e.has(n)||yA("Cannot "+t);var f=(n,e,t)=>(av(n,e,"read from private field"),t?t.call(n):e.get(n)),M=(n,e,t)=>e.has(n)?yA("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),$=(n,e,t,s)=>(av(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t),P=(n,e,t)=>(av(n,e,"access private method"),t);var hs=(n,e,t,s)=>({set _(i){$(n,e,i,t)},get _(){return f(n,e,s)}});import{s as Mo,d as q,j as S,V as ee,b as wo,a5 as eS,a6 as rn,a7 as gm,a8 as l0,L as Nd,a9 as RL,X as c0,aa as ML,i as ZC,C as IL}from"./index-DyXq7-Tg.js";import{u as XC,a as OL,c as NL,P as YC,i as LL,b as JC,e as tS,A as DL,v as jL,Z as FL,_ as zL,$ as HL,a0 as QC,a1 as BL}from"./chatSessions-Ck_dyM0d.js";/* empty css */import{H as Np,a as Lp,b as Dp}from"./hover-card-B45EJIn_.js";import{f as UL,i as e$,p as qL,C as VL,a as WL,T as GL}from"./CatalogEntityPreviewLink-BktpwL3_.js";import{G as h0}from"./github-RNrgGHRT.js";import{F as t$}from"./file-text-dvKtHbmD.js";import{r as KL,a as ZL,P as u0,c as XL}from"./PaperPreviewLink-CpCZSa8K.js";import{M as YL,d as JL}from"./index-mCi_y_l3.js";import{r as QL}from"./index-2CvJmBVB.js";import{c as vA}from"./chat-Ix1IrIwq.js";import{C as eD}from"./copy-CxR0OKx2.js";import{T as tD}from"./thumbs-up-CPLlGli7.js";import{u as ym}from"./useMutation-UWxBeqtn.js";import{A as nD}from"./arrow-left-PA_b6law.js";import{E as n$}from"./external-link-orY1Xz1I.js";import{P as sD}from"./plus-Yh42pKZz.js";import{S as iD}from"./search-8ssWDP68.js";import{C as s$,a as i$}from"./chevron-up-DYSYRyvz.js";import{A as rD}from"./AuthorAvatar-B-9xS2Wo.js";import{p as oD}from"./papers-Dh3ljlL0.js";/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const aD=Mo("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bA=Mo("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const nS=Mo("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const lD=Mo("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const cD=Mo("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const hD=Mo("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const r$=Mo("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const uD=Mo("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const dD=Mo("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);function d0({selection:n,editable:e=!1,onRemove:t}){const s=q.useId(),i=q.useRef(null),[r,o]=q.useState(!1),[a,l]=q.useState(!1),c=`Selection · Page ${n.page}`;return q.useEffect(()=>{const h=i.current;!h||r||l(h.scrollHeight>h.clientHeight+1)},[r,n.text]),S.jsxs("div",{className:`chat-paper-selection${e?" is-editable":""}`,children:[S.jsxs("div",{className:"chat-paper-selection-header",children:[S.jsx("span",{className:"chat-paper-selection-label",children:c}),S.jsxs("div",{className:"chat-paper-selection-actions",children:[(a||r)&&S.jsx("button",{type:"button",className:"chat-paper-selection-toggle","aria-expanded":r,"aria-controls":s,onClick:()=>o(h=>!h),children:r?"Collapse":"Expand"}),e&&t&&S.jsx("button",{type:"button",className:"chat-paper-selection-remove","aria-label":"Remove selected paper passage",onClick:t,children:"Remove"})]})]}),S.jsx("blockquote",{id:s,ref:i,className:`chat-paper-selection-quote${r?" is-expanded":""}`,children:n.text})]})}const fD=jL(),ese=({onSend:n,busy:e,placeholder:t,autoFocus:s,draft:i,onDraftChange:r,onStop:o,disabled:a=!1,describedBy:l,paperMentionsEnabled:c=!1,paperSelectionEnabled:h=!0,paperArtifactsEnabled:u=!1})=>{const[d,p]=q.useState(fD),m=i??d,y=q.useRef(null),[v,g]=q.useState(0),_=H=>{i||p(H),r==null||r(H)},b=XC({draft:m,onChange:_,enabled:c,textareaRef:y}),x=u&&m.text==="/",{completion:A,trackCaret:T}=OL(m,b.open||x);q.useEffect(()=>{const H=y.current;H&&(H.style.height="auto",H.style.height=`${Math.min(NL(H),200)}px`)},[m.text,A]),q.useEffect(()=>{var H;s&&((H=y.current)==null||H.focus())},[s]);const C=()=>{const H=m.text.length-m.text.trimStart().length,j=m.text.trim(),U=!!m.paperSelection&&!h;if(!j||e||a||U)return;const B=H+j.length,L={text:j,paperMentions:m.paperMentions.filter(X=>X.start>=H&&X.end<=B).map(X=>({...X,start:X.start-H,end:X.end-H})),...m.paperSelection?{paperSelection:m.paperSelection}:{}};n(L)},I=!!m.paperSelection&&!h,D=!!m.text.trim()&&!I;return S.jsxs("div",{className:"chat-composer ph-no-capture","data-ph-no-autocapture":"true","data-ph-no-capture":"true",children:[m.paperSelection&&S.jsx(d0,{selection:m.paperSelection,editable:!0,onRemove:()=>{var H;_({text:m.text,paperMentions:m.paperMentions}),(H=y.current)==null||H.focus()}}),I&&S.jsx("div",{className:"chat-paper-selection-disabled",role:"status",children:"Paper selection is currently disabled. Remove the selected passage or wait for the feature to recover."}),S.jsxs("div",{className:"chat-composer-textarea-wrap",children:[S.jsx(YC,{text:m.text,mentions:m.paperMentions,scrollTop:v,completion:A}),S.jsx("textarea",{className:"ph-no-capture","data-ph-no-autocapture":"true","data-ph-no-capture":"true",ref:y,rows:1,value:m.text,placeholder:t||(m.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:H=>{b.updateText(H.target.value,H.target.selectionStart),T(H.target)},onSelect:H=>{b.refresh(H.currentTarget.selectionStart),T(H.currentTarget)},onClick:H=>{b.refresh(H.currentTarget.selectionStart),T(H.currentTarget)},onScroll:H=>g(H.currentTarget.scrollTop),onBlur:H=>{var j,U;(U=(j=H.relatedTarget)==null?void 0:j.closest)!=null&&U.call(j,".chat-paper-picker, .chat-slash-command")||window.setTimeout(b.close,0)},onKeyDown:H=>{if(!b.keyDown(H)){if(LL(H)&&A){H.preventDefault();const j=m.text+A;b.updateText(j,j.length),window.requestAnimationFrame(()=>{var U;return(U=y.current)==null?void 0:U.setSelectionRange(j.length,j.length)});return}H.key==="Enter"&&!H.shiftKey&&!H.nativeEvent.isComposing&&(H.preventDefault(),C())}},role:"combobox","aria-expanded":b.open||x,"aria-controls":b.open?b.pickerId:x?"chat-write-paper-command":void 0,"aria-activedescendant":b.open&&b.results.length?`${b.optionIdPrefix}-${b.activeIndex}`:x?"chat-write-paper-command":void 0,"aria-autocomplete":"list","aria-describedby":[l,b.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),S.jsx(JC,{open:b.open,query:b.query,results:b.results,activeIndex:b.activeIndex,loading:b.loading,error:b.error,onSelect:b.select,id:b.pickerId,optionIdPrefix:b.optionIdPrefix}),x&&S.jsxs("button",{type:"button",id:"chat-write-paper-command",className:"chat-slash-command",role:"option",onMouseDown:H=>{var j;H.preventDefault(),_({...m,text:"/write-paper "}),(j=y.current)==null||j.focus()},children:[S.jsx("code",{children:"/write-paper"}),S.jsx("span",{children:"Draft a paper from this research chat"})]})]}),b.message&&S.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:b.message}),S.jsxs("div",{className:"chat-composer-row",children:[S.jsx("div",{className:"chat-composer-tools",children:S.jsxs("span",{className:"chat-composer-hint",children:[A?"Tab to complete · ":"","Enter to send · Shift+Enter for newline"]})}),S.jsx("button",{type:"button",className:`chat-send${e||D?" chat-send-on":""}`,onClick:e?o:C,disabled:a||(e?!o:!D),"aria-label":e?"Stop generating":"Send message",children:e?o?S.jsx("span",{"aria-hidden":"true",children:"■"}):S.jsx(tS,{light:!0}):S.jsx(DL,{})})]})]})};function pD(){const[n,e]=q.useState(!1);return q.useEffect(()=>{const t=window.setTimeout(()=>e(!0),15e3);return()=>window.clearTimeout(t)},[]),S.jsxs("div",{className:"chat-waiting chat-compaction-status",role:"status","aria-live":"polite",children:[S.jsx("span",{className:"chat-thinking",children:"Summarizing earlier context…"}),n&&S.jsx("span",{className:"chat-compaction-explanation",children:"This conversation is long. Preserving its details may take up to a minute."})]})}const lv=new Map,o$=n=>{if(!n)return Promise.resolve();const e=lv.get(n);if(e)return e;const t=new Promise(s=>{const i=new Image;i.onload=()=>{s()},i.onerror=()=>{lv.delete(n),s()},i.src=n});return lv.set(n,t),t},mD=new Set(["huggingface.co","www.huggingface.co"]),gD=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function yD(n){let e;try{e=new URL(n)}catch{return null}if(e.protocol!=="https:"||!mD.has(e.hostname))return null;const t=e.pathname.split("/").filter(Boolean),s=t[0]==="datasets"?"dataset":"model",i=s==="dataset"?t.slice(1):t;if(i.length!==2||s==="model"&&gD.has(i[0])||i.some(c=>!c||c==="."||c===".."))return null;const r=i.join("/"),o=i.map(encodeURIComponent).join("/"),a=s==="dataset"?`datasets/${o}`:o,l=s==="dataset"?"datasets":"models";return{type:s,repoId:r,url:`https://huggingface.co/${a}`,thumbnailUrl:`https://cdn-thumbnails.huggingface.co/social-thumbnails/${l}/${o}.png`}}const vD=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,bD=({repo:n})=>{const[e,t]=ee.useState(!1);return S.jsxs("div",{className:"hf-preview-card",children:[e?S.jsx("div",{className:"hf-preview-fallback","aria-hidden":"true",children:"🤗"}):S.jsx("img",{className:"hf-preview-image","data-testid":"hf-preview-image",src:n.thumbnailUrl,alt:"",loading:"eager",decoding:"async",onError:()=>t(!0)}),S.jsxs("div",{className:"hf-preview-meta",children:[S.jsxs("span",{className:"hf-preview-kind",children:["Hugging Face ",n.type]}),S.jsx("strong",{children:n.repoId}),S.jsx("span",{children:"huggingface.co"})]})]})},wD=({repo:n,children:e})=>{const[t,s]=ee.useState(!1),i=ee.useRef(null),r=ee.useCallback(()=>{o$(n.thumbnailUrl)},[n.thumbnailUrl]);return ee.useEffect(()=>{const o=i.current;if(!o||typeof IntersectionObserver>"u")return;const a=new IntersectionObserver(([l])=>{l.isIntersecting&&(r(),a.disconnect())},{rootMargin:"200px"});return a.observe(o),()=>a.disconnect()},[r]),S.jsxs(Np,{open:t,onOpenChange:o=>{(!o||!vD())&&s(o)},openDelay:150,closeDelay:100,children:[S.jsx(Lp,{asChild:!0,children:S.jsx("a",{ref:i,className:"chat-paper-link chat-hf-link",href:n.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:r,onFocus:r,children:e})}),S.jsx(Dp,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(bD,{repo:n})})]})},_D=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,SD=({repo:n,preview:e,unavailable:t})=>{const[s,i]=ee.useState(!1),r=!!(e!=null&&e.avatarUrl)&&!s;return S.jsxs("div",{className:"github-preview-card",children:[r?S.jsx("img",{className:"github-preview-image","data-testid":"github-preview-image",src:e==null?void 0:e.avatarUrl,alt:"",loading:"eager",decoding:"async",onError:()=>i(!0)}):S.jsx("div",{className:"github-preview-fallback","aria-hidden":"true",children:S.jsx(h0,{})}),S.jsxs("div",{className:"github-preview-meta",children:[S.jsx("span",{className:"github-preview-kind",children:"GitHub repository"}),S.jsx("strong",{children:n.repoId}),(e==null?void 0:e.description)&&S.jsx("span",{className:"github-preview-description",children:e.description}),e?S.jsxs("span",{className:"github-preview-stats",children:[e.language&&S.jsxs(S.Fragment,{children:[e.language," · "]}),"★ ",e.stars.toLocaleString()," · ⑂ ",e.forks.toLocaleString(),e.archived&&S.jsx(S.Fragment,{children:" · Archived"})]}):S.jsx("span",{children:t?"Preview unavailable":"Loading preview…"})]})]})},xD=({repo:n,children:e})=>{var c;const[t,s]=ee.useState(!1),[i,r]=ee.useState(!1),o=ee.useRef(null),a=ee.useCallback(()=>r(!0),[]),l=wo({queryKey:["github-repository-preview",n.repoId.toLowerCase()],queryFn:({signal:h})=>UL(n,h),enabled:t||i,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return ee.useEffect(()=>{const h=o.current;if(!h||typeof IntersectionObserver>"u")return;const u=new IntersectionObserver(([d])=>{d.isIntersecting&&(a(),u.disconnect())},{rootMargin:"200px"});return u.observe(h),()=>u.disconnect()},[a]),ee.useEffect(()=>{var h;(h=l.data)!=null&&h.avatarUrl&&o$(l.data.avatarUrl)},[(c=l.data)==null?void 0:c.avatarUrl]),S.jsxs(Np,{open:t,onOpenChange:h=>{(!h||!_D())&&s(h)},openDelay:150,closeDelay:100,children:[S.jsx(Lp,{asChild:!0,children:S.jsxs("a",{ref:o,className:"chat-github-link",href:n.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:a,onFocus:a,children:[S.jsx(h0,{"aria-hidden":"true"}),e]})}),S.jsx(Dp,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(SD,{repo:n,preview:l.data,unavailable:l.isError})})]})},AD=/^p\d+b\d+$/;function tse(n,e){const t=n.blocks[e];return t?t.label!=="Section-Header"?[{page:t.page,bbox:t.bbox}]:Object.entries(n.blocks).filter(([s,i])=>s===e||i.section===e).map(([,s])=>({page:s.page,bbox:s.bbox})):[]}function kD(n){const e=[...n.matchAll(/\]\(pdf:(p\d+b\d+)\)/g)].map(t=>t[1]);return[...new Set(e)]}const ED=320,wA=12,CD=170;function $D(n,e){const t=Math.min(ED,e*.7),s=e-wA-t-n.left,i=wA-n.left;return{left:Math.max(i,Math.min(0,s)),below:n.topq.useContext(PD);function l$(n){return n.length>220?`${n.slice(0,220).trimEnd()}…`:n}function RD({anchor:n,children:e}){var l;const t=a$(),[s,i]=q.useState({left:0,below:!1}),r=(l=t==null?void 0:t.layout)==null?void 0:l.blocks[n];if(!t||!r)return S.jsx("span",{className:"chat-invalid-citation",children:e});const o=r.label==="Section-Header",a=c=>i($D(c.getBoundingClientRect(),window.innerWidth));return S.jsxs("button",{type:"button",className:"chat-pdf-citation",onClick:()=>t.open(n),onMouseEnter:c=>a(c.currentTarget),onFocus:c=>a(c.currentTarget),"aria-label":`${o?"Jump to section":"Jump to passage"} on page ${r.page}`,children:[S.jsx(t$,{"aria-hidden":"true"}),S.jsx("span",{children:q.Children.map(e,(c,h)=>h===0&&typeof c=="string"?TD(c):c)}),S.jsxs("span",{className:`chat-pdf-citation-preview${s.below?" is-below":""}`,role:"tooltip",style:{left:s.left},children:[S.jsxs("strong",{children:["Page ",r.page,o?" · section":""]}),r.text&&S.jsx("span",{children:l$(r.text)})]})]})}function MD({text:n}){const e=a$(),t=e==null?void 0:e.layout;if(!e||!t)return null;const s=kD(n).filter(i=>t.blocks[i]);return s.length?S.jsxs("details",{className:"chat-pdf-sources",children:[S.jsxs("summary",{children:["Sources (",s.length,")"]}),S.jsx("ol",{children:s.map(i=>{const r=t.blocks[i];return S.jsx("li",{children:S.jsxs("button",{type:"button",onClick:()=>e.open(i),children:[S.jsxs("span",{className:"chat-pdf-sources-page",children:["p. ",r.page]}),S.jsx("span",{children:l$(r.text)||r.label})]})},i)})})]}):null}const ID=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function OD(n){try{return new URL(n).hostname.replace(/^www\./,"")}catch{return"Web source"}}const ND=({citation:n})=>{const[e,t]=ee.useState(!1),[s,i]=ee.useState(!1),r=n.thumbnail_url,o=n.favicon_url;return S.jsxs("div",{className:"web-preview-card",children:[r&&!e&&S.jsx("img",{className:"web-preview-image","data-testid":"web-preview-image",src:r,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>t(!0)}),S.jsxs("div",{className:"web-preview-meta",children:[S.jsxs("div",{className:"web-preview-source",children:[o&&!s&&S.jsx("img",{src:o,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>i(!0)}),S.jsx("span",{children:OD(n.url??"")}),n.published&&S.jsxs(S.Fragment,{children:[S.jsx("span",{"aria-hidden":"true",children:"·"}),S.jsx("time",{children:n.published.slice(0,10)})]})]}),S.jsx("strong",{children:n.title}),n.excerpt&&S.jsx("p",{children:n.excerpt.replace(/\s+/g," ").trim()})]})]})},LD=({citation:n,children:e})=>{const[t,s]=ee.useState(!1),i=n.url??"";return S.jsxs(Np,{open:t,onOpenChange:r=>{(!r||!ID())&&s(r)},openDelay:150,closeDelay:100,children:[S.jsx(Lp,{asChild:!0,children:S.jsx("a",{href:i,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:e})}),S.jsx(Dp,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(ND,{citation:n})})]})},DD=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,jD=n=>n==="semantic_scholar"?"Semantic Scholar":"External paper",FD=({citation:n})=>{var e,t;return S.jsxs("div",{className:"external-paper-preview-card",children:[S.jsxs("div",{className:"external-paper-preview-source",children:[S.jsx("span",{children:jD(n.provider)}),n.published&&S.jsxs(S.Fragment,{children:[S.jsx("span",{"aria-hidden":"true",children:"·"}),S.jsx("time",{children:n.published.slice(0,10)})]})]}),S.jsx("strong",{children:n.title}),(((e=n.authors)==null?void 0:e.length)??0)>0&&S.jsx("p",{className:"external-paper-preview-authors",children:(t=n.authors)==null?void 0:t.join(", ")}),n.excerpt&&S.jsx("p",{children:n.excerpt.replace(/\s+/g," ").trim()}),n.citation_count!==null&&n.citation_count!==void 0&&S.jsxs("span",{className:"external-paper-preview-citations",children:[n.citation_count.toLocaleString()," citations"]})]})},zD=({citation:n,children:e})=>{const[t,s]=ee.useState(!1);return S.jsxs(Np,{open:t,onOpenChange:i=>{(!i||!DD())&&s(i)},openDelay:150,closeDelay:100,children:[S.jsx(Lp,{asChild:!0,children:S.jsx("a",{href:n.url??"",className:"chat-external-paper-citation",target:"_blank",rel:"noopener noreferrer",children:e})}),S.jsx(Dp,{className:"external-paper-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(FD,{citation:n})})]})};function HD(n){const e=[];let t=0,s=null;for(const i of n.match(/.*(?:\n|$)/g)??[]){if(!i)continue;const r=i.endsWith(` -`)?i.slice(0,-1):i;if(s){const l=r.match(/^ {0,3}(`+|~+)[ \t]*$/);l&&l[1][0]===s.marker&&l[1].length>=s.length&&(e.push({start:s.start,end:t+i.length}),s=null),t+=i.length;continue}const o=r.match(/^ {0,3}(`{3,}|~{3,})/);if(o){s={marker:o[1][0],length:o[1].length,start:t},t+=i.length;continue}let a=0;for(;ae>=t.start&&e=0&&n[s]==="\\";s-=1)t+=1;return t%2===0}function xA(n,e,t,s){const i=[];let r=0;for(;rs.name),published:e.metadata.published,conference:e.metadata.conference,citationCount:e.metadata.citation_count,tasks:e.metadata.tasks};if(t)return{routeId:n,title:t.title,arxivId:t.arxiv_id??null,source:t.arxiv_id?"arxiv":"external",sourceUrl:t.source_url,thumbnailUrl:t.thumbnail_url??null,authors:t.authors??[],published:t.published??null,conference:t.conference??null,citationCount:t.citation_count??null,tasks:[]}}const c$=({routeId:n,paper:e,citation:t,className:s="chat-paper-link",children:i})=>S.jsx(u0,{routeId:n,initialData:UD(n,e,t),className:s,target:"_blank",children:i});function qD(n){const e=n.lastIndexOf("[");if(e===-1)return n;const t=n.slice(e);return/^\[[^\]]*(\]\(?[^)\s]*)?$/.test(t)?n.slice(0,e):n}const VD=n=>n.startsWith("paper:")||n.startsWith("pdf:")||e$(n)?n:JL(n);function WD(n){try{const e=new URL(n);return e.protocol==="https:"&&(e.hostname==="github.com"||e.hostname==="www.github.com")}catch{return!1}}const sb=({text:n,streaming:e,papers:t,citations:s,webCitations:i})=>{const r=BD(e?qD(n):n);return S.jsxs(S.Fragment,{children:[S.jsx(YL,{remarkPlugins:[QL,ZL],rehypePlugins:[KL],urlTransform:VD,components:{a:({href:o,children:a})=>{if(o!=null&&o.startsWith("paper:")){const h=o.slice(6);return!t[h]&&!(s!=null&&s[h])?S.jsx("span",{className:"chat-invalid-citation",children:a}):S.jsx(c$,{routeId:h,paper:t[h],citation:s==null?void 0:s[h],children:a})}if(o!=null&&o.startsWith("pdf:")){const h=o.slice(4);return AD.test(h)?S.jsx(RD,{anchor:h,children:a}):S.jsx("span",{className:"chat-invalid-citation",children:a})}if(o&&e$(o)){const h=qL(o);return h?S.jsx(VL,{entity:h,children:a}):S.jsx("span",{className:"chat-invalid-citation",children:a})}const l=o?yD(o):null;if(l)return S.jsx(wD,{repo:l,children:a});const c=o?WL(o):null;return c?S.jsx(xD,{repo:c,children:a}):o&&WD(o)?S.jsxs("a",{href:o,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[S.jsx(h0,{"aria-hidden":"true"}),a]}):o!=null&&o.startsWith("https://")&&(i!=null&&i[o])?i[o].source_type==="paper"?S.jsx(zD,{citation:i[o],children:a}):S.jsx(LD,{citation:i[o],children:a}):o!=null&&o.startsWith("https://")?S.jsx("a",{href:o,className:"chat-external-link",target:"_blank",rel:"noopener noreferrer",children:a}):S.jsx("span",{children:a})}},children:r}),!e&&S.jsx(MD,{text:r})]})},GD=Object.freeze({status:"aborted"});function Q(n,e,t){function s(a,l){var c;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(c=a._zod).traits??(c.traits=new Set),a._zod.traits.add(n),e(a,l);for(const h in o.prototype)h in a||Object.defineProperty(a,h,{value:o.prototype[h].bind(a)});a._zod.constr=o,a._zod.def=l}const i=(t==null?void 0:t.Parent)??Object;class r extends i{}Object.defineProperty(r,"name",{value:n});function o(a){var l;const c=t!=null&&t.Parent?new r:this;s(c,a),(l=c._zod).deferred??(l.deferred=[]);for(const h of c._zod.deferred)h();return c}return Object.defineProperty(o,"init",{value:s}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,c;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(c=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:c.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class nf extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const h$={};function $a(n){return h$}function KD(n){const e=Object.values(n).filter(s=>typeof s=="number");return Object.entries(n).filter(([s,i])=>e.indexOf(+s)===-1).map(([s,i])=>i)}function ZD(n,e){return typeof e=="bigint"?e.toString():e}function sS(n){return{get value(){{const e=n();return Object.defineProperty(this,"value",{value:e}),e}}}}function iS(n){return n==null}function rS(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function XD(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,i=t>s?t:s,r=Number.parseInt(n.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return r%o/10**i}function Pt(n,e,t){Object.defineProperty(n,e,{get(){{const s=t();return n[e]=s,s}},set(s){Object.defineProperty(n,e,{value:s})},configurable:!0})}function f0(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function Yu(n){return JSON.stringify(n)}const u$=Error.captureStackTrace?Error.captureStackTrace:(...n)=>{};function Qg(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const YD=sS(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ey(n){if(Qg(n)===!1)return!1;const e=n.constructor;if(e===void 0)return!0;const t=e.prototype;return!(Qg(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}const JD=new Set(["string","number","symbol"]);function jp(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cc(n,e,t){const s=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(s._zod.parent=n),s}function ve(n){const e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function QD(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}const e2={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function t2(n,e){const t={},s=n._zod.def;for(const i in e){if(!(i in s.shape))throw new Error(`Unrecognized key: "${i}"`);e[i]&&(t[i]=s.shape[i])}return Cc(n,{...n._zod.def,shape:t,checks:[]})}function n2(n,e){const t={...n._zod.def.shape},s=n._zod.def;for(const i in e){if(!(i in s.shape))throw new Error(`Unrecognized key: "${i}"`);e[i]&&delete t[i]}return Cc(n,{...n._zod.def,shape:t,checks:[]})}function s2(n,e){if(!ey(e))throw new Error("Invalid input to extend: expected a plain object");const t={...n._zod.def,get shape(){const s={...n._zod.def.shape,...e};return f0(this,"shape",s),s},checks:[]};return Cc(n,t)}function i2(n,e){return Cc(n,{...n._zod.def,get shape(){const t={...n._zod.def.shape,...e._zod.def.shape};return f0(this,"shape",t),t},catchall:e._zod.def.catchall,checks:[]})}function r2(n,e,t){const s=e._zod.def.shape,i={...s};if(t)for(const r in t){if(!(r in s))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(i[r]=n?new n({type:"optional",innerType:s[r]}):s[r])}else for(const r in s)i[r]=n?new n({type:"optional",innerType:s[r]}):s[r];return Cc(e,{...e._zod.def,shape:i,checks:[]})}function o2(n,e,t){const s=e._zod.def.shape,i={...s};if(t)for(const r in t){if(!(r in i))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(i[r]=new n({type:"nonoptional",innerType:s[r]}))}else for(const r in s)i[r]=new n({type:"nonoptional",innerType:s[r]});return Cc(e,{...e._zod.def,shape:i,checks:[]})}function Ld(n,e=0){var t;for(let s=e;s{var s;return(s=t).path??(s.path=[]),t.path.unshift(n),t})}function vm(n){return typeof n=="string"?n:n==null?void 0:n.message}function Ta(n,e,t){var i,r,o,a,l,c;const s={...n,path:n.path??[]};if(!n.message){const h=vm((o=(r=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:r.error)==null?void 0:o.call(r,n))??vm((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??vm((l=t.customError)==null?void 0:l.call(t,n))??vm((c=t.localeError)==null?void 0:c.call(t,n))??"Invalid input";s.message=h}return delete s.inst,delete s.continue,e!=null&&e.reportInput||delete s.input,s}function oS(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function sf(...n){const[e,t,s]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:s}:{...e}}const d$=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),Object.defineProperty(n,"message",{get(){return JSON.stringify(e,ZD,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},f$=Q("$ZodError",d$),p$=Q("$ZodError",d$,{Parent:Error});function a2(n,e=t=>t.message){const t={},s=[];for(const i of n.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):s.push(e(i));return{formErrors:s,fieldErrors:t}}function l2(n,e){const t=e||function(r){return r.message},s={_errors:[]},i=r=>{for(const o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>i({issues:a}));else if(o.code==="invalid_key")i({issues:o.issues});else if(o.code==="invalid_element")i({issues:o.issues});else if(o.path.length===0)s._errors.push(t(o));else{let a=s,l=0;for(;l(e,t,s,i)=>{const r=s?Object.assign(s,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise)throw new nf;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(l=>Ta(l,r,$a())));throw u$(a,i==null?void 0:i.callee),a}return o.value},h2=n=>async(e,t,s,i)=>{const r=s?Object.assign(s,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(l=>Ta(l,r,$a())));throw u$(a,i==null?void 0:i.callee),a}return o.value},m$=n=>(e,t,s)=>{const i=s?{...s,async:!1}:{async:!1},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)throw new nf;return r.issues.length?{success:!1,error:new(n??f$)(r.issues.map(o=>Ta(o,i,$a())))}:{success:!0,data:r.value}},g$=m$(p$),y$=n=>async(e,t,s)=>{const i=s?Object.assign(s,{async:!0}):{async:!0};let r=e._zod.run({value:t,issues:[]},i);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new n(r.issues.map(o=>Ta(o,i,$a())))}:{success:!0,data:r.value}},u2=y$(p$),d2=/^[cC][^\s-]{8,}$/,f2=/^[0-9a-z]+$/,p2=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,m2=/^[0-9a-vA-V]{20}$/,g2=/^[A-Za-z0-9]{27}$/,y2=/^[a-zA-Z0-9_-]{21}$/,v2=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,b2=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,AA=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,w2=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_2="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function S2(){return new RegExp(_2,"u")}const x2=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,A2=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,k2=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,E2=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,C2=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,v$=/^[A-Za-z0-9_-]*$/,$2=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,T2=/^\+(?:[0-9]){6,14}[0-9]$/,b$="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",P2=new RegExp(`^${b$}$`);function w$(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function R2(n){return new RegExp(`^${w$(n)}$`)}function M2(n){const e=w$({precision:n.precision}),t=["Z"];n.local&&t.push(""),n.offset&&t.push("([+-]\\d{2}:\\d{2})");const s=`${e}(?:${t.join("|")})`;return new RegExp(`^${b$}T(?:${s})$`)}const I2=n=>{const e=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},O2=/^\d+$/,N2=/^-?\d+(?:\.\d+)?/i,L2=/true|false/i,D2=/null/i,j2=/undefined/i,F2=/^[^A-Z]*$/,z2=/^[^a-z]*$/,Bs=Q("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),_$={number:"number",bigint:"bigint",object:"date"},S$=Q("$ZodCheckLessThan",(n,e)=>{Bs.init(n,e);const t=_$[typeof e.value];n._zod.onattach.push(s=>{const i=s._zod.bag,r=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value{(e.inclusive?s.value<=e.value:s.value{Bs.init(n,e);const t=_$[typeof e.value];n._zod.onattach.push(s=>{const i=s._zod.bag,r=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>r&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),n._zod.check=s=>{(e.inclusive?s.value>=e.value:s.value>e.value)||s.issues.push({origin:t,code:"too_small",minimum:e.value,input:s.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),H2=Q("$ZodCheckMultipleOf",(n,e)=>{Bs.init(n,e),n._zod.onattach.push(t=>{var s;(s=t._zod.bag).multipleOf??(s.multipleOf=e.value)}),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):XD(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),B2=Q("$ZodCheckNumberFormat",(n,e)=>{var o;Bs.init(n,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),s=t?"int":"number",[i,r]=e2[e.format];n._zod.onattach.push(a=>{const l=a._zod.bag;l.format=e.format,l.minimum=i,l.maximum=r,t&&(l.pattern=O2)}),n._zod.check=a=>{const l=a.value;if(t){if(!Number.isInteger(l)){a.issues.push({expected:s,format:e.format,code:"invalid_type",input:l,inst:n});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,continue:!e.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,continue:!e.abort});return}}lr&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:r,inst:n})}}),U2=Q("$ZodCheckMaxLength",(n,e)=>{var t;Bs.init(n,e),(t=n._zod.def).when??(t.when=s=>{const i=s.value;return!iS(i)&&i.length!==void 0}),n._zod.onattach.push(s=>{const i=s._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum{const i=s.value;if(i.length<=e.maximum)return;const o=oS(i);s.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),q2=Q("$ZodCheckMinLength",(n,e)=>{var t;Bs.init(n,e),(t=n._zod.def).when??(t.when=s=>{const i=s.value;return!iS(i)&&i.length!==void 0}),n._zod.onattach.push(s=>{const i=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(s._zod.bag.minimum=e.minimum)}),n._zod.check=s=>{const i=s.value;if(i.length>=e.minimum)return;const o=oS(i);s.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),V2=Q("$ZodCheckLengthEquals",(n,e)=>{var t;Bs.init(n,e),(t=n._zod.def).when??(t.when=s=>{const i=s.value;return!iS(i)&&i.length!==void 0}),n._zod.onattach.push(s=>{const i=s._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),n._zod.check=s=>{const i=s.value,r=i.length;if(r===e.length)return;const o=oS(i),a=r>e.length;s.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:s.value,inst:n,continue:!e.abort})}}),p0=Q("$ZodCheckStringFormat",(n,e)=>{var t,s;Bs.init(n,e),n._zod.onattach.push(i=>{const r=i._zod.bag;r.format=e.format,e.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(e.pattern))}),e.pattern?(t=n._zod).check??(t.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(s=n._zod).check??(s.check=()=>{})}),W2=Q("$ZodCheckRegex",(n,e)=>{p0.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),G2=Q("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=F2),p0.init(n,e)}),K2=Q("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=z2),p0.init(n,e)}),Z2=Q("$ZodCheckIncludes",(n,e)=>{Bs.init(n,e);const t=jp(e.includes),s=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=s,n._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(s)}),n._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:n,continue:!e.abort})}}),X2=Q("$ZodCheckStartsWith",(n,e)=>{Bs.init(n,e);const t=new RegExp(`^${jp(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=s=>{s.value.startsWith(e.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:s.value,inst:n,continue:!e.abort})}}),Y2=Q("$ZodCheckEndsWith",(n,e)=>{Bs.init(n,e);const t=new RegExp(`.*${jp(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=s=>{s.value.endsWith(e.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:s.value,inst:n,continue:!e.abort})}}),J2=Q("$ZodCheckOverwrite",(n,e)=>{Bs.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class Q2{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const s=e.split(` -`).filter(o=>o),i=Math.min(...s.map(o=>o.length-o.trimStart().length)),r=s.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of r)this.content.push(o)}compile(){const e=Function,t=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(r=>` ${r}`)];return new e(...t,i.join(` -`))}}const ej={major:4,minor:0,patch:0},At=Q("$ZodType",(n,e)=>{var i;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=ej;const s=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&s.unshift(n);for(const r of s)for(const o of r._zod.onattach)o(n);if(s.length===0)(t=n._zod).deferred??(t.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const r=(o,a,l)=>{let c=Ld(o),h;for(const u of a){if(u._zod.def.when){if(!u._zod.def.when(o))continue}else if(c)continue;const d=o.issues.length,p=u._zod.check(o);if(p instanceof Promise&&(l==null?void 0:l.async)===!1)throw new nf;if(h||p instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await p,o.issues.length!==d&&(c||(c=Ld(o,d)))});else{if(o.issues.length===d)continue;c||(c=Ld(o,d))}}return h?h.then(()=>o):o};n._zod.run=(o,a)=>{const l=n._zod.parse(o,a);if(l instanceof Promise){if(a.async===!1)throw new nf;return l.then(c=>r(c,s,a))}return r(l,s,a)}}n["~standard"]={validate:r=>{var o;try{const a=g$(n,r);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return u2(n,r).then(l=>{var c;return l.success?{value:l.data}:{issues:(c=l.error)==null?void 0:c.issues}})}},vendor:"zod",version:1}}),aS=Q("$ZodString",(n,e)=>{var t;At.init(n,e),n._zod.pattern=[...((t=n==null?void 0:n._zod.bag)==null?void 0:t.patterns)??[]].pop()??I2(n._zod.bag),n._zod.parse=(s,i)=>{if(e.coerce)try{s.value=String(s.value)}catch{}return typeof s.value=="string"||s.issues.push({expected:"string",code:"invalid_type",input:s.value,inst:n}),s}}),Nt=Q("$ZodStringFormat",(n,e)=>{p0.init(n,e),aS.init(n,e)}),tj=Q("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=b2),Nt.init(n,e)}),nj=Q("$ZodUUID",(n,e)=>{if(e.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(s===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=AA(s))}else e.pattern??(e.pattern=AA());Nt.init(n,e)}),sj=Q("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=w2),Nt.init(n,e)}),ij=Q("$ZodURL",(n,e)=>{Nt.init(n,e),n._zod.check=t=>{try{const s=t.value,i=new URL(s),r=i.href;e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:$2.source,input:t.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort})),!s.endsWith("/")&&r.endsWith("/")?t.value=r.slice(0,-1):t.value=r;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),rj=Q("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=S2()),Nt.init(n,e)}),oj=Q("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=y2),Nt.init(n,e)}),aj=Q("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=d2),Nt.init(n,e)}),lj=Q("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=f2),Nt.init(n,e)}),cj=Q("$ZodULID",(n,e)=>{e.pattern??(e.pattern=p2),Nt.init(n,e)}),hj=Q("$ZodXID",(n,e)=>{e.pattern??(e.pattern=m2),Nt.init(n,e)}),uj=Q("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=g2),Nt.init(n,e)}),dj=Q("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=M2(e)),Nt.init(n,e)}),fj=Q("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=P2),Nt.init(n,e)}),pj=Q("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=R2(e)),Nt.init(n,e)}),mj=Q("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=v2),Nt.init(n,e)}),gj=Q("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=x2),Nt.init(n,e),n._zod.onattach.push(t=>{const s=t._zod.bag;s.format="ipv4"})}),yj=Q("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=A2),Nt.init(n,e),n._zod.onattach.push(t=>{const s=t._zod.bag;s.format="ipv6"}),n._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}}),vj=Q("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=k2),Nt.init(n,e)}),bj=Q("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=E2),Nt.init(n,e),n._zod.check=t=>{const[s,i]=t.value.split("/");try{if(!i)throw new Error;const r=Number(i);if(`${r}`!==i)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${s}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}}});function A$(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const wj=Q("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=C2),Nt.init(n,e),n._zod.onattach.push(t=>{t._zod.bag.contentEncoding="base64"}),n._zod.check=t=>{A$(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});function _j(n){if(!v$.test(n))return!1;const e=n.replace(/[-_]/g,s=>s==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return A$(t)}const Sj=Q("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=v$),Nt.init(n,e),n._zod.onattach.push(t=>{t._zod.bag.contentEncoding="base64url"}),n._zod.check=t=>{_j(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),xj=Q("$ZodE164",(n,e)=>{e.pattern??(e.pattern=T2),Nt.init(n,e)});function Aj(n,e=null){try{const t=n.split(".");if(t.length!==3)return!1;const[s]=t;if(!s)return!1;const i=JSON.parse(atob(s));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const kj=Q("$ZodJWT",(n,e)=>{Nt.init(n,e),n._zod.check=t=>{Aj(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),k$=Q("$ZodNumber",(n,e)=>{At.init(n,e),n._zod.pattern=n._zod.bag.pattern??N2,n._zod.parse=(t,s)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const i=t.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return t;const r=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...r?{received:r}:{}}),t}}),Ej=Q("$ZodNumber",(n,e)=>{B2.init(n,e),k$.init(n,e)}),Cj=Q("$ZodBoolean",(n,e)=>{At.init(n,e),n._zod.pattern=L2,n._zod.parse=(t,s)=>{if(e.coerce)try{t.value=!!t.value}catch{}const i=t.value;return typeof i=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),t}}),$j=Q("$ZodUndefined",(n,e)=>{At.init(n,e),n._zod.pattern=j2,n._zod.values=new Set([void 0]),n._zod.optin="optional",n._zod.optout="optional",n._zod.parse=(t,s)=>{const i=t.value;return typeof i>"u"||t.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:n}),t}}),Tj=Q("$ZodNull",(n,e)=>{At.init(n,e),n._zod.pattern=D2,n._zod.values=new Set([null]),n._zod.parse=(t,s)=>{const i=t.value;return i===null||t.issues.push({expected:"null",code:"invalid_type",input:i,inst:n}),t}}),Pj=Q("$ZodAny",(n,e)=>{At.init(n,e),n._zod.parse=t=>t}),Rj=Q("$ZodUnknown",(n,e)=>{At.init(n,e),n._zod.parse=t=>t}),Mj=Q("$ZodNever",(n,e)=>{At.init(n,e),n._zod.parse=(t,s)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function kA(n,e,t){n.issues.length&&e.issues.push(...cl(t,n.issues)),e.value[t]=n.value}const Ij=Q("$ZodArray",(n,e)=>{At.init(n,e),n._zod.parse=(t,s)=>{const i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),t;t.value=Array(i.length);const r=[];for(let o=0;okA(c,t,o))):kA(l,t,o)}return r.length?Promise.all(r).then(()=>t):t}});function bm(n,e,t){n.issues.length&&e.issues.push(...cl(t,n.issues)),e.value[t]=n.value}function EA(n,e,t,s){n.issues.length?s[t]===void 0?t in s?e.value[t]=void 0:e.value[t]=n.value:e.issues.push(...cl(t,n.issues)):n.value===void 0?t in s&&(e.value[t]=void 0):e.value[t]=n.value}const Oj=Q("$ZodObject",(n,e)=>{At.init(n,e);const t=sS(()=>{const u=Object.keys(e.shape);for(const p of u)if(!(e.shape[p]instanceof At))throw new Error(`Invalid element at key "${p}": expected a Zod schema`);const d=QD(e.shape);return{shape:e.shape,keys:u,keySet:new Set(u),numKeys:u.length,optionalKeys:new Set(d)}});Pt(n._zod,"propValues",()=>{const u=e.shape,d={};for(const p in u){const m=u[p]._zod;if(m.values){d[p]??(d[p]=new Set);for(const y of m.values)d[p].add(y)}}return d});const s=u=>{const d=new Q2(["shape","payload","ctx"]),p=t.value,m=_=>{const b=Yu(_);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};d.write("const input = payload.value;");const y=Object.create(null);let v=0;for(const _ of p.keys)y[_]=`key_${v++}`;d.write("const newResult = {}");for(const _ of p.keys)if(p.optionalKeys.has(_)){const b=y[_];d.write(`const ${b} = ${m(_)};`);const x=Yu(_);d.write(` - if (${b}.issues.length) { - if (input[${x}] === undefined) { - if (${x} in input) { - newResult[${x}] = undefined; - } - } else { - payload.issues = payload.issues.concat( - ${b}.issues.map((iss) => ({ - ...iss, - path: iss.path ? [${x}, ...iss.path] : [${x}], - })) - ); - } - } else if (${b}.value === undefined) { - if (${x} in input) newResult[${x}] = undefined; - } else { - newResult[${x}] = ${b}.value; - } - `)}else{const b=y[_];d.write(`const ${b} = ${m(_)};`),d.write(` - if (${b}.issues.length) payload.issues = payload.issues.concat(${b}.issues.map(iss => ({ - ...iss, - path: iss.path ? [${Yu(_)}, ...iss.path] : [${Yu(_)}] - })));`),d.write(`newResult[${Yu(_)}] = ${b}.value`)}d.write("payload.value = newResult;"),d.write("return payload;");const g=d.compile();return(_,b)=>g(u,_,b)};let i;const r=Qg,o=!h$.jitless,l=o&&YD.value,c=e.catchall;let h;n._zod.parse=(u,d)=>{h??(h=t.value);const p=u.value;if(!r(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:n}),u;const m=[];if(o&&l&&(d==null?void 0:d.async)===!1&&d.jitless!==!0)i||(i=s(e.shape)),u=i(u,d);else{u.value={};const b=h.shape;for(const x of h.keys){const A=b[x],T=A._zod.run({value:p[x],issues:[]},d),C=A._zod.optin==="optional"&&A._zod.optout==="optional";T instanceof Promise?m.push(T.then(I=>C?EA(I,u,x,p):bm(I,u,x))):C?EA(T,u,x,p):bm(T,u,x)}}if(!c)return m.length?Promise.all(m).then(()=>u):u;const y=[],v=h.keySet,g=c._zod,_=g.def.type;for(const b of Object.keys(p)){if(v.has(b))continue;if(_==="never"){y.push(b);continue}const x=g.run({value:p[b],issues:[]},d);x instanceof Promise?m.push(x.then(A=>bm(A,u,b))):bm(x,u,b)}return y.length&&u.issues.push({code:"unrecognized_keys",keys:y,input:p,inst:n}),m.length?Promise.all(m).then(()=>u):u}});function CA(n,e,t,s){for(const i of n)if(i.issues.length===0)return e.value=i.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(i=>i.issues.map(r=>Ta(r,s,$a())))}),e}const E$=Q("$ZodUnion",(n,e)=>{At.init(n,e),Pt(n._zod,"optin",()=>e.options.some(t=>t._zod.optin==="optional")?"optional":void 0),Pt(n._zod,"optout",()=>e.options.some(t=>t._zod.optout==="optional")?"optional":void 0),Pt(n._zod,"values",()=>{if(e.options.every(t=>t._zod.values))return new Set(e.options.flatMap(t=>Array.from(t._zod.values)))}),Pt(n._zod,"pattern",()=>{if(e.options.every(t=>t._zod.pattern)){const t=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${t.map(s=>rS(s.source)).join("|")})$`)}}),n._zod.parse=(t,s)=>{let i=!1;const r=[];for(const o of e.options){const a=o._zod.run({value:t.value,issues:[]},s);if(a instanceof Promise)r.push(a),i=!0;else{if(a.issues.length===0)return a;r.push(a)}}return i?Promise.all(r).then(o=>CA(o,t,n,s)):CA(r,t,n,s)}}),Nj=Q("$ZodDiscriminatedUnion",(n,e)=>{E$.init(n,e);const t=n._zod.parse;Pt(n._zod,"propValues",()=>{const i={};for(const r of e.options){const o=r._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(const[a,l]of Object.entries(o)){i[a]||(i[a]=new Set);for(const c of l)i[a].add(c)}}return i});const s=sS(()=>{const i=e.options,r=new Map;for(const o of i){const a=o._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(const l of a){if(r.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);r.set(l,o)}}return r});n._zod.parse=(i,r)=>{const o=i.value;if(!Qg(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:n}),i;const a=s.value.get(o==null?void 0:o[e.discriminator]);return a?a._zod.run(i,r):e.unionFallback?t(i,r):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:o,path:[e.discriminator],inst:n}),i)}}),Lj=Q("$ZodIntersection",(n,e)=>{At.init(n,e),n._zod.parse=(t,s)=>{const i=t.value,r=e.left._zod.run({value:i,issues:[]},s),o=e.right._zod.run({value:i,issues:[]},s);return r instanceof Promise||o instanceof Promise?Promise.all([r,o]).then(([l,c])=>$A(t,l,c)):$A(t,r,o)}});function ib(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(ey(n)&&ey(e)){const t=Object.keys(e),s=Object.keys(n).filter(r=>t.indexOf(r)!==-1),i={...n,...e};for(const r of s){const o=ib(n[r],e[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};i[r]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let s=0;s{At.init(n,e),n._zod.parse=(t,s)=>{const i=t.value;if(!ey(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),t;const r=[];if(e.keyType._zod.values){const o=e.keyType._zod.values;t.value={};for(const l of o)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){const c=e.valueType._zod.run({value:i[l],issues:[]},s);c instanceof Promise?r.push(c.then(h=>{h.issues.length&&t.issues.push(...cl(l,h.issues)),t.value[l]=h.value})):(c.issues.length&&t.issues.push(...cl(l,c.issues)),t.value[l]=c.value)}let a;for(const l in i)o.has(l)||(a=a??[],a.push(l));a&&a.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:a})}else{t.value={};for(const o of Reflect.ownKeys(i)){if(o==="__proto__")continue;const a=e.keyType._zod.run({value:o,issues:[]},s);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){t.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(c=>Ta(c,s,$a())),input:o,path:[o],inst:n}),t.value[a.value]=a.value;continue}const l=e.valueType._zod.run({value:i[o],issues:[]},s);l instanceof Promise?r.push(l.then(c=>{c.issues.length&&t.issues.push(...cl(o,c.issues)),t.value[a.value]=c.value})):(l.issues.length&&t.issues.push(...cl(o,l.issues)),t.value[a.value]=l.value)}}return r.length?Promise.all(r).then(()=>t):t}}),jj=Q("$ZodEnum",(n,e)=>{At.init(n,e);const t=KD(e.entries);n._zod.values=new Set(t),n._zod.pattern=new RegExp(`^(${t.filter(s=>JD.has(typeof s)).map(s=>typeof s=="string"?jp(s):s.toString()).join("|")})$`),n._zod.parse=(s,i)=>{const r=s.value;return n._zod.values.has(r)||s.issues.push({code:"invalid_value",values:t,input:r,inst:n}),s}}),Fj=Q("$ZodLiteral",(n,e)=>{At.init(n,e),n._zod.values=new Set(e.values),n._zod.pattern=new RegExp(`^(${e.values.map(t=>typeof t=="string"?jp(t):t?t.toString():String(t)).join("|")})$`),n._zod.parse=(t,s)=>{const i=t.value;return n._zod.values.has(i)||t.issues.push({code:"invalid_value",values:e.values,input:i,inst:n}),t}}),zj=Q("$ZodTransform",(n,e)=>{At.init(n,e),n._zod.parse=(t,s)=>{const i=e.transform(t.value,t);if(s.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(t.value=o,t));if(i instanceof Promise)throw new nf;return t.value=i,t}}),Hj=Q("$ZodOptional",(n,e)=>{At.init(n,e),n._zod.optin="optional",n._zod.optout="optional",Pt(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Pt(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${rS(t.source)})?$`):void 0}),n._zod.parse=(t,s)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(t,s):t.value===void 0?t:e.innerType._zod.run(t,s)}),Bj=Q("$ZodNullable",(n,e)=>{At.init(n,e),Pt(n._zod,"optin",()=>e.innerType._zod.optin),Pt(n._zod,"optout",()=>e.innerType._zod.optout),Pt(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${rS(t.source)}|null)$`):void 0}),Pt(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(t,s)=>t.value===null?t:e.innerType._zod.run(t,s)}),Uj=Q("$ZodDefault",(n,e)=>{At.init(n,e),n._zod.optin="optional",Pt(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,s)=>{if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,s);return i instanceof Promise?i.then(r=>TA(r,e)):TA(i,e)}});function TA(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const qj=Q("$ZodPrefault",(n,e)=>{At.init(n,e),n._zod.optin="optional",Pt(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,s)=>(t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,s))}),Vj=Q("$ZodNonOptional",(n,e)=>{At.init(n,e),Pt(n._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(s=>s!==void 0)):void 0}),n._zod.parse=(t,s)=>{const i=e.innerType._zod.run(t,s);return i instanceof Promise?i.then(r=>PA(r,n)):PA(i,n)}});function PA(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}const Wj=Q("$ZodCatch",(n,e)=>{At.init(n,e),n._zod.optin="optional",Pt(n._zod,"optout",()=>e.innerType._zod.optout),Pt(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,s)=>{const i=e.innerType._zod.run(t,s);return i instanceof Promise?i.then(r=>(t.value=r.value,r.issues.length&&(t.value=e.catchValue({...t,error:{issues:r.issues.map(o=>Ta(o,s,$a()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(r=>Ta(r,s,$a()))},input:t.value}),t.issues=[]),t)}}),Gj=Q("$ZodPipe",(n,e)=>{At.init(n,e),Pt(n._zod,"values",()=>e.in._zod.values),Pt(n._zod,"optin",()=>e.in._zod.optin),Pt(n._zod,"optout",()=>e.out._zod.optout),n._zod.parse=(t,s)=>{const i=e.in._zod.run(t,s);return i instanceof Promise?i.then(r=>RA(r,e,s)):RA(i,e,s)}});function RA(n,e,t){return Ld(n)?n:e.out._zod.run({value:n.value,issues:n.issues},t)}const Kj=Q("$ZodReadonly",(n,e)=>{At.init(n,e),Pt(n._zod,"propValues",()=>e.innerType._zod.propValues),Pt(n._zod,"values",()=>e.innerType._zod.values),Pt(n._zod,"optin",()=>e.innerType._zod.optin),Pt(n._zod,"optout",()=>e.innerType._zod.optout),n._zod.parse=(t,s)=>{const i=e.innerType._zod.run(t,s);return i instanceof Promise?i.then(MA):MA(i)}});function MA(n){return n.value=Object.freeze(n.value),n}const Zj=Q("$ZodCustom",(n,e)=>{Bs.init(n,e),At.init(n,e),n._zod.parse=(t,s)=>t,n._zod.check=t=>{const s=t.value,i=e.fn(s);if(i instanceof Promise)return i.then(r=>IA(r,t,s,n));IA(i,t,s,n)}});function IA(n,e,t,s){if(!n){const i={code:"custom",input:t,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(i.params=s._zod.def.params),e.issues.push(sf(i))}}class Xj{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){const s=t[0];if(this._map.set(e,s),s&&typeof s=="object"&&"id"in s){if(this._idmap.has(s.id))throw new Error(`ID ${s.id} already exists in the registry`);this._idmap.set(s.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const s={...this.get(t)??{}};return delete s.id,{...s,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function Yj(){return new Xj}const wm=Yj();function Jj(n,e){return new n({type:"string",...ve(e)})}function Qj(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...ve(e)})}function OA(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...ve(e)})}function eF(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...ve(e)})}function tF(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ve(e)})}function nF(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ve(e)})}function sF(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ve(e)})}function C$(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...ve(e)})}function iF(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...ve(e)})}function rF(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...ve(e)})}function oF(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...ve(e)})}function aF(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...ve(e)})}function lF(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...ve(e)})}function cF(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...ve(e)})}function hF(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...ve(e)})}function uF(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...ve(e)})}function dF(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...ve(e)})}function fF(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ve(e)})}function pF(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ve(e)})}function mF(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...ve(e)})}function gF(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...ve(e)})}function yF(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...ve(e)})}function vF(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...ve(e)})}function bF(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ve(e)})}function wF(n,e){return new n({type:"string",format:"date",check:"string_format",...ve(e)})}function _F(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...ve(e)})}function SF(n,e){return new n({type:"string",format:"duration",check:"string_format",...ve(e)})}function xF(n,e){return new n({type:"number",checks:[],...ve(e)})}function AF(n,e){return new n({type:"number",coerce:!0,checks:[],...ve(e)})}function kF(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...ve(e)})}function EF(n,e){return new n({type:"boolean",...ve(e)})}function CF(n,e){return new n({type:"undefined",...ve(e)})}function $F(n,e){return new n({type:"null",...ve(e)})}function TF(n){return new n({type:"any"})}function PF(n){return new n({type:"unknown"})}function RF(n,e){return new n({type:"never",...ve(e)})}function NA(n,e){return new S$({check:"less_than",...ve(e),value:n,inclusive:!1})}function cv(n,e){return new S$({check:"less_than",...ve(e),value:n,inclusive:!0})}function LA(n,e){return new x$({check:"greater_than",...ve(e),value:n,inclusive:!1})}function hv(n,e){return new x$({check:"greater_than",...ve(e),value:n,inclusive:!0})}function DA(n,e){return new H2({check:"multiple_of",...ve(e),value:n})}function $$(n,e){return new U2({check:"max_length",...ve(e),maximum:n})}function ty(n,e){return new q2({check:"min_length",...ve(e),minimum:n})}function T$(n,e){return new V2({check:"length_equals",...ve(e),length:n})}function MF(n,e){return new W2({check:"string_format",format:"regex",...ve(e),pattern:n})}function IF(n){return new G2({check:"string_format",format:"lowercase",...ve(n)})}function OF(n){return new K2({check:"string_format",format:"uppercase",...ve(n)})}function NF(n,e){return new Z2({check:"string_format",format:"includes",...ve(e),includes:n})}function LF(n,e){return new X2({check:"string_format",format:"starts_with",...ve(e),prefix:n})}function DF(n,e){return new Y2({check:"string_format",format:"ends_with",...ve(e),suffix:n})}function Fp(n){return new J2({check:"overwrite",tx:n})}function jF(n){return Fp(e=>e.normalize(n))}function FF(){return Fp(n=>n.trim())}function zF(){return Fp(n=>n.toLowerCase())}function HF(){return Fp(n=>n.toUpperCase())}function BF(n,e,t){return new n({type:"array",element:e,...ve(t)})}function UF(n,e,t){const s=ve(t);return s.abort??(s.abort=!0),new n({type:"custom",check:"custom",fn:e,...s})}function qF(n,e,t){return new n({type:"custom",check:"custom",fn:e,...ve(t)})}const VF=Q("ZodISODateTime",(n,e)=>{dj.init(n,e),Ut.init(n,e)});function P$(n){return bF(VF,n)}const WF=Q("ZodISODate",(n,e)=>{fj.init(n,e),Ut.init(n,e)});function GF(n){return wF(WF,n)}const KF=Q("ZodISOTime",(n,e)=>{pj.init(n,e),Ut.init(n,e)});function ZF(n){return _F(KF,n)}const XF=Q("ZodISODuration",(n,e)=>{mj.init(n,e),Ut.init(n,e)});function YF(n){return SF(XF,n)}const JF=(n,e)=>{f$.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>l2(n,t)},flatten:{value:t=>a2(n,t)},addIssue:{value:t=>n.issues.push(t)},addIssues:{value:t=>n.issues.push(...t)},isEmpty:{get(){return n.issues.length===0}}})},m0=Q("ZodError",JF,{Parent:Error}),QF=c2(m0),ez=h2(m0),tz=m$(m0),nz=y$(m0),Rt=Q("ZodType",(n,e)=>(At.init(n,e),n.def=e,Object.defineProperty(n,"_def",{value:e}),n.check=(...t)=>n.clone({...e,checks:[...e.checks??[],...t.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),n.clone=(t,s)=>Cc(n,t,s),n.brand=()=>n,n.register=(t,s)=>(t.add(n,s),n),n.parse=(t,s)=>QF(n,t,s,{callee:n.parse}),n.safeParse=(t,s)=>tz(n,t,s),n.parseAsync=async(t,s)=>ez(n,t,s,{callee:n.parseAsync}),n.safeParseAsync=async(t,s)=>nz(n,t,s),n.spa=n.safeParseAsync,n.refine=(t,s)=>n.check(Kz(t,s)),n.superRefine=t=>n.check(Zz(t)),n.overwrite=t=>n.check(Fp(t)),n.optional=()=>Bt(n),n.nullable=()=>zA(n),n.nullish=()=>Bt(zA(n)),n.nonoptional=t=>zz(n,t),n.array=()=>re(n),n.or=t=>Ye([n,t]),n.and=t=>hS(n,t),n.transform=t=>lb(n,L$(t)),n.default=t=>Dz(n,t),n.prefault=t=>Fz(n,t),n.catch=t=>Bz(n,t),n.pipe=t=>lb(n,t),n.readonly=()=>Vz(n),n.describe=t=>{const s=n.clone();return wm.add(s,{description:t}),s},Object.defineProperty(n,"description",{get(){var t;return(t=wm.get(n))==null?void 0:t.description},configurable:!0}),n.meta=(...t)=>{if(t.length===0)return wm.get(n);const s=n.clone();return wm.add(s,t[0]),s},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n)),R$=Q("_ZodString",(n,e)=>{aS.init(n,e),Rt.init(n,e);const t=n._zod.bag;n.format=t.format??null,n.minLength=t.minimum??null,n.maxLength=t.maximum??null,n.regex=(...s)=>n.check(MF(...s)),n.includes=(...s)=>n.check(NF(...s)),n.startsWith=(...s)=>n.check(LF(...s)),n.endsWith=(...s)=>n.check(DF(...s)),n.min=(...s)=>n.check(ty(...s)),n.max=(...s)=>n.check($$(...s)),n.length=(...s)=>n.check(T$(...s)),n.nonempty=(...s)=>n.check(ty(1,...s)),n.lowercase=s=>n.check(IF(s)),n.uppercase=s=>n.check(OF(s)),n.trim=()=>n.check(FF()),n.normalize=(...s)=>n.check(jF(...s)),n.toLowerCase=()=>n.check(zF()),n.toUpperCase=()=>n.check(HF())}),sz=Q("ZodString",(n,e)=>{aS.init(n,e),R$.init(n,e),n.email=t=>n.check(Qj(iz,t)),n.url=t=>n.check(C$(M$,t)),n.jwt=t=>n.check(vF(wz,t)),n.emoji=t=>n.check(iF(oz,t)),n.guid=t=>n.check(OA(jA,t)),n.uuid=t=>n.check(eF(_m,t)),n.uuidv4=t=>n.check(tF(_m,t)),n.uuidv6=t=>n.check(nF(_m,t)),n.uuidv7=t=>n.check(sF(_m,t)),n.nanoid=t=>n.check(rF(az,t)),n.guid=t=>n.check(OA(jA,t)),n.cuid=t=>n.check(oF(lz,t)),n.cuid2=t=>n.check(aF(cz,t)),n.ulid=t=>n.check(lF(hz,t)),n.base64=t=>n.check(mF(yz,t)),n.base64url=t=>n.check(gF(vz,t)),n.xid=t=>n.check(cF(uz,t)),n.ksuid=t=>n.check(hF(dz,t)),n.ipv4=t=>n.check(uF(fz,t)),n.ipv6=t=>n.check(dF(pz,t)),n.cidrv4=t=>n.check(fF(mz,t)),n.cidrv6=t=>n.check(pF(gz,t)),n.e164=t=>n.check(yF(bz,t)),n.datetime=t=>n.check(P$(t)),n.date=t=>n.check(GF(t)),n.time=t=>n.check(ZF(t)),n.duration=t=>n.check(YF(t))});function F(n){return Jj(sz,n)}const Ut=Q("ZodStringFormat",(n,e)=>{Nt.init(n,e),R$.init(n,e)}),iz=Q("ZodEmail",(n,e)=>{sj.init(n,e),Ut.init(n,e)}),jA=Q("ZodGUID",(n,e)=>{tj.init(n,e),Ut.init(n,e)}),_m=Q("ZodUUID",(n,e)=>{nj.init(n,e),Ut.init(n,e)}),M$=Q("ZodURL",(n,e)=>{ij.init(n,e),Ut.init(n,e)});function rz(n){return C$(M$,n)}const oz=Q("ZodEmoji",(n,e)=>{rj.init(n,e),Ut.init(n,e)}),az=Q("ZodNanoID",(n,e)=>{oj.init(n,e),Ut.init(n,e)}),lz=Q("ZodCUID",(n,e)=>{aj.init(n,e),Ut.init(n,e)}),cz=Q("ZodCUID2",(n,e)=>{lj.init(n,e),Ut.init(n,e)}),hz=Q("ZodULID",(n,e)=>{cj.init(n,e),Ut.init(n,e)}),uz=Q("ZodXID",(n,e)=>{hj.init(n,e),Ut.init(n,e)}),dz=Q("ZodKSUID",(n,e)=>{uj.init(n,e),Ut.init(n,e)}),fz=Q("ZodIPv4",(n,e)=>{gj.init(n,e),Ut.init(n,e)}),pz=Q("ZodIPv6",(n,e)=>{yj.init(n,e),Ut.init(n,e)}),mz=Q("ZodCIDRv4",(n,e)=>{vj.init(n,e),Ut.init(n,e)}),gz=Q("ZodCIDRv6",(n,e)=>{bj.init(n,e),Ut.init(n,e)}),yz=Q("ZodBase64",(n,e)=>{wj.init(n,e),Ut.init(n,e)}),vz=Q("ZodBase64URL",(n,e)=>{Sj.init(n,e),Ut.init(n,e)}),bz=Q("ZodE164",(n,e)=>{xj.init(n,e),Ut.init(n,e)}),wz=Q("ZodJWT",(n,e)=>{kj.init(n,e),Ut.init(n,e)}),lS=Q("ZodNumber",(n,e)=>{k$.init(n,e),Rt.init(n,e),n.gt=(s,i)=>n.check(LA(s,i)),n.gte=(s,i)=>n.check(hv(s,i)),n.min=(s,i)=>n.check(hv(s,i)),n.lt=(s,i)=>n.check(NA(s,i)),n.lte=(s,i)=>n.check(cv(s,i)),n.max=(s,i)=>n.check(cv(s,i)),n.int=s=>n.check(FA(s)),n.safe=s=>n.check(FA(s)),n.positive=s=>n.check(LA(0,s)),n.nonnegative=s=>n.check(hv(0,s)),n.negative=s=>n.check(NA(0,s)),n.nonpositive=s=>n.check(cv(0,s)),n.multipleOf=(s,i)=>n.check(DA(s,i)),n.step=(s,i)=>n.check(DA(s,i)),n.finite=()=>n;const t=n._zod.bag;n.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),n.isFinite=!0,n.format=t.format??null});function je(n){return xF(lS,n)}const _z=Q("ZodNumberFormat",(n,e)=>{Ej.init(n,e),lS.init(n,e)});function FA(n){return kF(_z,n)}const Sz=Q("ZodBoolean",(n,e)=>{Cj.init(n,e),Rt.init(n,e)});function et(n){return EF(Sz,n)}const xz=Q("ZodUndefined",(n,e)=>{$j.init(n,e),Rt.init(n,e)});function rb(n){return CF(xz,n)}const Az=Q("ZodNull",(n,e)=>{Tj.init(n,e),Rt.init(n,e)});function kz(n){return $F(Az,n)}const Ez=Q("ZodAny",(n,e)=>{Pj.init(n,e),Rt.init(n,e)});function cS(){return TF(Ez)}const Cz=Q("ZodUnknown",(n,e)=>{Rj.init(n,e),Rt.init(n,e)});function xt(){return PF(Cz)}const $z=Q("ZodNever",(n,e)=>{Mj.init(n,e),Rt.init(n,e)});function ob(n){return RF($z,n)}const Tz=Q("ZodArray",(n,e)=>{Ij.init(n,e),Rt.init(n,e),n.element=e.element,n.min=(t,s)=>n.check(ty(t,s)),n.nonempty=t=>n.check(ty(1,t)),n.max=(t,s)=>n.check($$(t,s)),n.length=(t,s)=>n.check(T$(t,s)),n.unwrap=()=>n.element});function re(n,e){return BF(Tz,n,e)}const I$=Q("ZodObject",(n,e)=>{Oj.init(n,e),Rt.init(n,e),Pt(n,"shape",()=>e.shape),n.keyof=()=>oi(Object.keys(n._zod.def.shape)),n.catchall=t=>n.clone({...n._zod.def,catchall:t}),n.passthrough=()=>n.clone({...n._zod.def,catchall:xt()}),n.loose=()=>n.clone({...n._zod.def,catchall:xt()}),n.strict=()=>n.clone({...n._zod.def,catchall:ob()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>s2(n,t),n.merge=t=>i2(n,t),n.pick=t=>t2(n,t),n.omit=t=>n2(n,t),n.partial=(...t)=>r2(D$,n,t[0]),n.required=(...t)=>o2(j$,n,t[0])});function K(n,e){const t={type:"object",get shape(){return f0(this,"shape",{...n}),this.shape},...ve(e)};return new I$(t)}function qn(n,e){return new I$({type:"object",get shape(){return f0(this,"shape",{...n}),this.shape},catchall:xt(),...ve(e)})}const O$=Q("ZodUnion",(n,e)=>{E$.init(n,e),Rt.init(n,e),n.options=e.options});function Ye(n,e){return new O$({type:"union",options:n,...ve(e)})}const Pz=Q("ZodDiscriminatedUnion",(n,e)=>{O$.init(n,e),Nj.init(n,e)});function N$(n,e,t){return new Pz({type:"union",options:e,discriminator:n,...ve(t)})}const Rz=Q("ZodIntersection",(n,e)=>{Lj.init(n,e),Rt.init(n,e)});function hS(n,e){return new Rz({type:"intersection",left:n,right:e})}const Mz=Q("ZodRecord",(n,e)=>{Dj.init(n,e),Rt.init(n,e),n.keyType=e.keyType,n.valueType=e.valueType});function tt(n,e,t){return new Mz({type:"record",keyType:n,valueType:e,...ve(t)})}const ab=Q("ZodEnum",(n,e)=>{jj.init(n,e),Rt.init(n,e),n.enum=e.entries,n.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));n.extract=(s,i)=>{const r={};for(const o of s)if(t.has(o))r[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new ab({...e,checks:[],...ve(i),entries:r})},n.exclude=(s,i)=>{const r={...e.entries};for(const o of s)if(t.has(o))delete r[o];else throw new Error(`Key ${o} not found in enum`);return new ab({...e,checks:[],...ve(i),entries:r})}});function oi(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(s=>[s,s])):n;return new ab({type:"enum",entries:t,...ve(e)})}const Iz=Q("ZodLiteral",(n,e)=>{Fj.init(n,e),Rt.init(n,e),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function W(n,e){return new Iz({type:"literal",values:Array.isArray(n)?n:[n],...ve(e)})}const Oz=Q("ZodTransform",(n,e)=>{zj.init(n,e),Rt.init(n,e),n._zod.parse=(t,s)=>{t.addIssue=r=>{if(typeof r=="string")t.issues.push(sf(r,t.value,e));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),o.continue??(o.continue=!0),t.issues.push(sf(o))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(r=>(t.value=r,t)):(t.value=i,t)}});function L$(n){return new Oz({type:"transform",transform:n})}const D$=Q("ZodOptional",(n,e)=>{Hj.init(n,e),Rt.init(n,e),n.unwrap=()=>n._zod.def.innerType});function Bt(n){return new D$({type:"optional",innerType:n})}const Nz=Q("ZodNullable",(n,e)=>{Bj.init(n,e),Rt.init(n,e),n.unwrap=()=>n._zod.def.innerType});function zA(n){return new Nz({type:"nullable",innerType:n})}const Lz=Q("ZodDefault",(n,e)=>{Uj.init(n,e),Rt.init(n,e),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function Dz(n,e){return new Lz({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():e}})}const jz=Q("ZodPrefault",(n,e)=>{qj.init(n,e),Rt.init(n,e),n.unwrap=()=>n._zod.def.innerType});function Fz(n,e){return new jz({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():e}})}const j$=Q("ZodNonOptional",(n,e)=>{Vj.init(n,e),Rt.init(n,e),n.unwrap=()=>n._zod.def.innerType});function zz(n,e){return new j$({type:"nonoptional",innerType:n,...ve(e)})}const Hz=Q("ZodCatch",(n,e)=>{Wj.init(n,e),Rt.init(n,e),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function Bz(n,e){return new Hz({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const Uz=Q("ZodPipe",(n,e)=>{Gj.init(n,e),Rt.init(n,e),n.in=e.in,n.out=e.out});function lb(n,e){return new Uz({type:"pipe",in:n,out:e})}const qz=Q("ZodReadonly",(n,e)=>{Kj.init(n,e),Rt.init(n,e)});function Vz(n){return new qz({type:"readonly",innerType:n})}const F$=Q("ZodCustom",(n,e)=>{Zj.init(n,e),Rt.init(n,e)});function Wz(n){const e=new Bs({check:"custom"});return e._zod.check=n,e}function Gz(n,e){return UF(F$,n??(()=>!0),e)}function Kz(n,e={}){return qF(F$,n,e)}function Zz(n){const e=Wz(t=>(t.addIssue=s=>{if(typeof s=="string")t.issues.push(sf(s,t.value,e._zod.def));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),t.issues.push(sf(i))}},n(t.value,t)));return e}function z$(n,e){return lb(L$(n),e)}const Xz={custom:"custom"};function Yz(n){return AF(lS,n)}const g0="2025-11-25",Jz=[g0,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Ka="io.modelcontextprotocol/related-task",y0="2.0",gn=Gz(n=>n!==null&&(typeof n=="object"||typeof n=="function")),H$=Ye([F(),je().int()]),B$=F();qn({ttl:je().optional(),pollInterval:je().optional()});const Qz=K({ttl:je().optional()}),eH=K({taskId:F()}),uS=qn({progressToken:H$.optional(),[Ka]:eH.optional()}),ai=K({_meta:uS.optional()}),zp=ai.extend({task:Qz.optional()}),tH=n=>zp.safeParse(n).success,Gn=K({method:F(),params:ai.loose().optional()}),Ai=K({_meta:uS.optional()}),ki=K({method:F(),params:Ai.loose().optional()}),Kn=qn({_meta:uS.optional()}),Hp=Ye([F(),je().int()]),U$=K({jsonrpc:W(y0),id:Hp,...Gn.shape}).strict(),cb=n=>U$.safeParse(n).success,q$=K({jsonrpc:W(y0),...ki.shape}).strict(),nH=n=>q$.safeParse(n).success,dS=K({jsonrpc:W(y0),id:Hp,result:Kn}).strict(),ud=n=>dS.safeParse(n).success;var Re;(function(n){n[n.ConnectionClosed=-32e3]="ConnectionClosed",n[n.RequestTimeout=-32001]="RequestTimeout",n[n.ParseError=-32700]="ParseError",n[n.InvalidRequest=-32600]="InvalidRequest",n[n.MethodNotFound=-32601]="MethodNotFound",n[n.InvalidParams=-32602]="InvalidParams",n[n.InternalError=-32603]="InternalError",n[n.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(Re||(Re={}));const fS=K({jsonrpc:W(y0),id:Hp.optional(),error:K({code:je().int(),message:F(),data:xt().optional()})}).strict(),sH=n=>fS.safeParse(n).success,rg=Ye([U$,q$,dS,fS]);Ye([dS,fS]);const eh=Kn.strict(),iH=Ai.extend({requestId:Hp.optional(),reason:F().optional()}),pS=ki.extend({method:W("notifications/cancelled"),params:iH}),rH=K({src:F(),mimeType:F().optional(),sizes:re(F()).optional(),theme:oi(["light","dark"]).optional()}),Bp=K({icons:re(rH).optional()}),yu=K({name:F(),title:F().optional()}),v0=yu.extend({...yu.shape,...Bp.shape,version:F(),websiteUrl:F().optional(),description:F().optional()}),oH=hS(K({applyDefaults:et().optional()}),tt(F(),xt())),aH=z$(n=>n&&typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0?{form:{}}:n,hS(K({form:oH.optional(),url:gn.optional()}),tt(F(),xt()).optional())),lH=qn({list:gn.optional(),cancel:gn.optional(),requests:qn({sampling:qn({createMessage:gn.optional()}).optional(),elicitation:qn({create:gn.optional()}).optional()}).optional()}),cH=qn({list:gn.optional(),cancel:gn.optional(),requests:qn({tools:qn({call:gn.optional()}).optional()}).optional()}),hH=K({experimental:tt(F(),gn).optional(),sampling:K({context:gn.optional(),tools:gn.optional()}).optional(),elicitation:aH.optional(),roots:K({listChanged:et().optional()}).optional(),tasks:lH.optional(),extensions:tt(F(),gn).optional()}),uH=ai.extend({protocolVersion:F(),capabilities:hH,clientInfo:v0}),dH=Gn.extend({method:W("initialize"),params:uH}),fH=K({experimental:tt(F(),gn).optional(),logging:gn.optional(),completions:gn.optional(),prompts:K({listChanged:et().optional()}).optional(),resources:K({subscribe:et().optional(),listChanged:et().optional()}).optional(),tools:K({listChanged:et().optional()}).optional(),tasks:cH.optional(),extensions:tt(F(),gn).optional()}),V$=Kn.extend({protocolVersion:F(),capabilities:fH,serverInfo:v0,instructions:F().optional()}),W$=ki.extend({method:W("notifications/initialized"),params:Ai.optional()}),pH=n=>W$.safeParse(n).success,b0=Gn.extend({method:W("ping"),params:ai.optional()}),mH=K({progress:je(),total:Bt(je()),message:Bt(F())}),gH=K({...Ai.shape,...mH.shape,progressToken:H$}),mS=ki.extend({method:W("notifications/progress"),params:gH}),yH=ai.extend({cursor:B$.optional()}),Up=Gn.extend({params:yH.optional()}),qp=Kn.extend({nextCursor:B$.optional()}),vH=oi(["working","input_required","completed","failed","cancelled"]),Vp=K({taskId:F(),status:vH,ttl:Ye([je(),kz()]),createdAt:F(),lastUpdatedAt:F(),pollInterval:Bt(je()),statusMessage:Bt(F())}),rf=Kn.extend({task:Vp}),bH=Ai.merge(Vp),ny=ki.extend({method:W("notifications/tasks/status"),params:bH}),gS=Gn.extend({method:W("tasks/get"),params:ai.extend({taskId:F()})}),yS=Kn.merge(Vp),vS=Gn.extend({method:W("tasks/result"),params:ai.extend({taskId:F()})});Kn.loose();const bS=Up.extend({method:W("tasks/list")}),wS=qp.extend({tasks:re(Vp)}),_S=Gn.extend({method:W("tasks/cancel"),params:ai.extend({taskId:F()})}),wH=Kn.merge(Vp),G$=K({uri:F(),mimeType:Bt(F()),_meta:tt(F(),xt()).optional()}),K$=G$.extend({text:F()}),SS=F().refine(n=>{try{return atob(n),!0}catch{return!1}},{message:"Invalid Base64 string"}),Z$=G$.extend({blob:SS}),Wp=oi(["user","assistant"]),Ou=K({audience:re(Wp).optional(),priority:je().min(0).max(1).optional(),lastModified:P$({offset:!0}).optional()}),X$=K({...yu.shape,...Bp.shape,uri:F(),description:Bt(F()),mimeType:Bt(F()),size:Bt(je()),annotations:Ou.optional(),_meta:Bt(qn({}))}),_H=K({...yu.shape,...Bp.shape,uriTemplate:F(),description:Bt(F()),mimeType:Bt(F()),annotations:Ou.optional(),_meta:Bt(qn({}))}),Y$=Up.extend({method:W("resources/list")}),xS=qp.extend({resources:re(X$)}),J$=Up.extend({method:W("resources/templates/list")}),AS=qp.extend({resourceTemplates:re(_H)}),kS=ai.extend({uri:F()}),SH=kS,Q$=Gn.extend({method:W("resources/read"),params:SH}),ES=Kn.extend({contents:re(Ye([K$,Z$]))}),CS=ki.extend({method:W("notifications/resources/list_changed"),params:Ai.optional()}),xH=kS,AH=Gn.extend({method:W("resources/subscribe"),params:xH}),kH=kS,EH=Gn.extend({method:W("resources/unsubscribe"),params:kH}),CH=Ai.extend({uri:F()}),$H=ki.extend({method:W("notifications/resources/updated"),params:CH}),TH=K({name:F(),description:Bt(F()),required:Bt(et())}),PH=K({...yu.shape,...Bp.shape,description:Bt(F()),arguments:Bt(re(TH)),_meta:Bt(qn({}))}),eT=Up.extend({method:W("prompts/list")}),$S=qp.extend({prompts:re(PH)}),RH=ai.extend({name:F(),arguments:tt(F(),F()).optional()}),MH=Gn.extend({method:W("prompts/get"),params:RH}),TS=K({type:W("text"),text:F(),annotations:Ou.optional(),_meta:tt(F(),xt()).optional()}),PS=K({type:W("image"),data:SS,mimeType:F(),annotations:Ou.optional(),_meta:tt(F(),xt()).optional()}),RS=K({type:W("audio"),data:SS,mimeType:F(),annotations:Ou.optional(),_meta:tt(F(),xt()).optional()}),IH=K({type:W("tool_use"),name:F(),id:F(),input:tt(F(),xt()),_meta:tt(F(),xt()).optional()}),tT=K({type:W("resource"),resource:Ye([K$,Z$]),annotations:Ou.optional(),_meta:tt(F(),xt()).optional()}),nT=X$.extend({type:W("resource_link")}),Gp=Ye([TS,PS,RS,nT,tT]),OH=K({role:Wp,content:Gp}),sT=Kn.extend({description:F().optional(),messages:re(OH)}),MS=ki.extend({method:W("notifications/prompts/list_changed"),params:Ai.optional()}),NH=K({title:F().optional(),readOnlyHint:et().optional(),destructiveHint:et().optional(),idempotentHint:et().optional(),openWorldHint:et().optional()}),LH=K({taskSupport:oi(["required","optional","forbidden"]).optional()}),IS=K({...yu.shape,...Bp.shape,description:F().optional(),inputSchema:K({type:W("object"),properties:tt(F(),gn).optional(),required:re(F()).optional()}).catchall(xt()),outputSchema:K({type:W("object"),properties:tt(F(),gn).optional(),required:re(F()).optional()}).catchall(xt()).optional(),annotations:NH.optional(),execution:LH.optional(),_meta:tt(F(),xt()).optional()}),DH=Up.extend({method:W("tools/list")}),OS=qp.extend({tools:re(IS)}),cc=Kn.extend({content:re(Gp).default([]),structuredContent:tt(F(),xt()).optional(),isError:et().optional()});cc.or(Kn.extend({toolResult:xt()}));const jH=zp.extend({name:F(),arguments:tt(F(),xt()).optional()}),iT=Gn.extend({method:W("tools/call"),params:jH}),NS=ki.extend({method:W("notifications/tools/list_changed"),params:Ai.optional()}),FH=K({autoRefresh:et().default(!0),debounceMs:je().int().nonnegative().default(300)}),rT=oi(["debug","info","notice","warning","error","critical","alert","emergency"]),zH=ai.extend({level:rT}),HH=Gn.extend({method:W("logging/setLevel"),params:zH}),BH=Ai.extend({level:rT,logger:F().optional(),data:xt()}),oT=ki.extend({method:W("notifications/message"),params:BH}),UH=K({name:F().optional()}),qH=K({hints:re(UH).optional(),costPriority:je().min(0).max(1).optional(),speedPriority:je().min(0).max(1).optional(),intelligencePriority:je().min(0).max(1).optional()}),VH=K({mode:oi(["auto","required","none"]).optional()}),WH=K({type:W("tool_result"),toolUseId:F().describe("The unique identifier for the corresponding tool call."),content:re(Gp).default([]),structuredContent:K({}).loose().optional(),isError:et().optional(),_meta:tt(F(),xt()).optional()}),GH=N$("type",[TS,PS,RS]),sy=N$("type",[TS,PS,RS,IH,WH]),KH=K({role:Wp,content:Ye([sy,re(sy)]),_meta:tt(F(),xt()).optional()}),ZH=zp.extend({messages:re(KH),modelPreferences:qH.optional(),systemPrompt:F().optional(),includeContext:oi(["none","thisServer","allServers"]).optional(),temperature:je().optional(),maxTokens:je().int(),stopSequences:re(F()).optional(),metadata:gn.optional(),tools:re(IS).optional(),toolChoice:VH.optional()}),LS=Gn.extend({method:W("sampling/createMessage"),params:ZH}),aT=Kn.extend({model:F(),stopReason:Bt(oi(["endTurn","stopSequence","maxTokens"]).or(F())),role:Wp,content:GH}),lT=Kn.extend({model:F(),stopReason:Bt(oi(["endTurn","stopSequence","maxTokens","toolUse"]).or(F())),role:Wp,content:Ye([sy,re(sy)])}),XH=K({type:W("boolean"),title:F().optional(),description:F().optional(),default:et().optional()}),YH=K({type:W("string"),title:F().optional(),description:F().optional(),minLength:je().optional(),maxLength:je().optional(),format:oi(["email","uri","date","date-time"]).optional(),default:F().optional()}),JH=K({type:oi(["number","integer"]),title:F().optional(),description:F().optional(),minimum:je().optional(),maximum:je().optional(),default:je().optional()}),QH=K({type:W("string"),title:F().optional(),description:F().optional(),enum:re(F()),default:F().optional()}),eB=K({type:W("string"),title:F().optional(),description:F().optional(),oneOf:re(K({const:F(),title:F()})),default:F().optional()}),tB=K({type:W("string"),title:F().optional(),description:F().optional(),enum:re(F()),enumNames:re(F()).optional(),default:F().optional()}),nB=Ye([QH,eB]),sB=K({type:W("array"),title:F().optional(),description:F().optional(),minItems:je().optional(),maxItems:je().optional(),items:K({type:W("string"),enum:re(F())}),default:re(F()).optional()}),iB=K({type:W("array"),title:F().optional(),description:F().optional(),minItems:je().optional(),maxItems:je().optional(),items:K({anyOf:re(K({const:F(),title:F()}))}),default:re(F()).optional()}),rB=Ye([sB,iB]),oB=Ye([tB,nB,rB]),aB=Ye([oB,XH,YH,JH]),lB=zp.extend({mode:W("form").optional(),message:F(),requestedSchema:K({type:W("object"),properties:tt(F(),aB),required:re(F()).optional()})}),cB=zp.extend({mode:W("url"),message:F(),elicitationId:F(),url:F().url()}),hB=Ye([lB,cB]),cT=Gn.extend({method:W("elicitation/create"),params:hB}),uB=Ai.extend({elicitationId:F()}),dB=ki.extend({method:W("notifications/elicitation/complete"),params:uB}),hT=Kn.extend({action:oi(["accept","decline","cancel"]),content:z$(n=>n===null?void 0:n,tt(F(),Ye([F(),je(),et(),re(F())])).optional())}),fB=K({type:W("ref/resource"),uri:F()}),pB=K({type:W("ref/prompt"),name:F()}),mB=ai.extend({ref:Ye([pB,fB]),argument:K({name:F(),value:F()}),context:K({arguments:tt(F(),F()).optional()}).optional()}),gB=Gn.extend({method:W("completion/complete"),params:mB}),uT=Kn.extend({completion:qn({values:re(F()).max(100),total:Bt(je().int()),hasMore:Bt(et())})}),yB=K({uri:F().startsWith("file://"),name:F().optional(),_meta:tt(F(),xt()).optional()}),vB=Gn.extend({method:W("roots/list"),params:ai.optional()}),bB=Kn.extend({roots:re(yB)}),wB=ki.extend({method:W("notifications/roots/list_changed"),params:Ai.optional()});Ye([b0,dH,gB,HH,MH,eT,Y$,J$,Q$,AH,EH,iT,DH,gS,vS,bS,_S]);Ye([pS,mS,W$,wB,ny]);Ye([eh,aT,lT,hT,bB,yS,wS,rf]);Ye([b0,LS,cT,vB,gS,vS,bS,_S]);Ye([pS,mS,oT,$H,CS,NS,MS,ny,dB]);Ye([eh,V$,uT,sT,$S,xS,AS,ES,cc,OS,yS,wS,rf]);class Ee extends Error{constructor(e,t,s){super(`MCP error ${e}: ${t}`),this.code=e,this.data=s,this.name="McpError"}static fromError(e,t,s){if(e===Re.UrlElicitationRequired&&s){const i=s;if(i.elicitations)return new _B(i.elicitations,t)}return new Ee(e,t,s)}}class _B extends Ee{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(Re.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){var e;return((e=this.data)==null?void 0:e.elicitations)??[]}}function DS(n){return!!n._zod}function zo(n,e){return DS(n)?g$(n,e):n.safeParse(e)}function dT(n){var t,s;if(!n)return;let e;if(DS(n)?e=(s=(t=n._zod)==null?void 0:t.def)==null?void 0:s.shape:e=n.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function fT(n){var i;if(DS(n)){const o=(i=n._zod)==null?void 0:i.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}const t=n._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const s=n.value;if(s!==void 0)return s}function Ha(n){return n==="completed"||n==="failed"||n==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function HA(n){const e=dT(n),t=e==null?void 0:e.method;if(!t)throw new Error("Schema is missing a method literal");const s=fT(t);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function BA(n,e){const t=zo(n,e);if(!t.success)throw t.error;return t.data}const SB=6e4;class pT{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(pS,t=>{this._oncancel(t)}),this.setNotificationHandler(mS,t=>{this._onprogress(t)}),this.setRequestHandler(b0,t=>({})),this._taskStore=e==null?void 0:e.taskStore,this._taskMessageQueue=e==null?void 0:e.taskMessageQueue,this._taskStore&&(this.setRequestHandler(gS,async(t,s)=>{const i=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!i)throw new Ee(Re.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(vS,async(t,s)=>{const i=async()=>{var a;const r=t.params.taskId;if(this._taskMessageQueue){let l;for(;l=await this._taskMessageQueue.dequeue(r,s.sessionId);){if(l.type==="response"||l.type==="error"){const c=l.message,h=c.id,u=this._requestResolvers.get(h);if(u)if(this._requestResolvers.delete(h),l.type==="response")u(c);else{const d=c,p=new Ee(d.error.code,d.error.message,d.error.data);u(p)}else{const d=l.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${h}`))}continue}await((a=this._transport)==null?void 0:a.send(l.message,{relatedRequestId:s.requestId}))}}const o=await this._taskStore.getTask(r,s.sessionId);if(!o)throw new Ee(Re.InvalidParams,`Task not found: ${r}`);if(!Ha(o.status))return await this._waitForTaskUpdate(r,s.signal),await i();if(Ha(o.status)){const l=await this._taskStore.getTaskResult(r,s.sessionId);return this._clearTaskQueue(r),{...l,_meta:{...l._meta,[Ka]:{taskId:r}}}}return await i()};return await i()}),this.setRequestHandler(bS,async(t,s)=>{var i;try{const{tasks:r,nextCursor:o}=await this._taskStore.listTasks((i=t.params)==null?void 0:i.cursor,s.sessionId);return{tasks:r,nextCursor:o,_meta:{}}}catch(r){throw new Ee(Re.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(_S,async(t,s)=>{try{const i=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!i)throw new Ee(Re.InvalidParams,`Task not found: ${t.params.taskId}`);if(Ha(i.status))throw new Ee(Re.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(t.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(t.params.taskId);const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new Ee(Re.InvalidParams,`Task not found after cancellation: ${t.params.taskId}`);return{_meta:{},...r}}catch(i){throw i instanceof Ee?i:new Ee(Re.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;const t=this._requestHandlerAbortControllers.get(e.params.requestId);t==null||t.abort(e.params.reason)}_setupTimeout(e,t,s,i,r=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(i,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:r,onTimeout:i})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const s=Date.now()-t.startTime;if(t.maxTotalTimeout&&s>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),Ee.fromError(Re.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:s});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var r,o,a;if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;const t=(r=this.transport)==null?void 0:r.onclose;this._transport.onclose=()=>{t==null||t(),this._onclose()};const s=(o=this.transport)==null?void 0:o.onerror;this._transport.onerror=l=>{s==null||s(l),this._onerror(l)};const i=(a=this._transport)==null?void 0:a.onmessage;this._transport.onmessage=(l,c)=>{i==null||i(l,c),ud(l)||sH(l)?this._onresponse(l):cb(l)?this._onrequest(l,c):nH(l)?this._onnotification(l):this._onerror(new Error(`Unknown message type: ${JSON.stringify(l)}`))},await this._transport.start()}_onclose(){var s;const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const i of this._timeoutInfo.values())clearTimeout(i.timeoutId);this._timeoutInfo.clear();for(const i of this._requestHandlerAbortControllers.values())i.abort();this._requestHandlerAbortControllers.clear();const t=Ee.fromError(Re.ConnectionClosed,"Connection closed");this._transport=void 0,(s=this.onclose)==null||s.call(this);for(const i of e.values())i(t)}_onerror(e){var t;(t=this.onerror)==null||t.call(this,e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,t){var h,u,d,p;const s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,i=this._transport,r=(d=(u=(h=e.params)==null?void 0:h._meta)==null?void 0:u[Ka])==null?void 0:d.taskId;if(s===void 0){const m={jsonrpc:"2.0",id:e.id,error:{code:Re.MethodNotFound,message:"Method not found"}};r&&this._taskMessageQueue?this._enqueueTaskMessage(r,{type:"error",message:m,timestamp:Date.now()},i==null?void 0:i.sessionId).catch(y=>this._onerror(new Error(`Failed to enqueue error response: ${y}`))):i==null||i.send(m).catch(y=>this._onerror(new Error(`Failed to send an error response: ${y}`)));return}const o=new AbortController;this._requestHandlerAbortControllers.set(e.id,o);const a=tH(e.params)?e.params.task:void 0,l=this._taskStore?this.requestTaskStore(e,i==null?void 0:i.sessionId):void 0,c={signal:o.signal,sessionId:i==null?void 0:i.sessionId,_meta:(p=e.params)==null?void 0:p._meta,sendNotification:async m=>{if(o.signal.aborted)return;const y={relatedRequestId:e.id};r&&(y.relatedTask={taskId:r}),await this.notification(m,y)},sendRequest:async(m,y,v)=>{var b;if(o.signal.aborted)throw new Ee(Re.ConnectionClosed,"Request was cancelled");const g={...v,relatedRequestId:e.id};r&&!g.relatedTask&&(g.relatedTask={taskId:r});const _=((b=g.relatedTask)==null?void 0:b.taskId)??r;return _&&l&&await l.updateTaskStatus(_,"input_required"),await this.request(m,y,g)},authInfo:t==null?void 0:t.authInfo,requestId:e.id,requestInfo:t==null?void 0:t.requestInfo,taskId:r,taskStore:l,taskRequestedTtl:a==null?void 0:a.ttl,closeSSEStream:t==null?void 0:t.closeSSEStream,closeStandaloneSSEStream:t==null?void 0:t.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,c)).then(async m=>{if(o.signal.aborted)return;const y={result:m,jsonrpc:"2.0",id:e.id};r&&this._taskMessageQueue?await this._enqueueTaskMessage(r,{type:"response",message:y,timestamp:Date.now()},i==null?void 0:i.sessionId):await(i==null?void 0:i.send(y))},async m=>{if(o.signal.aborted)return;const y={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(m.code)?m.code:Re.InternalError,message:m.message??"Internal error",...m.data!==void 0&&{data:m.data}}};r&&this._taskMessageQueue?await this._enqueueTaskMessage(r,{type:"error",message:y,timestamp:Date.now()},i==null?void 0:i.sessionId):await(i==null?void 0:i.send(y))}).catch(m=>this._onerror(new Error(`Failed to send response: ${m}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===o&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...s}=e.params,i=Number(t),r=this._progressHandlers.get(i);if(!r){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const o=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&o&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(l){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),o(l);return}r(s)}_onresponse(e){const t=Number(e.id),s=this._requestResolvers.get(t);if(s){if(this._requestResolvers.delete(t),ud(e))s(e);else{const o=new Ee(e.error.code,e.error.message,e.error.data);s(o)}return}const i=this._responseHandlers.get(t);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let r=!1;if(ud(e)&&e.result&&typeof e.result=="object"){const o=e.result;if(o.task&&typeof o.task=="object"){const a=o.task;typeof a.taskId=="string"&&(r=!0,this._taskProgressTokens.set(a.taskId,t))}}if(r||this._progressHandlers.delete(t),ud(e))i(e);else{const o=Ee.fromError(e.error.code,e.error.message,e.error.data);i(o)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)==null?void 0:e.close())}async*requestStream(e,t,s){var o,a;const{task:i}=s??{};if(!i){try{yield{type:"result",result:await this.request(e,t,s)}}catch(l){yield{type:"error",error:l instanceof Ee?l:new Ee(Re.InternalError,String(l))}}return}let r;try{const l=await this.request(e,rf,s);if(l.task)r=l.task.taskId,yield{type:"taskCreated",task:l.task};else throw new Ee(Re.InternalError,"Task creation did not return a task");for(;;){const c=await this.getTask({taskId:r},s);if(yield{type:"taskStatus",task:c},Ha(c.status)){c.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:r},t,s)}:c.status==="failed"?yield{type:"error",error:new Ee(Re.InternalError,`Task ${r} failed`)}:c.status==="cancelled"&&(yield{type:"error",error:new Ee(Re.InternalError,`Task ${r} was cancelled`)});return}if(c.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:r},t,s)};return}const h=c.pollInterval??((o=this._options)==null?void 0:o.defaultTaskPollInterval)??1e3;await new Promise(u=>setTimeout(u,h)),(a=s==null?void 0:s.signal)==null||a.throwIfAborted()}}catch(l){yield{type:"error",error:l instanceof Ee?l:new Ee(Re.InternalError,String(l))}}}request(e,t,s){const{relatedRequestId:i,resumptionToken:r,onresumptiontoken:o,task:a,relatedTask:l}=s??{};return new Promise((c,h)=>{var _,b,x,A,T;const u=C=>{h(C)};if(!this._transport){u(new Error("Not connected"));return}if(((_=this._options)==null?void 0:_.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(C){u(C);return}(b=s==null?void 0:s.signal)==null||b.throwIfAborted();const d=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:d};s!=null&&s.onprogress&&(this._progressHandlers.set(d,s.onprogress),p.params={...e.params,_meta:{...((x=e.params)==null?void 0:x._meta)||{},progressToken:d}}),a&&(p.params={...p.params,task:a}),l&&(p.params={...p.params,_meta:{...((A=p.params)==null?void 0:A._meta)||{},[Ka]:l}});const m=C=>{var D;this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),(D=this._transport)==null||D.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:d,reason:String(C)}},{relatedRequestId:i,resumptionToken:r,onresumptiontoken:o}).catch(H=>this._onerror(new Error(`Failed to send cancellation: ${H}`)));const I=C instanceof Ee?C:new Ee(Re.RequestTimeout,String(C));h(I)};this._responseHandlers.set(d,C=>{var I;if(!((I=s==null?void 0:s.signal)!=null&&I.aborted)){if(C instanceof Error)return h(C);try{const D=zo(t,C.result);D.success?c(D.data):h(D.error)}catch(D){h(D)}}}),(T=s==null?void 0:s.signal)==null||T.addEventListener("abort",()=>{var C;m((C=s==null?void 0:s.signal)==null?void 0:C.reason)});const y=(s==null?void 0:s.timeout)??SB,v=()=>m(Ee.fromError(Re.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(d,y,s==null?void 0:s.maxTotalTimeout,v,(s==null?void 0:s.resetTimeoutOnProgress)??!1);const g=l==null?void 0:l.taskId;if(g){const C=I=>{const D=this._responseHandlers.get(d);D?D(I):this._onerror(new Error(`Response handler missing for side-channeled request ${d}`))};this._requestResolvers.set(d,C),this._enqueueTaskMessage(g,{type:"request",message:p,timestamp:Date.now()}).catch(I=>{this._cleanupTimeout(d),h(I)})}else this._transport.send(p,{relatedRequestId:i,resumptionToken:r,onresumptiontoken:o}).catch(C=>{this._cleanupTimeout(d),h(C)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},yS,t)}async getTaskResult(e,t,s){return this.request({method:"tasks/result",params:e},t,s)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},wS,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},wH,t)}async notification(e,t){var a,l,c,h;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const s=(a=t==null?void 0:t.relatedTask)==null?void 0:a.taskId;if(s){const u={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...((l=e.params)==null?void 0:l._meta)||{},[Ka]:t.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:u,timestamp:Date.now()});return}if((((c=this._options)==null?void 0:c.debouncedNotificationMethods)??[]).includes(e.method)&&!e.params&&!(t!=null&&t.relatedRequestId)&&!(t!=null&&t.relatedTask)){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var d,p;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let u={...e,jsonrpc:"2.0"};t!=null&&t.relatedTask&&(u={...u,params:{...u.params,_meta:{...((d=u.params)==null?void 0:d._meta)||{},[Ka]:t.relatedTask}}}),(p=this._transport)==null||p.send(u,t).catch(m=>this._onerror(m))});return}let o={...e,jsonrpc:"2.0"};t!=null&&t.relatedTask&&(o={...o,params:{...o.params,_meta:{...((h=o.params)==null?void 0:h._meta)||{},[Ka]:t.relatedTask}}}),await this._transport.send(o,t)}setRequestHandler(e,t){const s=HA(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(i,r)=>{const o=BA(e,i);return Promise.resolve(t(o,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const s=HA(e);this._notificationHandlers.set(s,i=>{const r=BA(e,i);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,s){var r;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const i=(r=this._options)==null?void 0:r.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,s,i)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(e,t);for(const i of s)if(i.type==="request"&&cb(i.message)){const r=i.message.id,o=this._requestResolvers.get(r);o?(o(new Ee(Re.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(r)):this._onerror(new Error(`Resolver missing for request ${r} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){var i,r;let s=((i=this._options)==null?void 0:i.defaultTaskPollInterval)??1e3;try{const o=await((r=this._taskStore)==null?void 0:r.getTask(e));o!=null&&o.pollInterval&&(s=o.pollInterval)}catch{}return new Promise((o,a)=>{if(t.aborted){a(new Ee(Re.InvalidRequest,"Request cancelled"));return}const l=setTimeout(o,s);t.addEventListener("abort",()=>{clearTimeout(l),a(new Ee(Re.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async i=>{if(!e)throw new Error("No request provided");return await s.createTask(i,e.id,{method:e.method,params:e.params},t)},getTask:async i=>{const r=await s.getTask(i,t);if(!r)throw new Ee(Re.InvalidParams,"Failed to retrieve task: Task not found");return r},storeTaskResult:async(i,r,o)=>{await s.storeTaskResult(i,r,o,t);const a=await s.getTask(i,t);if(a){const l=ny.parse({method:"notifications/tasks/status",params:a});await this.notification(l),Ha(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>s.getTaskResult(i,t),updateTaskStatus:async(i,r,o)=>{const a=await s.getTask(i,t);if(!a)throw new Ee(Re.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(Ha(a.status))throw new Ee(Re.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(i,r,o,t);const l=await s.getTask(i,t);if(l){const c=ny.parse({method:"notifications/tasks/status",params:l});await this.notification(c),Ha(l.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>s.listTasks(i,t)}}}function UA(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function xB(n,e){const t={...n};for(const s in e){const i=s,r=e[i];if(r===void 0)continue;const o=t[i];UA(o)&&UA(r)?t[i]={...o,...r}:t[i]=r}return t}(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});class AB extends pT{constructor(){super(...arguments);oe(this,"_registeredMethods",new Set);oe(this,"_eventSlots",new Map);oe(this,"setRequestHandler",(t,s)=>{this._assertMethodNotRegistered(t,"setRequestHandler"),super.setRequestHandler(t,s)});oe(this,"setNotificationHandler",(t,s)=>{this._assertMethodNotRegistered(t,"setNotificationHandler"),super.setNotificationHandler(t,s)});oe(this,"replaceRequestHandler",(t,s)=>{let i=t.shape.method.value;this._registeredMethods.add(i),super.setRequestHandler(t,s)})}onEventDispatch(t,s){}_ensureEventSlot(t){let s=this._eventSlots.get(t);if(!s){let i=this.eventSchemas[t];if(!i)throw Error(`Unknown event: ${String(t)}`);s={listeners:[]},this._eventSlots.set(t,s);let r=i.shape.method.value;this._registeredMethods.add(r);let o=s;super.setNotificationHandler(i,a=>{var c;let l=a.params;this.onEventDispatch(t,l),(c=o.onHandler)==null||c.call(o,l);for(let h of[...o.listeners])h(l)})}return s}setEventHandler(t,s){let i=this._ensureEventSlot(t);i.onHandler&&s&&console.warn(`[MCP Apps] on${String(t)} handler replaced. Use addEventListener("${String(t)}", …) to add multiple listeners without replacing.`),i.onHandler=s}getEventHandler(t){var s;return(s=this._eventSlots.get(t))==null?void 0:s.onHandler}addEventListener(t,s){this._ensureEventSlot(t).listeners.push(s)}removeEventListener(t,s){let i=this._eventSlots.get(t);if(!i)return;let r=i.listeners.indexOf(s);r!==-1&&i.listeners.splice(r,1)}warnIfRequestHandlerReplaced(t,s,i){s&&i&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}_assertMethodNotRegistered(t,s){let i=t.shape.method.value;if(this._registeredMethods.has(i))throw Error(`Handler for "${i}" already registered (via ${s}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(i)}}var mT="2026-01-26",kB="ui/notifications/tool-input-partial",EB=Ye([W("light"),W("dark")]).describe("Color theme preference for the host environment."),of=Ye([W("inline"),W("fullscreen"),W("pip")]).describe("Display mode for UI presentation."),CB=Ye([W("--color-background-primary"),W("--color-background-secondary"),W("--color-background-tertiary"),W("--color-background-inverse"),W("--color-background-ghost"),W("--color-background-info"),W("--color-background-danger"),W("--color-background-success"),W("--color-background-warning"),W("--color-background-disabled"),W("--color-text-primary"),W("--color-text-secondary"),W("--color-text-tertiary"),W("--color-text-inverse"),W("--color-text-ghost"),W("--color-text-info"),W("--color-text-danger"),W("--color-text-success"),W("--color-text-warning"),W("--color-text-disabled"),W("--color-border-primary"),W("--color-border-secondary"),W("--color-border-tertiary"),W("--color-border-inverse"),W("--color-border-ghost"),W("--color-border-info"),W("--color-border-danger"),W("--color-border-success"),W("--color-border-warning"),W("--color-border-disabled"),W("--color-ring-primary"),W("--color-ring-secondary"),W("--color-ring-inverse"),W("--color-ring-info"),W("--color-ring-danger"),W("--color-ring-success"),W("--color-ring-warning"),W("--font-sans"),W("--font-mono"),W("--font-weight-normal"),W("--font-weight-medium"),W("--font-weight-semibold"),W("--font-weight-bold"),W("--font-text-xs-size"),W("--font-text-sm-size"),W("--font-text-md-size"),W("--font-text-lg-size"),W("--font-heading-xs-size"),W("--font-heading-sm-size"),W("--font-heading-md-size"),W("--font-heading-lg-size"),W("--font-heading-xl-size"),W("--font-heading-2xl-size"),W("--font-heading-3xl-size"),W("--font-text-xs-line-height"),W("--font-text-sm-line-height"),W("--font-text-md-line-height"),W("--font-text-lg-line-height"),W("--font-heading-xs-line-height"),W("--font-heading-sm-line-height"),W("--font-heading-md-line-height"),W("--font-heading-lg-line-height"),W("--font-heading-xl-line-height"),W("--font-heading-2xl-line-height"),W("--font-heading-3xl-line-height"),W("--border-radius-xs"),W("--border-radius-sm"),W("--border-radius-md"),W("--border-radius-lg"),W("--border-radius-xl"),W("--border-radius-full"),W("--border-width-regular"),W("--shadow-hairline"),W("--shadow-sm"),W("--shadow-md"),W("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),$B=tt(CB.describe(`Style variables for theming MCP apps. - -Individual style keys are optional - hosts may provide any subset of these values. -Values are strings containing CSS values (colors, sizes, font stacks, etc.). - -Note: This type uses \`Record\` rather than \`Partial>\` -for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Ye([F(),rb()]).describe(`Style variables for theming MCP apps. - -Individual style keys are optional - hosts may provide any subset of these values. -Values are strings containing CSS values (colors, sizes, font stacks, etc.). - -Note: This type uses \`Record\` rather than \`Partial>\` -for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps. - -Individual style keys are optional - hosts may provide any subset of these values. -Values are strings containing CSS values (colors, sizes, font stacks, etc.). - -Note: This type uses \`Record\` rather than \`Partial>\` -for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),TB=K({method:W("ui/open-link"),params:K({url:F().describe("URL to open in the host's browser")})});K({isError:et().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();K({isError:et().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();K({isError:et().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var PB=K({method:W("ui/notifications/sandbox-proxy-ready"),params:K({})}),jS=K({connectDomains:re(F()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket). - -- Maps to CSP \`connect-src\` directive -- Empty or omitted → no network connections (secure default)`),resourceDomains:re(F()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:re(F()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:re(F()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),FS=K({camera:K({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:K({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:K({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:K({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),RB=K({method:W("ui/notifications/size-changed"),params:K({width:je().optional().describe("New width in pixels."),height:je().optional().describe("New height in pixels.")})});K({method:W("ui/notifications/tool-input"),params:K({arguments:tt(F(),xt().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});K({method:W("ui/notifications/tool-input-partial"),params:K({arguments:tt(F(),xt().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});K({method:W("ui/notifications/tool-cancelled"),params:K({reason:F().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var MB=K({fonts:F().optional()}),IB=K({variables:$B.optional().describe("CSS variables for theming the app."),css:MB.optional().describe("CSS blocks that apps can inject.")});K({method:W("ui/resource-teardown"),params:K({})});var OB=tt(F(),xt()),qA=K({text:K({}).optional().describe("Host supports text content blocks."),image:K({}).optional().describe("Host supports image content blocks."),audio:K({}).optional().describe("Host supports audio content blocks."),resource:K({}).optional().describe("Host supports resource content blocks."),resourceLink:K({}).optional().describe("Host supports resource link content blocks."),structuredContent:K({}).optional().describe("Host supports structured content.")}),NB=K({method:W("ui/notifications/request-teardown"),params:K({}).optional()}),LB=K({experimental:tt(F(),tt(F(),cS()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:K({}).optional().describe("Host supports opening external URLs."),downloadFile:K({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:K({listChanged:et().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:K({listChanged:et().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:K({}).optional().describe("Host accepts log messages."),sandbox:K({permissions:FS.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:jS.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:qA.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:qA.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:K({tools:K({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),DB=K({experimental:tt(F(),tt(F(),cS()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:K({listChanged:et().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:re(of).optional().describe("Display modes the app supports.")}),jB=K({method:W("ui/notifications/initialized"),params:K({}).optional()});K({csp:jS.optional().describe("Content Security Policy configuration for UI resources."),permissions:FS.optional().describe("Sandbox permissions requested by the UI resource."),domain:F().optional().describe(`Dedicated origin for view sandbox. - -Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists. - -**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include: -- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`) -- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`) - -If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:et().optional().describe(`Visual boundary preference - true if view prefers a visible border. - -Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary. - -- \`true\`: request visible border + background -- \`false\`: request no visible border + background -- omitted: host decides border`)});var VA=K({method:W("ui/request-display-mode"),params:K({mode:of.describe("The display mode being requested.")})});K({mode:of.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var FB=Ye([W("model"),W("app")]).describe("Tool visibility scope - who can access the tool.");K({resourceUri:F().optional(),visibility:re(FB).optional().describe(`Who can access this tool. Default: ["model", "app"] -- "model": Tool visible to and callable by the agent -- "app": Tool callable by the app from this server only`),csp:ob().optional(),permissions:ob().optional()});K({mimeTypes:re(F()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var zB=K({method:W("ui/download-file"),params:K({contents:re(Ye([tT,nT])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),HB=K({method:W("ui/message"),params:K({role:W("user").describe('Message role, currently only "user" is supported.'),content:re(Gp).describe("Message content blocks (text, image, etc.).")})});K({method:W("ui/notifications/sandbox-resource-ready"),params:K({html:F().describe("HTML content to load into the inner iframe."),sandbox:F().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:jS.optional().describe("CSP configuration from resource metadata."),permissions:FS.optional().describe("Sandbox permissions from resource metadata.")})});K({method:W("ui/notifications/tool-result"),params:cc.describe("Standard MCP tool execution result.")});var gT=K({toolInfo:K({id:Hp.optional().describe("JSON-RPC id of the tools/call request."),tool:IS.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:EB.optional().describe("Current color theme preference."),styles:IB.optional().describe("Style configuration for theming the app."),displayMode:of.optional().describe("How the UI is currently displayed."),availableDisplayModes:re(of).optional().describe("Display modes the host supports."),containerDimensions:Ye([K({height:je().describe("Fixed container height in pixels.")}),K({maxHeight:Ye([je(),rb()]).optional().describe("Maximum container height in pixels.")})]).and(Ye([K({width:je().describe("Fixed container width in pixels.")}),K({maxWidth:Ye([je(),rb()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other -container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:F().optional().describe("User's language and region preference in BCP 47 format."),timeZone:F().optional().describe("User's timezone in IANA format."),userAgent:F().optional().describe("Host application identifier."),platform:Ye([W("web"),W("desktop"),W("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:K({touch:et().optional().describe("Whether the device supports touch input."),hover:et().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:K({top:je().describe("Top safe area inset in pixels."),right:je().describe("Right safe area inset in pixels."),bottom:je().describe("Bottom safe area inset in pixels."),left:je().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();K({method:W("ui/notifications/host-context-changed"),params:gT.describe("Partial context update containing only changed fields.")});var BB=K({method:W("ui/update-model-context"),params:K({content:re(Gp).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:tt(F(),xt().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),UB=K({method:W("ui/initialize"),params:K({appInfo:v0.describe("App identification (name and version)."),appCapabilities:DB.describe("Features and capabilities this app provides."),protocolVersion:F().describe("Protocol version this app supports.")})});K({protocolVersion:F().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:v0.describe("Host application identification and version."),hostCapabilities:LB.describe("Features and capabilities provided by the host."),hostContext:gT.describe("Rich context about the host environment.")}).passthrough();class qB{constructor(e=window.parent,t){oe(this,"eventTarget");oe(this,"eventSource");oe(this,"messageListener");oe(this,"onclose");oe(this,"onerror");oe(this,"onmessage");oe(this,"sessionId");oe(this,"setProtocolVersion");this.eventTarget=e,this.eventSource=t,this.messageListener=s=>{var r,o,a;if(t&&s.source!==this.eventSource){console.debug("Ignoring message from unknown source",s);return}let i=rg.safeParse(s.data);i.success?(console.debug("Parsed message",i.data),(r=this.onmessage)==null||r.call(this,i.data)):((o=s.data)==null?void 0:o.jsonrpc)!=="2.0"?console.debug("Ignoring non-JSON-RPC message",i.error.message,s):(console.error("Failed to parse message",i.error.message,s),(a=this.onerror)==null||a.call(this,Error("Invalid JSON-RPC message received: "+i.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(e,t){e.method!==kB&&console.debug("Sending message",e),this.eventTarget.postMessage(e,"*")}async close(){var e;window.removeEventListener("message",this.messageListener),(e=this.onclose)==null||e.call(this)}}var VB=[mT];class WB extends AB{constructor(t,s,i,r){super(r);oe(this,"_client");oe(this,"_hostInfo");oe(this,"_capabilities");oe(this,"_appCapabilities");oe(this,"_hostContext",{});oe(this,"_appInfo");oe(this,"_initializedReceived",!1);oe(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);oe(this,"replaceRequestHandler",(t,s)=>{this._baseReplaceRequestHandler(t,(i,r)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${i.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),s(i,r)))});oe(this,"eventSchemas",{sizechange:RB,sandboxready:PB,initialized:jB,requestteardown:NB,loggingmessage:oT});oe(this,"onping");oe(this,"_onmessage");oe(this,"_onopenlink");oe(this,"_ondownloadfile");oe(this,"_onrequestdisplaymode");oe(this,"_onupdatemodelcontext");oe(this,"_oncalltool");oe(this,"_onlistresources");oe(this,"_onlistresourcetemplates");oe(this,"_onreadresource");oe(this,"_onlistprompts");oe(this,"sendResourceTeardown",this.teardownResource);this._client=t,this._hostInfo=s,this._capabilities=i,this.addEventListener("initialized",()=>{this._initializedReceived=!0}),this._hostContext=(r==null?void 0:r.hostContext)||{},this.setRequestHandler(UB,o=>this._oninitialize(o)),this.setRequestHandler(b0,(o,a)=>{var l;return(l=this.onping)==null||l.call(this,o.params,a),{}}),this.replaceRequestHandler(VA,o=>({mode:this._hostContext.displayMode??"inline"}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(t){this.setEventHandler("sizechange",t)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(t){this.setEventHandler("sandboxready",t)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(t){this.setEventHandler("initialized",t)}get onmessage(){return this._onmessage}set onmessage(t){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,t),this._onmessage=t,this.replaceRequestHandler(HB,async(s,i)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(s.params,i)})}get onopenlink(){return this._onopenlink}set onopenlink(t){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,t),this._onopenlink=t,this.replaceRequestHandler(TB,async(s,i)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(s.params,i)})}get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(t){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,t),this._ondownloadfile=t,this.replaceRequestHandler(zB,async(s,i)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(s.params,i)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(t){this.setEventHandler("requestteardown",t)}get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(t){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,t),this._onrequestdisplaymode=t,this.replaceRequestHandler(VA,async(s,i)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(s.params,i)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(t){this.setEventHandler("loggingmessage",t)}get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(t){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,t),this._onupdatemodelcontext=t,this.replaceRequestHandler(BB,async(s,i)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(s.params,i)})}get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler(iT,async(s,i)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(s.params,i)})}set oncreatesamplingmessage(t){this.setRequestHandler(LS,async(s,i)=>t(s.params,i))}sendToolListChanged(t={}){return this.notification({method:"notifications/tools/list_changed",params:t})}get onlistresources(){return this._onlistresources}set onlistresources(t){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,t),this._onlistresources=t,this.replaceRequestHandler(Y$,async(s,i)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(s.params,i)})}get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(t){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,t),this._onlistresourcetemplates=t,this.replaceRequestHandler(J$,async(s,i)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(s.params,i)})}get onreadresource(){return this._onreadresource}set onreadresource(t){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,t),this._onreadresource=t,this.replaceRequestHandler(Q$,async(s,i)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(s.params,i)})}sendResourceListChanged(t={}){return this.notification({method:"notifications/resources/list_changed",params:t})}get onlistprompts(){return this._onlistprompts}set onlistprompts(t){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,t),this._onlistprompts=t,this.replaceRequestHandler(eT,async(s,i)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(s.params,i)})}sendPromptListChanged(t={}){return this.notification({method:"notifications/prompts/list_changed",params:t})}assertCapabilityForMethod(t){}assertRequestHandlerCapability(t){}assertNotificationCapability(t){}assertTaskCapability(t){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(t){throw Error("Task handlers are not supported in MCP Apps")}getCapabilities(){return this._capabilities}async _oninitialize(t){let s=t.params.protocolVersion;return this._appInfo!==void 0&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=t.params.appCapabilities,this._appInfo=t.params.appInfo,{protocolVersion:VB.includes(s)?s:mT,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(t){let s={},i=!1;for(let r of Object.keys(t)){let o=this._hostContext[r],a=t[r];GB(o,a)||(s[r]=a,i=!0)}i&&(this._hostContext=t,this.sendHostContextChange(s))}sendHostContextChange(t){return this.notification({method:"ui/notifications/host-context-changed",params:t})}sendToolInput(t){return this.notification({method:"ui/notifications/tool-input",params:t})}sendToolInputPartial(t){return this.notification({method:"ui/notifications/tool-input-partial",params:t})}sendToolResult(t){return this.notification({method:"ui/notifications/tool-result",params:t})}sendToolCancelled(t){return this.notification({method:"ui/notifications/tool-cancelled",params:t})}sendSandboxResourceReady(t){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:t})}teardownResource(t,s){return this.request({method:"ui/resource-teardown",params:t},OB,s)}callTool(t,s){return this.request({method:"tools/call",params:t},cc,s)}listTools(t,s){return this.request({method:"tools/list",params:t},OS,s)}async connect(t){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let s=this._client.getServerCapabilities();if(!s)throw Error("Client server capabilities not available");s.tools&&(this.oncalltool=async(i,r)=>this._client.request({method:"tools/call",params:i},cc,{signal:r.signal}),s.tools.listChanged&&this._client.setNotificationHandler(NS,i=>this.sendToolListChanged(i.params))),s.resources&&(this.onlistresources=async(i,r)=>this._client.request({method:"resources/list",params:i},xS,{signal:r.signal}),this.onlistresourcetemplates=async(i,r)=>this._client.request({method:"resources/templates/list",params:i},AS,{signal:r.signal}),this.onreadresource=async(i,r)=>this._client.request({method:"resources/read",params:i},ES,{signal:r.signal}),s.resources.listChanged&&this._client.setNotificationHandler(CS,i=>this.sendResourceListChanged(i.params))),s.prompts&&(this.onlistprompts=async(i,r)=>this._client.request({method:"prompts/list",params:i},$S,{signal:r.signal}),s.prompts.listChanged&&this._client.setNotificationHandler(MS,i=>this.sendPromptListChanged(i.params)))}return super.connect(t)}}function GB(n,e){return JSON.stringify(n)===JSON.stringify(e)}const KB={x:0,y:0,width:1024,height:768},hb=28,ZB=12,XB=.9;function ba(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function yT(n){if(!(!n||typeof n!="object"||Array.isArray(n)))return n}function ub(n){if(Array.isArray(n))return n.map(ub);const e=yT(n);return e?Object.fromEntries(Object.entries(e).map(([t,s])=>[t,(t==="text"||t==="originalText")&&typeof s=="string"?s.replace(/\\r\\n|\\n|\\r/gu,` -`):ub(s)])):n}function YB(n){return n.type==="text"&&typeof(n.text??n.originalText)=="string"}function vT(n){const e=String(n.text??n.originalText??""),t=ba(n.fontSize)??20,s=e.length*t*XB,i=ba(n.width);return Math.max(i&&i>0?i:0,s)}function JB(n){for(const e of n){if(e.type!=="cameraUpdate")continue;const t=ba(e.width),s=ba(e.height);if(!(!t||t<=0||!s||s<=0))return{x:ba(e.x)??0,y:ba(e.y)??0,width:t,height:s}}return KB}function QB(n,e){const t=ba(n.x);if(t===void 0)return!1;const s=vT(n),i=e.x+hb,r=e.x+e.width-hb;return tr+1}function eU(n,e){const t={...n},s=ba(t.fontSize)??20;let i=vT(t);const r=Math.max(1,e.width-hb*2);if(i>r){const o=r/i;t.fontSize=Math.max(ZB,s*o),typeof t.height=="number"&&(t.height*=Number(t.fontSize)/s),i=Math.min(r,i*(Number(t.fontSize)/s))}return t.width=i,t.autoResize=!1,t.textAlign="left",t.x=e.x+(e.width-i)/2,t}function tU(n){const t=ub(n).map(yT);if(t.some(r=>r===void 0))return n;const s=t,i=JB(s);return s.map(r=>!YB(r)||!QB(r,i)?r:eU(r,i))}var db={exports:{}},bT={},Yi={},vu={},Kp={},Ke={},af={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.regexpCode=n.getEsmExportName=n.getProperty=n.safeStringify=n.stringify=n.strConcat=n.addCodeArg=n.str=n._=n.nil=n._Code=n.Name=n.IDENTIFIER=n._CodeOrName=void 0;class e{}n._CodeOrName=e,n.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class t extends e{constructor(_){if(super(),!n.IDENTIFIER.test(_))throw new Error("CodeGen: name must be a valid identifier");this.str=_}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}n.Name=t;class s extends e{constructor(_){super(),this._items=typeof _=="string"?[_]:_}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const _=this._items[0];return _===""||_==='""'}get str(){var _;return(_=this._str)!==null&&_!==void 0?_:this._str=this._items.reduce((b,x)=>`${b}${x}`,"")}get names(){var _;return(_=this._names)!==null&&_!==void 0?_:this._names=this._items.reduce((b,x)=>(x instanceof t&&(b[x.str]=(b[x.str]||0)+1),b),{})}}n._Code=s,n.nil=new s("");function i(g,..._){const b=[g[0]];let x=0;for(;x<_.length;)a(b,_[x]),b.push(g[++x]);return new s(b)}n._=i;const r=new s("+");function o(g,..._){const b=[p(g[0])];let x=0;for(;x<_.length;)b.push(r),a(b,_[x]),b.push(r,p(g[++x]));return l(b),new s(b)}n.str=o;function a(g,_){_ instanceof s?g.push(..._._items):_ instanceof t?g.push(_):g.push(u(_))}n.addCodeArg=a;function l(g){let _=1;for(;_{if(u.scopePath===void 0)throw new Error(`CodeGen: name "${u}" has no value`);return(0,e._)`${c}${u.scopePath}`})}scopeCode(c=this._values,h,u){return this._reduceValues(c,d=>{if(d.value===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return d.value.code},h,u)}_reduceValues(c,h,u={},d){let p=e.nil;for(const m in c){const y=c[m];if(!y)continue;const v=u[m]=u[m]||new Map;y.forEach(g=>{if(v.has(g))return;v.set(g,s.Started);let _=h(g);if(_){const b=this.opts.es5?n.varKinds.var:n.varKinds.const;p=(0,e._)`${p}${b} ${g} = ${_};${this.opts._n}`}else if(_=d==null?void 0:d(g))p=(0,e._)`${p}${_}${this.opts._n}`;else throw new t(g);v.set(g,s.Completed)})}return p}}n.ValueScope=a})(fb);(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.or=n.and=n.not=n.CodeGen=n.operators=n.varKinds=n.ValueScopeName=n.ValueScope=n.Scope=n.Name=n.regexpCode=n.stringify=n.getProperty=n.nil=n.strConcat=n.str=n._=void 0;const e=af,t=fb;var s=af;Object.defineProperty(n,"_",{enumerable:!0,get:function(){return s._}}),Object.defineProperty(n,"str",{enumerable:!0,get:function(){return s.str}}),Object.defineProperty(n,"strConcat",{enumerable:!0,get:function(){return s.strConcat}}),Object.defineProperty(n,"nil",{enumerable:!0,get:function(){return s.nil}}),Object.defineProperty(n,"getProperty",{enumerable:!0,get:function(){return s.getProperty}}),Object.defineProperty(n,"stringify",{enumerable:!0,get:function(){return s.stringify}}),Object.defineProperty(n,"regexpCode",{enumerable:!0,get:function(){return s.regexpCode}}),Object.defineProperty(n,"Name",{enumerable:!0,get:function(){return s.Name}});var i=fb;Object.defineProperty(n,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(n,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(n,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(n,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),n.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class r{optimizeNodes(){return this}optimizeNames(w,k){return this}}class o extends r{constructor(w,k,N){super(),this.varKind=w,this.name=k,this.rhs=N}render({es5:w,_n:k}){const N=w?t.varKinds.var:this.varKind,G=this.rhs===void 0?"":` = ${this.rhs}`;return`${N} ${this.name}${G};`+k}optimizeNames(w,k){if(w[this.name.str])return this.rhs&&(this.rhs=L(this.rhs,w,k)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class a extends r{constructor(w,k,N){super(),this.lhs=w,this.rhs=k,this.sideEffects=N}render({_n:w}){return`${this.lhs} = ${this.rhs};`+w}optimizeNames(w,k){if(!(this.lhs instanceof e.Name&&!w[this.lhs.str]&&!this.sideEffects))return this.rhs=L(this.rhs,w,k),this}get names(){const w=this.lhs instanceof e.Name?{}:{...this.lhs.names};return B(w,this.rhs)}}class l extends a{constructor(w,k,N,G){super(w,N,G),this.op=k}render({_n:w}){return`${this.lhs} ${this.op}= ${this.rhs};`+w}}class c extends r{constructor(w){super(),this.label=w,this.names={}}render({_n:w}){return`${this.label}:`+w}}class h extends r{constructor(w){super(),this.label=w,this.names={}}render({_n:w}){return`break${this.label?` ${this.label}`:""};`+w}}class u extends r{constructor(w){super(),this.error=w}render({_n:w}){return`throw ${this.error};`+w}get names(){return this.error.names}}class d extends r{constructor(w){super(),this.code=w}render({_n:w}){return`${this.code};`+w}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(w,k){return this.code=L(this.code,w,k),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class p extends r{constructor(w=[]){super(),this.nodes=w}render(w){return this.nodes.reduce((k,N)=>k+N.render(w),"")}optimizeNodes(){const{nodes:w}=this;let k=w.length;for(;k--;){const N=w[k].optimizeNodes();Array.isArray(N)?w.splice(k,1,...N):N?w[k]=N:w.splice(k,1)}return w.length>0?this:void 0}optimizeNames(w,k){const{nodes:N}=this;let G=N.length;for(;G--;){const Z=N[G];Z.optimizeNames(w,k)||(X(w,Z.names),N.splice(G,1))}return N.length>0?this:void 0}get names(){return this.nodes.reduce((w,k)=>U(w,k.names),{})}}class m extends p{render(w){return"{"+w._n+super.render(w)+"}"+w._n}}class y extends p{}class v extends m{}v.kind="else";class g extends m{constructor(w,k){super(k),this.condition=w}render(w){let k=`if(${this.condition})`+super.render(w);return this.else&&(k+="else "+this.else.render(w)),k}optimizeNodes(){super.optimizeNodes();const w=this.condition;if(w===!0)return this.nodes;let k=this.else;if(k){const N=k.optimizeNodes();k=this.else=Array.isArray(N)?new v(N):N}if(k)return w===!1?k instanceof g?k:k.nodes:this.nodes.length?this:new g(se(w),k instanceof g?[k]:k.nodes);if(!(w===!1||!this.nodes.length))return this}optimizeNames(w,k){var N;if(this.else=(N=this.else)===null||N===void 0?void 0:N.optimizeNames(w,k),!!(super.optimizeNames(w,k)||this.else))return this.condition=L(this.condition,w,k),this}get names(){const w=super.names;return B(w,this.condition),this.else&&U(w,this.else.names),w}}g.kind="if";class _ extends m{}_.kind="for";class b extends _{constructor(w){super(),this.iteration=w}render(w){return`for(${this.iteration})`+super.render(w)}optimizeNames(w,k){if(super.optimizeNames(w,k))return this.iteration=L(this.iteration,w,k),this}get names(){return U(super.names,this.iteration.names)}}class x extends _{constructor(w,k,N,G){super(),this.varKind=w,this.name=k,this.from=N,this.to=G}render(w){const k=w.es5?t.varKinds.var:this.varKind,{name:N,from:G,to:Z}=this;return`for(${k} ${N}=${G}; ${N}<${Z}; ${N}++)`+super.render(w)}get names(){const w=B(super.names,this.from);return B(w,this.to)}}class A extends _{constructor(w,k,N,G){super(),this.loop=w,this.varKind=k,this.name=N,this.iterable=G}render(w){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(w)}optimizeNames(w,k){if(super.optimizeNames(w,k))return this.iterable=L(this.iterable,w,k),this}get names(){return U(super.names,this.iterable.names)}}class T extends m{constructor(w,k,N){super(),this.name=w,this.args=k,this.async=N}render(w){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(w)}}T.kind="func";class C extends p{render(w){return"return "+super.render(w)}}C.kind="return";class I extends m{render(w){let k="try"+super.render(w);return this.catch&&(k+=this.catch.render(w)),this.finally&&(k+=this.finally.render(w)),k}optimizeNodes(){var w,k;return super.optimizeNodes(),(w=this.catch)===null||w===void 0||w.optimizeNodes(),(k=this.finally)===null||k===void 0||k.optimizeNodes(),this}optimizeNames(w,k){var N,G;return super.optimizeNames(w,k),(N=this.catch)===null||N===void 0||N.optimizeNames(w,k),(G=this.finally)===null||G===void 0||G.optimizeNames(w,k),this}get names(){const w=super.names;return this.catch&&U(w,this.catch.names),this.finally&&U(w,this.finally.names),w}}class D extends m{constructor(w){super(),this.error=w}render(w){return`catch(${this.error})`+super.render(w)}}D.kind="catch";class H extends m{render(w){return"finally"+super.render(w)}}H.kind="finally";class j{constructor(w,k={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...k,_n:k.lines?` -`:""},this._extScope=w,this._scope=new t.Scope({parent:w}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(w){return this._scope.name(w)}scopeName(w){return this._extScope.name(w)}scopeValue(w,k){const N=this._extScope.value(w,k);return(this._values[N.prefix]||(this._values[N.prefix]=new Set)).add(N),N}getScopeValue(w,k){return this._extScope.getValue(w,k)}scopeRefs(w){return this._extScope.scopeRefs(w,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(w,k,N,G){const Z=this._scope.toName(k);return N!==void 0&&G&&(this._constants[Z.str]=N),this._leafNode(new o(w,Z,N)),Z}const(w,k,N){return this._def(t.varKinds.const,w,k,N)}let(w,k,N){return this._def(t.varKinds.let,w,k,N)}var(w,k,N){return this._def(t.varKinds.var,w,k,N)}assign(w,k,N){return this._leafNode(new a(w,k,N))}add(w,k){return this._leafNode(new l(w,n.operators.ADD,k))}code(w){return typeof w=="function"?w():w!==e.nil&&this._leafNode(new d(w)),this}object(...w){const k=["{"];for(const[N,G]of w)k.length>1&&k.push(","),k.push(N),(N!==G||this.opts.es5)&&(k.push(":"),(0,e.addCodeArg)(k,G));return k.push("}"),new e._Code(k)}if(w,k,N){if(this._blockNode(new g(w)),k&&N)this.code(k).else().code(N).endIf();else if(k)this.code(k).endIf();else if(N)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(w){return this._elseNode(new g(w))}else(){return this._elseNode(new v)}endIf(){return this._endBlockNode(g,v)}_for(w,k){return this._blockNode(w),k&&this.code(k).endFor(),this}for(w,k){return this._for(new b(w),k)}forRange(w,k,N,G,Z=this.opts.es5?t.varKinds.var:t.varKinds.let){const ae=this._scope.toName(w);return this._for(new x(Z,ae,k,N),()=>G(ae))}forOf(w,k,N,G=t.varKinds.const){const Z=this._scope.toName(w);if(this.opts.es5){const ae=k instanceof e.Name?k:this.var("_arr",k);return this.forRange("_i",0,(0,e._)`${ae}.length`,ie=>{this.var(Z,(0,e._)`${ae}[${ie}]`),N(Z)})}return this._for(new A("of",G,Z,k),()=>N(Z))}forIn(w,k,N,G=this.opts.es5?t.varKinds.var:t.varKinds.const){if(this.opts.ownProperties)return this.forOf(w,(0,e._)`Object.keys(${k})`,N);const Z=this._scope.toName(w);return this._for(new A("in",G,Z,k),()=>N(Z))}endFor(){return this._endBlockNode(_)}label(w){return this._leafNode(new c(w))}break(w){return this._leafNode(new h(w))}return(w){const k=new C;if(this._blockNode(k),this.code(w),k.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(C)}try(w,k,N){if(!k&&!N)throw new Error('CodeGen: "try" without "catch" and "finally"');const G=new I;if(this._blockNode(G),this.code(w),k){const Z=this.name("e");this._currNode=G.catch=new D(Z),k(Z)}return N&&(this._currNode=G.finally=new H,this.code(N)),this._endBlockNode(D,H)}throw(w){return this._leafNode(new u(w))}block(w,k){return this._blockStarts.push(this._nodes.length),w&&this.code(w).endBlock(k),this}endBlock(w){const k=this._blockStarts.pop();if(k===void 0)throw new Error("CodeGen: not in self-balancing block");const N=this._nodes.length-k;if(N<0||w!==void 0&&N!==w)throw new Error(`CodeGen: wrong number of nodes: ${N} vs ${w} expected`);return this._nodes.length=k,this}func(w,k=e.nil,N,G){return this._blockNode(new T(w,k,N)),G&&this.code(G).endFunc(),this}endFunc(){return this._endBlockNode(T)}optimize(w=1){for(;w-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(w){return this._currNode.nodes.push(w),this}_blockNode(w){this._currNode.nodes.push(w),this._nodes.push(w)}_endBlockNode(w,k){const N=this._currNode;if(N instanceof w||k&&N instanceof k)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${k?`${w.kind}/${k.kind}`:w.kind}"`)}_elseNode(w){const k=this._currNode;if(!(k instanceof g))throw new Error('CodeGen: "else" without "if"');return this._currNode=k.else=w,this}get _root(){return this._nodes[0]}get _currNode(){const w=this._nodes;return w[w.length-1]}set _currNode(w){const k=this._nodes;k[k.length-1]=w}}n.CodeGen=j;function U(R,w){for(const k in w)R[k]=(R[k]||0)+(w[k]||0);return R}function B(R,w){return w instanceof e._CodeOrName?U(R,w.names):R}function L(R,w,k){if(R instanceof e.Name)return N(R);if(!G(R))return R;return new e._Code(R._items.reduce((Z,ae)=>(ae instanceof e.Name&&(ae=N(ae)),ae instanceof e._Code?Z.push(...ae._items):Z.push(ae),Z),[]));function N(Z){const ae=k[Z.str];return ae===void 0||w[Z.str]!==1?Z:(delete w[Z.str],ae)}function G(Z){return Z instanceof e._Code&&Z._items.some(ae=>ae instanceof e.Name&&w[ae.str]===1&&k[ae.str]!==void 0)}}function X(R,w){for(const k in w)R[k]=(R[k]||0)-(w[k]||0)}function se(R){return typeof R=="boolean"||typeof R=="number"||R===null?!R:(0,e._)`!${O(R)}`}n.not=se;const J=E(n.operators.AND);function Y(...R){return R.reduce(J)}n.and=Y;const ge=E(n.operators.OR);function z(...R){return R.reduce(ge)}n.or=z;function E(R){return(w,k)=>w===e.nil?k:k===e.nil?w:(0,e._)`${O(w)} ${R} ${O(k)}`}function O(R){return R instanceof e.Name?R:(0,e._)`(${R})`}})(Ke);var fe={};Object.defineProperty(fe,"__esModule",{value:!0});fe.checkStrictMode=fe.getErrorPath=fe.Type=fe.useFunc=fe.setEvaluated=fe.evaluatedPropsToName=fe.mergeEvaluated=fe.eachItem=fe.unescapeJsonPointer=fe.escapeJsonPointer=fe.escapeFragment=fe.unescapeFragment=fe.schemaRefOrVal=fe.schemaHasRulesButRef=fe.schemaHasRules=fe.checkUnknownRules=fe.alwaysValidSchema=fe.toHash=void 0;const bt=Ke,nU=af;function sU(n){const e={};for(const t of n)e[t]=!0;return e}fe.toHash=sU;function iU(n,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(wT(n,e),!_T(e,n.self.RULES.all))}fe.alwaysValidSchema=iU;function wT(n,e=n.schema){const{opts:t,self:s}=n;if(!t.strictSchema||typeof e=="boolean")return;const i=s.RULES.keywords;for(const r in e)i[r]||AT(n,`unknown keyword: "${r}"`)}fe.checkUnknownRules=wT;function _T(n,e){if(typeof n=="boolean")return!n;for(const t in n)if(e[t])return!0;return!1}fe.schemaHasRules=_T;function rU(n,e){if(typeof n=="boolean")return!n;for(const t in n)if(t!=="$ref"&&e.all[t])return!0;return!1}fe.schemaHasRulesButRef=rU;function oU({topSchemaRef:n,schemaPath:e},t,s,i){if(!i){if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="string")return(0,bt._)`${t}`}return(0,bt._)`${n}${e}${(0,bt.getProperty)(s)}`}fe.schemaRefOrVal=oU;function aU(n){return ST(decodeURIComponent(n))}fe.unescapeFragment=aU;function lU(n){return encodeURIComponent(zS(n))}fe.escapeFragment=lU;function zS(n){return typeof n=="number"?`${n}`:n.replace(/~/g,"~0").replace(/\//g,"~1")}fe.escapeJsonPointer=zS;function ST(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}fe.unescapeJsonPointer=ST;function cU(n,e){if(Array.isArray(n))for(const t of n)e(t);else e(n)}fe.eachItem=cU;function WA({mergeNames:n,mergeToName:e,mergeValues:t,resultToName:s}){return(i,r,o,a)=>{const l=o===void 0?r:o instanceof bt.Name?(r instanceof bt.Name?n(i,r,o):e(i,r,o),o):r instanceof bt.Name?(e(i,o,r),r):t(r,o);return a===bt.Name&&!(l instanceof bt.Name)?s(i,l):l}}fe.mergeEvaluated={props:WA({mergeNames:(n,e,t)=>n.if((0,bt._)`${t} !== true && ${e} !== undefined`,()=>{n.if((0,bt._)`${e} === true`,()=>n.assign(t,!0),()=>n.assign(t,(0,bt._)`${t} || {}`).code((0,bt._)`Object.assign(${t}, ${e})`))}),mergeToName:(n,e,t)=>n.if((0,bt._)`${t} !== true`,()=>{e===!0?n.assign(t,!0):(n.assign(t,(0,bt._)`${t} || {}`),HS(n,t,e))}),mergeValues:(n,e)=>n===!0?!0:{...n,...e},resultToName:xT}),items:WA({mergeNames:(n,e,t)=>n.if((0,bt._)`${t} !== true && ${e} !== undefined`,()=>n.assign(t,(0,bt._)`${e} === true ? true : ${t} > ${e} ? ${t} : ${e}`)),mergeToName:(n,e,t)=>n.if((0,bt._)`${t} !== true`,()=>n.assign(t,e===!0?!0:(0,bt._)`${t} > ${e} ? ${t} : ${e}`)),mergeValues:(n,e)=>n===!0?!0:Math.max(n,e),resultToName:(n,e)=>n.var("items",e)})};function xT(n,e){if(e===!0)return n.var("props",!0);const t=n.var("props",(0,bt._)`{}`);return e!==void 0&&HS(n,t,e),t}fe.evaluatedPropsToName=xT;function HS(n,e,t){Object.keys(t).forEach(s=>n.assign((0,bt._)`${e}${(0,bt.getProperty)(s)}`,!0))}fe.setEvaluated=HS;const GA={};function hU(n,e){return n.scopeValue("func",{ref:e,code:GA[e.code]||(GA[e.code]=new nU._Code(e.code))})}fe.useFunc=hU;var pb;(function(n){n[n.Num=0]="Num",n[n.Str=1]="Str"})(pb||(fe.Type=pb={}));function uU(n,e,t){if(n instanceof bt.Name){const s=e===pb.Num;return t?s?(0,bt._)`"[" + ${n} + "]"`:(0,bt._)`"['" + ${n} + "']"`:s?(0,bt._)`"/" + ${n}`:(0,bt._)`"/" + ${n}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return t?(0,bt.getProperty)(n).toString():"/"+zS(n)}fe.getErrorPath=uU;function AT(n,e,t=n.opts.strictSchema){if(t){if(e=`strict mode: ${e}`,t===!0)throw new Error(e);n.self.logger.warn(e)}}fe.checkStrictMode=AT;var Dr={};Object.defineProperty(Dr,"__esModule",{value:!0});const Xn=Ke,dU={data:new Xn.Name("data"),valCxt:new Xn.Name("valCxt"),instancePath:new Xn.Name("instancePath"),parentData:new Xn.Name("parentData"),parentDataProperty:new Xn.Name("parentDataProperty"),rootData:new Xn.Name("rootData"),dynamicAnchors:new Xn.Name("dynamicAnchors"),vErrors:new Xn.Name("vErrors"),errors:new Xn.Name("errors"),this:new Xn.Name("this"),self:new Xn.Name("self"),scope:new Xn.Name("scope"),json:new Xn.Name("json"),jsonPos:new Xn.Name("jsonPos"),jsonLen:new Xn.Name("jsonLen"),jsonPart:new Xn.Name("jsonPart")};Dr.default=dU;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.extendErrors=n.resetErrorsCount=n.reportExtraError=n.reportError=n.keyword$DataError=n.keywordError=void 0;const e=Ke,t=fe,s=Dr;n.keywordError={message:({keyword:v})=>(0,e.str)`must pass "${v}" keyword validation`},n.keyword$DataError={message:({keyword:v,schemaType:g})=>g?(0,e.str)`"${v}" keyword must be ${g} ($data)`:(0,e.str)`"${v}" keyword is invalid ($data)`};function i(v,g=n.keywordError,_,b){const{it:x}=v,{gen:A,compositeRule:T,allErrors:C}=x,I=u(v,g,_);b??(T||C)?l(A,I):c(x,(0,e._)`[${I}]`)}n.reportError=i;function r(v,g=n.keywordError,_){const{it:b}=v,{gen:x,compositeRule:A,allErrors:T}=b,C=u(v,g,_);l(x,C),A||T||c(b,s.default.vErrors)}n.reportExtraError=r;function o(v,g){v.assign(s.default.errors,g),v.if((0,e._)`${s.default.vErrors} !== null`,()=>v.if(g,()=>v.assign((0,e._)`${s.default.vErrors}.length`,g),()=>v.assign(s.default.vErrors,null)))}n.resetErrorsCount=o;function a({gen:v,keyword:g,schemaValue:_,data:b,errsCount:x,it:A}){if(x===void 0)throw new Error("ajv implementation error");const T=v.name("err");v.forRange("i",x,s.default.errors,C=>{v.const(T,(0,e._)`${s.default.vErrors}[${C}]`),v.if((0,e._)`${T}.instancePath === undefined`,()=>v.assign((0,e._)`${T}.instancePath`,(0,e.strConcat)(s.default.instancePath,A.errorPath))),v.assign((0,e._)`${T}.schemaPath`,(0,e.str)`${A.errSchemaPath}/${g}`),A.opts.verbose&&(v.assign((0,e._)`${T}.schema`,_),v.assign((0,e._)`${T}.data`,b))})}n.extendErrors=a;function l(v,g){const _=v.const("err",g);v.if((0,e._)`${s.default.vErrors} === null`,()=>v.assign(s.default.vErrors,(0,e._)`[${_}]`),(0,e._)`${s.default.vErrors}.push(${_})`),v.code((0,e._)`${s.default.errors}++`)}function c(v,g){const{gen:_,validateName:b,schemaEnv:x}=v;x.$async?_.throw((0,e._)`new ${v.ValidationError}(${g})`):(_.assign((0,e._)`${b}.errors`,g),_.return(!1))}const h={keyword:new e.Name("keyword"),schemaPath:new e.Name("schemaPath"),params:new e.Name("params"),propertyName:new e.Name("propertyName"),message:new e.Name("message"),schema:new e.Name("schema"),parentSchema:new e.Name("parentSchema")};function u(v,g,_){const{createErrors:b}=v.it;return b===!1?(0,e._)`{}`:d(v,g,_)}function d(v,g,_={}){const{gen:b,it:x}=v,A=[p(x,_),m(v,_)];return y(v,g,A),b.object(...A)}function p({errorPath:v},{instancePath:g}){const _=g?(0,e.str)`${v}${(0,t.getErrorPath)(g,t.Type.Str)}`:v;return[s.default.instancePath,(0,e.strConcat)(s.default.instancePath,_)]}function m({keyword:v,it:{errSchemaPath:g}},{schemaPath:_,parentSchema:b}){let x=b?g:(0,e.str)`${g}/${v}`;return _&&(x=(0,e.str)`${x}${(0,t.getErrorPath)(_,t.Type.Str)}`),[h.schemaPath,x]}function y(v,{params:g,message:_},b){const{keyword:x,data:A,schemaValue:T,it:C}=v,{opts:I,propertyName:D,topSchemaRef:H,schemaPath:j}=C;b.push([h.keyword,x],[h.params,typeof g=="function"?g(v):g||(0,e._)`{}`]),I.messages&&b.push([h.message,typeof _=="function"?_(v):_]),I.verbose&&b.push([h.schema,T],[h.parentSchema,(0,e._)`${H}${j}`],[s.default.data,A]),D&&b.push([h.propertyName,D])}})(Kp);Object.defineProperty(vu,"__esModule",{value:!0});vu.boolOrEmptySchema=vu.topBoolOrEmptySchema=void 0;const fU=Kp,pU=Ke,mU=Dr,gU={message:"boolean schema is false"};function yU(n){const{gen:e,schema:t,validateName:s}=n;t===!1?kT(n,!1):typeof t=="object"&&t.$async===!0?e.return(mU.default.data):(e.assign((0,pU._)`${s}.errors`,null),e.return(!0))}vu.topBoolOrEmptySchema=yU;function vU(n,e){const{gen:t,schema:s}=n;s===!1?(t.var(e,!1),kT(n)):t.var(e,!0)}vu.boolOrEmptySchema=vU;function kT(n,e){const{gen:t,data:s}=n,i={gen:t,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:n};(0,fU.reportError)(i,gU,void 0,e)}var dn={},hc={};Object.defineProperty(hc,"__esModule",{value:!0});hc.getRules=hc.isJSONType=void 0;const bU=["string","number","integer","boolean","null","object","array"],wU=new Set(bU);function _U(n){return typeof n=="string"&&wU.has(n)}hc.isJSONType=_U;function SU(){const n={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...n,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},n.number,n.string,n.array,n.object],post:{rules:[]},all:{},keywords:{}}}hc.getRules=SU;var _o={};Object.defineProperty(_o,"__esModule",{value:!0});_o.shouldUseRule=_o.shouldUseGroup=_o.schemaHasRulesForType=void 0;function xU({schema:n,self:e},t){const s=e.RULES.types[t];return s&&s!==!0&&ET(n,s)}_o.schemaHasRulesForType=xU;function ET(n,e){return e.rules.some(t=>CT(n,t))}_o.shouldUseGroup=ET;function CT(n,e){var t;return n[e.keyword]!==void 0||((t=e.definition.implements)===null||t===void 0?void 0:t.some(s=>n[s]!==void 0))}_o.shouldUseRule=CT;Object.defineProperty(dn,"__esModule",{value:!0});dn.reportTypeError=dn.checkDataTypes=dn.checkDataType=dn.coerceAndCheckDataType=dn.getJSONTypes=dn.getSchemaTypes=dn.DataType=void 0;const AU=hc,kU=_o,EU=Kp,Ne=Ke,$T=fe;var oh;(function(n){n[n.Correct=0]="Correct",n[n.Wrong=1]="Wrong"})(oh||(dn.DataType=oh={}));function CU(n){const e=TT(n.type);if(e.includes("null")){if(n.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&n.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');n.nullable===!0&&e.push("null")}return e}dn.getSchemaTypes=CU;function TT(n){const e=Array.isArray(n)?n:n?[n]:[];if(e.every(AU.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}dn.getJSONTypes=TT;function $U(n,e){const{gen:t,data:s,opts:i}=n,r=TU(e,i.coerceTypes),o=e.length>0&&!(r.length===0&&e.length===1&&(0,kU.schemaHasRulesForType)(n,e[0]));if(o){const a=BS(e,s,i.strictNumbers,oh.Wrong);t.if(a,()=>{r.length?PU(n,e,r):US(n)})}return o}dn.coerceAndCheckDataType=$U;const PT=new Set(["string","number","integer","boolean","null"]);function TU(n,e){return e?n.filter(t=>PT.has(t)||e==="array"&&t==="array"):[]}function PU(n,e,t){const{gen:s,data:i,opts:r}=n,o=s.let("dataType",(0,Ne._)`typeof ${i}`),a=s.let("coerced",(0,Ne._)`undefined`);r.coerceTypes==="array"&&s.if((0,Ne._)`${o} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>s.assign(i,(0,Ne._)`${i}[0]`).assign(o,(0,Ne._)`typeof ${i}`).if(BS(e,i,r.strictNumbers),()=>s.assign(a,i))),s.if((0,Ne._)`${a} !== undefined`);for(const c of t)(PT.has(c)||c==="array"&&r.coerceTypes==="array")&&l(c);s.else(),US(n),s.endIf(),s.if((0,Ne._)`${a} !== undefined`,()=>{s.assign(i,a),RU(n,a)});function l(c){switch(c){case"string":s.elseIf((0,Ne._)`${o} == "number" || ${o} == "boolean"`).assign(a,(0,Ne._)`"" + ${i}`).elseIf((0,Ne._)`${i} === null`).assign(a,(0,Ne._)`""`);return;case"number":s.elseIf((0,Ne._)`${o} == "boolean" || ${i} === null - || (${o} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,Ne._)`+${i}`);return;case"integer":s.elseIf((0,Ne._)`${o} === "boolean" || ${i} === null - || (${o} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,Ne._)`+${i}`);return;case"boolean":s.elseIf((0,Ne._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,Ne._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":s.elseIf((0,Ne._)`${i} === "" || ${i} === 0 || ${i} === false`),s.assign(a,null);return;case"array":s.elseIf((0,Ne._)`${o} === "string" || ${o} === "number" - || ${o} === "boolean" || ${i} === null`).assign(a,(0,Ne._)`[${i}]`)}}}function RU({gen:n,parentData:e,parentDataProperty:t},s){n.if((0,Ne._)`${e} !== undefined`,()=>n.assign((0,Ne._)`${e}[${t}]`,s))}function mb(n,e,t,s=oh.Correct){const i=s===oh.Correct?Ne.operators.EQ:Ne.operators.NEQ;let r;switch(n){case"null":return(0,Ne._)`${e} ${i} null`;case"array":r=(0,Ne._)`Array.isArray(${e})`;break;case"object":r=(0,Ne._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":r=o((0,Ne._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":r=o();break;default:return(0,Ne._)`typeof ${e} ${i} ${n}`}return s===oh.Correct?r:(0,Ne.not)(r);function o(a=Ne.nil){return(0,Ne.and)((0,Ne._)`typeof ${e} == "number"`,a,t?(0,Ne._)`isFinite(${e})`:Ne.nil)}}dn.checkDataType=mb;function BS(n,e,t,s){if(n.length===1)return mb(n[0],e,t,s);let i;const r=(0,$T.toHash)(n);if(r.array&&r.object){const o=(0,Ne._)`typeof ${e} != "object"`;i=r.null?o:(0,Ne._)`!${e} || ${o}`,delete r.null,delete r.array,delete r.object}else i=Ne.nil;r.number&&delete r.integer;for(const o in r)i=(0,Ne.and)(i,mb(o,e,t,s));return i}dn.checkDataTypes=BS;const MU={message:({schema:n})=>`must be ${n}`,params:({schema:n,schemaValue:e})=>typeof n=="string"?(0,Ne._)`{type: ${n}}`:(0,Ne._)`{type: ${e}}`};function US(n){const e=IU(n);(0,EU.reportError)(e,MU)}dn.reportTypeError=US;function IU(n){const{gen:e,data:t,schema:s}=n,i=(0,$T.schemaRefOrVal)(n,s,"type");return{gen:e,keyword:"type",data:t,schema:s.type,schemaCode:i,schemaValue:i,parentSchema:s,params:{},it:n}}var w0={};Object.defineProperty(w0,"__esModule",{value:!0});w0.assignDefaults=void 0;const Oc=Ke,OU=fe;function NU(n,e){const{properties:t,items:s}=n.schema;if(e==="object"&&t)for(const i in t)KA(n,i,t[i].default);else e==="array"&&Array.isArray(s)&&s.forEach((i,r)=>KA(n,r,i.default))}w0.assignDefaults=NU;function KA(n,e,t){const{gen:s,compositeRule:i,data:r,opts:o}=n;if(t===void 0)return;const a=(0,Oc._)`${r}${(0,Oc.getProperty)(e)}`;if(i){(0,OU.checkStrictMode)(n,`default is ignored for: ${a}`);return}let l=(0,Oc._)`${a} === undefined`;o.useDefaults==="empty"&&(l=(0,Oc._)`${l} || ${a} === null || ${a} === ""`),s.if(l,(0,Oc._)`${a} = ${(0,Oc.stringify)(t)}`)}var Tr={},We={};Object.defineProperty(We,"__esModule",{value:!0});We.validateUnion=We.validateArray=We.usePattern=We.callValidateCode=We.schemaProperties=We.allSchemaProperties=We.noPropertyInData=We.propertyInData=We.isOwnProperty=We.hasPropFunc=We.reportMissingProp=We.checkMissingProp=We.checkReportMissingProp=void 0;const Ct=Ke,qS=fe,Oo=Dr,LU=fe;function DU(n,e){const{gen:t,data:s,it:i}=n;t.if(WS(t,s,e,i.opts.ownProperties),()=>{n.setParams({missingProperty:(0,Ct._)`${e}`},!0),n.error()})}We.checkReportMissingProp=DU;function jU({gen:n,data:e,it:{opts:t}},s,i){return(0,Ct.or)(...s.map(r=>(0,Ct.and)(WS(n,e,r,t.ownProperties),(0,Ct._)`${i} = ${r}`)))}We.checkMissingProp=jU;function FU(n,e){n.setParams({missingProperty:e},!0),n.error()}We.reportMissingProp=FU;function RT(n){return n.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Ct._)`Object.prototype.hasOwnProperty`})}We.hasPropFunc=RT;function VS(n,e,t){return(0,Ct._)`${RT(n)}.call(${e}, ${t})`}We.isOwnProperty=VS;function zU(n,e,t,s){const i=(0,Ct._)`${e}${(0,Ct.getProperty)(t)} !== undefined`;return s?(0,Ct._)`${i} && ${VS(n,e,t)}`:i}We.propertyInData=zU;function WS(n,e,t,s){const i=(0,Ct._)`${e}${(0,Ct.getProperty)(t)} === undefined`;return s?(0,Ct.or)(i,(0,Ct.not)(VS(n,e,t))):i}We.noPropertyInData=WS;function MT(n){return n?Object.keys(n).filter(e=>e!=="__proto__"):[]}We.allSchemaProperties=MT;function HU(n,e){return MT(e).filter(t=>!(0,qS.alwaysValidSchema)(n,e[t]))}We.schemaProperties=HU;function BU({schemaCode:n,data:e,it:{gen:t,topSchemaRef:s,schemaPath:i,errorPath:r},it:o},a,l,c){const h=c?(0,Ct._)`${n}, ${e}, ${s}${i}`:e,u=[[Oo.default.instancePath,(0,Ct.strConcat)(Oo.default.instancePath,r)],[Oo.default.parentData,o.parentData],[Oo.default.parentDataProperty,o.parentDataProperty],[Oo.default.rootData,Oo.default.rootData]];o.opts.dynamicRef&&u.push([Oo.default.dynamicAnchors,Oo.default.dynamicAnchors]);const d=(0,Ct._)`${h}, ${t.object(...u)}`;return l!==Ct.nil?(0,Ct._)`${a}.call(${l}, ${d})`:(0,Ct._)`${a}(${d})`}We.callValidateCode=BU;const UU=(0,Ct._)`new RegExp`;function qU({gen:n,it:{opts:e}},t){const s=e.unicodeRegExp?"u":"",{regExp:i}=e.code,r=i(t,s);return n.scopeValue("pattern",{key:r.toString(),ref:r,code:(0,Ct._)`${i.code==="new RegExp"?UU:(0,LU.useFunc)(n,i)}(${t}, ${s})`})}We.usePattern=qU;function VU(n){const{gen:e,data:t,keyword:s,it:i}=n,r=e.name("valid");if(i.allErrors){const a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(r,!0),o(()=>e.break()),r;function o(a){const l=e.const("len",(0,Ct._)`${t}.length`);e.forRange("i",0,l,c=>{n.subschema({keyword:s,dataProp:c,dataPropType:qS.Type.Num},r),e.if((0,Ct.not)(r),a)})}}We.validateArray=VU;function WU(n){const{gen:e,schema:t,keyword:s,it:i}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");if(t.some(l=>(0,qS.alwaysValidSchema)(i,l))&&!i.opts.unevaluated)return;const o=e.let("valid",!1),a=e.name("_valid");e.block(()=>t.forEach((l,c)=>{const h=n.subschema({keyword:s,schemaProp:c,compositeRule:!0},a);e.assign(o,(0,Ct._)`${o} || ${a}`),n.mergeValidEvaluated(h,a)||e.if((0,Ct.not)(o))})),n.result(o,()=>n.reset(),()=>n.error(!0))}We.validateUnion=WU;Object.defineProperty(Tr,"__esModule",{value:!0});Tr.validateKeywordUsage=Tr.validSchemaType=Tr.funcKeywordCode=Tr.macroKeywordCode=void 0;const fs=Ke,el=Dr,GU=We,KU=Kp;function ZU(n,e){const{gen:t,keyword:s,schema:i,parentSchema:r,it:o}=n,a=e.macro.call(o.self,i,r,o),l=IT(t,s,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);const c=t.name("valid");n.subschema({schema:a,schemaPath:fs.nil,errSchemaPath:`${o.errSchemaPath}/${s}`,topSchemaRef:l,compositeRule:!0},c),n.pass(c,()=>n.error(!0))}Tr.macroKeywordCode=ZU;function XU(n,e){var t;const{gen:s,keyword:i,schema:r,parentSchema:o,$data:a,it:l}=n;JU(l,e);const c=!a&&e.compile?e.compile.call(l.self,r,o,l):e.validate,h=IT(s,i,c),u=s.let("valid");n.block$data(u,d),n.ok((t=e.valid)!==null&&t!==void 0?t:u);function d(){if(e.errors===!1)y(),e.modifying&&ZA(n),v(()=>n.error());else{const g=e.async?p():m();e.modifying&&ZA(n),v(()=>YU(n,g))}}function p(){const g=s.let("ruleErrs",null);return s.try(()=>y((0,fs._)`await `),_=>s.assign(u,!1).if((0,fs._)`${_} instanceof ${l.ValidationError}`,()=>s.assign(g,(0,fs._)`${_}.errors`),()=>s.throw(_))),g}function m(){const g=(0,fs._)`${h}.errors`;return s.assign(g,null),y(fs.nil),g}function y(g=e.async?(0,fs._)`await `:fs.nil){const _=l.opts.passContext?el.default.this:el.default.self,b=!("compile"in e&&!a||e.schema===!1);s.assign(u,(0,fs._)`${g}${(0,GU.callValidateCode)(n,h,_,b)}`,e.modifying)}function v(g){var _;s.if((0,fs.not)((_=e.valid)!==null&&_!==void 0?_:u),g)}}Tr.funcKeywordCode=XU;function ZA(n){const{gen:e,data:t,it:s}=n;e.if(s.parentData,()=>e.assign(t,(0,fs._)`${s.parentData}[${s.parentDataProperty}]`))}function YU(n,e){const{gen:t}=n;t.if((0,fs._)`Array.isArray(${e})`,()=>{t.assign(el.default.vErrors,(0,fs._)`${el.default.vErrors} === null ? ${e} : ${el.default.vErrors}.concat(${e})`).assign(el.default.errors,(0,fs._)`${el.default.vErrors}.length`),(0,KU.extendErrors)(n)},()=>n.error())}function JU({schemaEnv:n},e){if(e.async&&!n.$async)throw new Error("async keyword in sync schema")}function IT(n,e,t){if(t===void 0)throw new Error(`keyword "${e}" failed to compile`);return n.scopeValue("keyword",typeof t=="function"?{ref:t}:{ref:t,code:(0,fs.stringify)(t)})}function QU(n,e,t=!1){return!e.length||e.some(s=>s==="array"?Array.isArray(n):s==="object"?n&&typeof n=="object"&&!Array.isArray(n):typeof n==s||t&&typeof n>"u")}Tr.validSchemaType=QU;function eq({schema:n,opts:e,self:t,errSchemaPath:s},i,r){if(Array.isArray(i.keyword)?!i.keyword.includes(r):i.keyword!==r)throw new Error("ajv implementation error");const o=i.dependencies;if(o!=null&&o.some(a=>!Object.prototype.hasOwnProperty.call(n,a)))throw new Error(`parent schema must have dependencies of ${r}: ${o.join(",")}`);if(i.validateSchema&&!i.validateSchema(n[r])){const l=`keyword "${r}" value is invalid at path "${s}": `+t.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")t.logger.error(l);else throw new Error(l)}}Tr.validateKeywordUsage=eq;var ka={};Object.defineProperty(ka,"__esModule",{value:!0});ka.extendSubschemaMode=ka.extendSubschemaData=ka.getSubschema=void 0;const kr=Ke,OT=fe;function tq(n,{keyword:e,schemaProp:t,schema:s,schemaPath:i,errSchemaPath:r,topSchemaRef:o}){if(e!==void 0&&s!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){const a=n.schema[e];return t===void 0?{schema:a,schemaPath:(0,kr._)`${n.schemaPath}${(0,kr.getProperty)(e)}`,errSchemaPath:`${n.errSchemaPath}/${e}`}:{schema:a[t],schemaPath:(0,kr._)`${n.schemaPath}${(0,kr.getProperty)(e)}${(0,kr.getProperty)(t)}`,errSchemaPath:`${n.errSchemaPath}/${e}/${(0,OT.escapeFragment)(t)}`}}if(s!==void 0){if(i===void 0||r===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:i,topSchemaRef:o,errSchemaPath:r}}throw new Error('either "keyword" or "schema" must be passed')}ka.getSubschema=tq;function nq(n,e,{dataProp:t,dataPropType:s,data:i,dataTypes:r,propertyName:o}){if(i!==void 0&&t!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:a}=e;if(t!==void 0){const{errorPath:c,dataPathArr:h,opts:u}=e,d=a.let("data",(0,kr._)`${e.data}${(0,kr.getProperty)(t)}`,!0);l(d),n.errorPath=(0,kr.str)`${c}${(0,OT.getErrorPath)(t,s,u.jsPropertySyntax)}`,n.parentDataProperty=(0,kr._)`${t}`,n.dataPathArr=[...h,n.parentDataProperty]}if(i!==void 0){const c=i instanceof kr.Name?i:a.let("data",i,!0);l(c),o!==void 0&&(n.propertyName=o)}r&&(n.dataTypes=r);function l(c){n.data=c,n.dataLevel=e.dataLevel+1,n.dataTypes=[],e.definedProperties=new Set,n.parentData=e.data,n.dataNames=[...e.dataNames,c]}}ka.extendSubschemaData=nq;function sq(n,{jtdDiscriminator:e,jtdMetadata:t,compositeRule:s,createErrors:i,allErrors:r}){s!==void 0&&(n.compositeRule=s),i!==void 0&&(n.createErrors=i),r!==void 0&&(n.allErrors=r),n.jtdDiscriminator=e,n.jtdMetadata=t}ka.extendSubschemaMode=sq;var Hn={},_0=function n(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var s,i,r;if(Array.isArray(e)){if(s=e.length,s!=t.length)return!1;for(i=s;i--!==0;)if(!n(e[i],t[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(r=Object.keys(e),s=r.length,s!==Object.keys(t).length)return!1;for(i=s;i--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[i]))return!1;for(i=s;i--!==0;){var o=r[i];if(!n(e[o],t[o]))return!1}return!0}return e!==e&&t!==t},NT={exports:{}},wa=NT.exports=function(n,e,t){typeof e=="function"&&(t=e,e={}),t=e.cb||t;var s=typeof t=="function"?t:t.pre||function(){},i=t.post||function(){};og(e,s,i,n,"",n)};wa.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};wa.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};wa.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};wa.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function og(n,e,t,s,i,r,o,a,l,c){if(s&&typeof s=="object"&&!Array.isArray(s)){e(s,i,r,o,a,l,c);for(var h in s){var u=s[h];if(Array.isArray(u)){if(h in wa.arrayKeywords)for(var d=0;de+=LT(s)),e===1/0))return 1/0}return e}function DT(n,e="",t){t!==!1&&(e=ah(e));const s=n.parse(e);return jT(n,s)}Hn.getFullPath=DT;function jT(n,e){return n.serialize(e).split("#")[0]+"#"}Hn._getFullPath=jT;const dq=/#\/?$/;function ah(n){return n?n.replace(dq,""):""}Hn.normalizeId=ah;function fq(n,e,t){return t=ah(t),n.resolve(e,t)}Hn.resolveUrl=fq;const pq=/^[a-z_][-a-z0-9._]*$/i;function mq(n,e){if(typeof n=="boolean")return{};const{schemaId:t,uriResolver:s}=this.opts,i=ah(n[t]||e),r={"":i},o=DT(s,i,!1),a={},l=new Set;return lq(n,{allKeys:!0},(u,d,p,m)=>{if(m===void 0)return;const y=o+d;let v=r[m];typeof u[t]=="string"&&(v=g.call(this,u[t])),_.call(this,u.$anchor),_.call(this,u.$dynamicAnchor),r[d]=v;function g(b){const x=this.opts.uriResolver.resolve;if(b=ah(v?x(v,b):b),l.has(b))throw h(b);l.add(b);let A=this.refs[b];return typeof A=="string"&&(A=this.refs[A]),typeof A=="object"?c(u,A.schema,b):b!==ah(y)&&(b[0]==="#"?(c(u,a[b],b),a[b]=u):this.refs[b]=y),b}function _(b){if(typeof b=="string"){if(!pq.test(b))throw new Error(`invalid anchor "${b}"`);g.call(this,`#${b}`)}}}),a;function c(u,d,p){if(d!==void 0&&!aq(u,d))throw h(p)}function h(u){return new Error(`reference "${u}" resolves to more than one schema`)}}Hn.getSchemaRefs=mq;Object.defineProperty(Yi,"__esModule",{value:!0});Yi.getData=Yi.KeywordCxt=Yi.validateFunctionCode=void 0;const FT=vu,XA=dn,GS=_o,iy=dn,gq=w0,Dd=Tr,uv=ka,we=Ke,$e=Dr,yq=Hn,So=fe,Ju=Kp;function vq(n){if(BT(n)&&(UT(n),HT(n))){_q(n);return}zT(n,()=>(0,FT.topBoolOrEmptySchema)(n))}Yi.validateFunctionCode=vq;function zT({gen:n,validateName:e,schema:t,schemaEnv:s,opts:i},r){i.code.es5?n.func(e,(0,we._)`${$e.default.data}, ${$e.default.valCxt}`,s.$async,()=>{n.code((0,we._)`"use strict"; ${YA(t,i)}`),wq(n,i),n.code(r)}):n.func(e,(0,we._)`${$e.default.data}, ${bq(i)}`,s.$async,()=>n.code(YA(t,i)).code(r))}function bq(n){return(0,we._)`{${$e.default.instancePath}="", ${$e.default.parentData}, ${$e.default.parentDataProperty}, ${$e.default.rootData}=${$e.default.data}${n.dynamicRef?(0,we._)`, ${$e.default.dynamicAnchors}={}`:we.nil}}={}`}function wq(n,e){n.if($e.default.valCxt,()=>{n.var($e.default.instancePath,(0,we._)`${$e.default.valCxt}.${$e.default.instancePath}`),n.var($e.default.parentData,(0,we._)`${$e.default.valCxt}.${$e.default.parentData}`),n.var($e.default.parentDataProperty,(0,we._)`${$e.default.valCxt}.${$e.default.parentDataProperty}`),n.var($e.default.rootData,(0,we._)`${$e.default.valCxt}.${$e.default.rootData}`),e.dynamicRef&&n.var($e.default.dynamicAnchors,(0,we._)`${$e.default.valCxt}.${$e.default.dynamicAnchors}`)},()=>{n.var($e.default.instancePath,(0,we._)`""`),n.var($e.default.parentData,(0,we._)`undefined`),n.var($e.default.parentDataProperty,(0,we._)`undefined`),n.var($e.default.rootData,$e.default.data),e.dynamicRef&&n.var($e.default.dynamicAnchors,(0,we._)`{}`)})}function _q(n){const{schema:e,opts:t,gen:s}=n;zT(n,()=>{t.$comment&&e.$comment&&VT(n),Eq(n),s.let($e.default.vErrors,null),s.let($e.default.errors,0),t.unevaluated&&Sq(n),qT(n),Tq(n)})}function Sq(n){const{gen:e,validateName:t}=n;n.evaluated=e.const("evaluated",(0,we._)`${t}.evaluated`),e.if((0,we._)`${n.evaluated}.dynamicProps`,()=>e.assign((0,we._)`${n.evaluated}.props`,(0,we._)`undefined`)),e.if((0,we._)`${n.evaluated}.dynamicItems`,()=>e.assign((0,we._)`${n.evaluated}.items`,(0,we._)`undefined`))}function YA(n,e){const t=typeof n=="object"&&n[e.schemaId];return t&&(e.code.source||e.code.process)?(0,we._)`/*# sourceURL=${t} */`:we.nil}function xq(n,e){if(BT(n)&&(UT(n),HT(n))){Aq(n,e);return}(0,FT.boolOrEmptySchema)(n,e)}function HT({schema:n,self:e}){if(typeof n=="boolean")return!n;for(const t in n)if(e.RULES.all[t])return!0;return!1}function BT(n){return typeof n.schema!="boolean"}function Aq(n,e){const{schema:t,gen:s,opts:i}=n;i.$comment&&t.$comment&&VT(n),Cq(n),$q(n);const r=s.const("_errs",$e.default.errors);qT(n,r),s.var(e,(0,we._)`${r} === ${$e.default.errors}`)}function UT(n){(0,So.checkUnknownRules)(n),kq(n)}function qT(n,e){if(n.opts.jtd)return JA(n,[],!1,e);const t=(0,XA.getSchemaTypes)(n.schema),s=(0,XA.coerceAndCheckDataType)(n,t);JA(n,t,!s,e)}function kq(n){const{schema:e,errSchemaPath:t,opts:s,self:i}=n;e.$ref&&s.ignoreKeywordsWithRef&&(0,So.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${t}"`)}function Eq(n){const{schema:e,opts:t}=n;e.default!==void 0&&t.useDefaults&&t.strictSchema&&(0,So.checkStrictMode)(n,"default is ignored in the schema root")}function Cq(n){const e=n.schema[n.opts.schemaId];e&&(n.baseId=(0,yq.resolveUrl)(n.opts.uriResolver,n.baseId,e))}function $q(n){if(n.schema.$async&&!n.schemaEnv.$async)throw new Error("async schema in sync schema")}function VT({gen:n,schemaEnv:e,schema:t,errSchemaPath:s,opts:i}){const r=t.$comment;if(i.$comment===!0)n.code((0,we._)`${$e.default.self}.logger.log(${r})`);else if(typeof i.$comment=="function"){const o=(0,we.str)`${s}/$comment`,a=n.scopeValue("root",{ref:e.root});n.code((0,we._)`${$e.default.self}.opts.$comment(${r}, ${o}, ${a}.schema)`)}}function Tq(n){const{gen:e,schemaEnv:t,validateName:s,ValidationError:i,opts:r}=n;t.$async?e.if((0,we._)`${$e.default.errors} === 0`,()=>e.return($e.default.data),()=>e.throw((0,we._)`new ${i}(${$e.default.vErrors})`)):(e.assign((0,we._)`${s}.errors`,$e.default.vErrors),r.unevaluated&&Pq(n),e.return((0,we._)`${$e.default.errors} === 0`))}function Pq({gen:n,evaluated:e,props:t,items:s}){t instanceof we.Name&&n.assign((0,we._)`${e}.props`,t),s instanceof we.Name&&n.assign((0,we._)`${e}.items`,s)}function JA(n,e,t,s){const{gen:i,schema:r,data:o,allErrors:a,opts:l,self:c}=n,{RULES:h}=c;if(r.$ref&&(l.ignoreKeywordsWithRef||!(0,So.schemaHasRulesButRef)(r,h))){i.block(()=>KT(n,"$ref",h.all.$ref.definition));return}l.jtd||Rq(n,e),i.block(()=>{for(const d of h.rules)u(d);u(h.post)});function u(d){(0,GS.shouldUseGroup)(r,d)&&(d.type?(i.if((0,iy.checkDataType)(d.type,o,l.strictNumbers)),QA(n,d),e.length===1&&e[0]===d.type&&t&&(i.else(),(0,iy.reportTypeError)(n)),i.endIf()):QA(n,d),a||i.if((0,we._)`${$e.default.errors} === ${s||0}`))}}function QA(n,e){const{gen:t,schema:s,opts:{useDefaults:i}}=n;i&&(0,gq.assignDefaults)(n,e.type),t.block(()=>{for(const r of e.rules)(0,GS.shouldUseRule)(s,r)&&KT(n,r.keyword,r.definition,e.type)})}function Rq(n,e){n.schemaEnv.meta||!n.opts.strictTypes||(Mq(n,e),n.opts.allowUnionTypes||Iq(n,e),Oq(n,n.dataTypes))}function Mq(n,e){if(e.length){if(!n.dataTypes.length){n.dataTypes=e;return}e.forEach(t=>{WT(n.dataTypes,t)||KS(n,`type "${t}" not allowed by context "${n.dataTypes.join(",")}"`)}),Lq(n,e)}}function Iq(n,e){e.length>1&&!(e.length===2&&e.includes("null"))&&KS(n,"use allowUnionTypes to allow union type keyword")}function Oq(n,e){const t=n.self.RULES.all;for(const s in t){const i=t[s];if(typeof i=="object"&&(0,GS.shouldUseRule)(n.schema,i)){const{type:r}=i.definition;r.length&&!r.some(o=>Nq(e,o))&&KS(n,`missing type "${r.join(",")}" for keyword "${s}"`)}}}function Nq(n,e){return n.includes(e)||e==="number"&&n.includes("integer")}function WT(n,e){return n.includes(e)||e==="integer"&&n.includes("number")}function Lq(n,e){const t=[];for(const s of n.dataTypes)WT(e,s)?t.push(s):e.includes("integer")&&s==="number"&&t.push("integer");n.dataTypes=t}function KS(n,e){const t=n.schemaEnv.baseId+n.errSchemaPath;e+=` at "${t}" (strictTypes)`,(0,So.checkStrictMode)(n,e,n.opts.strictTypes)}let GT=class{constructor(e,t,s){if((0,Dd.validateKeywordUsage)(e,t,s),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=s,this.data=e.data,this.schema=e.schema[s],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,So.schemaRefOrVal)(e,this.schema,s,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",ZT(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Dd.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${s} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const("_errs",$e.default.errors))}result(e,t,s){this.failResult((0,we.not)(e),t,s)}failResult(e,t,s){this.gen.if(e),s?s():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,we.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail((0,we._)`${t} !== undefined && (${(0,we.or)(this.invalid$data(),e)})`)}error(e,t,s){if(t){this.setParams(t),this._error(e,s),this.setParams({});return}this._error(e,s)}_error(e,t){(e?Ju.reportExtraError:Ju.reportError)(this,this.def.error,t)}$dataError(){(0,Ju.reportError)(this,this.def.$dataError||Ju.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Ju.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,s=we.nil){this.gen.block(()=>{this.check$data(e,s),t()})}check$data(e=we.nil,t=we.nil){if(!this.$data)return;const{gen:s,schemaCode:i,schemaType:r,def:o}=this;s.if((0,we.or)((0,we._)`${i} === undefined`,t)),e!==we.nil&&s.assign(e,!0),(r.length||o.validateSchema)&&(s.elseIf(this.invalid$data()),this.$dataError(),e!==we.nil&&s.assign(e,!1)),s.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:s,def:i,it:r}=this;return(0,we.or)(o(),a());function o(){if(s.length){if(!(t instanceof we.Name))throw new Error("ajv implementation error");const l=Array.isArray(s)?s:[s];return(0,we._)`${(0,iy.checkDataTypes)(l,t,r.opts.strictNumbers,iy.DataType.Wrong)}`}return we.nil}function a(){if(i.validateSchema){const l=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,we._)`!${l}(${t})`}return we.nil}}subschema(e,t){const s=(0,uv.getSubschema)(this.it,e);(0,uv.extendSubschemaData)(s,this.it,e),(0,uv.extendSubschemaMode)(s,e);const i={...this.it,...s,items:void 0,props:void 0};return xq(i,t),i}mergeEvaluated(e,t){const{it:s,gen:i}=this;s.opts.unevaluated&&(s.props!==!0&&e.props!==void 0&&(s.props=So.mergeEvaluated.props(i,e.props,s.props,t)),s.items!==!0&&e.items!==void 0&&(s.items=So.mergeEvaluated.items(i,e.items,s.items,t)))}mergeValidEvaluated(e,t){const{it:s,gen:i}=this;if(s.opts.unevaluated&&(s.props!==!0||s.items!==!0))return i.if(t,()=>this.mergeEvaluated(e,we.Name)),!0}};Yi.KeywordCxt=GT;function KT(n,e,t,s){const i=new GT(n,t,e);"code"in t?t.code(i,s):i.$data&&t.validate?(0,Dd.funcKeywordCode)(i,t):"macro"in t?(0,Dd.macroKeywordCode)(i,t):(t.compile||t.validate)&&(0,Dd.funcKeywordCode)(i,t)}const Dq=/^\/(?:[^~]|~0|~1)*$/,jq=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ZT(n,{dataLevel:e,dataNames:t,dataPathArr:s}){let i,r;if(n==="")return $e.default.rootData;if(n[0]==="/"){if(!Dq.test(n))throw new Error(`Invalid JSON-pointer: ${n}`);i=n,r=$e.default.rootData}else{const c=jq.exec(n);if(!c)throw new Error(`Invalid JSON-pointer: ${n}`);const h=+c[1];if(i=c[2],i==="#"){if(h>=e)throw new Error(l("property/index",h));return s[e-h]}if(h>e)throw new Error(l("data",h));if(r=t[e-h],!i)return r}let o=r;const a=i.split("/");for(const c of a)c&&(r=(0,we._)`${r}${(0,we.getProperty)((0,So.unescapeJsonPointer)(c))}`,o=(0,we._)`${o} && ${r}`);return o;function l(c,h){return`Cannot access ${c} ${h} levels up, current level is ${e}`}}Yi.getData=ZT;var Zp={};Object.defineProperty(Zp,"__esModule",{value:!0});let Fq=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Zp.default=Fq;var Nu={};Object.defineProperty(Nu,"__esModule",{value:!0});const dv=Hn;let zq=class extends Error{constructor(e,t,s,i){super(i||`can't resolve reference ${s} from id ${t}`),this.missingRef=(0,dv.resolveUrl)(e,t,s),this.missingSchema=(0,dv.normalizeId)((0,dv.getFullPath)(e,this.missingRef))}};Nu.default=zq;var Ls={};Object.defineProperty(Ls,"__esModule",{value:!0});Ls.resolveSchema=Ls.getCompilingSchema=Ls.resolveRef=Ls.compileSchema=Ls.SchemaEnv=void 0;const Ci=Ke,Hq=Zp,Ba=Dr,Wi=Hn,ek=fe,Bq=Yi;let S0=class{constructor(e){var t;this.refs={},this.dynamicAnchors={};let s;typeof e.schema=="object"&&(s=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(t=e.baseId)!==null&&t!==void 0?t:(0,Wi.normalizeId)(s==null?void 0:s[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=s==null?void 0:s.$async,this.refs={}}};Ls.SchemaEnv=S0;function ZS(n){const e=XT.call(this,n);if(e)return e;const t=(0,Wi.getFullPath)(this.opts.uriResolver,n.root.baseId),{es5:s,lines:i}=this.opts.code,{ownProperties:r}=this.opts,o=new Ci.CodeGen(this.scope,{es5:s,lines:i,ownProperties:r});let a;n.$async&&(a=o.scopeValue("Error",{ref:Hq.default,code:(0,Ci._)`require("ajv/dist/runtime/validation_error").default`}));const l=o.scopeName("validate");n.validateName=l;const c={gen:o,allErrors:this.opts.allErrors,data:Ba.default.data,parentData:Ba.default.parentData,parentDataProperty:Ba.default.parentDataProperty,dataNames:[Ba.default.data],dataPathArr:[Ci.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:n.schema,code:(0,Ci.stringify)(n.schema)}:{ref:n.schema}),validateName:l,ValidationError:a,schema:n.schema,schemaEnv:n,rootId:t,baseId:n.baseId||t,schemaPath:Ci.nil,errSchemaPath:n.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Ci._)`""`,opts:this.opts,self:this};let h;try{this._compilations.add(n),(0,Bq.validateFunctionCode)(c),o.optimize(this.opts.code.optimize);const u=o.toString();h=`${o.scopeRefs(Ba.default.scope)}return ${u}`,this.opts.code.process&&(h=this.opts.code.process(h,n));const p=new Function(`${Ba.default.self}`,`${Ba.default.scope}`,h)(this,this.scope.get());if(this.scope.value(l,{ref:p}),p.errors=null,p.schema=n.schema,p.schemaEnv=n,n.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:l,validateCode:u,scopeValues:o._values}),this.opts.unevaluated){const{props:m,items:y}=c;p.evaluated={props:m instanceof Ci.Name?void 0:m,items:y instanceof Ci.Name?void 0:y,dynamicProps:m instanceof Ci.Name,dynamicItems:y instanceof Ci.Name},p.source&&(p.source.evaluated=(0,Ci.stringify)(p.evaluated))}return n.validate=p,n}catch(u){throw delete n.validate,delete n.validateName,h&&this.logger.error("Error compiling schema, function code:",h),u}finally{this._compilations.delete(n)}}Ls.compileSchema=ZS;function Uq(n,e,t){var s;t=(0,Wi.resolveUrl)(this.opts.uriResolver,e,t);const i=n.refs[t];if(i)return i;let r=Wq.call(this,n,t);if(r===void 0){const o=(s=n.localRefs)===null||s===void 0?void 0:s[t],{schemaId:a}=this.opts;o&&(r=new S0({schema:o,schemaId:a,root:n,baseId:e}))}if(r!==void 0)return n.refs[t]=qq.call(this,r)}Ls.resolveRef=Uq;function qq(n){return(0,Wi.inlineRef)(n.schema,this.opts.inlineRefs)?n.schema:n.validate?n:ZS.call(this,n)}function XT(n){for(const e of this._compilations)if(Vq(e,n))return e}Ls.getCompilingSchema=XT;function Vq(n,e){return n.schema===e.schema&&n.root===e.root&&n.baseId===e.baseId}function Wq(n,e){let t;for(;typeof(t=this.refs[e])=="string";)e=t;return t||this.schemas[e]||x0.call(this,n,e)}function x0(n,e){const t=this.opts.uriResolver.parse(e),s=(0,Wi._getFullPath)(this.opts.uriResolver,t);let i=(0,Wi.getFullPath)(this.opts.uriResolver,n.baseId,void 0);if(Object.keys(n.schema).length>0&&s===i)return fv.call(this,t,n);const r=(0,Wi.normalizeId)(s),o=this.refs[r]||this.schemas[r];if(typeof o=="string"){const a=x0.call(this,n,o);return typeof(a==null?void 0:a.schema)!="object"?void 0:fv.call(this,t,a)}if(typeof(o==null?void 0:o.schema)=="object"){if(o.validate||ZS.call(this,o),r===(0,Wi.normalizeId)(e)){const{schema:a}=o,{schemaId:l}=this.opts,c=a[l];return c&&(i=(0,Wi.resolveUrl)(this.opts.uriResolver,i,c)),new S0({schema:a,schemaId:l,root:n,baseId:i})}return fv.call(this,t,o)}}Ls.resolveSchema=x0;const Gq=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function fv(n,{baseId:e,schema:t,root:s}){var i;if(((i=n.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(const a of n.fragment.slice(1).split("/")){if(typeof t=="boolean")return;const l=t[(0,ek.unescapeFragment)(a)];if(l===void 0)return;t=l;const c=typeof t=="object"&&t[this.opts.schemaId];!Gq.has(a)&&c&&(e=(0,Wi.resolveUrl)(this.opts.uriResolver,e,c))}let r;if(typeof t!="boolean"&&t.$ref&&!(0,ek.schemaHasRulesButRef)(t,this.RULES)){const a=(0,Wi.resolveUrl)(this.opts.uriResolver,e,t.$ref);r=x0.call(this,s,a)}const{schemaId:o}=this.opts;if(r=r||new S0({schema:t,schemaId:o,root:s,baseId:e}),r.schema!==r.root.schema)return r}const Kq="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",Zq="Meta-schema for $data reference (JSON AnySchema extension proposal)",Xq="object",Yq=["$data"],Jq={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},Qq=!1,eV={$id:Kq,description:Zq,type:Xq,required:Yq,properties:Jq,additionalProperties:Qq};var XS={},A0={exports:{}};const tV=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),YT=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),YS=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),JT=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),nV=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function QT(n){let e="",t=0,s=0;for(s=0;s=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102))return"";e+=n[s];break}for(s+=1;s=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102))return"";e+=n[s]}return e}const sV=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function tk(n){return n.length=0,!0}function iV(n,e,t){if(n.length){const s=QT(n);if(s!=="")e.push(s);else return t.error=!0,!1;n.length=0}return!0}function rV(n){let e=0;const t={error:!1,address:"",zone:""},s=[],i=[];let r=!1,o=!1,a=iV;for(let l=0;l7){t.error=!0;break}l>0&&n[l-1]===":"&&(r=!0),s.push(":");continue}else if(c==="%"){if(!a(i,s,t))break;a=tk}else{i.push(c);continue}}return i.length&&(a===tk?t.zone=i.join(""):o?s.push(i.join("")):s.push(QT(i))),t.address=s.join(""),t}function eP(n){if(oV(n,":")<2)return{host:n,isIPV6:!1};const e=rV(n);if(e.error)return{host:n,isIPV6:!1};{let t=e.address,s=e.address;return e.zone&&(t+="%"+e.zone,s+="%25"+e.zone),{host:t,isIPV6:!0,escapedHost:s}}}function oV(n,e){let t=0;for(let s=0;slV[s])}function uV(n,e=!1){if(n.indexOf("%")===-1)return n;let t="";for(let s=0;s65535))return"URI port is malformed."}function oy(n,e){const t=Object.assign({},e),s={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let i=!1,r=!1;t.reference==="suffix"&&(t.scheme?n=t.scheme+":"+n:n="//"+n);const o=n.match(HV);o!==null&&o[1].indexOf("\\")!==-1&&(s.error="URI authority must not contain a literal backslash.",i=!0);const a=n.match(BV);if(a!==null){const c=a[1],h=c.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(s.error=s.error||"URI authority must not contain a literal backslash.",i=!0):c.length!==h.length&&(s.error=s.error||"URI authority introducer must not contain whitespace.",i=!0))}const l=n.match(zV);if(l){s.scheme=l[1],s.userinfo=l[3],s.host=l[4],s.port=parseInt(l[5],10),s.path=l[6]||"",s.query=l[7],s.fragment=l[8],isNaN(s.port)&&(s.port=l[5]);const c=UV(s,l);if(c!==void 0&&(s.error=s.error||c,i=!0),s.host)if(OV(s.host)===!1){const d=$V(s.host);s.host=d.host.toLowerCase(),r=d.isIPV6}else r=!0;s.scheme===void 0&&s.userinfo===void 0&&s.host===void 0&&s.port===void 0&&s.query===void 0&&!s.path?s.reference="same-document":s.scheme===void 0?s.reference="relative":s.fragment===void 0?s.reference="absolute":s.reference="uri",t.reference&&t.reference!=="suffix"&&t.reference!==s.reference&&(s.error=s.error||"URI is not a "+t.reference+" reference.");const h=aP(t.scheme||s.scheme);if(!t.unicodeSupport&&(!h||!h.unicodeSupport)&&s.host&&(t.domainHost||h&&h.domainHost)&&r===!1&&NV(s.host))try{s.host=new URL("http://"+s.host).hostname}catch(u){s.error=s.error||"Host's domain name can not be converted to ASCII: "+u}if((!h||h&&!h.skipNormalize)&&(n.indexOf("%")!==-1&&(s.scheme!==void 0&&(s.scheme=unescape(s.scheme)),s.host!==void 0&&(s.host=IV(unescape(s.host),r))),s.path&&(s.path=RV(s.path)),s.fragment))try{s.fragment=encodeURI(decodeURIComponent(s.fragment))}catch{s.error=s.error||"URI malformed"}h&&h.parse&&h.parse(s,t)}else s.error=s.error||"URI can not be parsed.";return{parsed:s,malformedAuthorityOrPort:i}}function ay(n,e){return oy(n,e).parsed}function qV(n,e){return cP(n,e).normalized}function cP(n,e){const{parsed:t,malformedAuthorityOrPort:s}=oy(n,e);return{normalized:s?n:uc(t,e),malformedAuthorityOrPort:s}}function nk(n,e){if(typeof n=="string"){const{normalized:t,malformedAuthorityOrPort:s}=cP(n,e);return s?void 0:t}if(typeof n=="object")return uc(n,e)}const QS={SCHEMES:LV,normalize:DV,resolve:jV,resolveComponent:lP,equal:FV,serialize:uc,parse:ay};A0.exports=QS;A0.exports.default=QS;A0.exports.fastUri=QS;var hP=A0.exports;Object.defineProperty(XS,"__esModule",{value:!0});const uP=hP;uP.code='require("ajv/dist/runtime/uri").default';XS.default=uP;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.CodeGen=n.Name=n.nil=n.stringify=n.str=n._=n.KeywordCxt=void 0;var e=Yi;Object.defineProperty(n,"KeywordCxt",{enumerable:!0,get:function(){return e.KeywordCxt}});var t=Ke;Object.defineProperty(n,"_",{enumerable:!0,get:function(){return t._}}),Object.defineProperty(n,"str",{enumerable:!0,get:function(){return t.str}}),Object.defineProperty(n,"stringify",{enumerable:!0,get:function(){return t.stringify}}),Object.defineProperty(n,"nil",{enumerable:!0,get:function(){return t.nil}}),Object.defineProperty(n,"Name",{enumerable:!0,get:function(){return t.Name}}),Object.defineProperty(n,"CodeGen",{enumerable:!0,get:function(){return t.CodeGen}});const s=Zp,i=Nu,r=hc,o=Ls,a=Ke,l=Hn,c=dn,h=fe,u=eV,d=XS,p=(z,E)=>new RegExp(z,E);p.code="new RegExp";const m=["removeAdditional","useDefaults","coerceTypes"],y=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),v={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},g={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},_=200;function b(z){var E,O,R,w,k,N,G,Z,ae,ie,Ae,ct,Ie,Fe,Je,it,bn,ut,Ss,xs,Pn,ls,As,ks,cs;const wn=z.strict,Kt=(E=z.code)===null||E===void 0?void 0:E.optimize,Zn=Kt===!0||Kt===void 0?1:Kt||0,an=(R=(O=z.code)===null||O===void 0?void 0:O.regExp)!==null&&R!==void 0?R:p,Es=(w=z.uriResolver)!==null&&w!==void 0?w:d.default;return{strictSchema:(N=(k=z.strictSchema)!==null&&k!==void 0?k:wn)!==null&&N!==void 0?N:!0,strictNumbers:(Z=(G=z.strictNumbers)!==null&&G!==void 0?G:wn)!==null&&Z!==void 0?Z:!0,strictTypes:(ie=(ae=z.strictTypes)!==null&&ae!==void 0?ae:wn)!==null&&ie!==void 0?ie:"log",strictTuples:(ct=(Ae=z.strictTuples)!==null&&Ae!==void 0?Ae:wn)!==null&&ct!==void 0?ct:"log",strictRequired:(Fe=(Ie=z.strictRequired)!==null&&Ie!==void 0?Ie:wn)!==null&&Fe!==void 0?Fe:!1,code:z.code?{...z.code,optimize:Zn,regExp:an}:{optimize:Zn,regExp:an},loopRequired:(Je=z.loopRequired)!==null&&Je!==void 0?Je:_,loopEnum:(it=z.loopEnum)!==null&&it!==void 0?it:_,meta:(bn=z.meta)!==null&&bn!==void 0?bn:!0,messages:(ut=z.messages)!==null&&ut!==void 0?ut:!0,inlineRefs:(Ss=z.inlineRefs)!==null&&Ss!==void 0?Ss:!0,schemaId:(xs=z.schemaId)!==null&&xs!==void 0?xs:"$id",addUsedSchema:(Pn=z.addUsedSchema)!==null&&Pn!==void 0?Pn:!0,validateSchema:(ls=z.validateSchema)!==null&&ls!==void 0?ls:!0,validateFormats:(As=z.validateFormats)!==null&&As!==void 0?As:!0,unicodeRegExp:(ks=z.unicodeRegExp)!==null&&ks!==void 0?ks:!0,int32range:(cs=z.int32range)!==null&&cs!==void 0?cs:!0,uriResolver:Es}}class x{constructor(E={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,E=this.opts={...E,...b(E)};const{es5:O,lines:R}=this.opts.code;this.scope=new a.ValueScope({scope:{},prefixes:y,es5:O,lines:R}),this.logger=U(E.logger);const w=E.validateFormats;E.validateFormats=!1,this.RULES=(0,r.getRules)(),A.call(this,v,E,"NOT SUPPORTED"),A.call(this,g,E,"DEPRECATED","warn"),this._metaOpts=H.call(this),E.formats&&I.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),E.keywords&&D.call(this,E.keywords),typeof E.meta=="object"&&this.addMetaSchema(E.meta),C.call(this),E.validateFormats=w}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:E,meta:O,schemaId:R}=this.opts;let w=u;R==="id"&&(w={...u},w.id=w.$id,delete w.$id),O&&E&&this.addMetaSchema(w,w[R],!1)}defaultMeta(){const{meta:E,schemaId:O}=this.opts;return this.opts.defaultMeta=typeof E=="object"?E[O]||E:void 0}validate(E,O){let R;if(typeof E=="string"){if(R=this.getSchema(E),!R)throw new Error(`no schema with key or ref "${E}"`)}else R=this.compile(E);const w=R(O);return"$async"in R||(this.errors=R.errors),w}compile(E,O){const R=this._addSchema(E,O);return R.validate||this._compileSchemaEnv(R)}compileAsync(E,O){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:R}=this.opts;return w.call(this,E,O);async function w(ie,Ae){await k.call(this,ie.$schema);const ct=this._addSchema(ie,Ae);return ct.validate||N.call(this,ct)}async function k(ie){ie&&!this.getSchema(ie)&&await w.call(this,{$ref:ie},!0)}async function N(ie){try{return this._compileSchemaEnv(ie)}catch(Ae){if(!(Ae instanceof i.default))throw Ae;return G.call(this,Ae),await Z.call(this,Ae.missingSchema),N.call(this,ie)}}function G({missingSchema:ie,missingRef:Ae}){if(this.refs[ie])throw new Error(`AnySchema ${ie} is loaded but ${Ae} cannot be resolved`)}async function Z(ie){const Ae=await ae.call(this,ie);this.refs[ie]||await k.call(this,Ae.$schema),this.refs[ie]||this.addSchema(Ae,ie,O)}async function ae(ie){const Ae=this._loading[ie];if(Ae)return Ae;try{return await(this._loading[ie]=R(ie))}finally{delete this._loading[ie]}}}addSchema(E,O,R,w=this.opts.validateSchema){if(Array.isArray(E)){for(const N of E)this.addSchema(N,void 0,R,w);return this}let k;if(typeof E=="object"){const{schemaId:N}=this.opts;if(k=E[N],k!==void 0&&typeof k!="string")throw new Error(`schema ${N} must be string`)}return O=(0,l.normalizeId)(O||k),this._checkUnique(O),this.schemas[O]=this._addSchema(E,R,O,w,!0),this}addMetaSchema(E,O,R=this.opts.validateSchema){return this.addSchema(E,O,!0,R),this}validateSchema(E,O){if(typeof E=="boolean")return!0;let R;if(R=E.$schema,R!==void 0&&typeof R!="string")throw new Error("$schema must be a string");if(R=R||this.opts.defaultMeta||this.defaultMeta(),!R)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const w=this.validate(R,E);if(!w&&O){const k="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(k);else throw new Error(k)}return w}getSchema(E){let O;for(;typeof(O=T.call(this,E))=="string";)E=O;if(O===void 0){const{schemaId:R}=this.opts,w=new o.SchemaEnv({schema:{},schemaId:R});if(O=o.resolveSchema.call(this,w,E),!O)return;this.refs[E]=O}return O.validate||this._compileSchemaEnv(O)}removeSchema(E){if(E instanceof RegExp)return this._removeAllSchemas(this.schemas,E),this._removeAllSchemas(this.refs,E),this;switch(typeof E){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const O=T.call(this,E);return typeof O=="object"&&this._cache.delete(O.schema),delete this.schemas[E],delete this.refs[E],this}case"object":{const O=E;this._cache.delete(O);let R=E[this.opts.schemaId];return R&&(R=(0,l.normalizeId)(R),delete this.schemas[R],delete this.refs[R]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(E){for(const O of E)this.addKeyword(O);return this}addKeyword(E,O){let R;if(typeof E=="string")R=E,typeof O=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),O.keyword=R);else if(typeof E=="object"&&O===void 0){if(O=E,R=O.keyword,Array.isArray(R)&&!R.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(L.call(this,R,O),!O)return(0,h.eachItem)(R,k=>X.call(this,k)),this;J.call(this,O);const w={...O,type:(0,c.getJSONTypes)(O.type),schemaType:(0,c.getJSONTypes)(O.schemaType)};return(0,h.eachItem)(R,w.type.length===0?k=>X.call(this,k,w):k=>w.type.forEach(N=>X.call(this,k,w,N))),this}getKeyword(E){const O=this.RULES.all[E];return typeof O=="object"?O.definition:!!O}removeKeyword(E){const{RULES:O}=this;delete O.keywords[E],delete O.all[E];for(const R of O.rules){const w=R.rules.findIndex(k=>k.keyword===E);w>=0&&R.rules.splice(w,1)}return this}addFormat(E,O){return typeof O=="string"&&(O=new RegExp(O)),this.formats[E]=O,this}errorsText(E=this.errors,{separator:O=", ",dataVar:R="data"}={}){return!E||E.length===0?"No errors":E.map(w=>`${R}${w.instancePath} ${w.message}`).reduce((w,k)=>w+O+k)}$dataMetaSchema(E,O){const R=this.RULES.all;E=JSON.parse(JSON.stringify(E));for(const w of O){const k=w.split("/").slice(1);let N=E;for(const G of k)N=N[G];for(const G in R){const Z=R[G];if(typeof Z!="object")continue;const{$data:ae}=Z.definition,ie=N[G];ae&&ie&&(N[G]=ge(ie))}}return E}_removeAllSchemas(E,O){for(const R in E){const w=E[R];(!O||O.test(R))&&(typeof w=="string"?delete E[R]:w&&!w.meta&&(this._cache.delete(w.schema),delete E[R]))}}_addSchema(E,O,R,w=this.opts.validateSchema,k=this.opts.addUsedSchema){let N;const{schemaId:G}=this.opts;if(typeof E=="object")N=E[G];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof E!="boolean")throw new Error("schema must be object or boolean")}let Z=this._cache.get(E);if(Z!==void 0)return Z;R=(0,l.normalizeId)(N||R);const ae=l.getSchemaRefs.call(this,E,R);return Z=new o.SchemaEnv({schema:E,schemaId:G,meta:O,baseId:R,localRefs:ae}),this._cache.set(Z.schema,Z),k&&!R.startsWith("#")&&(R&&this._checkUnique(R),this.refs[R]=Z),w&&this.validateSchema(E,!0),Z}_checkUnique(E){if(this.schemas[E]||this.refs[E])throw new Error(`schema with key or id "${E}" already exists`)}_compileSchemaEnv(E){if(E.meta?this._compileMetaSchema(E):o.compileSchema.call(this,E),!E.validate)throw new Error("ajv implementation error");return E.validate}_compileMetaSchema(E){const O=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,E)}finally{this.opts=O}}}x.ValidationError=s.default,x.MissingRefError=i.default,n.default=x;function A(z,E,O,R="error"){for(const w in z){const k=w;k in E&&this.logger[R](`${O}: option ${w}. ${z[k]}`)}}function T(z){return z=(0,l.normalizeId)(z),this.schemas[z]||this.refs[z]}function C(){const z=this.opts.schemas;if(z)if(Array.isArray(z))this.addSchema(z);else for(const E in z)this.addSchema(z[E],E)}function I(){for(const z in this.opts.formats){const E=this.opts.formats[z];E&&this.addFormat(z,E)}}function D(z){if(Array.isArray(z)){this.addVocabulary(z);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const E in z){const O=z[E];O.keyword||(O.keyword=E),this.addKeyword(O)}}function H(){const z={...this.opts};for(const E of m)delete z[E];return z}const j={log(){},warn(){},error(){}};function U(z){if(z===!1)return j;if(z===void 0)return console;if(z.log&&z.warn&&z.error)return z;throw new Error("logger must implement log, warn and error methods")}const B=/^[a-z_$][a-z0-9_$:-]*$/i;function L(z,E){const{RULES:O}=this;if((0,h.eachItem)(z,R=>{if(O.keywords[R])throw new Error(`Keyword ${R} is already defined`);if(!B.test(R))throw new Error(`Keyword ${R} has invalid name`)}),!!E&&E.$data&&!("code"in E||"validate"in E))throw new Error('$data keyword must have "code" or "validate" function')}function X(z,E,O){var R;const w=E==null?void 0:E.post;if(O&&w)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:k}=this;let N=w?k.post:k.rules.find(({type:Z})=>Z===O);if(N||(N={type:O,rules:[]},k.rules.push(N)),k.keywords[z]=!0,!E)return;const G={keyword:z,definition:{...E,type:(0,c.getJSONTypes)(E.type),schemaType:(0,c.getJSONTypes)(E.schemaType)}};E.before?se.call(this,N,G,E.before):N.rules.push(G),k.all[z]=G,(R=E.implements)===null||R===void 0||R.forEach(Z=>this.addKeyword(Z))}function se(z,E,O){const R=z.rules.findIndex(w=>w.keyword===O);R>=0?z.rules.splice(R,0,E):(z.rules.push(E),this.logger.warn(`rule ${O} is not defined`))}function J(z){let{metaSchema:E}=z;E!==void 0&&(z.$data&&this.opts.$data&&(E=ge(E)),z.validateSchema=this.compile(E,!0))}const Y={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ge(z){return{anyOf:[z,Y]}}})(bT);var e1={},t1={},n1={};Object.defineProperty(n1,"__esModule",{value:!0});const VV={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};n1.default=VV;var dc={};Object.defineProperty(dc,"__esModule",{value:!0});dc.callRef=dc.getValidate=void 0;const WV=Nu,sk=We,Is=Ke,Nc=Dr,ik=Ls,Sm=fe,GV={keyword:"$ref",schemaType:"string",code(n){const{gen:e,schema:t,it:s}=n,{baseId:i,schemaEnv:r,validateName:o,opts:a,self:l}=s,{root:c}=r;if((t==="#"||t==="#/")&&i===c.baseId)return u();const h=ik.resolveRef.call(l,c,i,t);if(h===void 0)throw new WV.default(s.opts.uriResolver,i,t);if(h instanceof ik.SchemaEnv)return d(h);return p(h);function u(){if(r===c)return lg(n,o,r,r.$async);const m=e.scopeValue("root",{ref:c});return lg(n,(0,Is._)`${m}.validate`,c,c.$async)}function d(m){const y=dP(n,m);lg(n,y,m,m.$async)}function p(m){const y=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Is.stringify)(m)}:{ref:m}),v=e.name("valid"),g=n.subschema({schema:m,dataTypes:[],schemaPath:Is.nil,topSchemaRef:y,errSchemaPath:t},v);n.mergeEvaluated(g),n.ok(v)}}};function dP(n,e){const{gen:t}=n;return e.validate?t.scopeValue("validate",{ref:e.validate}):(0,Is._)`${t.scopeValue("wrapper",{ref:e})}.validate`}dc.getValidate=dP;function lg(n,e,t,s){const{gen:i,it:r}=n,{allErrors:o,schemaEnv:a,opts:l}=r,c=l.passContext?Nc.default.this:Is.nil;s?h():u();function h(){if(!a.$async)throw new Error("async schema referenced by sync schema");const m=i.let("valid");i.try(()=>{i.code((0,Is._)`await ${(0,sk.callValidateCode)(n,e,c)}`),p(e),o||i.assign(m,!0)},y=>{i.if((0,Is._)`!(${y} instanceof ${r.ValidationError})`,()=>i.throw(y)),d(y),o||i.assign(m,!1)}),n.ok(m)}function u(){n.result((0,sk.callValidateCode)(n,e,c),()=>p(e),()=>d(e))}function d(m){const y=(0,Is._)`${m}.errors`;i.assign(Nc.default.vErrors,(0,Is._)`${Nc.default.vErrors} === null ? ${y} : ${Nc.default.vErrors}.concat(${y})`),i.assign(Nc.default.errors,(0,Is._)`${Nc.default.vErrors}.length`)}function p(m){var y;if(!r.opts.unevaluated)return;const v=(y=t==null?void 0:t.validate)===null||y===void 0?void 0:y.evaluated;if(r.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(r.props=Sm.mergeEvaluated.props(i,v.props,r.props));else{const g=i.var("props",(0,Is._)`${m}.evaluated.props`);r.props=Sm.mergeEvaluated.props(i,g,r.props,Is.Name)}if(r.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(r.items=Sm.mergeEvaluated.items(i,v.items,r.items));else{const g=i.var("items",(0,Is._)`${m}.evaluated.items`);r.items=Sm.mergeEvaluated.items(i,g,r.items,Is.Name)}}}dc.callRef=lg;dc.default=GV;Object.defineProperty(t1,"__esModule",{value:!0});const KV=n1,ZV=dc,XV=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",KV.default,ZV.default];t1.default=XV;var s1={},i1={};Object.defineProperty(i1,"__esModule",{value:!0});const ly=Ke,No=ly.operators,cy={maximum:{okStr:"<=",ok:No.LTE,fail:No.GT},minimum:{okStr:">=",ok:No.GTE,fail:No.LT},exclusiveMaximum:{okStr:"<",ok:No.LT,fail:No.GTE},exclusiveMinimum:{okStr:">",ok:No.GT,fail:No.LTE}},YV={message:({keyword:n,schemaCode:e})=>(0,ly.str)`must be ${cy[n].okStr} ${e}`,params:({keyword:n,schemaCode:e})=>(0,ly._)`{comparison: ${cy[n].okStr}, limit: ${e}}`},JV={keyword:Object.keys(cy),type:"number",schemaType:"number",$data:!0,error:YV,code(n){const{keyword:e,data:t,schemaCode:s}=n;n.fail$data((0,ly._)`${t} ${cy[e].fail} ${s} || isNaN(${t})`)}};i1.default=JV;var r1={};Object.defineProperty(r1,"__esModule",{value:!0});const jd=Ke,QV={message:({schemaCode:n})=>(0,jd.str)`must be multiple of ${n}`,params:({schemaCode:n})=>(0,jd._)`{multipleOf: ${n}}`},e3={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:QV,code(n){const{gen:e,data:t,schemaCode:s,it:i}=n,r=i.opts.multipleOfPrecision,o=e.let("res"),a=r?(0,jd._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${r}`:(0,jd._)`${o} !== parseInt(${o})`;n.fail$data((0,jd._)`(${s} === 0 || (${o} = ${t}/${s}, ${a}))`)}};r1.default=e3;var o1={},a1={};Object.defineProperty(a1,"__esModule",{value:!0});function fP(n){const e=n.length;let t=0,s=0,i;for(;s=55296&&i<=56319&&s(0,tl._)`{limit: ${n}}`},i3={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:s3,code(n){const{keyword:e,data:t,schemaCode:s,it:i}=n,r=e==="maxLength"?tl.operators.GT:tl.operators.LT,o=i.opts.unicode===!1?(0,tl._)`${t}.length`:(0,tl._)`${(0,t3.useFunc)(n.gen,n3.default)}(${t})`;n.fail$data((0,tl._)`${o} ${r} ${s}`)}};o1.default=i3;var l1={};Object.defineProperty(l1,"__esModule",{value:!0});const r3=We,o3=fe,th=Ke,a3={message:({schemaCode:n})=>(0,th.str)`must match pattern "${n}"`,params:({schemaCode:n})=>(0,th._)`{pattern: ${n}}`},l3={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:a3,code(n){const{gen:e,data:t,$data:s,schema:i,schemaCode:r,it:o}=n,a=o.opts.unicodeRegExp?"u":"";if(s){const{regExp:l}=o.opts.code,c=l.code==="new RegExp"?(0,th._)`new RegExp`:(0,o3.useFunc)(e,l),h=e.let("valid");e.try(()=>e.assign(h,(0,th._)`${c}(${r}, ${a}).test(${t})`),()=>e.assign(h,!1)),n.fail$data((0,th._)`!${h}`)}else{const l=(0,r3.usePattern)(n,i);n.fail$data((0,th._)`!${l}.test(${t})`)}}};l1.default=l3;var c1={};Object.defineProperty(c1,"__esModule",{value:!0});const Fd=Ke,c3={message({keyword:n,schemaCode:e}){const t=n==="maxProperties"?"more":"fewer";return(0,Fd.str)`must NOT have ${t} than ${e} properties`},params:({schemaCode:n})=>(0,Fd._)`{limit: ${n}}`},h3={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:c3,code(n){const{keyword:e,data:t,schemaCode:s}=n,i=e==="maxProperties"?Fd.operators.GT:Fd.operators.LT;n.fail$data((0,Fd._)`Object.keys(${t}).length ${i} ${s}`)}};c1.default=h3;var h1={};Object.defineProperty(h1,"__esModule",{value:!0});const Qu=We,zd=Ke,u3=fe,d3={message:({params:{missingProperty:n}})=>(0,zd.str)`must have required property '${n}'`,params:({params:{missingProperty:n}})=>(0,zd._)`{missingProperty: ${n}}`},f3={keyword:"required",type:"object",schemaType:"array",$data:!0,error:d3,code(n){const{gen:e,schema:t,schemaCode:s,data:i,$data:r,it:o}=n,{opts:a}=o;if(!r&&t.length===0)return;const l=t.length>=a.loopRequired;if(o.allErrors?c():h(),a.strictRequired){const p=n.parentSchema.properties,{definedProperties:m}=n.it;for(const y of t)if((p==null?void 0:p[y])===void 0&&!m.has(y)){const v=o.schemaEnv.baseId+o.errSchemaPath,g=`required property "${y}" is not defined at "${v}" (strictRequired)`;(0,u3.checkStrictMode)(o,g,o.opts.strictRequired)}}function c(){if(l||r)n.block$data(zd.nil,u);else for(const p of t)(0,Qu.checkReportMissingProp)(n,p)}function h(){const p=e.let("missing");if(l||r){const m=e.let("valid",!0);n.block$data(m,()=>d(p,m)),n.ok(m)}else e.if((0,Qu.checkMissingProp)(n,t,p)),(0,Qu.reportMissingProp)(n,p),e.else()}function u(){e.forOf("prop",s,p=>{n.setParams({missingProperty:p}),e.if((0,Qu.noPropertyInData)(e,i,p,a.ownProperties),()=>n.error())})}function d(p,m){n.setParams({missingProperty:p}),e.forOf(p,s,()=>{e.assign(m,(0,Qu.propertyInData)(e,i,p,a.ownProperties)),e.if((0,zd.not)(m),()=>{n.error(),e.break()})},zd.nil)}}};h1.default=f3;var u1={};Object.defineProperty(u1,"__esModule",{value:!0});const Hd=Ke,p3={message({keyword:n,schemaCode:e}){const t=n==="maxItems"?"more":"fewer";return(0,Hd.str)`must NOT have ${t} than ${e} items`},params:({schemaCode:n})=>(0,Hd._)`{limit: ${n}}`},m3={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:p3,code(n){const{keyword:e,data:t,schemaCode:s}=n,i=e==="maxItems"?Hd.operators.GT:Hd.operators.LT;n.fail$data((0,Hd._)`${t}.length ${i} ${s}`)}};u1.default=m3;var d1={},Xp={};Object.defineProperty(Xp,"__esModule",{value:!0});const pP=_0;pP.code='require("ajv/dist/runtime/equal").default';Xp.default=pP;Object.defineProperty(d1,"__esModule",{value:!0});const pv=dn,In=Ke,g3=fe,y3=Xp,v3={message:({params:{i:n,j:e}})=>(0,In.str)`must NOT have duplicate items (items ## ${e} and ${n} are identical)`,params:({params:{i:n,j:e}})=>(0,In._)`{i: ${n}, j: ${e}}`},b3={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:v3,code(n){const{gen:e,data:t,$data:s,schema:i,parentSchema:r,schemaCode:o,it:a}=n;if(!s&&!i)return;const l=e.let("valid"),c=r.items?(0,pv.getSchemaTypes)(r.items):[];n.block$data(l,h,(0,In._)`${o} === false`),n.ok(l);function h(){const m=e.let("i",(0,In._)`${t}.length`),y=e.let("j");n.setParams({i:m,j:y}),e.assign(l,!0),e.if((0,In._)`${m} > 1`,()=>(u()?d:p)(m,y))}function u(){return c.length>0&&!c.some(m=>m==="object"||m==="array")}function d(m,y){const v=e.name("item"),g=(0,pv.checkDataTypes)(c,v,a.opts.strictNumbers,pv.DataType.Wrong),_=e.const("indices",(0,In._)`{}`);e.for((0,In._)`;${m}--;`,()=>{e.let(v,(0,In._)`${t}[${m}]`),e.if(g,(0,In._)`continue`),c.length>1&&e.if((0,In._)`typeof ${v} == "string"`,(0,In._)`${v} += "_"`),e.if((0,In._)`typeof ${_}[${v}] == "number"`,()=>{e.assign(y,(0,In._)`${_}[${v}]`),n.error(),e.assign(l,!1).break()}).code((0,In._)`${_}[${v}] = ${m}`)})}function p(m,y){const v=(0,g3.useFunc)(e,y3.default),g=e.name("outer");e.label(g).for((0,In._)`;${m}--;`,()=>e.for((0,In._)`${y} = ${m}; ${y}--;`,()=>e.if((0,In._)`${v}(${t}[${m}], ${t}[${y}])`,()=>{n.error(),e.assign(l,!1).break(g)})))}}};d1.default=b3;var f1={};Object.defineProperty(f1,"__esModule",{value:!0});const yb=Ke,w3=fe,_3=Xp,S3={message:"must be equal to constant",params:({schemaCode:n})=>(0,yb._)`{allowedValue: ${n}}`},x3={keyword:"const",$data:!0,error:S3,code(n){const{gen:e,data:t,$data:s,schemaCode:i,schema:r}=n;s||r&&typeof r=="object"?n.fail$data((0,yb._)`!${(0,w3.useFunc)(e,_3.default)}(${t}, ${i})`):n.fail((0,yb._)`${r} !== ${t}`)}};f1.default=x3;var p1={};Object.defineProperty(p1,"__esModule",{value:!0});const fd=Ke,A3=fe,k3=Xp,E3={message:"must be equal to one of the allowed values",params:({schemaCode:n})=>(0,fd._)`{allowedValues: ${n}}`},C3={keyword:"enum",schemaType:"array",$data:!0,error:E3,code(n){const{gen:e,data:t,$data:s,schema:i,schemaCode:r,it:o}=n;if(!s&&i.length===0)throw new Error("enum must have non-empty array");const a=i.length>=o.opts.loopEnum;let l;const c=()=>l??(l=(0,A3.useFunc)(e,k3.default));let h;if(a||s)h=e.let("valid"),n.block$data(h,u);else{if(!Array.isArray(i))throw new Error("ajv implementation error");const p=e.const("vSchema",r);h=(0,fd.or)(...i.map((m,y)=>d(p,y)))}n.pass(h);function u(){e.assign(h,!1),e.forOf("v",r,p=>e.if((0,fd._)`${c()}(${t}, ${p})`,()=>e.assign(h,!0).break()))}function d(p,m){const y=i[m];return typeof y=="object"&&y!==null?(0,fd._)`${c()}(${t}, ${p}[${m}])`:(0,fd._)`${t} === ${y}`}}};p1.default=C3;Object.defineProperty(s1,"__esModule",{value:!0});const $3=i1,T3=r1,P3=o1,R3=l1,M3=c1,I3=h1,O3=u1,N3=d1,L3=f1,D3=p1,j3=[$3.default,T3.default,P3.default,R3.default,M3.default,I3.default,O3.default,N3.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},L3.default,D3.default];s1.default=j3;var m1={},Lu={};Object.defineProperty(Lu,"__esModule",{value:!0});Lu.validateAdditionalItems=void 0;const nl=Ke,vb=fe,F3={message:({params:{len:n}})=>(0,nl.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0,nl._)`{limit: ${n}}`},z3={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:F3,code(n){const{parentSchema:e,it:t}=n,{items:s}=e;if(!Array.isArray(s)){(0,vb.checkStrictMode)(t,'"additionalItems" is ignored when "items" is not an array of schemas');return}mP(n,s)}};function mP(n,e){const{gen:t,schema:s,data:i,keyword:r,it:o}=n;o.items=!0;const a=t.const("len",(0,nl._)`${i}.length`);if(s===!1)n.setParams({len:e.length}),n.pass((0,nl._)`${a} <= ${e.length}`);else if(typeof s=="object"&&!(0,vb.alwaysValidSchema)(o,s)){const c=t.var("valid",(0,nl._)`${a} <= ${e.length}`);t.if((0,nl.not)(c),()=>l(c)),n.ok(c)}function l(c){t.forRange("i",e.length,a,h=>{n.subschema({keyword:r,dataProp:h,dataPropType:vb.Type.Num},c),o.allErrors||t.if((0,nl.not)(c),()=>t.break())})}}Lu.validateAdditionalItems=mP;Lu.default=z3;var g1={},Du={};Object.defineProperty(Du,"__esModule",{value:!0});Du.validateTuple=void 0;const rk=Ke,cg=fe,H3=We,B3={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(n){const{schema:e,it:t}=n;if(Array.isArray(e))return gP(n,"additionalItems",e);t.items=!0,!(0,cg.alwaysValidSchema)(t,e)&&n.ok((0,H3.validateArray)(n))}};function gP(n,e,t=n.schema){const{gen:s,parentSchema:i,data:r,keyword:o,it:a}=n;h(i),a.opts.unevaluated&&t.length&&a.items!==!0&&(a.items=cg.mergeEvaluated.items(s,t.length,a.items));const l=s.name("valid"),c=s.const("len",(0,rk._)`${r}.length`);t.forEach((u,d)=>{(0,cg.alwaysValidSchema)(a,u)||(s.if((0,rk._)`${c} > ${d}`,()=>n.subschema({keyword:o,schemaProp:d,dataProp:d},l)),n.ok(l))});function h(u){const{opts:d,errSchemaPath:p}=a,m=t.length,y=m===u.minItems&&(m===u.maxItems||u[e]===!1);if(d.strictTuples&&!y){const v=`"${o}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,cg.checkStrictMode)(a,v,d.strictTuples)}}}Du.validateTuple=gP;Du.default=B3;Object.defineProperty(g1,"__esModule",{value:!0});const U3=Du,q3={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:n=>(0,U3.validateTuple)(n,"items")};g1.default=q3;var y1={};Object.defineProperty(y1,"__esModule",{value:!0});const ok=Ke,V3=fe,W3=We,G3=Lu,K3={message:({params:{len:n}})=>(0,ok.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0,ok._)`{limit: ${n}}`},Z3={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:K3,code(n){const{schema:e,parentSchema:t,it:s}=n,{prefixItems:i}=t;s.items=!0,!(0,V3.alwaysValidSchema)(s,e)&&(i?(0,G3.validateAdditionalItems)(n,i):n.ok((0,W3.validateArray)(n)))}};y1.default=Z3;var v1={};Object.defineProperty(v1,"__esModule",{value:!0});const pi=Ke,xm=fe,X3={message:({params:{min:n,max:e}})=>e===void 0?(0,pi.str)`must contain at least ${n} valid item(s)`:(0,pi.str)`must contain at least ${n} and no more than ${e} valid item(s)`,params:({params:{min:n,max:e}})=>e===void 0?(0,pi._)`{minContains: ${n}}`:(0,pi._)`{minContains: ${n}, maxContains: ${e}}`},Y3={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:X3,code(n){const{gen:e,schema:t,parentSchema:s,data:i,it:r}=n;let o,a;const{minContains:l,maxContains:c}=s;r.opts.next?(o=l===void 0?1:l,a=c):o=1;const h=e.const("len",(0,pi._)`${i}.length`);if(n.setParams({min:o,max:a}),a===void 0&&o===0){(0,xm.checkStrictMode)(r,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,xm.checkStrictMode)(r,'"minContains" > "maxContains" is always invalid'),n.fail();return}if((0,xm.alwaysValidSchema)(r,t)){let y=(0,pi._)`${h} >= ${o}`;a!==void 0&&(y=(0,pi._)`${y} && ${h} <= ${a}`),n.pass(y);return}r.items=!0;const u=e.name("valid");a===void 0&&o===1?p(u,()=>e.if(u,()=>e.break())):o===0?(e.let(u,!0),a!==void 0&&e.if((0,pi._)`${i}.length > 0`,d)):(e.let(u,!1),d()),n.result(u,()=>n.reset());function d(){const y=e.name("_valid"),v=e.let("count",0);p(y,()=>e.if(y,()=>m(v)))}function p(y,v){e.forRange("i",0,h,g=>{n.subschema({keyword:"contains",dataProp:g,dataPropType:xm.Type.Num,compositeRule:!0},y),v()})}function m(y){e.code((0,pi._)`${y}++`),a===void 0?e.if((0,pi._)`${y} >= ${o}`,()=>e.assign(u,!0).break()):(e.if((0,pi._)`${y} > ${a}`,()=>e.assign(u,!1).break()),o===1?e.assign(u,!0):e.if((0,pi._)`${y} >= ${o}`,()=>e.assign(u,!0)))}}};v1.default=Y3;var yP={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateSchemaDeps=n.validatePropertyDeps=n.error=void 0;const e=Ke,t=fe,s=We;n.error={message:({params:{property:l,depsCount:c,deps:h}})=>{const u=c===1?"property":"properties";return(0,e.str)`must have ${u} ${h} when property ${l} is present`},params:({params:{property:l,depsCount:c,deps:h,missingProperty:u}})=>(0,e._)`{property: ${l}, - missingProperty: ${u}, - depsCount: ${c}, - deps: ${h}}`};const i={keyword:"dependencies",type:"object",schemaType:"object",error:n.error,code(l){const[c,h]=r(l);o(l,c),a(l,h)}};function r({schema:l}){const c={},h={};for(const u in l){if(u==="__proto__")continue;const d=Array.isArray(l[u])?c:h;d[u]=l[u]}return[c,h]}function o(l,c=l.schema){const{gen:h,data:u,it:d}=l;if(Object.keys(c).length===0)return;const p=h.let("missing");for(const m in c){const y=c[m];if(y.length===0)continue;const v=(0,s.propertyInData)(h,u,m,d.opts.ownProperties);l.setParams({property:m,depsCount:y.length,deps:y.join(", ")}),d.allErrors?h.if(v,()=>{for(const g of y)(0,s.checkReportMissingProp)(l,g)}):(h.if((0,e._)`${v} && (${(0,s.checkMissingProp)(l,y,p)})`),(0,s.reportMissingProp)(l,p),h.else())}}n.validatePropertyDeps=o;function a(l,c=l.schema){const{gen:h,data:u,keyword:d,it:p}=l,m=h.name("valid");for(const y in c)(0,t.alwaysValidSchema)(p,c[y])||(h.if((0,s.propertyInData)(h,u,y,p.opts.ownProperties),()=>{const v=l.subschema({keyword:d,schemaProp:y},m);l.mergeValidEvaluated(v,m)},()=>h.var(m,!0)),l.ok(m))}n.validateSchemaDeps=a,n.default=i})(yP);var b1={};Object.defineProperty(b1,"__esModule",{value:!0});const vP=Ke,J3=fe,Q3={message:"property name must be valid",params:({params:n})=>(0,vP._)`{propertyName: ${n.propertyName}}`},eW={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Q3,code(n){const{gen:e,schema:t,data:s,it:i}=n;if((0,J3.alwaysValidSchema)(i,t))return;const r=e.name("valid");e.forIn("key",s,o=>{n.setParams({propertyName:o}),n.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},r),e.if((0,vP.not)(r),()=>{n.error(!0),i.allErrors||e.break()})}),n.ok(r)}};b1.default=eW;var k0={};Object.defineProperty(k0,"__esModule",{value:!0});const Am=We,Ti=Ke,tW=Dr,km=fe,nW={message:"must NOT have additional properties",params:({params:n})=>(0,Ti._)`{additionalProperty: ${n.additionalProperty}}`},sW={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:nW,code(n){const{gen:e,schema:t,parentSchema:s,data:i,errsCount:r,it:o}=n;if(!r)throw new Error("ajv implementation error");const{allErrors:a,opts:l}=o;if(o.props=!0,l.removeAdditional!=="all"&&(0,km.alwaysValidSchema)(o,t))return;const c=(0,Am.allSchemaProperties)(s.properties),h=(0,Am.allSchemaProperties)(s.patternProperties);u(),n.ok((0,Ti._)`${r} === ${tW.default.errors}`);function u(){e.forIn("key",i,v=>{!c.length&&!h.length?m(v):e.if(d(v),()=>m(v))})}function d(v){let g;if(c.length>8){const _=(0,km.schemaRefOrVal)(o,s.properties,"properties");g=(0,Am.isOwnProperty)(e,_,v)}else c.length?g=(0,Ti.or)(...c.map(_=>(0,Ti._)`${v} === ${_}`)):g=Ti.nil;return h.length&&(g=(0,Ti.or)(g,...h.map(_=>(0,Ti._)`${(0,Am.usePattern)(n,_)}.test(${v})`))),(0,Ti.not)(g)}function p(v){e.code((0,Ti._)`delete ${i}[${v}]`)}function m(v){if(l.removeAdditional==="all"||l.removeAdditional&&t===!1){p(v);return}if(t===!1){n.setParams({additionalProperty:v}),n.error(),a||e.break();return}if(typeof t=="object"&&!(0,km.alwaysValidSchema)(o,t)){const g=e.name("valid");l.removeAdditional==="failing"?(y(v,g,!1),e.if((0,Ti.not)(g),()=>{n.reset(),p(v)})):(y(v,g),a||e.if((0,Ti.not)(g),()=>e.break()))}}function y(v,g,_){const b={keyword:"additionalProperties",dataProp:v,dataPropType:km.Type.Str};_===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),n.subschema(b,g)}}};k0.default=sW;var w1={};Object.defineProperty(w1,"__esModule",{value:!0});const iW=Yi,ak=We,mv=fe,lk=k0,rW={keyword:"properties",type:"object",schemaType:"object",code(n){const{gen:e,schema:t,parentSchema:s,data:i,it:r}=n;r.opts.removeAdditional==="all"&&s.additionalProperties===void 0&&lk.default.code(new iW.KeywordCxt(r,lk.default,"additionalProperties"));const o=(0,ak.allSchemaProperties)(t);for(const u of o)r.definedProperties.add(u);r.opts.unevaluated&&o.length&&r.props!==!0&&(r.props=mv.mergeEvaluated.props(e,(0,mv.toHash)(o),r.props));const a=o.filter(u=>!(0,mv.alwaysValidSchema)(r,t[u]));if(a.length===0)return;const l=e.name("valid");for(const u of a)c(u)?h(u):(e.if((0,ak.propertyInData)(e,i,u,r.opts.ownProperties)),h(u),r.allErrors||e.else().var(l,!0),e.endIf()),n.it.definedProperties.add(u),n.ok(l);function c(u){return r.opts.useDefaults&&!r.compositeRule&&t[u].default!==void 0}function h(u){n.subschema({keyword:"properties",schemaProp:u,dataProp:u},l)}}};w1.default=rW;var _1={};Object.defineProperty(_1,"__esModule",{value:!0});const ck=We,Em=Ke,hk=fe,uk=fe,oW={keyword:"patternProperties",type:"object",schemaType:"object",code(n){const{gen:e,schema:t,data:s,parentSchema:i,it:r}=n,{opts:o}=r,a=(0,ck.allSchemaProperties)(t),l=a.filter(y=>(0,hk.alwaysValidSchema)(r,t[y]));if(a.length===0||l.length===a.length&&(!r.opts.unevaluated||r.props===!0))return;const c=o.strictSchema&&!o.allowMatchingProperties&&i.properties,h=e.name("valid");r.props!==!0&&!(r.props instanceof Em.Name)&&(r.props=(0,uk.evaluatedPropsToName)(e,r.props));const{props:u}=r;d();function d(){for(const y of a)c&&p(y),r.allErrors?m(y):(e.var(h,!0),m(y),e.if(h))}function p(y){for(const v in c)new RegExp(y).test(v)&&(0,hk.checkStrictMode)(r,`property ${v} matches pattern ${y} (use allowMatchingProperties)`)}function m(y){e.forIn("key",s,v=>{e.if((0,Em._)`${(0,ck.usePattern)(n,y)}.test(${v})`,()=>{const g=l.includes(y);g||n.subschema({keyword:"patternProperties",schemaProp:y,dataProp:v,dataPropType:uk.Type.Str},h),r.opts.unevaluated&&u!==!0?e.assign((0,Em._)`${u}[${v}]`,!0):!g&&!r.allErrors&&e.if((0,Em.not)(h),()=>e.break())})})}}};_1.default=oW;var S1={};Object.defineProperty(S1,"__esModule",{value:!0});const aW=fe,lW={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(n){const{gen:e,schema:t,it:s}=n;if((0,aW.alwaysValidSchema)(s,t)){n.fail();return}const i=e.name("valid");n.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),n.failResult(i,()=>n.reset(),()=>n.error())},error:{message:"must NOT be valid"}};S1.default=lW;var x1={};Object.defineProperty(x1,"__esModule",{value:!0});const cW=We,hW={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:cW.validateUnion,error:{message:"must match a schema in anyOf"}};x1.default=hW;var A1={};Object.defineProperty(A1,"__esModule",{value:!0});const hg=Ke,uW=fe,dW={message:"must match exactly one schema in oneOf",params:({params:n})=>(0,hg._)`{passingSchemas: ${n.passing}}`},fW={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:dW,code(n){const{gen:e,schema:t,parentSchema:s,it:i}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");if(i.opts.discriminator&&s.discriminator)return;const r=t,o=e.let("valid",!1),a=e.let("passing",null),l=e.name("_valid");n.setParams({passing:a}),e.block(c),n.result(o,()=>n.reset(),()=>n.error(!0));function c(){r.forEach((h,u)=>{let d;(0,uW.alwaysValidSchema)(i,h)?e.var(l,!0):d=n.subschema({keyword:"oneOf",schemaProp:u,compositeRule:!0},l),u>0&&e.if((0,hg._)`${l} && ${o}`).assign(o,!1).assign(a,(0,hg._)`[${a}, ${u}]`).else(),e.if(l,()=>{e.assign(o,!0),e.assign(a,u),d&&n.mergeEvaluated(d,hg.Name)})})}}};A1.default=fW;var k1={};Object.defineProperty(k1,"__esModule",{value:!0});const pW=fe,mW={keyword:"allOf",schemaType:"array",code(n){const{gen:e,schema:t,it:s}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");const i=e.name("valid");t.forEach((r,o)=>{if((0,pW.alwaysValidSchema)(s,r))return;const a=n.subschema({keyword:"allOf",schemaProp:o},i);n.ok(i),n.mergeEvaluated(a)})}};k1.default=mW;var E1={};Object.defineProperty(E1,"__esModule",{value:!0});const hy=Ke,bP=fe,gW={message:({params:n})=>(0,hy.str)`must match "${n.ifClause}" schema`,params:({params:n})=>(0,hy._)`{failingKeyword: ${n.ifClause}}`},yW={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:gW,code(n){const{gen:e,parentSchema:t,it:s}=n;t.then===void 0&&t.else===void 0&&(0,bP.checkStrictMode)(s,'"if" without "then" and "else" is ignored');const i=dk(s,"then"),r=dk(s,"else");if(!i&&!r)return;const o=e.let("valid",!0),a=e.name("_valid");if(l(),n.reset(),i&&r){const h=e.let("ifClause");n.setParams({ifClause:h}),e.if(a,c("then",h),c("else",h))}else i?e.if(a,c("then")):e.if((0,hy.not)(a),c("else"));n.pass(o,()=>n.error(!0));function l(){const h=n.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);n.mergeEvaluated(h)}function c(h,u){return()=>{const d=n.subschema({keyword:h},a);e.assign(o,a),n.mergeValidEvaluated(d,o),u?e.assign(u,(0,hy._)`${h}`):n.setParams({ifClause:h})}}}};function dk(n,e){const t=n.schema[e];return t!==void 0&&!(0,bP.alwaysValidSchema)(n,t)}E1.default=yW;var C1={};Object.defineProperty(C1,"__esModule",{value:!0});const vW=fe,bW={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:n,parentSchema:e,it:t}){e.if===void 0&&(0,vW.checkStrictMode)(t,`"${n}" without "if" is ignored`)}};C1.default=bW;Object.defineProperty(m1,"__esModule",{value:!0});const wW=Lu,_W=g1,SW=Du,xW=y1,AW=v1,kW=yP,EW=b1,CW=k0,$W=w1,TW=_1,PW=S1,RW=x1,MW=A1,IW=k1,OW=E1,NW=C1;function LW(n=!1){const e=[PW.default,RW.default,MW.default,IW.default,OW.default,NW.default,EW.default,CW.default,kW.default,$W.default,TW.default];return n?e.push(_W.default,xW.default):e.push(wW.default,SW.default),e.push(AW.default),e}m1.default=LW;var $1={},T1={};Object.defineProperty(T1,"__esModule",{value:!0});const Zt=Ke,DW={message:({schemaCode:n})=>(0,Zt.str)`must match format "${n}"`,params:({schemaCode:n})=>(0,Zt._)`{format: ${n}}`},jW={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:DW,code(n,e){const{gen:t,data:s,$data:i,schema:r,schemaCode:o,it:a}=n,{opts:l,errSchemaPath:c,schemaEnv:h,self:u}=a;if(!l.validateFormats)return;i?d():p();function d(){const m=t.scopeValue("formats",{ref:u.formats,code:l.code.formats}),y=t.const("fDef",(0,Zt._)`${m}[${o}]`),v=t.let("fType"),g=t.let("format");t.if((0,Zt._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>t.assign(v,(0,Zt._)`${y}.type || "string"`).assign(g,(0,Zt._)`${y}.validate`),()=>t.assign(v,(0,Zt._)`"string"`).assign(g,y)),n.fail$data((0,Zt.or)(_(),b()));function _(){return l.strictSchema===!1?Zt.nil:(0,Zt._)`${o} && !${g}`}function b(){const x=h.$async?(0,Zt._)`(${y}.async ? await ${g}(${s}) : ${g}(${s}))`:(0,Zt._)`${g}(${s})`,A=(0,Zt._)`(typeof ${g} == "function" ? ${x} : ${g}.test(${s}))`;return(0,Zt._)`${g} && ${g} !== true && ${v} === ${e} && !${A}`}}function p(){const m=u.formats[r];if(!m){_();return}if(m===!0)return;const[y,v,g]=b(m);y===e&&n.pass(x());function _(){if(l.strictSchema===!1){u.logger.warn(A());return}throw new Error(A());function A(){return`unknown format "${r}" ignored in schema at path "${c}"`}}function b(A){const T=A instanceof RegExp?(0,Zt.regexpCode)(A):l.code.formats?(0,Zt._)`${l.code.formats}${(0,Zt.getProperty)(r)}`:void 0,C=t.scopeValue("formats",{key:r,ref:A,code:T});return typeof A=="object"&&!(A instanceof RegExp)?[A.type||"string",A.validate,(0,Zt._)`${C}.validate`]:["string",A,C]}function x(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!h.$async)throw new Error("async format in sync schema");return(0,Zt._)`await ${g}(${s})`}return typeof v=="function"?(0,Zt._)`${g}(${s})`:(0,Zt._)`${g}.test(${s})`}}}};T1.default=jW;Object.defineProperty($1,"__esModule",{value:!0});const FW=T1,zW=[FW.default];$1.default=zW;var bu={};Object.defineProperty(bu,"__esModule",{value:!0});bu.contentVocabulary=bu.metadataVocabulary=void 0;bu.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];bu.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(e1,"__esModule",{value:!0});const HW=t1,BW=s1,UW=m1,qW=$1,fk=bu,VW=[HW.default,BW.default,(0,UW.default)(),qW.default,fk.metadataVocabulary,fk.contentVocabulary];e1.default=VW;var P1={},E0={};Object.defineProperty(E0,"__esModule",{value:!0});E0.DiscrError=void 0;var pk;(function(n){n.Tag="tag",n.Mapping="mapping"})(pk||(E0.DiscrError=pk={}));Object.defineProperty(P1,"__esModule",{value:!0});const zc=Ke,bb=E0,mk=Ls,WW=Nu,GW=fe,KW={message:({params:{discrError:n,tagName:e}})=>n===bb.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:n,tag:e,tagName:t}})=>(0,zc._)`{error: ${n}, tag: ${t}, tagValue: ${e}}`},ZW={keyword:"discriminator",type:"object",schemaType:"object",error:KW,code(n){const{gen:e,data:t,schema:s,parentSchema:i,it:r}=n,{oneOf:o}=i;if(!r.opts.discriminator)throw new Error("discriminator: requires discriminator option");const a=s.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(s.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");const l=e.let("valid",!1),c=e.const("tag",(0,zc._)`${t}${(0,zc.getProperty)(a)}`);e.if((0,zc._)`typeof ${c} == "string"`,()=>h(),()=>n.error(!1,{discrError:bb.DiscrError.Tag,tag:c,tagName:a})),n.ok(l);function h(){const p=d();e.if(!1);for(const m in p)e.elseIf((0,zc._)`${c} === ${m}`),e.assign(l,u(p[m]));e.else(),n.error(!1,{discrError:bb.DiscrError.Mapping,tag:c,tagName:a}),e.endIf()}function u(p){const m=e.name("valid"),y=n.subschema({keyword:"oneOf",schemaProp:p},m);return n.mergeEvaluated(y,zc.Name),m}function d(){var p;const m={},y=g(i);let v=!0;for(let x=0;xthis.addVocabulary(m)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const m=this.opts.$data?this.$dataMetaSchema(r,o):r;this.addMetaSchema(m,a,!1),this.refs["http://json-schema.org/schema"]=a}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}e.Ajv=l,n.exports=e=l,n.exports.Ajv=l,Object.defineProperty(e,"__esModule",{value:!0}),e.default=l;var c=Yi;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var h=Ke;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return h._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return h.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return h.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return h.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return h.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return h.CodeGen}});var u=Zp;Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=Nu;Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return d.default}})})(db,db.exports);var s4=db.exports;const i4=eS(s4);var wb={exports:{}},wP={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.formatNames=n.fastFormats=n.fullFormats=void 0;function e(j,U){return{validate:j,compare:U}}n.fullFormats={date:e(r,o),time:e(l(!0),c),"date-time":e(d(!0),p),"iso-time":e(l(),h),"iso-date-time":e(d(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:g,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:H,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:b,int32:{type:"number",validate:T},int64:{type:"number",validate:C},float:{type:"number",validate:I},double:{type:"number",validate:I},password:!0,binary:!0},n.fastFormats={...n.fullFormats,date:e(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:e(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,c),"date-time":e(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":e(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,h),"iso-date-time":e(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,m),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},n.formatNames=Object.keys(n.fullFormats);function t(j){return j%4===0&&(j%100!==0||j%400===0)}const s=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function r(j){const U=s.exec(j);if(!U)return!1;const B=+U[1],L=+U[2],X=+U[3];return L>=1&&L<=12&&X>=1&&X<=(L===2&&t(B)?29:i[L])}function o(j,U){if(j&&U)return j>U?1:j23||E>59||j&&!Y)return!1;if(X<=23&&se<=59&&J<60)return!0;const O=se-E*ge,R=X-z*ge-(O<0?1:0);return(R===23||R===-1)&&(O===59||O===-1)&&J<61}}function c(j,U){if(!(j&&U))return;const B=new Date("2020-01-01T"+j).valueOf(),L=new Date("2020-01-01T"+U).valueOf();if(B&&L)return B-L}function h(j,U){if(!(j&&U))return;const B=a.exec(j),L=a.exec(U);if(B&&L)return j=B[1]+B[2]+B[3],U=L[1]+L[2]+L[3],j>U?1:j=x}function C(j){return Number.isInteger(j)}function I(){return!0}const D=/[^\\]\\Z/;function H(j){if(D.test(j))return!1;try{return new RegExp(j),!0}catch{return!1}}})(wP);var _P={},_b={exports:{}},SP={},Ji={},wu={},Yp={},Be={},lf={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.regexpCode=n.getEsmExportName=n.getProperty=n.safeStringify=n.stringify=n.strConcat=n.addCodeArg=n.str=n._=n.nil=n._Code=n.Name=n.IDENTIFIER=n._CodeOrName=void 0;class e{}n._CodeOrName=e,n.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class t extends e{constructor(_){if(super(),!n.IDENTIFIER.test(_))throw new Error("CodeGen: name must be a valid identifier");this.str=_}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}n.Name=t;class s extends e{constructor(_){super(),this._items=typeof _=="string"?[_]:_}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const _=this._items[0];return _===""||_==='""'}get str(){var _;return(_=this._str)!==null&&_!==void 0?_:this._str=this._items.reduce((b,x)=>`${b}${x}`,"")}get names(){var _;return(_=this._names)!==null&&_!==void 0?_:this._names=this._items.reduce((b,x)=>(x instanceof t&&(b[x.str]=(b[x.str]||0)+1),b),{})}}n._Code=s,n.nil=new s("");function i(g,..._){const b=[g[0]];let x=0;for(;x<_.length;)a(b,_[x]),b.push(g[++x]);return new s(b)}n._=i;const r=new s("+");function o(g,..._){const b=[p(g[0])];let x=0;for(;x<_.length;)b.push(r),a(b,_[x]),b.push(r,p(g[++x]));return l(b),new s(b)}n.str=o;function a(g,_){_ instanceof s?g.push(..._._items):_ instanceof t?g.push(_):g.push(u(_))}n.addCodeArg=a;function l(g){let _=1;for(;_{if(u.scopePath===void 0)throw new Error(`CodeGen: name "${u}" has no value`);return(0,e._)`${c}${u.scopePath}`})}scopeCode(c=this._values,h,u){return this._reduceValues(c,d=>{if(d.value===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return d.value.code},h,u)}_reduceValues(c,h,u={},d){let p=e.nil;for(const m in c){const y=c[m];if(!y)continue;const v=u[m]=u[m]||new Map;y.forEach(g=>{if(v.has(g))return;v.set(g,s.Started);let _=h(g);if(_){const b=this.opts.es5?n.varKinds.var:n.varKinds.const;p=(0,e._)`${p}${b} ${g} = ${_};${this.opts._n}`}else if(_=d==null?void 0:d(g))p=(0,e._)`${p}${_}${this.opts._n}`;else throw new t(g);v.set(g,s.Completed)})}return p}}n.ValueScope=a})(Sb);(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.or=n.and=n.not=n.CodeGen=n.operators=n.varKinds=n.ValueScopeName=n.ValueScope=n.Scope=n.Name=n.regexpCode=n.stringify=n.getProperty=n.nil=n.strConcat=n.str=n._=void 0;const e=lf,t=Sb;var s=lf;Object.defineProperty(n,"_",{enumerable:!0,get:function(){return s._}}),Object.defineProperty(n,"str",{enumerable:!0,get:function(){return s.str}}),Object.defineProperty(n,"strConcat",{enumerable:!0,get:function(){return s.strConcat}}),Object.defineProperty(n,"nil",{enumerable:!0,get:function(){return s.nil}}),Object.defineProperty(n,"getProperty",{enumerable:!0,get:function(){return s.getProperty}}),Object.defineProperty(n,"stringify",{enumerable:!0,get:function(){return s.stringify}}),Object.defineProperty(n,"regexpCode",{enumerable:!0,get:function(){return s.regexpCode}}),Object.defineProperty(n,"Name",{enumerable:!0,get:function(){return s.Name}});var i=Sb;Object.defineProperty(n,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(n,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(n,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(n,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),n.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class r{optimizeNodes(){return this}optimizeNames(w,k){return this}}class o extends r{constructor(w,k,N){super(),this.varKind=w,this.name=k,this.rhs=N}render({es5:w,_n:k}){const N=w?t.varKinds.var:this.varKind,G=this.rhs===void 0?"":` = ${this.rhs}`;return`${N} ${this.name}${G};`+k}optimizeNames(w,k){if(w[this.name.str])return this.rhs&&(this.rhs=L(this.rhs,w,k)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class a extends r{constructor(w,k,N){super(),this.lhs=w,this.rhs=k,this.sideEffects=N}render({_n:w}){return`${this.lhs} = ${this.rhs};`+w}optimizeNames(w,k){if(!(this.lhs instanceof e.Name&&!w[this.lhs.str]&&!this.sideEffects))return this.rhs=L(this.rhs,w,k),this}get names(){const w=this.lhs instanceof e.Name?{}:{...this.lhs.names};return B(w,this.rhs)}}class l extends a{constructor(w,k,N,G){super(w,N,G),this.op=k}render({_n:w}){return`${this.lhs} ${this.op}= ${this.rhs};`+w}}class c extends r{constructor(w){super(),this.label=w,this.names={}}render({_n:w}){return`${this.label}:`+w}}class h extends r{constructor(w){super(),this.label=w,this.names={}}render({_n:w}){return`break${this.label?` ${this.label}`:""};`+w}}class u extends r{constructor(w){super(),this.error=w}render({_n:w}){return`throw ${this.error};`+w}get names(){return this.error.names}}class d extends r{constructor(w){super(),this.code=w}render({_n:w}){return`${this.code};`+w}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(w,k){return this.code=L(this.code,w,k),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class p extends r{constructor(w=[]){super(),this.nodes=w}render(w){return this.nodes.reduce((k,N)=>k+N.render(w),"")}optimizeNodes(){const{nodes:w}=this;let k=w.length;for(;k--;){const N=w[k].optimizeNodes();Array.isArray(N)?w.splice(k,1,...N):N?w[k]=N:w.splice(k,1)}return w.length>0?this:void 0}optimizeNames(w,k){const{nodes:N}=this;let G=N.length;for(;G--;){const Z=N[G];Z.optimizeNames(w,k)||(X(w,Z.names),N.splice(G,1))}return N.length>0?this:void 0}get names(){return this.nodes.reduce((w,k)=>U(w,k.names),{})}}class m extends p{render(w){return"{"+w._n+super.render(w)+"}"+w._n}}class y extends p{}class v extends m{}v.kind="else";class g extends m{constructor(w,k){super(k),this.condition=w}render(w){let k=`if(${this.condition})`+super.render(w);return this.else&&(k+="else "+this.else.render(w)),k}optimizeNodes(){super.optimizeNodes();const w=this.condition;if(w===!0)return this.nodes;let k=this.else;if(k){const N=k.optimizeNodes();k=this.else=Array.isArray(N)?new v(N):N}if(k)return w===!1?k instanceof g?k:k.nodes:this.nodes.length?this:new g(se(w),k instanceof g?[k]:k.nodes);if(!(w===!1||!this.nodes.length))return this}optimizeNames(w,k){var N;if(this.else=(N=this.else)===null||N===void 0?void 0:N.optimizeNames(w,k),!!(super.optimizeNames(w,k)||this.else))return this.condition=L(this.condition,w,k),this}get names(){const w=super.names;return B(w,this.condition),this.else&&U(w,this.else.names),w}}g.kind="if";class _ extends m{}_.kind="for";class b extends _{constructor(w){super(),this.iteration=w}render(w){return`for(${this.iteration})`+super.render(w)}optimizeNames(w,k){if(super.optimizeNames(w,k))return this.iteration=L(this.iteration,w,k),this}get names(){return U(super.names,this.iteration.names)}}class x extends _{constructor(w,k,N,G){super(),this.varKind=w,this.name=k,this.from=N,this.to=G}render(w){const k=w.es5?t.varKinds.var:this.varKind,{name:N,from:G,to:Z}=this;return`for(${k} ${N}=${G}; ${N}<${Z}; ${N}++)`+super.render(w)}get names(){const w=B(super.names,this.from);return B(w,this.to)}}class A extends _{constructor(w,k,N,G){super(),this.loop=w,this.varKind=k,this.name=N,this.iterable=G}render(w){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(w)}optimizeNames(w,k){if(super.optimizeNames(w,k))return this.iterable=L(this.iterable,w,k),this}get names(){return U(super.names,this.iterable.names)}}class T extends m{constructor(w,k,N){super(),this.name=w,this.args=k,this.async=N}render(w){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(w)}}T.kind="func";class C extends p{render(w){return"return "+super.render(w)}}C.kind="return";class I extends m{render(w){let k="try"+super.render(w);return this.catch&&(k+=this.catch.render(w)),this.finally&&(k+=this.finally.render(w)),k}optimizeNodes(){var w,k;return super.optimizeNodes(),(w=this.catch)===null||w===void 0||w.optimizeNodes(),(k=this.finally)===null||k===void 0||k.optimizeNodes(),this}optimizeNames(w,k){var N,G;return super.optimizeNames(w,k),(N=this.catch)===null||N===void 0||N.optimizeNames(w,k),(G=this.finally)===null||G===void 0||G.optimizeNames(w,k),this}get names(){const w=super.names;return this.catch&&U(w,this.catch.names),this.finally&&U(w,this.finally.names),w}}class D extends m{constructor(w){super(),this.error=w}render(w){return`catch(${this.error})`+super.render(w)}}D.kind="catch";class H extends m{render(w){return"finally"+super.render(w)}}H.kind="finally";class j{constructor(w,k={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...k,_n:k.lines?` -`:""},this._extScope=w,this._scope=new t.Scope({parent:w}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(w){return this._scope.name(w)}scopeName(w){return this._extScope.name(w)}scopeValue(w,k){const N=this._extScope.value(w,k);return(this._values[N.prefix]||(this._values[N.prefix]=new Set)).add(N),N}getScopeValue(w,k){return this._extScope.getValue(w,k)}scopeRefs(w){return this._extScope.scopeRefs(w,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(w,k,N,G){const Z=this._scope.toName(k);return N!==void 0&&G&&(this._constants[Z.str]=N),this._leafNode(new o(w,Z,N)),Z}const(w,k,N){return this._def(t.varKinds.const,w,k,N)}let(w,k,N){return this._def(t.varKinds.let,w,k,N)}var(w,k,N){return this._def(t.varKinds.var,w,k,N)}assign(w,k,N){return this._leafNode(new a(w,k,N))}add(w,k){return this._leafNode(new l(w,n.operators.ADD,k))}code(w){return typeof w=="function"?w():w!==e.nil&&this._leafNode(new d(w)),this}object(...w){const k=["{"];for(const[N,G]of w)k.length>1&&k.push(","),k.push(N),(N!==G||this.opts.es5)&&(k.push(":"),(0,e.addCodeArg)(k,G));return k.push("}"),new e._Code(k)}if(w,k,N){if(this._blockNode(new g(w)),k&&N)this.code(k).else().code(N).endIf();else if(k)this.code(k).endIf();else if(N)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(w){return this._elseNode(new g(w))}else(){return this._elseNode(new v)}endIf(){return this._endBlockNode(g,v)}_for(w,k){return this._blockNode(w),k&&this.code(k).endFor(),this}for(w,k){return this._for(new b(w),k)}forRange(w,k,N,G,Z=this.opts.es5?t.varKinds.var:t.varKinds.let){const ae=this._scope.toName(w);return this._for(new x(Z,ae,k,N),()=>G(ae))}forOf(w,k,N,G=t.varKinds.const){const Z=this._scope.toName(w);if(this.opts.es5){const ae=k instanceof e.Name?k:this.var("_arr",k);return this.forRange("_i",0,(0,e._)`${ae}.length`,ie=>{this.var(Z,(0,e._)`${ae}[${ie}]`),N(Z)})}return this._for(new A("of",G,Z,k),()=>N(Z))}forIn(w,k,N,G=this.opts.es5?t.varKinds.var:t.varKinds.const){if(this.opts.ownProperties)return this.forOf(w,(0,e._)`Object.keys(${k})`,N);const Z=this._scope.toName(w);return this._for(new A("in",G,Z,k),()=>N(Z))}endFor(){return this._endBlockNode(_)}label(w){return this._leafNode(new c(w))}break(w){return this._leafNode(new h(w))}return(w){const k=new C;if(this._blockNode(k),this.code(w),k.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(C)}try(w,k,N){if(!k&&!N)throw new Error('CodeGen: "try" without "catch" and "finally"');const G=new I;if(this._blockNode(G),this.code(w),k){const Z=this.name("e");this._currNode=G.catch=new D(Z),k(Z)}return N&&(this._currNode=G.finally=new H,this.code(N)),this._endBlockNode(D,H)}throw(w){return this._leafNode(new u(w))}block(w,k){return this._blockStarts.push(this._nodes.length),w&&this.code(w).endBlock(k),this}endBlock(w){const k=this._blockStarts.pop();if(k===void 0)throw new Error("CodeGen: not in self-balancing block");const N=this._nodes.length-k;if(N<0||w!==void 0&&N!==w)throw new Error(`CodeGen: wrong number of nodes: ${N} vs ${w} expected`);return this._nodes.length=k,this}func(w,k=e.nil,N,G){return this._blockNode(new T(w,k,N)),G&&this.code(G).endFunc(),this}endFunc(){return this._endBlockNode(T)}optimize(w=1){for(;w-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(w){return this._currNode.nodes.push(w),this}_blockNode(w){this._currNode.nodes.push(w),this._nodes.push(w)}_endBlockNode(w,k){const N=this._currNode;if(N instanceof w||k&&N instanceof k)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${k?`${w.kind}/${k.kind}`:w.kind}"`)}_elseNode(w){const k=this._currNode;if(!(k instanceof g))throw new Error('CodeGen: "else" without "if"');return this._currNode=k.else=w,this}get _root(){return this._nodes[0]}get _currNode(){const w=this._nodes;return w[w.length-1]}set _currNode(w){const k=this._nodes;k[k.length-1]=w}}n.CodeGen=j;function U(R,w){for(const k in w)R[k]=(R[k]||0)+(w[k]||0);return R}function B(R,w){return w instanceof e._CodeOrName?U(R,w.names):R}function L(R,w,k){if(R instanceof e.Name)return N(R);if(!G(R))return R;return new e._Code(R._items.reduce((Z,ae)=>(ae instanceof e.Name&&(ae=N(ae)),ae instanceof e._Code?Z.push(...ae._items):Z.push(ae),Z),[]));function N(Z){const ae=k[Z.str];return ae===void 0||w[Z.str]!==1?Z:(delete w[Z.str],ae)}function G(Z){return Z instanceof e._Code&&Z._items.some(ae=>ae instanceof e.Name&&w[ae.str]===1&&k[ae.str]!==void 0)}}function X(R,w){for(const k in w)R[k]=(R[k]||0)-(w[k]||0)}function se(R){return typeof R=="boolean"||typeof R=="number"||R===null?!R:(0,e._)`!${O(R)}`}n.not=se;const J=E(n.operators.AND);function Y(...R){return R.reduce(J)}n.and=Y;const ge=E(n.operators.OR);function z(...R){return R.reduce(ge)}n.or=z;function E(R){return(w,k)=>w===e.nil?k:k===e.nil?w:(0,e._)`${O(w)} ${R} ${O(k)}`}function O(R){return R instanceof e.Name?R:(0,e._)`(${R})`}})(Be);var pe={};Object.defineProperty(pe,"__esModule",{value:!0});pe.checkStrictMode=pe.getErrorPath=pe.Type=pe.useFunc=pe.setEvaluated=pe.evaluatedPropsToName=pe.mergeEvaluated=pe.eachItem=pe.unescapeJsonPointer=pe.escapeJsonPointer=pe.escapeFragment=pe.unescapeFragment=pe.schemaRefOrVal=pe.schemaHasRulesButRef=pe.schemaHasRules=pe.checkUnknownRules=pe.alwaysValidSchema=pe.toHash=void 0;const wt=Be,r4=lf;function o4(n){const e={};for(const t of n)e[t]=!0;return e}pe.toHash=o4;function a4(n,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(xP(n,e),!AP(e,n.self.RULES.all))}pe.alwaysValidSchema=a4;function xP(n,e=n.schema){const{opts:t,self:s}=n;if(!t.strictSchema||typeof e=="boolean")return;const i=s.RULES.keywords;for(const r in e)i[r]||CP(n,`unknown keyword: "${r}"`)}pe.checkUnknownRules=xP;function AP(n,e){if(typeof n=="boolean")return!n;for(const t in n)if(e[t])return!0;return!1}pe.schemaHasRules=AP;function l4(n,e){if(typeof n=="boolean")return!n;for(const t in n)if(t!=="$ref"&&e.all[t])return!0;return!1}pe.schemaHasRulesButRef=l4;function c4({topSchemaRef:n,schemaPath:e},t,s,i){if(!i){if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="string")return(0,wt._)`${t}`}return(0,wt._)`${n}${e}${(0,wt.getProperty)(s)}`}pe.schemaRefOrVal=c4;function h4(n){return kP(decodeURIComponent(n))}pe.unescapeFragment=h4;function u4(n){return encodeURIComponent(R1(n))}pe.escapeFragment=u4;function R1(n){return typeof n=="number"?`${n}`:n.replace(/~/g,"~0").replace(/\//g,"~1")}pe.escapeJsonPointer=R1;function kP(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}pe.unescapeJsonPointer=kP;function d4(n,e){if(Array.isArray(n))for(const t of n)e(t);else e(n)}pe.eachItem=d4;function gk({mergeNames:n,mergeToName:e,mergeValues:t,resultToName:s}){return(i,r,o,a)=>{const l=o===void 0?r:o instanceof wt.Name?(r instanceof wt.Name?n(i,r,o):e(i,r,o),o):r instanceof wt.Name?(e(i,o,r),r):t(r,o);return a===wt.Name&&!(l instanceof wt.Name)?s(i,l):l}}pe.mergeEvaluated={props:gk({mergeNames:(n,e,t)=>n.if((0,wt._)`${t} !== true && ${e} !== undefined`,()=>{n.if((0,wt._)`${e} === true`,()=>n.assign(t,!0),()=>n.assign(t,(0,wt._)`${t} || {}`).code((0,wt._)`Object.assign(${t}, ${e})`))}),mergeToName:(n,e,t)=>n.if((0,wt._)`${t} !== true`,()=>{e===!0?n.assign(t,!0):(n.assign(t,(0,wt._)`${t} || {}`),M1(n,t,e))}),mergeValues:(n,e)=>n===!0?!0:{...n,...e},resultToName:EP}),items:gk({mergeNames:(n,e,t)=>n.if((0,wt._)`${t} !== true && ${e} !== undefined`,()=>n.assign(t,(0,wt._)`${e} === true ? true : ${t} > ${e} ? ${t} : ${e}`)),mergeToName:(n,e,t)=>n.if((0,wt._)`${t} !== true`,()=>n.assign(t,e===!0?!0:(0,wt._)`${t} > ${e} ? ${t} : ${e}`)),mergeValues:(n,e)=>n===!0?!0:Math.max(n,e),resultToName:(n,e)=>n.var("items",e)})};function EP(n,e){if(e===!0)return n.var("props",!0);const t=n.var("props",(0,wt._)`{}`);return e!==void 0&&M1(n,t,e),t}pe.evaluatedPropsToName=EP;function M1(n,e,t){Object.keys(t).forEach(s=>n.assign((0,wt._)`${e}${(0,wt.getProperty)(s)}`,!0))}pe.setEvaluated=M1;const yk={};function f4(n,e){return n.scopeValue("func",{ref:e,code:yk[e.code]||(yk[e.code]=new r4._Code(e.code))})}pe.useFunc=f4;var xb;(function(n){n[n.Num=0]="Num",n[n.Str=1]="Str"})(xb||(pe.Type=xb={}));function p4(n,e,t){if(n instanceof wt.Name){const s=e===xb.Num;return t?s?(0,wt._)`"[" + ${n} + "]"`:(0,wt._)`"['" + ${n} + "']"`:s?(0,wt._)`"/" + ${n}`:(0,wt._)`"/" + ${n}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return t?(0,wt.getProperty)(n).toString():"/"+R1(n)}pe.getErrorPath=p4;function CP(n,e,t=n.opts.strictSchema){if(t){if(e=`strict mode: ${e}`,t===!0)throw new Error(e);n.self.logger.warn(e)}}pe.checkStrictMode=CP;var jr={};Object.defineProperty(jr,"__esModule",{value:!0});const Yn=Be,m4={data:new Yn.Name("data"),valCxt:new Yn.Name("valCxt"),instancePath:new Yn.Name("instancePath"),parentData:new Yn.Name("parentData"),parentDataProperty:new Yn.Name("parentDataProperty"),rootData:new Yn.Name("rootData"),dynamicAnchors:new Yn.Name("dynamicAnchors"),vErrors:new Yn.Name("vErrors"),errors:new Yn.Name("errors"),this:new Yn.Name("this"),self:new Yn.Name("self"),scope:new Yn.Name("scope"),json:new Yn.Name("json"),jsonPos:new Yn.Name("jsonPos"),jsonLen:new Yn.Name("jsonLen"),jsonPart:new Yn.Name("jsonPart")};jr.default=m4;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.extendErrors=n.resetErrorsCount=n.reportExtraError=n.reportError=n.keyword$DataError=n.keywordError=void 0;const e=Be,t=pe,s=jr;n.keywordError={message:({keyword:v})=>(0,e.str)`must pass "${v}" keyword validation`},n.keyword$DataError={message:({keyword:v,schemaType:g})=>g?(0,e.str)`"${v}" keyword must be ${g} ($data)`:(0,e.str)`"${v}" keyword is invalid ($data)`};function i(v,g=n.keywordError,_,b){const{it:x}=v,{gen:A,compositeRule:T,allErrors:C}=x,I=u(v,g,_);b??(T||C)?l(A,I):c(x,(0,e._)`[${I}]`)}n.reportError=i;function r(v,g=n.keywordError,_){const{it:b}=v,{gen:x,compositeRule:A,allErrors:T}=b,C=u(v,g,_);l(x,C),A||T||c(b,s.default.vErrors)}n.reportExtraError=r;function o(v,g){v.assign(s.default.errors,g),v.if((0,e._)`${s.default.vErrors} !== null`,()=>v.if(g,()=>v.assign((0,e._)`${s.default.vErrors}.length`,g),()=>v.assign(s.default.vErrors,null)))}n.resetErrorsCount=o;function a({gen:v,keyword:g,schemaValue:_,data:b,errsCount:x,it:A}){if(x===void 0)throw new Error("ajv implementation error");const T=v.name("err");v.forRange("i",x,s.default.errors,C=>{v.const(T,(0,e._)`${s.default.vErrors}[${C}]`),v.if((0,e._)`${T}.instancePath === undefined`,()=>v.assign((0,e._)`${T}.instancePath`,(0,e.strConcat)(s.default.instancePath,A.errorPath))),v.assign((0,e._)`${T}.schemaPath`,(0,e.str)`${A.errSchemaPath}/${g}`),A.opts.verbose&&(v.assign((0,e._)`${T}.schema`,_),v.assign((0,e._)`${T}.data`,b))})}n.extendErrors=a;function l(v,g){const _=v.const("err",g);v.if((0,e._)`${s.default.vErrors} === null`,()=>v.assign(s.default.vErrors,(0,e._)`[${_}]`),(0,e._)`${s.default.vErrors}.push(${_})`),v.code((0,e._)`${s.default.errors}++`)}function c(v,g){const{gen:_,validateName:b,schemaEnv:x}=v;x.$async?_.throw((0,e._)`new ${v.ValidationError}(${g})`):(_.assign((0,e._)`${b}.errors`,g),_.return(!1))}const h={keyword:new e.Name("keyword"),schemaPath:new e.Name("schemaPath"),params:new e.Name("params"),propertyName:new e.Name("propertyName"),message:new e.Name("message"),schema:new e.Name("schema"),parentSchema:new e.Name("parentSchema")};function u(v,g,_){const{createErrors:b}=v.it;return b===!1?(0,e._)`{}`:d(v,g,_)}function d(v,g,_={}){const{gen:b,it:x}=v,A=[p(x,_),m(v,_)];return y(v,g,A),b.object(...A)}function p({errorPath:v},{instancePath:g}){const _=g?(0,e.str)`${v}${(0,t.getErrorPath)(g,t.Type.Str)}`:v;return[s.default.instancePath,(0,e.strConcat)(s.default.instancePath,_)]}function m({keyword:v,it:{errSchemaPath:g}},{schemaPath:_,parentSchema:b}){let x=b?g:(0,e.str)`${g}/${v}`;return _&&(x=(0,e.str)`${x}${(0,t.getErrorPath)(_,t.Type.Str)}`),[h.schemaPath,x]}function y(v,{params:g,message:_},b){const{keyword:x,data:A,schemaValue:T,it:C}=v,{opts:I,propertyName:D,topSchemaRef:H,schemaPath:j}=C;b.push([h.keyword,x],[h.params,typeof g=="function"?g(v):g||(0,e._)`{}`]),I.messages&&b.push([h.message,typeof _=="function"?_(v):_]),I.verbose&&b.push([h.schema,T],[h.parentSchema,(0,e._)`${H}${j}`],[s.default.data,A]),D&&b.push([h.propertyName,D])}})(Yp);Object.defineProperty(wu,"__esModule",{value:!0});wu.boolOrEmptySchema=wu.topBoolOrEmptySchema=void 0;const g4=Yp,y4=Be,v4=jr,b4={message:"boolean schema is false"};function w4(n){const{gen:e,schema:t,validateName:s}=n;t===!1?$P(n,!1):typeof t=="object"&&t.$async===!0?e.return(v4.default.data):(e.assign((0,y4._)`${s}.errors`,null),e.return(!0))}wu.topBoolOrEmptySchema=w4;function _4(n,e){const{gen:t,schema:s}=n;s===!1?(t.var(e,!1),$P(n)):t.var(e,!0)}wu.boolOrEmptySchema=_4;function $P(n,e){const{gen:t,data:s}=n,i={gen:t,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:n};(0,g4.reportError)(i,b4,void 0,e)}var fn={},fc={};Object.defineProperty(fc,"__esModule",{value:!0});fc.getRules=fc.isJSONType=void 0;const S4=["string","number","integer","boolean","null","object","array"],x4=new Set(S4);function A4(n){return typeof n=="string"&&x4.has(n)}fc.isJSONType=A4;function k4(){const n={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...n,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},n.number,n.string,n.array,n.object],post:{rules:[]},all:{},keywords:{}}}fc.getRules=k4;var xo={};Object.defineProperty(xo,"__esModule",{value:!0});xo.shouldUseRule=xo.shouldUseGroup=xo.schemaHasRulesForType=void 0;function E4({schema:n,self:e},t){const s=e.RULES.types[t];return s&&s!==!0&&TP(n,s)}xo.schemaHasRulesForType=E4;function TP(n,e){return e.rules.some(t=>PP(n,t))}xo.shouldUseGroup=TP;function PP(n,e){var t;return n[e.keyword]!==void 0||((t=e.definition.implements)===null||t===void 0?void 0:t.some(s=>n[s]!==void 0))}xo.shouldUseRule=PP;Object.defineProperty(fn,"__esModule",{value:!0});fn.reportTypeError=fn.checkDataTypes=fn.checkDataType=fn.coerceAndCheckDataType=fn.getJSONTypes=fn.getSchemaTypes=fn.DataType=void 0;const C4=fc,$4=xo,T4=Yp,Le=Be,RP=pe;var lh;(function(n){n[n.Correct=0]="Correct",n[n.Wrong=1]="Wrong"})(lh||(fn.DataType=lh={}));function P4(n){const e=MP(n.type);if(e.includes("null")){if(n.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&n.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');n.nullable===!0&&e.push("null")}return e}fn.getSchemaTypes=P4;function MP(n){const e=Array.isArray(n)?n:n?[n]:[];if(e.every(C4.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}fn.getJSONTypes=MP;function R4(n,e){const{gen:t,data:s,opts:i}=n,r=M4(e,i.coerceTypes),o=e.length>0&&!(r.length===0&&e.length===1&&(0,$4.schemaHasRulesForType)(n,e[0]));if(o){const a=I1(e,s,i.strictNumbers,lh.Wrong);t.if(a,()=>{r.length?I4(n,e,r):O1(n)})}return o}fn.coerceAndCheckDataType=R4;const IP=new Set(["string","number","integer","boolean","null"]);function M4(n,e){return e?n.filter(t=>IP.has(t)||e==="array"&&t==="array"):[]}function I4(n,e,t){const{gen:s,data:i,opts:r}=n,o=s.let("dataType",(0,Le._)`typeof ${i}`),a=s.let("coerced",(0,Le._)`undefined`);r.coerceTypes==="array"&&s.if((0,Le._)`${o} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>s.assign(i,(0,Le._)`${i}[0]`).assign(o,(0,Le._)`typeof ${i}`).if(I1(e,i,r.strictNumbers),()=>s.assign(a,i))),s.if((0,Le._)`${a} !== undefined`);for(const c of t)(IP.has(c)||c==="array"&&r.coerceTypes==="array")&&l(c);s.else(),O1(n),s.endIf(),s.if((0,Le._)`${a} !== undefined`,()=>{s.assign(i,a),O4(n,a)});function l(c){switch(c){case"string":s.elseIf((0,Le._)`${o} == "number" || ${o} == "boolean"`).assign(a,(0,Le._)`"" + ${i}`).elseIf((0,Le._)`${i} === null`).assign(a,(0,Le._)`""`);return;case"number":s.elseIf((0,Le._)`${o} == "boolean" || ${i} === null - || (${o} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,Le._)`+${i}`);return;case"integer":s.elseIf((0,Le._)`${o} === "boolean" || ${i} === null - || (${o} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,Le._)`+${i}`);return;case"boolean":s.elseIf((0,Le._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,Le._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":s.elseIf((0,Le._)`${i} === "" || ${i} === 0 || ${i} === false`),s.assign(a,null);return;case"array":s.elseIf((0,Le._)`${o} === "string" || ${o} === "number" - || ${o} === "boolean" || ${i} === null`).assign(a,(0,Le._)`[${i}]`)}}}function O4({gen:n,parentData:e,parentDataProperty:t},s){n.if((0,Le._)`${e} !== undefined`,()=>n.assign((0,Le._)`${e}[${t}]`,s))}function Ab(n,e,t,s=lh.Correct){const i=s===lh.Correct?Le.operators.EQ:Le.operators.NEQ;let r;switch(n){case"null":return(0,Le._)`${e} ${i} null`;case"array":r=(0,Le._)`Array.isArray(${e})`;break;case"object":r=(0,Le._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":r=o((0,Le._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":r=o();break;default:return(0,Le._)`typeof ${e} ${i} ${n}`}return s===lh.Correct?r:(0,Le.not)(r);function o(a=Le.nil){return(0,Le.and)((0,Le._)`typeof ${e} == "number"`,a,t?(0,Le._)`isFinite(${e})`:Le.nil)}}fn.checkDataType=Ab;function I1(n,e,t,s){if(n.length===1)return Ab(n[0],e,t,s);let i;const r=(0,RP.toHash)(n);if(r.array&&r.object){const o=(0,Le._)`typeof ${e} != "object"`;i=r.null?o:(0,Le._)`!${e} || ${o}`,delete r.null,delete r.array,delete r.object}else i=Le.nil;r.number&&delete r.integer;for(const o in r)i=(0,Le.and)(i,Ab(o,e,t,s));return i}fn.checkDataTypes=I1;const N4={message:({schema:n})=>`must be ${n}`,params:({schema:n,schemaValue:e})=>typeof n=="string"?(0,Le._)`{type: ${n}}`:(0,Le._)`{type: ${e}}`};function O1(n){const e=L4(n);(0,T4.reportError)(e,N4)}fn.reportTypeError=O1;function L4(n){const{gen:e,data:t,schema:s}=n,i=(0,RP.schemaRefOrVal)(n,s,"type");return{gen:e,keyword:"type",data:t,schema:s.type,schemaCode:i,schemaValue:i,parentSchema:s,params:{},it:n}}var C0={};Object.defineProperty(C0,"__esModule",{value:!0});C0.assignDefaults=void 0;const Lc=Be,D4=pe;function j4(n,e){const{properties:t,items:s}=n.schema;if(e==="object"&&t)for(const i in t)vk(n,i,t[i].default);else e==="array"&&Array.isArray(s)&&s.forEach((i,r)=>vk(n,r,i.default))}C0.assignDefaults=j4;function vk(n,e,t){const{gen:s,compositeRule:i,data:r,opts:o}=n;if(t===void 0)return;const a=(0,Lc._)`${r}${(0,Lc.getProperty)(e)}`;if(i){(0,D4.checkStrictMode)(n,`default is ignored for: ${a}`);return}let l=(0,Lc._)`${a} === undefined`;o.useDefaults==="empty"&&(l=(0,Lc._)`${l} || ${a} === null || ${a} === ""`),s.if(l,(0,Lc._)`${a} = ${(0,Lc.stringify)(t)}`)}var Pr={},Ge={};Object.defineProperty(Ge,"__esModule",{value:!0});Ge.validateUnion=Ge.validateArray=Ge.usePattern=Ge.callValidateCode=Ge.schemaProperties=Ge.allSchemaProperties=Ge.noPropertyInData=Ge.propertyInData=Ge.isOwnProperty=Ge.hasPropFunc=Ge.reportMissingProp=Ge.checkMissingProp=Ge.checkReportMissingProp=void 0;const $t=Be,N1=pe,Lo=jr,F4=pe;function z4(n,e){const{gen:t,data:s,it:i}=n;t.if(D1(t,s,e,i.opts.ownProperties),()=>{n.setParams({missingProperty:(0,$t._)`${e}`},!0),n.error()})}Ge.checkReportMissingProp=z4;function H4({gen:n,data:e,it:{opts:t}},s,i){return(0,$t.or)(...s.map(r=>(0,$t.and)(D1(n,e,r,t.ownProperties),(0,$t._)`${i} = ${r}`)))}Ge.checkMissingProp=H4;function B4(n,e){n.setParams({missingProperty:e},!0),n.error()}Ge.reportMissingProp=B4;function OP(n){return n.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,$t._)`Object.prototype.hasOwnProperty`})}Ge.hasPropFunc=OP;function L1(n,e,t){return(0,$t._)`${OP(n)}.call(${e}, ${t})`}Ge.isOwnProperty=L1;function U4(n,e,t,s){const i=(0,$t._)`${e}${(0,$t.getProperty)(t)} !== undefined`;return s?(0,$t._)`${i} && ${L1(n,e,t)}`:i}Ge.propertyInData=U4;function D1(n,e,t,s){const i=(0,$t._)`${e}${(0,$t.getProperty)(t)} === undefined`;return s?(0,$t.or)(i,(0,$t.not)(L1(n,e,t))):i}Ge.noPropertyInData=D1;function NP(n){return n?Object.keys(n).filter(e=>e!=="__proto__"):[]}Ge.allSchemaProperties=NP;function q4(n,e){return NP(e).filter(t=>!(0,N1.alwaysValidSchema)(n,e[t]))}Ge.schemaProperties=q4;function V4({schemaCode:n,data:e,it:{gen:t,topSchemaRef:s,schemaPath:i,errorPath:r},it:o},a,l,c){const h=c?(0,$t._)`${n}, ${e}, ${s}${i}`:e,u=[[Lo.default.instancePath,(0,$t.strConcat)(Lo.default.instancePath,r)],[Lo.default.parentData,o.parentData],[Lo.default.parentDataProperty,o.parentDataProperty],[Lo.default.rootData,Lo.default.rootData]];o.opts.dynamicRef&&u.push([Lo.default.dynamicAnchors,Lo.default.dynamicAnchors]);const d=(0,$t._)`${h}, ${t.object(...u)}`;return l!==$t.nil?(0,$t._)`${a}.call(${l}, ${d})`:(0,$t._)`${a}(${d})`}Ge.callValidateCode=V4;const W4=(0,$t._)`new RegExp`;function G4({gen:n,it:{opts:e}},t){const s=e.unicodeRegExp?"u":"",{regExp:i}=e.code,r=i(t,s);return n.scopeValue("pattern",{key:r.toString(),ref:r,code:(0,$t._)`${i.code==="new RegExp"?W4:(0,F4.useFunc)(n,i)}(${t}, ${s})`})}Ge.usePattern=G4;function K4(n){const{gen:e,data:t,keyword:s,it:i}=n,r=e.name("valid");if(i.allErrors){const a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(r,!0),o(()=>e.break()),r;function o(a){const l=e.const("len",(0,$t._)`${t}.length`);e.forRange("i",0,l,c=>{n.subschema({keyword:s,dataProp:c,dataPropType:N1.Type.Num},r),e.if((0,$t.not)(r),a)})}}Ge.validateArray=K4;function Z4(n){const{gen:e,schema:t,keyword:s,it:i}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");if(t.some(l=>(0,N1.alwaysValidSchema)(i,l))&&!i.opts.unevaluated)return;const o=e.let("valid",!1),a=e.name("_valid");e.block(()=>t.forEach((l,c)=>{const h=n.subschema({keyword:s,schemaProp:c,compositeRule:!0},a);e.assign(o,(0,$t._)`${o} || ${a}`),n.mergeValidEvaluated(h,a)||e.if((0,$t.not)(o))})),n.result(o,()=>n.reset(),()=>n.error(!0))}Ge.validateUnion=Z4;Object.defineProperty(Pr,"__esModule",{value:!0});Pr.validateKeywordUsage=Pr.validSchemaType=Pr.funcKeywordCode=Pr.macroKeywordCode=void 0;const ps=Be,sl=jr,X4=Ge,Y4=Yp;function J4(n,e){const{gen:t,keyword:s,schema:i,parentSchema:r,it:o}=n,a=e.macro.call(o.self,i,r,o),l=LP(t,s,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);const c=t.name("valid");n.subschema({schema:a,schemaPath:ps.nil,errSchemaPath:`${o.errSchemaPath}/${s}`,topSchemaRef:l,compositeRule:!0},c),n.pass(c,()=>n.error(!0))}Pr.macroKeywordCode=J4;function Q4(n,e){var t;const{gen:s,keyword:i,schema:r,parentSchema:o,$data:a,it:l}=n;t5(l,e);const c=!a&&e.compile?e.compile.call(l.self,r,o,l):e.validate,h=LP(s,i,c),u=s.let("valid");n.block$data(u,d),n.ok((t=e.valid)!==null&&t!==void 0?t:u);function d(){if(e.errors===!1)y(),e.modifying&&bk(n),v(()=>n.error());else{const g=e.async?p():m();e.modifying&&bk(n),v(()=>e5(n,g))}}function p(){const g=s.let("ruleErrs",null);return s.try(()=>y((0,ps._)`await `),_=>s.assign(u,!1).if((0,ps._)`${_} instanceof ${l.ValidationError}`,()=>s.assign(g,(0,ps._)`${_}.errors`),()=>s.throw(_))),g}function m(){const g=(0,ps._)`${h}.errors`;return s.assign(g,null),y(ps.nil),g}function y(g=e.async?(0,ps._)`await `:ps.nil){const _=l.opts.passContext?sl.default.this:sl.default.self,b=!("compile"in e&&!a||e.schema===!1);s.assign(u,(0,ps._)`${g}${(0,X4.callValidateCode)(n,h,_,b)}`,e.modifying)}function v(g){var _;s.if((0,ps.not)((_=e.valid)!==null&&_!==void 0?_:u),g)}}Pr.funcKeywordCode=Q4;function bk(n){const{gen:e,data:t,it:s}=n;e.if(s.parentData,()=>e.assign(t,(0,ps._)`${s.parentData}[${s.parentDataProperty}]`))}function e5(n,e){const{gen:t}=n;t.if((0,ps._)`Array.isArray(${e})`,()=>{t.assign(sl.default.vErrors,(0,ps._)`${sl.default.vErrors} === null ? ${e} : ${sl.default.vErrors}.concat(${e})`).assign(sl.default.errors,(0,ps._)`${sl.default.vErrors}.length`),(0,Y4.extendErrors)(n)},()=>n.error())}function t5({schemaEnv:n},e){if(e.async&&!n.$async)throw new Error("async keyword in sync schema")}function LP(n,e,t){if(t===void 0)throw new Error(`keyword "${e}" failed to compile`);return n.scopeValue("keyword",typeof t=="function"?{ref:t}:{ref:t,code:(0,ps.stringify)(t)})}function n5(n,e,t=!1){return!e.length||e.some(s=>s==="array"?Array.isArray(n):s==="object"?n&&typeof n=="object"&&!Array.isArray(n):typeof n==s||t&&typeof n>"u")}Pr.validSchemaType=n5;function s5({schema:n,opts:e,self:t,errSchemaPath:s},i,r){if(Array.isArray(i.keyword)?!i.keyword.includes(r):i.keyword!==r)throw new Error("ajv implementation error");const o=i.dependencies;if(o!=null&&o.some(a=>!Object.prototype.hasOwnProperty.call(n,a)))throw new Error(`parent schema must have dependencies of ${r}: ${o.join(",")}`);if(i.validateSchema&&!i.validateSchema(n[r])){const l=`keyword "${r}" value is invalid at path "${s}": `+t.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")t.logger.error(l);else throw new Error(l)}}Pr.validateKeywordUsage=s5;var Ea={};Object.defineProperty(Ea,"__esModule",{value:!0});Ea.extendSubschemaMode=Ea.extendSubschemaData=Ea.getSubschema=void 0;const Er=Be,DP=pe;function i5(n,{keyword:e,schemaProp:t,schema:s,schemaPath:i,errSchemaPath:r,topSchemaRef:o}){if(e!==void 0&&s!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){const a=n.schema[e];return t===void 0?{schema:a,schemaPath:(0,Er._)`${n.schemaPath}${(0,Er.getProperty)(e)}`,errSchemaPath:`${n.errSchemaPath}/${e}`}:{schema:a[t],schemaPath:(0,Er._)`${n.schemaPath}${(0,Er.getProperty)(e)}${(0,Er.getProperty)(t)}`,errSchemaPath:`${n.errSchemaPath}/${e}/${(0,DP.escapeFragment)(t)}`}}if(s!==void 0){if(i===void 0||r===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:i,topSchemaRef:o,errSchemaPath:r}}throw new Error('either "keyword" or "schema" must be passed')}Ea.getSubschema=i5;function r5(n,e,{dataProp:t,dataPropType:s,data:i,dataTypes:r,propertyName:o}){if(i!==void 0&&t!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:a}=e;if(t!==void 0){const{errorPath:c,dataPathArr:h,opts:u}=e,d=a.let("data",(0,Er._)`${e.data}${(0,Er.getProperty)(t)}`,!0);l(d),n.errorPath=(0,Er.str)`${c}${(0,DP.getErrorPath)(t,s,u.jsPropertySyntax)}`,n.parentDataProperty=(0,Er._)`${t}`,n.dataPathArr=[...h,n.parentDataProperty]}if(i!==void 0){const c=i instanceof Er.Name?i:a.let("data",i,!0);l(c),o!==void 0&&(n.propertyName=o)}r&&(n.dataTypes=r);function l(c){n.data=c,n.dataLevel=e.dataLevel+1,n.dataTypes=[],e.definedProperties=new Set,n.parentData=e.data,n.dataNames=[...e.dataNames,c]}}Ea.extendSubschemaData=r5;function o5(n,{jtdDiscriminator:e,jtdMetadata:t,compositeRule:s,createErrors:i,allErrors:r}){s!==void 0&&(n.compositeRule=s),i!==void 0&&(n.createErrors=i),r!==void 0&&(n.allErrors=r),n.jtdDiscriminator=e,n.jtdMetadata=t}Ea.extendSubschemaMode=o5;var Bn={},jP={exports:{}},_a=jP.exports=function(n,e,t){typeof e=="function"&&(t=e,e={}),t=e.cb||t;var s=typeof t=="function"?t:t.pre||function(){},i=t.post||function(){};ug(e,s,i,n,"",n)};_a.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};_a.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};_a.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};_a.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function ug(n,e,t,s,i,r,o,a,l,c){if(s&&typeof s=="object"&&!Array.isArray(s)){e(s,i,r,o,a,l,c);for(var h in s){var u=s[h];if(Array.isArray(u)){if(h in _a.arrayKeywords)for(var d=0;de+=FP(s)),e===1/0))return 1/0}return e}function zP(n,e="",t){t!==!1&&(e=ch(e));const s=n.parse(e);return HP(n,s)}Bn.getFullPath=zP;function HP(n,e){return n.serialize(e).split("#")[0]+"#"}Bn._getFullPath=HP;const m5=/#\/?$/;function ch(n){return n?n.replace(m5,""):""}Bn.normalizeId=ch;function g5(n,e,t){return t=ch(t),n.resolve(e,t)}Bn.resolveUrl=g5;const y5=/^[a-z_][-a-z0-9._]*$/i;function v5(n,e){if(typeof n=="boolean")return{};const{schemaId:t,uriResolver:s}=this.opts,i=ch(n[t]||e),r={"":i},o=zP(s,i,!1),a={},l=new Set;return u5(n,{allKeys:!0},(u,d,p,m)=>{if(m===void 0)return;const y=o+d;let v=r[m];typeof u[t]=="string"&&(v=g.call(this,u[t])),_.call(this,u.$anchor),_.call(this,u.$dynamicAnchor),r[d]=v;function g(b){const x=this.opts.uriResolver.resolve;if(b=ch(v?x(v,b):b),l.has(b))throw h(b);l.add(b);let A=this.refs[b];return typeof A=="string"&&(A=this.refs[A]),typeof A=="object"?c(u,A.schema,b):b!==ch(y)&&(b[0]==="#"?(c(u,a[b],b),a[b]=u):this.refs[b]=y),b}function _(b){if(typeof b=="string"){if(!y5.test(b))throw new Error(`invalid anchor "${b}"`);g.call(this,`#${b}`)}}}),a;function c(u,d,p){if(d!==void 0&&!h5(u,d))throw h(p)}function h(u){return new Error(`reference "${u}" resolves to more than one schema`)}}Bn.getSchemaRefs=v5;Object.defineProperty(Ji,"__esModule",{value:!0});Ji.getData=Ji.KeywordCxt=Ji.validateFunctionCode=void 0;const BP=wu,wk=fn,j1=xo,uy=fn,b5=C0,Bd=Pr,gv=Ea,_e=Be,Te=jr,w5=Bn,Ao=pe,ed=Yp;function _5(n){if(VP(n)&&(WP(n),qP(n))){A5(n);return}UP(n,()=>(0,BP.topBoolOrEmptySchema)(n))}Ji.validateFunctionCode=_5;function UP({gen:n,validateName:e,schema:t,schemaEnv:s,opts:i},r){i.code.es5?n.func(e,(0,_e._)`${Te.default.data}, ${Te.default.valCxt}`,s.$async,()=>{n.code((0,_e._)`"use strict"; ${_k(t,i)}`),x5(n,i),n.code(r)}):n.func(e,(0,_e._)`${Te.default.data}, ${S5(i)}`,s.$async,()=>n.code(_k(t,i)).code(r))}function S5(n){return(0,_e._)`{${Te.default.instancePath}="", ${Te.default.parentData}, ${Te.default.parentDataProperty}, ${Te.default.rootData}=${Te.default.data}${n.dynamicRef?(0,_e._)`, ${Te.default.dynamicAnchors}={}`:_e.nil}}={}`}function x5(n,e){n.if(Te.default.valCxt,()=>{n.var(Te.default.instancePath,(0,_e._)`${Te.default.valCxt}.${Te.default.instancePath}`),n.var(Te.default.parentData,(0,_e._)`${Te.default.valCxt}.${Te.default.parentData}`),n.var(Te.default.parentDataProperty,(0,_e._)`${Te.default.valCxt}.${Te.default.parentDataProperty}`),n.var(Te.default.rootData,(0,_e._)`${Te.default.valCxt}.${Te.default.rootData}`),e.dynamicRef&&n.var(Te.default.dynamicAnchors,(0,_e._)`${Te.default.valCxt}.${Te.default.dynamicAnchors}`)},()=>{n.var(Te.default.instancePath,(0,_e._)`""`),n.var(Te.default.parentData,(0,_e._)`undefined`),n.var(Te.default.parentDataProperty,(0,_e._)`undefined`),n.var(Te.default.rootData,Te.default.data),e.dynamicRef&&n.var(Te.default.dynamicAnchors,(0,_e._)`{}`)})}function A5(n){const{schema:e,opts:t,gen:s}=n;UP(n,()=>{t.$comment&&e.$comment&&KP(n),T5(n),s.let(Te.default.vErrors,null),s.let(Te.default.errors,0),t.unevaluated&&k5(n),GP(n),M5(n)})}function k5(n){const{gen:e,validateName:t}=n;n.evaluated=e.const("evaluated",(0,_e._)`${t}.evaluated`),e.if((0,_e._)`${n.evaluated}.dynamicProps`,()=>e.assign((0,_e._)`${n.evaluated}.props`,(0,_e._)`undefined`)),e.if((0,_e._)`${n.evaluated}.dynamicItems`,()=>e.assign((0,_e._)`${n.evaluated}.items`,(0,_e._)`undefined`))}function _k(n,e){const t=typeof n=="object"&&n[e.schemaId];return t&&(e.code.source||e.code.process)?(0,_e._)`/*# sourceURL=${t} */`:_e.nil}function E5(n,e){if(VP(n)&&(WP(n),qP(n))){C5(n,e);return}(0,BP.boolOrEmptySchema)(n,e)}function qP({schema:n,self:e}){if(typeof n=="boolean")return!n;for(const t in n)if(e.RULES.all[t])return!0;return!1}function VP(n){return typeof n.schema!="boolean"}function C5(n,e){const{schema:t,gen:s,opts:i}=n;i.$comment&&t.$comment&&KP(n),P5(n),R5(n);const r=s.const("_errs",Te.default.errors);GP(n,r),s.var(e,(0,_e._)`${r} === ${Te.default.errors}`)}function WP(n){(0,Ao.checkUnknownRules)(n),$5(n)}function GP(n,e){if(n.opts.jtd)return Sk(n,[],!1,e);const t=(0,wk.getSchemaTypes)(n.schema),s=(0,wk.coerceAndCheckDataType)(n,t);Sk(n,t,!s,e)}function $5(n){const{schema:e,errSchemaPath:t,opts:s,self:i}=n;e.$ref&&s.ignoreKeywordsWithRef&&(0,Ao.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${t}"`)}function T5(n){const{schema:e,opts:t}=n;e.default!==void 0&&t.useDefaults&&t.strictSchema&&(0,Ao.checkStrictMode)(n,"default is ignored in the schema root")}function P5(n){const e=n.schema[n.opts.schemaId];e&&(n.baseId=(0,w5.resolveUrl)(n.opts.uriResolver,n.baseId,e))}function R5(n){if(n.schema.$async&&!n.schemaEnv.$async)throw new Error("async schema in sync schema")}function KP({gen:n,schemaEnv:e,schema:t,errSchemaPath:s,opts:i}){const r=t.$comment;if(i.$comment===!0)n.code((0,_e._)`${Te.default.self}.logger.log(${r})`);else if(typeof i.$comment=="function"){const o=(0,_e.str)`${s}/$comment`,a=n.scopeValue("root",{ref:e.root});n.code((0,_e._)`${Te.default.self}.opts.$comment(${r}, ${o}, ${a}.schema)`)}}function M5(n){const{gen:e,schemaEnv:t,validateName:s,ValidationError:i,opts:r}=n;t.$async?e.if((0,_e._)`${Te.default.errors} === 0`,()=>e.return(Te.default.data),()=>e.throw((0,_e._)`new ${i}(${Te.default.vErrors})`)):(e.assign((0,_e._)`${s}.errors`,Te.default.vErrors),r.unevaluated&&I5(n),e.return((0,_e._)`${Te.default.errors} === 0`))}function I5({gen:n,evaluated:e,props:t,items:s}){t instanceof _e.Name&&n.assign((0,_e._)`${e}.props`,t),s instanceof _e.Name&&n.assign((0,_e._)`${e}.items`,s)}function Sk(n,e,t,s){const{gen:i,schema:r,data:o,allErrors:a,opts:l,self:c}=n,{RULES:h}=c;if(r.$ref&&(l.ignoreKeywordsWithRef||!(0,Ao.schemaHasRulesButRef)(r,h))){i.block(()=>YP(n,"$ref",h.all.$ref.definition));return}l.jtd||O5(n,e),i.block(()=>{for(const d of h.rules)u(d);u(h.post)});function u(d){(0,j1.shouldUseGroup)(r,d)&&(d.type?(i.if((0,uy.checkDataType)(d.type,o,l.strictNumbers)),xk(n,d),e.length===1&&e[0]===d.type&&t&&(i.else(),(0,uy.reportTypeError)(n)),i.endIf()):xk(n,d),a||i.if((0,_e._)`${Te.default.errors} === ${s||0}`))}}function xk(n,e){const{gen:t,schema:s,opts:{useDefaults:i}}=n;i&&(0,b5.assignDefaults)(n,e.type),t.block(()=>{for(const r of e.rules)(0,j1.shouldUseRule)(s,r)&&YP(n,r.keyword,r.definition,e.type)})}function O5(n,e){n.schemaEnv.meta||!n.opts.strictTypes||(N5(n,e),n.opts.allowUnionTypes||L5(n,e),D5(n,n.dataTypes))}function N5(n,e){if(e.length){if(!n.dataTypes.length){n.dataTypes=e;return}e.forEach(t=>{ZP(n.dataTypes,t)||F1(n,`type "${t}" not allowed by context "${n.dataTypes.join(",")}"`)}),F5(n,e)}}function L5(n,e){e.length>1&&!(e.length===2&&e.includes("null"))&&F1(n,"use allowUnionTypes to allow union type keyword")}function D5(n,e){const t=n.self.RULES.all;for(const s in t){const i=t[s];if(typeof i=="object"&&(0,j1.shouldUseRule)(n.schema,i)){const{type:r}=i.definition;r.length&&!r.some(o=>j5(e,o))&&F1(n,`missing type "${r.join(",")}" for keyword "${s}"`)}}}function j5(n,e){return n.includes(e)||e==="number"&&n.includes("integer")}function ZP(n,e){return n.includes(e)||e==="integer"&&n.includes("number")}function F5(n,e){const t=[];for(const s of n.dataTypes)ZP(e,s)?t.push(s):e.includes("integer")&&s==="number"&&t.push("integer");n.dataTypes=t}function F1(n,e){const t=n.schemaEnv.baseId+n.errSchemaPath;e+=` at "${t}" (strictTypes)`,(0,Ao.checkStrictMode)(n,e,n.opts.strictTypes)}class XP{constructor(e,t,s){if((0,Bd.validateKeywordUsage)(e,t,s),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=s,this.data=e.data,this.schema=e.schema[s],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Ao.schemaRefOrVal)(e,this.schema,s,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",JP(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Bd.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${s} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const("_errs",Te.default.errors))}result(e,t,s){this.failResult((0,_e.not)(e),t,s)}failResult(e,t,s){this.gen.if(e),s?s():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,_e.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail((0,_e._)`${t} !== undefined && (${(0,_e.or)(this.invalid$data(),e)})`)}error(e,t,s){if(t){this.setParams(t),this._error(e,s),this.setParams({});return}this._error(e,s)}_error(e,t){(e?ed.reportExtraError:ed.reportError)(this,this.def.error,t)}$dataError(){(0,ed.reportError)(this,this.def.$dataError||ed.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,ed.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,s=_e.nil){this.gen.block(()=>{this.check$data(e,s),t()})}check$data(e=_e.nil,t=_e.nil){if(!this.$data)return;const{gen:s,schemaCode:i,schemaType:r,def:o}=this;s.if((0,_e.or)((0,_e._)`${i} === undefined`,t)),e!==_e.nil&&s.assign(e,!0),(r.length||o.validateSchema)&&(s.elseIf(this.invalid$data()),this.$dataError(),e!==_e.nil&&s.assign(e,!1)),s.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:s,def:i,it:r}=this;return(0,_e.or)(o(),a());function o(){if(s.length){if(!(t instanceof _e.Name))throw new Error("ajv implementation error");const l=Array.isArray(s)?s:[s];return(0,_e._)`${(0,uy.checkDataTypes)(l,t,r.opts.strictNumbers,uy.DataType.Wrong)}`}return _e.nil}function a(){if(i.validateSchema){const l=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,_e._)`!${l}(${t})`}return _e.nil}}subschema(e,t){const s=(0,gv.getSubschema)(this.it,e);(0,gv.extendSubschemaData)(s,this.it,e),(0,gv.extendSubschemaMode)(s,e);const i={...this.it,...s,items:void 0,props:void 0};return E5(i,t),i}mergeEvaluated(e,t){const{it:s,gen:i}=this;s.opts.unevaluated&&(s.props!==!0&&e.props!==void 0&&(s.props=Ao.mergeEvaluated.props(i,e.props,s.props,t)),s.items!==!0&&e.items!==void 0&&(s.items=Ao.mergeEvaluated.items(i,e.items,s.items,t)))}mergeValidEvaluated(e,t){const{it:s,gen:i}=this;if(s.opts.unevaluated&&(s.props!==!0||s.items!==!0))return i.if(t,()=>this.mergeEvaluated(e,_e.Name)),!0}}Ji.KeywordCxt=XP;function YP(n,e,t,s){const i=new XP(n,t,e);"code"in t?t.code(i,s):i.$data&&t.validate?(0,Bd.funcKeywordCode)(i,t):"macro"in t?(0,Bd.macroKeywordCode)(i,t):(t.compile||t.validate)&&(0,Bd.funcKeywordCode)(i,t)}const z5=/^\/(?:[^~]|~0|~1)*$/,H5=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function JP(n,{dataLevel:e,dataNames:t,dataPathArr:s}){let i,r;if(n==="")return Te.default.rootData;if(n[0]==="/"){if(!z5.test(n))throw new Error(`Invalid JSON-pointer: ${n}`);i=n,r=Te.default.rootData}else{const c=H5.exec(n);if(!c)throw new Error(`Invalid JSON-pointer: ${n}`);const h=+c[1];if(i=c[2],i==="#"){if(h>=e)throw new Error(l("property/index",h));return s[e-h]}if(h>e)throw new Error(l("data",h));if(r=t[e-h],!i)return r}let o=r;const a=i.split("/");for(const c of a)c&&(r=(0,_e._)`${r}${(0,_e.getProperty)((0,Ao.unescapeJsonPointer)(c))}`,o=(0,_e._)`${o} && ${r}`);return o;function l(c,h){return`Cannot access ${c} ${h} levels up, current level is ${e}`}}Ji.getData=JP;var Jp={};Object.defineProperty(Jp,"__esModule",{value:!0});class B5 extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}Jp.default=B5;var ju={};Object.defineProperty(ju,"__esModule",{value:!0});const yv=Bn;class U5 extends Error{constructor(e,t,s,i){super(i||`can't resolve reference ${s} from id ${t}`),this.missingRef=(0,yv.resolveUrl)(e,t,s),this.missingSchema=(0,yv.normalizeId)((0,yv.getFullPath)(e,this.missingRef))}}ju.default=U5;var Ds={};Object.defineProperty(Ds,"__esModule",{value:!0});Ds.resolveSchema=Ds.getCompilingSchema=Ds.resolveRef=Ds.compileSchema=Ds.SchemaEnv=void 0;const $i=Be,q5=Jp,Ua=jr,Gi=Bn,Ak=pe,V5=Ji;class $0{constructor(e){var t;this.refs={},this.dynamicAnchors={};let s;typeof e.schema=="object"&&(s=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(t=e.baseId)!==null&&t!==void 0?t:(0,Gi.normalizeId)(s==null?void 0:s[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=s==null?void 0:s.$async,this.refs={}}}Ds.SchemaEnv=$0;function z1(n){const e=QP.call(this,n);if(e)return e;const t=(0,Gi.getFullPath)(this.opts.uriResolver,n.root.baseId),{es5:s,lines:i}=this.opts.code,{ownProperties:r}=this.opts,o=new $i.CodeGen(this.scope,{es5:s,lines:i,ownProperties:r});let a;n.$async&&(a=o.scopeValue("Error",{ref:q5.default,code:(0,$i._)`require("ajv/dist/runtime/validation_error").default`}));const l=o.scopeName("validate");n.validateName=l;const c={gen:o,allErrors:this.opts.allErrors,data:Ua.default.data,parentData:Ua.default.parentData,parentDataProperty:Ua.default.parentDataProperty,dataNames:[Ua.default.data],dataPathArr:[$i.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:n.schema,code:(0,$i.stringify)(n.schema)}:{ref:n.schema}),validateName:l,ValidationError:a,schema:n.schema,schemaEnv:n,rootId:t,baseId:n.baseId||t,schemaPath:$i.nil,errSchemaPath:n.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,$i._)`""`,opts:this.opts,self:this};let h;try{this._compilations.add(n),(0,V5.validateFunctionCode)(c),o.optimize(this.opts.code.optimize);const u=o.toString();h=`${o.scopeRefs(Ua.default.scope)}return ${u}`,this.opts.code.process&&(h=this.opts.code.process(h,n));const p=new Function(`${Ua.default.self}`,`${Ua.default.scope}`,h)(this,this.scope.get());if(this.scope.value(l,{ref:p}),p.errors=null,p.schema=n.schema,p.schemaEnv=n,n.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:l,validateCode:u,scopeValues:o._values}),this.opts.unevaluated){const{props:m,items:y}=c;p.evaluated={props:m instanceof $i.Name?void 0:m,items:y instanceof $i.Name?void 0:y,dynamicProps:m instanceof $i.Name,dynamicItems:y instanceof $i.Name},p.source&&(p.source.evaluated=(0,$i.stringify)(p.evaluated))}return n.validate=p,n}catch(u){throw delete n.validate,delete n.validateName,h&&this.logger.error("Error compiling schema, function code:",h),u}finally{this._compilations.delete(n)}}Ds.compileSchema=z1;function W5(n,e,t){var s;t=(0,Gi.resolveUrl)(this.opts.uriResolver,e,t);const i=n.refs[t];if(i)return i;let r=Z5.call(this,n,t);if(r===void 0){const o=(s=n.localRefs)===null||s===void 0?void 0:s[t],{schemaId:a}=this.opts;o&&(r=new $0({schema:o,schemaId:a,root:n,baseId:e}))}if(r!==void 0)return n.refs[t]=G5.call(this,r)}Ds.resolveRef=W5;function G5(n){return(0,Gi.inlineRef)(n.schema,this.opts.inlineRefs)?n.schema:n.validate?n:z1.call(this,n)}function QP(n){for(const e of this._compilations)if(K5(e,n))return e}Ds.getCompilingSchema=QP;function K5(n,e){return n.schema===e.schema&&n.root===e.root&&n.baseId===e.baseId}function Z5(n,e){let t;for(;typeof(t=this.refs[e])=="string";)e=t;return t||this.schemas[e]||T0.call(this,n,e)}function T0(n,e){const t=this.opts.uriResolver.parse(e),s=(0,Gi._getFullPath)(this.opts.uriResolver,t);let i=(0,Gi.getFullPath)(this.opts.uriResolver,n.baseId,void 0);if(Object.keys(n.schema).length>0&&s===i)return vv.call(this,t,n);const r=(0,Gi.normalizeId)(s),o=this.refs[r]||this.schemas[r];if(typeof o=="string"){const a=T0.call(this,n,o);return typeof(a==null?void 0:a.schema)!="object"?void 0:vv.call(this,t,a)}if(typeof(o==null?void 0:o.schema)=="object"){if(o.validate||z1.call(this,o),r===(0,Gi.normalizeId)(e)){const{schema:a}=o,{schemaId:l}=this.opts,c=a[l];return c&&(i=(0,Gi.resolveUrl)(this.opts.uriResolver,i,c)),new $0({schema:a,schemaId:l,root:n,baseId:i})}return vv.call(this,t,o)}}Ds.resolveSchema=T0;const X5=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function vv(n,{baseId:e,schema:t,root:s}){var i;if(((i=n.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(const a of n.fragment.slice(1).split("/")){if(typeof t=="boolean")return;const l=t[(0,Ak.unescapeFragment)(a)];if(l===void 0)return;t=l;const c=typeof t=="object"&&t[this.opts.schemaId];!X5.has(a)&&c&&(e=(0,Gi.resolveUrl)(this.opts.uriResolver,e,c))}let r;if(typeof t!="boolean"&&t.$ref&&!(0,Ak.schemaHasRulesButRef)(t,this.RULES)){const a=(0,Gi.resolveUrl)(this.opts.uriResolver,e,t.$ref);r=T0.call(this,s,a)}const{schemaId:o}=this.opts;if(r=r||new $0({schema:t,schemaId:o,root:s,baseId:e}),r.schema!==r.root.schema)return r}const Y5="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",J5="Meta-schema for $data reference (JSON AnySchema extension proposal)",Q5="object",eG=["$data"],tG={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},nG=!1,sG={$id:Y5,description:J5,type:Q5,required:eG,properties:tG,additionalProperties:nG};var H1={};Object.defineProperty(H1,"__esModule",{value:!0});const eR=hP;eR.code='require("ajv/dist/runtime/uri").default';H1.default=eR;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.CodeGen=n.Name=n.nil=n.stringify=n.str=n._=n.KeywordCxt=void 0;var e=Ji;Object.defineProperty(n,"KeywordCxt",{enumerable:!0,get:function(){return e.KeywordCxt}});var t=Be;Object.defineProperty(n,"_",{enumerable:!0,get:function(){return t._}}),Object.defineProperty(n,"str",{enumerable:!0,get:function(){return t.str}}),Object.defineProperty(n,"stringify",{enumerable:!0,get:function(){return t.stringify}}),Object.defineProperty(n,"nil",{enumerable:!0,get:function(){return t.nil}}),Object.defineProperty(n,"Name",{enumerable:!0,get:function(){return t.Name}}),Object.defineProperty(n,"CodeGen",{enumerable:!0,get:function(){return t.CodeGen}});const s=Jp,i=ju,r=fc,o=Ds,a=Be,l=Bn,c=fn,h=pe,u=sG,d=H1,p=(z,E)=>new RegExp(z,E);p.code="new RegExp";const m=["removeAdditional","useDefaults","coerceTypes"],y=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),v={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},g={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},_=200;function b(z){var E,O,R,w,k,N,G,Z,ae,ie,Ae,ct,Ie,Fe,Je,it,bn,ut,Ss,xs,Pn,ls,As,ks,cs;const wn=z.strict,Kt=(E=z.code)===null||E===void 0?void 0:E.optimize,Zn=Kt===!0||Kt===void 0?1:Kt||0,an=(R=(O=z.code)===null||O===void 0?void 0:O.regExp)!==null&&R!==void 0?R:p,Es=(w=z.uriResolver)!==null&&w!==void 0?w:d.default;return{strictSchema:(N=(k=z.strictSchema)!==null&&k!==void 0?k:wn)!==null&&N!==void 0?N:!0,strictNumbers:(Z=(G=z.strictNumbers)!==null&&G!==void 0?G:wn)!==null&&Z!==void 0?Z:!0,strictTypes:(ie=(ae=z.strictTypes)!==null&&ae!==void 0?ae:wn)!==null&&ie!==void 0?ie:"log",strictTuples:(ct=(Ae=z.strictTuples)!==null&&Ae!==void 0?Ae:wn)!==null&&ct!==void 0?ct:"log",strictRequired:(Fe=(Ie=z.strictRequired)!==null&&Ie!==void 0?Ie:wn)!==null&&Fe!==void 0?Fe:!1,code:z.code?{...z.code,optimize:Zn,regExp:an}:{optimize:Zn,regExp:an},loopRequired:(Je=z.loopRequired)!==null&&Je!==void 0?Je:_,loopEnum:(it=z.loopEnum)!==null&&it!==void 0?it:_,meta:(bn=z.meta)!==null&&bn!==void 0?bn:!0,messages:(ut=z.messages)!==null&&ut!==void 0?ut:!0,inlineRefs:(Ss=z.inlineRefs)!==null&&Ss!==void 0?Ss:!0,schemaId:(xs=z.schemaId)!==null&&xs!==void 0?xs:"$id",addUsedSchema:(Pn=z.addUsedSchema)!==null&&Pn!==void 0?Pn:!0,validateSchema:(ls=z.validateSchema)!==null&&ls!==void 0?ls:!0,validateFormats:(As=z.validateFormats)!==null&&As!==void 0?As:!0,unicodeRegExp:(ks=z.unicodeRegExp)!==null&&ks!==void 0?ks:!0,int32range:(cs=z.int32range)!==null&&cs!==void 0?cs:!0,uriResolver:Es}}class x{constructor(E={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,E=this.opts={...E,...b(E)};const{es5:O,lines:R}=this.opts.code;this.scope=new a.ValueScope({scope:{},prefixes:y,es5:O,lines:R}),this.logger=U(E.logger);const w=E.validateFormats;E.validateFormats=!1,this.RULES=(0,r.getRules)(),A.call(this,v,E,"NOT SUPPORTED"),A.call(this,g,E,"DEPRECATED","warn"),this._metaOpts=H.call(this),E.formats&&I.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),E.keywords&&D.call(this,E.keywords),typeof E.meta=="object"&&this.addMetaSchema(E.meta),C.call(this),E.validateFormats=w}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:E,meta:O,schemaId:R}=this.opts;let w=u;R==="id"&&(w={...u},w.id=w.$id,delete w.$id),O&&E&&this.addMetaSchema(w,w[R],!1)}defaultMeta(){const{meta:E,schemaId:O}=this.opts;return this.opts.defaultMeta=typeof E=="object"?E[O]||E:void 0}validate(E,O){let R;if(typeof E=="string"){if(R=this.getSchema(E),!R)throw new Error(`no schema with key or ref "${E}"`)}else R=this.compile(E);const w=R(O);return"$async"in R||(this.errors=R.errors),w}compile(E,O){const R=this._addSchema(E,O);return R.validate||this._compileSchemaEnv(R)}compileAsync(E,O){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:R}=this.opts;return w.call(this,E,O);async function w(ie,Ae){await k.call(this,ie.$schema);const ct=this._addSchema(ie,Ae);return ct.validate||N.call(this,ct)}async function k(ie){ie&&!this.getSchema(ie)&&await w.call(this,{$ref:ie},!0)}async function N(ie){try{return this._compileSchemaEnv(ie)}catch(Ae){if(!(Ae instanceof i.default))throw Ae;return G.call(this,Ae),await Z.call(this,Ae.missingSchema),N.call(this,ie)}}function G({missingSchema:ie,missingRef:Ae}){if(this.refs[ie])throw new Error(`AnySchema ${ie} is loaded but ${Ae} cannot be resolved`)}async function Z(ie){const Ae=await ae.call(this,ie);this.refs[ie]||await k.call(this,Ae.$schema),this.refs[ie]||this.addSchema(Ae,ie,O)}async function ae(ie){const Ae=this._loading[ie];if(Ae)return Ae;try{return await(this._loading[ie]=R(ie))}finally{delete this._loading[ie]}}}addSchema(E,O,R,w=this.opts.validateSchema){if(Array.isArray(E)){for(const N of E)this.addSchema(N,void 0,R,w);return this}let k;if(typeof E=="object"){const{schemaId:N}=this.opts;if(k=E[N],k!==void 0&&typeof k!="string")throw new Error(`schema ${N} must be string`)}return O=(0,l.normalizeId)(O||k),this._checkUnique(O),this.schemas[O]=this._addSchema(E,R,O,w,!0),this}addMetaSchema(E,O,R=this.opts.validateSchema){return this.addSchema(E,O,!0,R),this}validateSchema(E,O){if(typeof E=="boolean")return!0;let R;if(R=E.$schema,R!==void 0&&typeof R!="string")throw new Error("$schema must be a string");if(R=R||this.opts.defaultMeta||this.defaultMeta(),!R)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const w=this.validate(R,E);if(!w&&O){const k="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(k);else throw new Error(k)}return w}getSchema(E){let O;for(;typeof(O=T.call(this,E))=="string";)E=O;if(O===void 0){const{schemaId:R}=this.opts,w=new o.SchemaEnv({schema:{},schemaId:R});if(O=o.resolveSchema.call(this,w,E),!O)return;this.refs[E]=O}return O.validate||this._compileSchemaEnv(O)}removeSchema(E){if(E instanceof RegExp)return this._removeAllSchemas(this.schemas,E),this._removeAllSchemas(this.refs,E),this;switch(typeof E){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const O=T.call(this,E);return typeof O=="object"&&this._cache.delete(O.schema),delete this.schemas[E],delete this.refs[E],this}case"object":{const O=E;this._cache.delete(O);let R=E[this.opts.schemaId];return R&&(R=(0,l.normalizeId)(R),delete this.schemas[R],delete this.refs[R]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(E){for(const O of E)this.addKeyword(O);return this}addKeyword(E,O){let R;if(typeof E=="string")R=E,typeof O=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),O.keyword=R);else if(typeof E=="object"&&O===void 0){if(O=E,R=O.keyword,Array.isArray(R)&&!R.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(L.call(this,R,O),!O)return(0,h.eachItem)(R,k=>X.call(this,k)),this;J.call(this,O);const w={...O,type:(0,c.getJSONTypes)(O.type),schemaType:(0,c.getJSONTypes)(O.schemaType)};return(0,h.eachItem)(R,w.type.length===0?k=>X.call(this,k,w):k=>w.type.forEach(N=>X.call(this,k,w,N))),this}getKeyword(E){const O=this.RULES.all[E];return typeof O=="object"?O.definition:!!O}removeKeyword(E){const{RULES:O}=this;delete O.keywords[E],delete O.all[E];for(const R of O.rules){const w=R.rules.findIndex(k=>k.keyword===E);w>=0&&R.rules.splice(w,1)}return this}addFormat(E,O){return typeof O=="string"&&(O=new RegExp(O)),this.formats[E]=O,this}errorsText(E=this.errors,{separator:O=", ",dataVar:R="data"}={}){return!E||E.length===0?"No errors":E.map(w=>`${R}${w.instancePath} ${w.message}`).reduce((w,k)=>w+O+k)}$dataMetaSchema(E,O){const R=this.RULES.all;E=JSON.parse(JSON.stringify(E));for(const w of O){const k=w.split("/").slice(1);let N=E;for(const G of k)N=N[G];for(const G in R){const Z=R[G];if(typeof Z!="object")continue;const{$data:ae}=Z.definition,ie=N[G];ae&&ie&&(N[G]=ge(ie))}}return E}_removeAllSchemas(E,O){for(const R in E){const w=E[R];(!O||O.test(R))&&(typeof w=="string"?delete E[R]:w&&!w.meta&&(this._cache.delete(w.schema),delete E[R]))}}_addSchema(E,O,R,w=this.opts.validateSchema,k=this.opts.addUsedSchema){let N;const{schemaId:G}=this.opts;if(typeof E=="object")N=E[G];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof E!="boolean")throw new Error("schema must be object or boolean")}let Z=this._cache.get(E);if(Z!==void 0)return Z;R=(0,l.normalizeId)(N||R);const ae=l.getSchemaRefs.call(this,E,R);return Z=new o.SchemaEnv({schema:E,schemaId:G,meta:O,baseId:R,localRefs:ae}),this._cache.set(Z.schema,Z),k&&!R.startsWith("#")&&(R&&this._checkUnique(R),this.refs[R]=Z),w&&this.validateSchema(E,!0),Z}_checkUnique(E){if(this.schemas[E]||this.refs[E])throw new Error(`schema with key or id "${E}" already exists`)}_compileSchemaEnv(E){if(E.meta?this._compileMetaSchema(E):o.compileSchema.call(this,E),!E.validate)throw new Error("ajv implementation error");return E.validate}_compileMetaSchema(E){const O=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,E)}finally{this.opts=O}}}x.ValidationError=s.default,x.MissingRefError=i.default,n.default=x;function A(z,E,O,R="error"){for(const w in z){const k=w;k in E&&this.logger[R](`${O}: option ${w}. ${z[k]}`)}}function T(z){return z=(0,l.normalizeId)(z),this.schemas[z]||this.refs[z]}function C(){const z=this.opts.schemas;if(z)if(Array.isArray(z))this.addSchema(z);else for(const E in z)this.addSchema(z[E],E)}function I(){for(const z in this.opts.formats){const E=this.opts.formats[z];E&&this.addFormat(z,E)}}function D(z){if(Array.isArray(z)){this.addVocabulary(z);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const E in z){const O=z[E];O.keyword||(O.keyword=E),this.addKeyword(O)}}function H(){const z={...this.opts};for(const E of m)delete z[E];return z}const j={log(){},warn(){},error(){}};function U(z){if(z===!1)return j;if(z===void 0)return console;if(z.log&&z.warn&&z.error)return z;throw new Error("logger must implement log, warn and error methods")}const B=/^[a-z_$][a-z0-9_$:-]*$/i;function L(z,E){const{RULES:O}=this;if((0,h.eachItem)(z,R=>{if(O.keywords[R])throw new Error(`Keyword ${R} is already defined`);if(!B.test(R))throw new Error(`Keyword ${R} has invalid name`)}),!!E&&E.$data&&!("code"in E||"validate"in E))throw new Error('$data keyword must have "code" or "validate" function')}function X(z,E,O){var R;const w=E==null?void 0:E.post;if(O&&w)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:k}=this;let N=w?k.post:k.rules.find(({type:Z})=>Z===O);if(N||(N={type:O,rules:[]},k.rules.push(N)),k.keywords[z]=!0,!E)return;const G={keyword:z,definition:{...E,type:(0,c.getJSONTypes)(E.type),schemaType:(0,c.getJSONTypes)(E.schemaType)}};E.before?se.call(this,N,G,E.before):N.rules.push(G),k.all[z]=G,(R=E.implements)===null||R===void 0||R.forEach(Z=>this.addKeyword(Z))}function se(z,E,O){const R=z.rules.findIndex(w=>w.keyword===O);R>=0?z.rules.splice(R,0,E):(z.rules.push(E),this.logger.warn(`rule ${O} is not defined`))}function J(z){let{metaSchema:E}=z;E!==void 0&&(z.$data&&this.opts.$data&&(E=ge(E)),z.validateSchema=this.compile(E,!0))}const Y={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ge(z){return{anyOf:[z,Y]}}})(SP);var B1={},U1={},q1={};Object.defineProperty(q1,"__esModule",{value:!0});const iG={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};q1.default=iG;var pc={};Object.defineProperty(pc,"__esModule",{value:!0});pc.callRef=pc.getValidate=void 0;const rG=ju,kk=Ge,Os=Be,Dc=jr,Ek=Ds,Cm=pe,oG={keyword:"$ref",schemaType:"string",code(n){const{gen:e,schema:t,it:s}=n,{baseId:i,schemaEnv:r,validateName:o,opts:a,self:l}=s,{root:c}=r;if((t==="#"||t==="#/")&&i===c.baseId)return u();const h=Ek.resolveRef.call(l,c,i,t);if(h===void 0)throw new rG.default(s.opts.uriResolver,i,t);if(h instanceof Ek.SchemaEnv)return d(h);return p(h);function u(){if(r===c)return dg(n,o,r,r.$async);const m=e.scopeValue("root",{ref:c});return dg(n,(0,Os._)`${m}.validate`,c,c.$async)}function d(m){const y=tR(n,m);dg(n,y,m,m.$async)}function p(m){const y=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Os.stringify)(m)}:{ref:m}),v=e.name("valid"),g=n.subschema({schema:m,dataTypes:[],schemaPath:Os.nil,topSchemaRef:y,errSchemaPath:t},v);n.mergeEvaluated(g),n.ok(v)}}};function tR(n,e){const{gen:t}=n;return e.validate?t.scopeValue("validate",{ref:e.validate}):(0,Os._)`${t.scopeValue("wrapper",{ref:e})}.validate`}pc.getValidate=tR;function dg(n,e,t,s){const{gen:i,it:r}=n,{allErrors:o,schemaEnv:a,opts:l}=r,c=l.passContext?Dc.default.this:Os.nil;s?h():u();function h(){if(!a.$async)throw new Error("async schema referenced by sync schema");const m=i.let("valid");i.try(()=>{i.code((0,Os._)`await ${(0,kk.callValidateCode)(n,e,c)}`),p(e),o||i.assign(m,!0)},y=>{i.if((0,Os._)`!(${y} instanceof ${r.ValidationError})`,()=>i.throw(y)),d(y),o||i.assign(m,!1)}),n.ok(m)}function u(){n.result((0,kk.callValidateCode)(n,e,c),()=>p(e),()=>d(e))}function d(m){const y=(0,Os._)`${m}.errors`;i.assign(Dc.default.vErrors,(0,Os._)`${Dc.default.vErrors} === null ? ${y} : ${Dc.default.vErrors}.concat(${y})`),i.assign(Dc.default.errors,(0,Os._)`${Dc.default.vErrors}.length`)}function p(m){var y;if(!r.opts.unevaluated)return;const v=(y=t==null?void 0:t.validate)===null||y===void 0?void 0:y.evaluated;if(r.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(r.props=Cm.mergeEvaluated.props(i,v.props,r.props));else{const g=i.var("props",(0,Os._)`${m}.evaluated.props`);r.props=Cm.mergeEvaluated.props(i,g,r.props,Os.Name)}if(r.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(r.items=Cm.mergeEvaluated.items(i,v.items,r.items));else{const g=i.var("items",(0,Os._)`${m}.evaluated.items`);r.items=Cm.mergeEvaluated.items(i,g,r.items,Os.Name)}}}pc.callRef=dg;pc.default=oG;Object.defineProperty(U1,"__esModule",{value:!0});const aG=q1,lG=pc,cG=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",aG.default,lG.default];U1.default=cG;var V1={},W1={};Object.defineProperty(W1,"__esModule",{value:!0});const dy=Be,Do=dy.operators,fy={maximum:{okStr:"<=",ok:Do.LTE,fail:Do.GT},minimum:{okStr:">=",ok:Do.GTE,fail:Do.LT},exclusiveMaximum:{okStr:"<",ok:Do.LT,fail:Do.GTE},exclusiveMinimum:{okStr:">",ok:Do.GT,fail:Do.LTE}},hG={message:({keyword:n,schemaCode:e})=>(0,dy.str)`must be ${fy[n].okStr} ${e}`,params:({keyword:n,schemaCode:e})=>(0,dy._)`{comparison: ${fy[n].okStr}, limit: ${e}}`},uG={keyword:Object.keys(fy),type:"number",schemaType:"number",$data:!0,error:hG,code(n){const{keyword:e,data:t,schemaCode:s}=n;n.fail$data((0,dy._)`${t} ${fy[e].fail} ${s} || isNaN(${t})`)}};W1.default=uG;var G1={};Object.defineProperty(G1,"__esModule",{value:!0});const Ud=Be,dG={message:({schemaCode:n})=>(0,Ud.str)`must be multiple of ${n}`,params:({schemaCode:n})=>(0,Ud._)`{multipleOf: ${n}}`},fG={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:dG,code(n){const{gen:e,data:t,schemaCode:s,it:i}=n,r=i.opts.multipleOfPrecision,o=e.let("res"),a=r?(0,Ud._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${r}`:(0,Ud._)`${o} !== parseInt(${o})`;n.fail$data((0,Ud._)`(${s} === 0 || (${o} = ${t}/${s}, ${a}))`)}};G1.default=fG;var K1={},Z1={};Object.defineProperty(Z1,"__esModule",{value:!0});function nR(n){const e=n.length;let t=0,s=0,i;for(;s=55296&&i<=56319&&s(0,il._)`{limit: ${n}}`},yG={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:gG,code(n){const{keyword:e,data:t,schemaCode:s,it:i}=n,r=e==="maxLength"?il.operators.GT:il.operators.LT,o=i.opts.unicode===!1?(0,il._)`${t}.length`:(0,il._)`${(0,pG.useFunc)(n.gen,mG.default)}(${t})`;n.fail$data((0,il._)`${o} ${r} ${s}`)}};K1.default=yG;var X1={};Object.defineProperty(X1,"__esModule",{value:!0});const vG=Ge,bG=pe,nh=Be,wG={message:({schemaCode:n})=>(0,nh.str)`must match pattern "${n}"`,params:({schemaCode:n})=>(0,nh._)`{pattern: ${n}}`},_G={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:wG,code(n){const{gen:e,data:t,$data:s,schema:i,schemaCode:r,it:o}=n,a=o.opts.unicodeRegExp?"u":"";if(s){const{regExp:l}=o.opts.code,c=l.code==="new RegExp"?(0,nh._)`new RegExp`:(0,bG.useFunc)(e,l),h=e.let("valid");e.try(()=>e.assign(h,(0,nh._)`${c}(${r}, ${a}).test(${t})`),()=>e.assign(h,!1)),n.fail$data((0,nh._)`!${h}`)}else{const l=(0,vG.usePattern)(n,i);n.fail$data((0,nh._)`!${l}.test(${t})`)}}};X1.default=_G;var Y1={};Object.defineProperty(Y1,"__esModule",{value:!0});const qd=Be,SG={message({keyword:n,schemaCode:e}){const t=n==="maxProperties"?"more":"fewer";return(0,qd.str)`must NOT have ${t} than ${e} properties`},params:({schemaCode:n})=>(0,qd._)`{limit: ${n}}`},xG={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:SG,code(n){const{keyword:e,data:t,schemaCode:s}=n,i=e==="maxProperties"?qd.operators.GT:qd.operators.LT;n.fail$data((0,qd._)`Object.keys(${t}).length ${i} ${s}`)}};Y1.default=xG;var J1={};Object.defineProperty(J1,"__esModule",{value:!0});const td=Ge,Vd=Be,AG=pe,kG={message:({params:{missingProperty:n}})=>(0,Vd.str)`must have required property '${n}'`,params:({params:{missingProperty:n}})=>(0,Vd._)`{missingProperty: ${n}}`},EG={keyword:"required",type:"object",schemaType:"array",$data:!0,error:kG,code(n){const{gen:e,schema:t,schemaCode:s,data:i,$data:r,it:o}=n,{opts:a}=o;if(!r&&t.length===0)return;const l=t.length>=a.loopRequired;if(o.allErrors?c():h(),a.strictRequired){const p=n.parentSchema.properties,{definedProperties:m}=n.it;for(const y of t)if((p==null?void 0:p[y])===void 0&&!m.has(y)){const v=o.schemaEnv.baseId+o.errSchemaPath,g=`required property "${y}" is not defined at "${v}" (strictRequired)`;(0,AG.checkStrictMode)(o,g,o.opts.strictRequired)}}function c(){if(l||r)n.block$data(Vd.nil,u);else for(const p of t)(0,td.checkReportMissingProp)(n,p)}function h(){const p=e.let("missing");if(l||r){const m=e.let("valid",!0);n.block$data(m,()=>d(p,m)),n.ok(m)}else e.if((0,td.checkMissingProp)(n,t,p)),(0,td.reportMissingProp)(n,p),e.else()}function u(){e.forOf("prop",s,p=>{n.setParams({missingProperty:p}),e.if((0,td.noPropertyInData)(e,i,p,a.ownProperties),()=>n.error())})}function d(p,m){n.setParams({missingProperty:p}),e.forOf(p,s,()=>{e.assign(m,(0,td.propertyInData)(e,i,p,a.ownProperties)),e.if((0,Vd.not)(m),()=>{n.error(),e.break()})},Vd.nil)}}};J1.default=EG;var Q1={};Object.defineProperty(Q1,"__esModule",{value:!0});const Wd=Be,CG={message({keyword:n,schemaCode:e}){const t=n==="maxItems"?"more":"fewer";return(0,Wd.str)`must NOT have ${t} than ${e} items`},params:({schemaCode:n})=>(0,Wd._)`{limit: ${n}}`},$G={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:CG,code(n){const{keyword:e,data:t,schemaCode:s}=n,i=e==="maxItems"?Wd.operators.GT:Wd.operators.LT;n.fail$data((0,Wd._)`${t}.length ${i} ${s}`)}};Q1.default=$G;var ex={},Qp={};Object.defineProperty(Qp,"__esModule",{value:!0});const sR=_0;sR.code='require("ajv/dist/runtime/equal").default';Qp.default=sR;Object.defineProperty(ex,"__esModule",{value:!0});const bv=fn,On=Be,TG=pe,PG=Qp,RG={message:({params:{i:n,j:e}})=>(0,On.str)`must NOT have duplicate items (items ## ${e} and ${n} are identical)`,params:({params:{i:n,j:e}})=>(0,On._)`{i: ${n}, j: ${e}}`},MG={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:RG,code(n){const{gen:e,data:t,$data:s,schema:i,parentSchema:r,schemaCode:o,it:a}=n;if(!s&&!i)return;const l=e.let("valid"),c=r.items?(0,bv.getSchemaTypes)(r.items):[];n.block$data(l,h,(0,On._)`${o} === false`),n.ok(l);function h(){const m=e.let("i",(0,On._)`${t}.length`),y=e.let("j");n.setParams({i:m,j:y}),e.assign(l,!0),e.if((0,On._)`${m} > 1`,()=>(u()?d:p)(m,y))}function u(){return c.length>0&&!c.some(m=>m==="object"||m==="array")}function d(m,y){const v=e.name("item"),g=(0,bv.checkDataTypes)(c,v,a.opts.strictNumbers,bv.DataType.Wrong),_=e.const("indices",(0,On._)`{}`);e.for((0,On._)`;${m}--;`,()=>{e.let(v,(0,On._)`${t}[${m}]`),e.if(g,(0,On._)`continue`),c.length>1&&e.if((0,On._)`typeof ${v} == "string"`,(0,On._)`${v} += "_"`),e.if((0,On._)`typeof ${_}[${v}] == "number"`,()=>{e.assign(y,(0,On._)`${_}[${v}]`),n.error(),e.assign(l,!1).break()}).code((0,On._)`${_}[${v}] = ${m}`)})}function p(m,y){const v=(0,TG.useFunc)(e,PG.default),g=e.name("outer");e.label(g).for((0,On._)`;${m}--;`,()=>e.for((0,On._)`${y} = ${m}; ${y}--;`,()=>e.if((0,On._)`${v}(${t}[${m}], ${t}[${y}])`,()=>{n.error(),e.assign(l,!1).break(g)})))}}};ex.default=MG;var tx={};Object.defineProperty(tx,"__esModule",{value:!0});const Eb=Be,IG=pe,OG=Qp,NG={message:"must be equal to constant",params:({schemaCode:n})=>(0,Eb._)`{allowedValue: ${n}}`},LG={keyword:"const",$data:!0,error:NG,code(n){const{gen:e,data:t,$data:s,schemaCode:i,schema:r}=n;s||r&&typeof r=="object"?n.fail$data((0,Eb._)`!${(0,IG.useFunc)(e,OG.default)}(${t}, ${i})`):n.fail((0,Eb._)`${r} !== ${t}`)}};tx.default=LG;var nx={};Object.defineProperty(nx,"__esModule",{value:!0});const pd=Be,DG=pe,jG=Qp,FG={message:"must be equal to one of the allowed values",params:({schemaCode:n})=>(0,pd._)`{allowedValues: ${n}}`},zG={keyword:"enum",schemaType:"array",$data:!0,error:FG,code(n){const{gen:e,data:t,$data:s,schema:i,schemaCode:r,it:o}=n;if(!s&&i.length===0)throw new Error("enum must have non-empty array");const a=i.length>=o.opts.loopEnum;let l;const c=()=>l??(l=(0,DG.useFunc)(e,jG.default));let h;if(a||s)h=e.let("valid"),n.block$data(h,u);else{if(!Array.isArray(i))throw new Error("ajv implementation error");const p=e.const("vSchema",r);h=(0,pd.or)(...i.map((m,y)=>d(p,y)))}n.pass(h);function u(){e.assign(h,!1),e.forOf("v",r,p=>e.if((0,pd._)`${c()}(${t}, ${p})`,()=>e.assign(h,!0).break()))}function d(p,m){const y=i[m];return typeof y=="object"&&y!==null?(0,pd._)`${c()}(${t}, ${p}[${m}])`:(0,pd._)`${t} === ${y}`}}};nx.default=zG;Object.defineProperty(V1,"__esModule",{value:!0});const HG=W1,BG=G1,UG=K1,qG=X1,VG=Y1,WG=J1,GG=Q1,KG=ex,ZG=tx,XG=nx,YG=[HG.default,BG.default,UG.default,qG.default,VG.default,WG.default,GG.default,KG.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},ZG.default,XG.default];V1.default=YG;var sx={},Fu={};Object.defineProperty(Fu,"__esModule",{value:!0});Fu.validateAdditionalItems=void 0;const rl=Be,Cb=pe,JG={message:({params:{len:n}})=>(0,rl.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0,rl._)`{limit: ${n}}`},QG={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:JG,code(n){const{parentSchema:e,it:t}=n,{items:s}=e;if(!Array.isArray(s)){(0,Cb.checkStrictMode)(t,'"additionalItems" is ignored when "items" is not an array of schemas');return}iR(n,s)}};function iR(n,e){const{gen:t,schema:s,data:i,keyword:r,it:o}=n;o.items=!0;const a=t.const("len",(0,rl._)`${i}.length`);if(s===!1)n.setParams({len:e.length}),n.pass((0,rl._)`${a} <= ${e.length}`);else if(typeof s=="object"&&!(0,Cb.alwaysValidSchema)(o,s)){const c=t.var("valid",(0,rl._)`${a} <= ${e.length}`);t.if((0,rl.not)(c),()=>l(c)),n.ok(c)}function l(c){t.forRange("i",e.length,a,h=>{n.subschema({keyword:r,dataProp:h,dataPropType:Cb.Type.Num},c),o.allErrors||t.if((0,rl.not)(c),()=>t.break())})}}Fu.validateAdditionalItems=iR;Fu.default=QG;var ix={},zu={};Object.defineProperty(zu,"__esModule",{value:!0});zu.validateTuple=void 0;const Ck=Be,fg=pe,eK=Ge,tK={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(n){const{schema:e,it:t}=n;if(Array.isArray(e))return rR(n,"additionalItems",e);t.items=!0,!(0,fg.alwaysValidSchema)(t,e)&&n.ok((0,eK.validateArray)(n))}};function rR(n,e,t=n.schema){const{gen:s,parentSchema:i,data:r,keyword:o,it:a}=n;h(i),a.opts.unevaluated&&t.length&&a.items!==!0&&(a.items=fg.mergeEvaluated.items(s,t.length,a.items));const l=s.name("valid"),c=s.const("len",(0,Ck._)`${r}.length`);t.forEach((u,d)=>{(0,fg.alwaysValidSchema)(a,u)||(s.if((0,Ck._)`${c} > ${d}`,()=>n.subschema({keyword:o,schemaProp:d,dataProp:d},l)),n.ok(l))});function h(u){const{opts:d,errSchemaPath:p}=a,m=t.length,y=m===u.minItems&&(m===u.maxItems||u[e]===!1);if(d.strictTuples&&!y){const v=`"${o}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,fg.checkStrictMode)(a,v,d.strictTuples)}}}zu.validateTuple=rR;zu.default=tK;Object.defineProperty(ix,"__esModule",{value:!0});const nK=zu,sK={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:n=>(0,nK.validateTuple)(n,"items")};ix.default=sK;var rx={};Object.defineProperty(rx,"__esModule",{value:!0});const $k=Be,iK=pe,rK=Ge,oK=Fu,aK={message:({params:{len:n}})=>(0,$k.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0,$k._)`{limit: ${n}}`},lK={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:aK,code(n){const{schema:e,parentSchema:t,it:s}=n,{prefixItems:i}=t;s.items=!0,!(0,iK.alwaysValidSchema)(s,e)&&(i?(0,oK.validateAdditionalItems)(n,i):n.ok((0,rK.validateArray)(n)))}};rx.default=lK;var ox={};Object.defineProperty(ox,"__esModule",{value:!0});const mi=Be,$m=pe,cK={message:({params:{min:n,max:e}})=>e===void 0?(0,mi.str)`must contain at least ${n} valid item(s)`:(0,mi.str)`must contain at least ${n} and no more than ${e} valid item(s)`,params:({params:{min:n,max:e}})=>e===void 0?(0,mi._)`{minContains: ${n}}`:(0,mi._)`{minContains: ${n}, maxContains: ${e}}`},hK={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:cK,code(n){const{gen:e,schema:t,parentSchema:s,data:i,it:r}=n;let o,a;const{minContains:l,maxContains:c}=s;r.opts.next?(o=l===void 0?1:l,a=c):o=1;const h=e.const("len",(0,mi._)`${i}.length`);if(n.setParams({min:o,max:a}),a===void 0&&o===0){(0,$m.checkStrictMode)(r,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,$m.checkStrictMode)(r,'"minContains" > "maxContains" is always invalid'),n.fail();return}if((0,$m.alwaysValidSchema)(r,t)){let y=(0,mi._)`${h} >= ${o}`;a!==void 0&&(y=(0,mi._)`${y} && ${h} <= ${a}`),n.pass(y);return}r.items=!0;const u=e.name("valid");a===void 0&&o===1?p(u,()=>e.if(u,()=>e.break())):o===0?(e.let(u,!0),a!==void 0&&e.if((0,mi._)`${i}.length > 0`,d)):(e.let(u,!1),d()),n.result(u,()=>n.reset());function d(){const y=e.name("_valid"),v=e.let("count",0);p(y,()=>e.if(y,()=>m(v)))}function p(y,v){e.forRange("i",0,h,g=>{n.subschema({keyword:"contains",dataProp:g,dataPropType:$m.Type.Num,compositeRule:!0},y),v()})}function m(y){e.code((0,mi._)`${y}++`),a===void 0?e.if((0,mi._)`${y} >= ${o}`,()=>e.assign(u,!0).break()):(e.if((0,mi._)`${y} > ${a}`,()=>e.assign(u,!1).break()),o===1?e.assign(u,!0):e.if((0,mi._)`${y} >= ${o}`,()=>e.assign(u,!0)))}}};ox.default=hK;var oR={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateSchemaDeps=n.validatePropertyDeps=n.error=void 0;const e=Be,t=pe,s=Ge;n.error={message:({params:{property:l,depsCount:c,deps:h}})=>{const u=c===1?"property":"properties";return(0,e.str)`must have ${u} ${h} when property ${l} is present`},params:({params:{property:l,depsCount:c,deps:h,missingProperty:u}})=>(0,e._)`{property: ${l}, - missingProperty: ${u}, - depsCount: ${c}, - deps: ${h}}`};const i={keyword:"dependencies",type:"object",schemaType:"object",error:n.error,code(l){const[c,h]=r(l);o(l,c),a(l,h)}};function r({schema:l}){const c={},h={};for(const u in l){if(u==="__proto__")continue;const d=Array.isArray(l[u])?c:h;d[u]=l[u]}return[c,h]}function o(l,c=l.schema){const{gen:h,data:u,it:d}=l;if(Object.keys(c).length===0)return;const p=h.let("missing");for(const m in c){const y=c[m];if(y.length===0)continue;const v=(0,s.propertyInData)(h,u,m,d.opts.ownProperties);l.setParams({property:m,depsCount:y.length,deps:y.join(", ")}),d.allErrors?h.if(v,()=>{for(const g of y)(0,s.checkReportMissingProp)(l,g)}):(h.if((0,e._)`${v} && (${(0,s.checkMissingProp)(l,y,p)})`),(0,s.reportMissingProp)(l,p),h.else())}}n.validatePropertyDeps=o;function a(l,c=l.schema){const{gen:h,data:u,keyword:d,it:p}=l,m=h.name("valid");for(const y in c)(0,t.alwaysValidSchema)(p,c[y])||(h.if((0,s.propertyInData)(h,u,y,p.opts.ownProperties),()=>{const v=l.subschema({keyword:d,schemaProp:y},m);l.mergeValidEvaluated(v,m)},()=>h.var(m,!0)),l.ok(m))}n.validateSchemaDeps=a,n.default=i})(oR);var ax={};Object.defineProperty(ax,"__esModule",{value:!0});const aR=Be,uK=pe,dK={message:"property name must be valid",params:({params:n})=>(0,aR._)`{propertyName: ${n.propertyName}}`},fK={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:dK,code(n){const{gen:e,schema:t,data:s,it:i}=n;if((0,uK.alwaysValidSchema)(i,t))return;const r=e.name("valid");e.forIn("key",s,o=>{n.setParams({propertyName:o}),n.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},r),e.if((0,aR.not)(r),()=>{n.error(!0),i.allErrors||e.break()})}),n.ok(r)}};ax.default=fK;var P0={};Object.defineProperty(P0,"__esModule",{value:!0});const Tm=Ge,Pi=Be,pK=jr,Pm=pe,mK={message:"must NOT have additional properties",params:({params:n})=>(0,Pi._)`{additionalProperty: ${n.additionalProperty}}`},gK={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:mK,code(n){const{gen:e,schema:t,parentSchema:s,data:i,errsCount:r,it:o}=n;if(!r)throw new Error("ajv implementation error");const{allErrors:a,opts:l}=o;if(o.props=!0,l.removeAdditional!=="all"&&(0,Pm.alwaysValidSchema)(o,t))return;const c=(0,Tm.allSchemaProperties)(s.properties),h=(0,Tm.allSchemaProperties)(s.patternProperties);u(),n.ok((0,Pi._)`${r} === ${pK.default.errors}`);function u(){e.forIn("key",i,v=>{!c.length&&!h.length?m(v):e.if(d(v),()=>m(v))})}function d(v){let g;if(c.length>8){const _=(0,Pm.schemaRefOrVal)(o,s.properties,"properties");g=(0,Tm.isOwnProperty)(e,_,v)}else c.length?g=(0,Pi.or)(...c.map(_=>(0,Pi._)`${v} === ${_}`)):g=Pi.nil;return h.length&&(g=(0,Pi.or)(g,...h.map(_=>(0,Pi._)`${(0,Tm.usePattern)(n,_)}.test(${v})`))),(0,Pi.not)(g)}function p(v){e.code((0,Pi._)`delete ${i}[${v}]`)}function m(v){if(l.removeAdditional==="all"||l.removeAdditional&&t===!1){p(v);return}if(t===!1){n.setParams({additionalProperty:v}),n.error(),a||e.break();return}if(typeof t=="object"&&!(0,Pm.alwaysValidSchema)(o,t)){const g=e.name("valid");l.removeAdditional==="failing"?(y(v,g,!1),e.if((0,Pi.not)(g),()=>{n.reset(),p(v)})):(y(v,g),a||e.if((0,Pi.not)(g),()=>e.break()))}}function y(v,g,_){const b={keyword:"additionalProperties",dataProp:v,dataPropType:Pm.Type.Str};_===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),n.subschema(b,g)}}};P0.default=gK;var lx={};Object.defineProperty(lx,"__esModule",{value:!0});const yK=Ji,Tk=Ge,wv=pe,Pk=P0,vK={keyword:"properties",type:"object",schemaType:"object",code(n){const{gen:e,schema:t,parentSchema:s,data:i,it:r}=n;r.opts.removeAdditional==="all"&&s.additionalProperties===void 0&&Pk.default.code(new yK.KeywordCxt(r,Pk.default,"additionalProperties"));const o=(0,Tk.allSchemaProperties)(t);for(const u of o)r.definedProperties.add(u);r.opts.unevaluated&&o.length&&r.props!==!0&&(r.props=wv.mergeEvaluated.props(e,(0,wv.toHash)(o),r.props));const a=o.filter(u=>!(0,wv.alwaysValidSchema)(r,t[u]));if(a.length===0)return;const l=e.name("valid");for(const u of a)c(u)?h(u):(e.if((0,Tk.propertyInData)(e,i,u,r.opts.ownProperties)),h(u),r.allErrors||e.else().var(l,!0),e.endIf()),n.it.definedProperties.add(u),n.ok(l);function c(u){return r.opts.useDefaults&&!r.compositeRule&&t[u].default!==void 0}function h(u){n.subschema({keyword:"properties",schemaProp:u,dataProp:u},l)}}};lx.default=vK;var cx={};Object.defineProperty(cx,"__esModule",{value:!0});const Rk=Ge,Rm=Be,Mk=pe,Ik=pe,bK={keyword:"patternProperties",type:"object",schemaType:"object",code(n){const{gen:e,schema:t,data:s,parentSchema:i,it:r}=n,{opts:o}=r,a=(0,Rk.allSchemaProperties)(t),l=a.filter(y=>(0,Mk.alwaysValidSchema)(r,t[y]));if(a.length===0||l.length===a.length&&(!r.opts.unevaluated||r.props===!0))return;const c=o.strictSchema&&!o.allowMatchingProperties&&i.properties,h=e.name("valid");r.props!==!0&&!(r.props instanceof Rm.Name)&&(r.props=(0,Ik.evaluatedPropsToName)(e,r.props));const{props:u}=r;d();function d(){for(const y of a)c&&p(y),r.allErrors?m(y):(e.var(h,!0),m(y),e.if(h))}function p(y){for(const v in c)new RegExp(y).test(v)&&(0,Mk.checkStrictMode)(r,`property ${v} matches pattern ${y} (use allowMatchingProperties)`)}function m(y){e.forIn("key",s,v=>{e.if((0,Rm._)`${(0,Rk.usePattern)(n,y)}.test(${v})`,()=>{const g=l.includes(y);g||n.subschema({keyword:"patternProperties",schemaProp:y,dataProp:v,dataPropType:Ik.Type.Str},h),r.opts.unevaluated&&u!==!0?e.assign((0,Rm._)`${u}[${v}]`,!0):!g&&!r.allErrors&&e.if((0,Rm.not)(h),()=>e.break())})})}}};cx.default=bK;var hx={};Object.defineProperty(hx,"__esModule",{value:!0});const wK=pe,_K={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(n){const{gen:e,schema:t,it:s}=n;if((0,wK.alwaysValidSchema)(s,t)){n.fail();return}const i=e.name("valid");n.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),n.failResult(i,()=>n.reset(),()=>n.error())},error:{message:"must NOT be valid"}};hx.default=_K;var ux={};Object.defineProperty(ux,"__esModule",{value:!0});const SK=Ge,xK={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:SK.validateUnion,error:{message:"must match a schema in anyOf"}};ux.default=xK;var dx={};Object.defineProperty(dx,"__esModule",{value:!0});const pg=Be,AK=pe,kK={message:"must match exactly one schema in oneOf",params:({params:n})=>(0,pg._)`{passingSchemas: ${n.passing}}`},EK={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:kK,code(n){const{gen:e,schema:t,parentSchema:s,it:i}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");if(i.opts.discriminator&&s.discriminator)return;const r=t,o=e.let("valid",!1),a=e.let("passing",null),l=e.name("_valid");n.setParams({passing:a}),e.block(c),n.result(o,()=>n.reset(),()=>n.error(!0));function c(){r.forEach((h,u)=>{let d;(0,AK.alwaysValidSchema)(i,h)?e.var(l,!0):d=n.subschema({keyword:"oneOf",schemaProp:u,compositeRule:!0},l),u>0&&e.if((0,pg._)`${l} && ${o}`).assign(o,!1).assign(a,(0,pg._)`[${a}, ${u}]`).else(),e.if(l,()=>{e.assign(o,!0),e.assign(a,u),d&&n.mergeEvaluated(d,pg.Name)})})}}};dx.default=EK;var fx={};Object.defineProperty(fx,"__esModule",{value:!0});const CK=pe,$K={keyword:"allOf",schemaType:"array",code(n){const{gen:e,schema:t,it:s}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");const i=e.name("valid");t.forEach((r,o)=>{if((0,CK.alwaysValidSchema)(s,r))return;const a=n.subschema({keyword:"allOf",schemaProp:o},i);n.ok(i),n.mergeEvaluated(a)})}};fx.default=$K;var px={};Object.defineProperty(px,"__esModule",{value:!0});const py=Be,lR=pe,TK={message:({params:n})=>(0,py.str)`must match "${n.ifClause}" schema`,params:({params:n})=>(0,py._)`{failingKeyword: ${n.ifClause}}`},PK={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:TK,code(n){const{gen:e,parentSchema:t,it:s}=n;t.then===void 0&&t.else===void 0&&(0,lR.checkStrictMode)(s,'"if" without "then" and "else" is ignored');const i=Ok(s,"then"),r=Ok(s,"else");if(!i&&!r)return;const o=e.let("valid",!0),a=e.name("_valid");if(l(),n.reset(),i&&r){const h=e.let("ifClause");n.setParams({ifClause:h}),e.if(a,c("then",h),c("else",h))}else i?e.if(a,c("then")):e.if((0,py.not)(a),c("else"));n.pass(o,()=>n.error(!0));function l(){const h=n.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);n.mergeEvaluated(h)}function c(h,u){return()=>{const d=n.subschema({keyword:h},a);e.assign(o,a),n.mergeValidEvaluated(d,o),u?e.assign(u,(0,py._)`${h}`):n.setParams({ifClause:h})}}}};function Ok(n,e){const t=n.schema[e];return t!==void 0&&!(0,lR.alwaysValidSchema)(n,t)}px.default=PK;var mx={};Object.defineProperty(mx,"__esModule",{value:!0});const RK=pe,MK={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:n,parentSchema:e,it:t}){e.if===void 0&&(0,RK.checkStrictMode)(t,`"${n}" without "if" is ignored`)}};mx.default=MK;Object.defineProperty(sx,"__esModule",{value:!0});const IK=Fu,OK=ix,NK=zu,LK=rx,DK=ox,jK=oR,FK=ax,zK=P0,HK=lx,BK=cx,UK=hx,qK=ux,VK=dx,WK=fx,GK=px,KK=mx;function ZK(n=!1){const e=[UK.default,qK.default,VK.default,WK.default,GK.default,KK.default,FK.default,zK.default,jK.default,HK.default,BK.default];return n?e.push(OK.default,LK.default):e.push(IK.default,NK.default),e.push(DK.default),e}sx.default=ZK;var gx={},yx={};Object.defineProperty(yx,"__esModule",{value:!0});const Xt=Be,XK={message:({schemaCode:n})=>(0,Xt.str)`must match format "${n}"`,params:({schemaCode:n})=>(0,Xt._)`{format: ${n}}`},YK={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:XK,code(n,e){const{gen:t,data:s,$data:i,schema:r,schemaCode:o,it:a}=n,{opts:l,errSchemaPath:c,schemaEnv:h,self:u}=a;if(!l.validateFormats)return;i?d():p();function d(){const m=t.scopeValue("formats",{ref:u.formats,code:l.code.formats}),y=t.const("fDef",(0,Xt._)`${m}[${o}]`),v=t.let("fType"),g=t.let("format");t.if((0,Xt._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>t.assign(v,(0,Xt._)`${y}.type || "string"`).assign(g,(0,Xt._)`${y}.validate`),()=>t.assign(v,(0,Xt._)`"string"`).assign(g,y)),n.fail$data((0,Xt.or)(_(),b()));function _(){return l.strictSchema===!1?Xt.nil:(0,Xt._)`${o} && !${g}`}function b(){const x=h.$async?(0,Xt._)`(${y}.async ? await ${g}(${s}) : ${g}(${s}))`:(0,Xt._)`${g}(${s})`,A=(0,Xt._)`(typeof ${g} == "function" ? ${x} : ${g}.test(${s}))`;return(0,Xt._)`${g} && ${g} !== true && ${v} === ${e} && !${A}`}}function p(){const m=u.formats[r];if(!m){_();return}if(m===!0)return;const[y,v,g]=b(m);y===e&&n.pass(x());function _(){if(l.strictSchema===!1){u.logger.warn(A());return}throw new Error(A());function A(){return`unknown format "${r}" ignored in schema at path "${c}"`}}function b(A){const T=A instanceof RegExp?(0,Xt.regexpCode)(A):l.code.formats?(0,Xt._)`${l.code.formats}${(0,Xt.getProperty)(r)}`:void 0,C=t.scopeValue("formats",{key:r,ref:A,code:T});return typeof A=="object"&&!(A instanceof RegExp)?[A.type||"string",A.validate,(0,Xt._)`${C}.validate`]:["string",A,C]}function x(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!h.$async)throw new Error("async format in sync schema");return(0,Xt._)`await ${g}(${s})`}return typeof v=="function"?(0,Xt._)`${g}(${s})`:(0,Xt._)`${g}.test(${s})`}}}};yx.default=YK;Object.defineProperty(gx,"__esModule",{value:!0});const JK=yx,QK=[JK.default];gx.default=QK;var _u={};Object.defineProperty(_u,"__esModule",{value:!0});_u.contentVocabulary=_u.metadataVocabulary=void 0;_u.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];_u.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(B1,"__esModule",{value:!0});const e9=U1,t9=V1,n9=sx,s9=gx,Nk=_u,i9=[e9.default,t9.default,(0,n9.default)(),s9.default,Nk.metadataVocabulary,Nk.contentVocabulary];B1.default=i9;var vx={},R0={};Object.defineProperty(R0,"__esModule",{value:!0});R0.DiscrError=void 0;var Lk;(function(n){n.Tag="tag",n.Mapping="mapping"})(Lk||(R0.DiscrError=Lk={}));Object.defineProperty(vx,"__esModule",{value:!0});const Hc=Be,$b=R0,Dk=Ds,r9=ju,o9=pe,a9={message:({params:{discrError:n,tagName:e}})=>n===$b.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:n,tag:e,tagName:t}})=>(0,Hc._)`{error: ${n}, tag: ${t}, tagValue: ${e}}`},l9={keyword:"discriminator",type:"object",schemaType:"object",error:a9,code(n){const{gen:e,data:t,schema:s,parentSchema:i,it:r}=n,{oneOf:o}=i;if(!r.opts.discriminator)throw new Error("discriminator: requires discriminator option");const a=s.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(s.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");const l=e.let("valid",!1),c=e.const("tag",(0,Hc._)`${t}${(0,Hc.getProperty)(a)}`);e.if((0,Hc._)`typeof ${c} == "string"`,()=>h(),()=>n.error(!1,{discrError:$b.DiscrError.Tag,tag:c,tagName:a})),n.ok(l);function h(){const p=d();e.if(!1);for(const m in p)e.elseIf((0,Hc._)`${c} === ${m}`),e.assign(l,u(p[m]));e.else(),n.error(!1,{discrError:$b.DiscrError.Mapping,tag:c,tagName:a}),e.endIf()}function u(p){const m=e.name("valid"),y=n.subschema({keyword:"oneOf",schemaProp:p},m);return n.mergeEvaluated(y,Hc.Name),m}function d(){var p;const m={},y=g(i);let v=!0;for(let x=0;xthis.addVocabulary(m)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const m=this.opts.$data?this.$dataMetaSchema(r,o):r;this.addMetaSchema(m,a,!1),this.refs["http://json-schema.org/schema"]=a}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}e.Ajv=l,n.exports=e=l,n.exports.Ajv=l,Object.defineProperty(e,"__esModule",{value:!0}),e.default=l;var c=Ji;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var h=Be;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return h._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return h.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return h.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return h.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return h.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return h.CodeGen}});var u=Jp;Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=ju;Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return d.default}})})(_b,_b.exports);var g9=_b.exports;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.formatLimitDefinition=void 0;const e=g9,t=Be,s=t.operators,i={formatMaximum:{okStr:"<=",ok:s.LTE,fail:s.GT},formatMinimum:{okStr:">=",ok:s.GTE,fail:s.LT},formatExclusiveMaximum:{okStr:"<",ok:s.LT,fail:s.GTE},formatExclusiveMinimum:{okStr:">",ok:s.GT,fail:s.LTE}},r={message:({keyword:a,schemaCode:l})=>(0,t.str)`should be ${i[a].okStr} ${l}`,params:({keyword:a,schemaCode:l})=>(0,t._)`{comparison: ${i[a].okStr}, limit: ${l}}`};n.formatLimitDefinition={keyword:Object.keys(i),type:"string",schemaType:"string",$data:!0,error:r,code(a){const{gen:l,data:c,schemaCode:h,keyword:u,it:d}=a,{opts:p,self:m}=d;if(!p.validateFormats)return;const y=new e.KeywordCxt(d,m.RULES.all.format.definition,"format");y.$data?v():g();function v(){const b=l.scopeValue("formats",{ref:m.formats,code:p.code.formats}),x=l.const("fmt",(0,t._)`${b}[${y.schemaCode}]`);a.fail$data((0,t.or)((0,t._)`typeof ${x} != "object"`,(0,t._)`${x} instanceof RegExp`,(0,t._)`typeof ${x}.compare != "function"`,_(x)))}function g(){const b=y.schema,x=m.formats[b];if(!x||x===!0)return;if(typeof x!="object"||x instanceof RegExp||typeof x.compare!="function")throw new Error(`"${u}": format "${b}" does not define "compare" function`);const A=l.scopeValue("formats",{key:b,ref:x,code:p.code.formats?(0,t._)`${p.code.formats}${(0,t.getProperty)(b)}`:void 0});a.fail$data(_(A))}function _(b){return(0,t._)`${b}.compare(${c}, ${h}) ${i[u].fail} 0`}},dependencies:["format"]};const o=a=>(a.addKeyword(n.formatLimitDefinition),a);n.default=o})(_P);(function(n,e){Object.defineProperty(e,"__esModule",{value:!0});const t=wP,s=_P,i=Be,r=new i.Name("fullFormats"),o=new i.Name("fastFormats"),a=(c,h={keywords:!0})=>{if(Array.isArray(h))return l(c,h,t.fullFormats,r),c;const[u,d]=h.mode==="fast"?[t.fastFormats,o]:[t.fullFormats,r],p=h.formats||t.formatNames;return l(c,p,u,d),h.keywords&&(0,s.default)(c),c};a.get=(c,h="full")=>{const d=(h==="fast"?t.fastFormats:t.fullFormats)[c];if(!d)throw new Error(`Unknown format "${c}"`);return d};function l(c,h,u,d){var p,m;(p=(m=c.opts.code).formats)!==null&&p!==void 0||(m.formats=(0,i._)`require("ajv-formats/dist/formats").${d}`);for(const y of h)c.addFormat(y,u[y])}n.exports=e=a,Object.defineProperty(e,"__esModule",{value:!0}),e.default=a})(wb,wb.exports);var y9=wb.exports;const v9=eS(y9);function b9(){const n=new i4({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return v9(n),n}class w9{constructor(e){this._ajv=e??b9()}getValidator(e){const t="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return s=>t(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class _9{constructor(e){this._client=e}async*callToolStream(e,t=cc,s){const i=this._client,r={...s,task:(s==null?void 0:s.task)??(i.isToolTask(e.name)?{}:void 0)},o=i.requestStream({method:"tools/call",params:e},t,r),a=i.getToolOutputValidator(e.name);for await(const l of o){if(l.type==="result"&&a){const c=l.result;if(!c.structuredContent&&!c.isError){yield{type:"error",error:new Ee(Re.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(c.structuredContent)try{const h=a(c.structuredContent);if(!h.valid){yield{type:"error",error:new Ee(Re.InvalidParams,`Structured content does not match the tool's output schema: ${h.errorMessage}`)};return}}catch(h){if(h instanceof Ee){yield{type:"error",error:h};return}yield{type:"error",error:new Ee(Re.InvalidParams,`Failed to validate structured content: ${h instanceof Error?h.message:String(h)}`)};return}}yield l}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,s){return this._client.getTaskResult({taskId:e},t,s)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,s){return this._client.requestStream(e,t,s)}}function S9(n,e,t){var s;if(!n)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!((s=n.tools)!=null&&s.call))throw new Error(`${t} does not support task creation for tools/call (required for ${e})`);break}}function x9(n,e,t){var s,i;if(!n)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!((s=n.sampling)!=null&&s.createMessage))throw new Error(`${t} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!((i=n.elicitation)!=null&&i.create))throw new Error(`${t} does not support task creation for elicitation/create (required for ${e})`);break}}function mg(n,e){if(!(!n||e===null||typeof e!="object")){if(n.type==="object"&&n.properties&&typeof n.properties=="object"){const t=e,s=n.properties;for(const i of Object.keys(s)){const r=s[i];t[i]===void 0&&Object.prototype.hasOwnProperty.call(r,"default")&&(t[i]=r.default),t[i]!==void 0&&mg(r,t[i])}}if(Array.isArray(n.anyOf))for(const t of n.anyOf)typeof t!="boolean"&&mg(t,e);if(Array.isArray(n.oneOf))for(const t of n.oneOf)typeof t!="boolean"&&mg(t,e)}}function A9(n){if(!n)return{supportsFormMode:!1,supportsUrlMode:!1};const e=n.form!==void 0,t=n.url!==void 0;return{supportsFormMode:e||!e&&!t,supportsUrlMode:t}}class k9 extends pT{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=(t==null?void 0:t.capabilities)??{},this._jsonSchemaValidator=(t==null?void 0:t.jsonSchemaValidator)??new w9,t!=null&&t.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){var t,s,i,r,o,a;e.tools&&((s=(t=this._serverCapabilities)==null?void 0:t.tools)!=null&&s.listChanged)&&this._setupListChangedHandler("tools",NS,e.tools,async()=>(await this.listTools()).tools),e.prompts&&((r=(i=this._serverCapabilities)==null?void 0:i.prompts)!=null&&r.listChanged)&&this._setupListChangedHandler("prompts",MS,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&((a=(o=this._serverCapabilities)==null?void 0:o.resources)!=null&&a.listChanged)&&this._setupListChangedHandler("resources",CS,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new _9(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=xB(this._capabilities,e)}setRequestHandler(e,t){const s=dT(e),i=s==null?void 0:s.method;if(!i)throw new Error("Schema is missing a method literal");const r=fT(i);if(typeof r!="string")throw new Error("Schema method literal must be a string");const o=r;if(o==="elicitation/create"){const a=async(l,c)=>{var _,b;const h=zo(cT,l);if(!h.success){const x=h.error instanceof Error?h.error.message:String(h.error);throw new Ee(Re.InvalidParams,`Invalid elicitation request: ${x}`)}const{params:u}=h.data;u.mode=u.mode??"form";const{supportsFormMode:d,supportsUrlMode:p}=A9(this._capabilities.elicitation);if(u.mode==="form"&&!d)throw new Ee(Re.InvalidParams,"Client does not support form-mode elicitation requests");if(u.mode==="url"&&!p)throw new Ee(Re.InvalidParams,"Client does not support URL-mode elicitation requests");const m=await Promise.resolve(t(l,c));if(u.task){const x=zo(rf,m);if(!x.success){const A=x.error instanceof Error?x.error.message:String(x.error);throw new Ee(Re.InvalidParams,`Invalid task creation result: ${A}`)}return x.data}const y=zo(hT,m);if(!y.success){const x=y.error instanceof Error?y.error.message:String(y.error);throw new Ee(Re.InvalidParams,`Invalid elicitation result: ${x}`)}const v=y.data,g=u.mode==="form"?u.requestedSchema:void 0;if(u.mode==="form"&&v.action==="accept"&&v.content&&g&&(b=(_=this._capabilities.elicitation)==null?void 0:_.form)!=null&&b.applyDefaults)try{mg(g,v.content)}catch{}return v};return super.setRequestHandler(e,a)}if(o==="sampling/createMessage"){const a=async(l,c)=>{const h=zo(LS,l);if(!h.success){const v=h.error instanceof Error?h.error.message:String(h.error);throw new Ee(Re.InvalidParams,`Invalid sampling request: ${v}`)}const{params:u}=h.data,d=await Promise.resolve(t(l,c));if(u.task){const v=zo(rf,d);if(!v.success){const g=v.error instanceof Error?v.error.message:String(v.error);throw new Ee(Re.InvalidParams,`Invalid task creation result: ${g}`)}return v.data}const m=u.tools||u.toolChoice?lT:aT,y=zo(m,d);if(!y.success){const v=y.error instanceof Error?y.error.message:String(y.error);throw new Ee(Re.InvalidParams,`Invalid sampling result: ${v}`)}return y.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,t)}assertCapability(e,t){var s;if(!((s=this._serverCapabilities)!=null&&s[e]))throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{const s=await this.request({method:"initialize",params:{protocolVersion:g0,capabilities:this._capabilities,clientInfo:this._clientInfo}},V$,t);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!Jz.includes(s.protocolVersion))throw new Error(`Server's protocol version is not supported: ${s.protocolVersion}`);this._serverCapabilities=s.capabilities,this._serverVersion=s.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(s.protocolVersion),this._instructions=s.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(s){throw this.close(),s}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var t,s,i,r,o;switch(e){case"logging/setLevel":if(!((t=this._serverCapabilities)!=null&&t.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!((s=this._serverCapabilities)!=null&&s.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!((i=this._serverCapabilities)!=null&&i.resources))throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!((r=this._serverCapabilities)!=null&&r.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!((o=this._serverCapabilities)!=null&&o.completions))throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){var t;switch(e){case"notifications/roots/list_changed":if(!((t=this._capabilities.roots)!=null&&t.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break}}assertTaskCapability(e){var t,s;S9((s=(t=this._serverCapabilities)==null?void 0:t.tasks)==null?void 0:s.requests,e,"Server")}assertTaskHandlerCapability(e){var t;this._capabilities&&x9((t=this._capabilities.tasks)==null?void 0:t.requests,e,"Client")}async ping(e){return this.request({method:"ping"},eh,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},uT,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},eh,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},sT,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},$S,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},xS,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},AS,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},ES,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},eh,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},eh,t)}async callTool(e,t=cc,s){if(this.isToolTaskRequired(e.name))throw new Ee(Re.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const i=await this.request({method:"tools/call",params:e},t,s),r=this.getToolOutputValidator(e.name);if(r){if(!i.structuredContent&&!i.isError)throw new Ee(Re.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(i.structuredContent)try{const o=r(i.structuredContent);if(!o.valid)throw new Ee(Re.InvalidParams,`Structured content does not match the tool's output schema: ${o.errorMessage}`)}catch(o){throw o instanceof Ee?o:new Ee(Re.InvalidParams,`Failed to validate structured content: ${o instanceof Error?o.message:String(o)}`)}}return i}isToolTask(e){var t,s,i,r;return(r=(i=(s=(t=this._serverCapabilities)==null?void 0:t.tasks)==null?void 0:s.requests)==null?void 0:i.tools)!=null&&r.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){var t;this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const s of e){if(s.outputSchema){const r=this._jsonSchemaValidator.getValidator(s.outputSchema);this._cachedToolOutputValidators.set(s.name,r)}const i=(t=s.execution)==null?void 0:t.taskSupport;(i==="required"||i==="optional")&&this._cachedKnownTaskTools.add(s.name),i==="required"&&this._cachedRequiredTaskTools.add(s.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const s=await this.request({method:"tools/list",params:e},OS,t);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,t,s,i){const r=FH.safeParse(s);if(!r.success)throw new Error(`Invalid ${e} listChanged options: ${r.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:o,debounceMs:a}=r.data,{onChanged:l}=s,c=async()=>{if(!o){l(null,null);return}try{const u=await i();l(null,u)}catch(u){const d=u instanceof Error?u:new Error(String(u));l(d,null)}},h=()=>{if(a){const u=this._listChangedDebounceTimers.get(e);u&&clearTimeout(u);const d=setTimeout(c,a);this._listChangedDebounceTimers.set(e,d)}else c()};this.setNotificationHandler(t,h)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}var bx={};/*! - * content-type - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */var jk=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,E9=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,cR=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,C9=/\\([\u000b\u0020-\u00ff])/g,$9=/([\\"])/g,hR=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;bx.format=T9;bx.parse=P9;function T9(n){if(!n||typeof n!="object")throw new TypeError("argument obj is required");var e=n.parameters,t=n.type;if(!t||!hR.test(t))throw new TypeError("invalid type");var s=t;if(e&&typeof e=="object")for(var i,r=Object.keys(e).sort(),o=0;o0&&!E9.test(e))throw new TypeError("invalid parameter value");return'"'+e.replace($9,"\\$1")+'"'}function I9(n){this.parameters=Object.create(null),this.type=n}function O9(n){if(n)try{return bx.parse(n).type}catch{const e=(n.split(";",1)[0]??"").trim().toLowerCase();return e===""||n.slice(e.length).includes(",")?void 0:e}}function Tb(n){return n?n instanceof Headers?Object.fromEntries(n.entries()):Array.isArray(n)?Object.fromEntries(n):{...n}:{}}function N9(n=fetch,e){return e?async(t,s)=>{const i={...e,...s,headers:s!=null&&s.headers?{...Tb(e.headers),...Tb(s.headers)}:e.headers};return n(t,i)}:n}let wx;wx=globalThis.crypto;async function L9(n){return(await wx).getRandomValues(new Uint8Array(n))}async function D9(n){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",t=Math.pow(2,8)-Math.pow(2,8)%e.length;let s="";for(;s.length128)throw`Expected a length between 43 and 128. Received ${n}.`;const e=await j9(n),t=await F9(e);return{code_verifier:e,code_challenge:t}}const zn=rz().superRefine((n,e)=>{if(!URL.canParse(n))return e.addIssue({code:Xz.custom,message:"URL must be parseable",fatal:!0}),GD}).refine(n=>{const e=new URL(n);return e.protocol!=="javascript:"&&e.protocol!=="data:"&&e.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),H9=qn({resource:F().url(),authorization_servers:re(zn).optional(),jwks_uri:F().url().optional(),scopes_supported:re(F()).optional(),bearer_methods_supported:re(F()).optional(),resource_signing_alg_values_supported:re(F()).optional(),resource_name:F().optional(),resource_documentation:F().optional(),resource_policy_uri:F().url().optional(),resource_tos_uri:F().url().optional(),tls_client_certificate_bound_access_tokens:et().optional(),authorization_details_types_supported:re(F()).optional(),dpop_signing_alg_values_supported:re(F()).optional(),dpop_bound_access_tokens_required:et().optional()}),uR=qn({issuer:F(),authorization_endpoint:zn,token_endpoint:zn,registration_endpoint:zn.optional(),scopes_supported:re(F()).optional(),response_types_supported:re(F()),response_modes_supported:re(F()).optional(),grant_types_supported:re(F()).optional(),token_endpoint_auth_methods_supported:re(F()).optional(),token_endpoint_auth_signing_alg_values_supported:re(F()).optional(),service_documentation:zn.optional(),revocation_endpoint:zn.optional(),revocation_endpoint_auth_methods_supported:re(F()).optional(),revocation_endpoint_auth_signing_alg_values_supported:re(F()).optional(),introspection_endpoint:F().optional(),introspection_endpoint_auth_methods_supported:re(F()).optional(),introspection_endpoint_auth_signing_alg_values_supported:re(F()).optional(),code_challenge_methods_supported:re(F()).optional(),client_id_metadata_document_supported:et().optional()}),B9=qn({issuer:F(),authorization_endpoint:zn,token_endpoint:zn,userinfo_endpoint:zn.optional(),jwks_uri:zn,registration_endpoint:zn.optional(),scopes_supported:re(F()).optional(),response_types_supported:re(F()),response_modes_supported:re(F()).optional(),grant_types_supported:re(F()).optional(),acr_values_supported:re(F()).optional(),subject_types_supported:re(F()),id_token_signing_alg_values_supported:re(F()),id_token_encryption_alg_values_supported:re(F()).optional(),id_token_encryption_enc_values_supported:re(F()).optional(),userinfo_signing_alg_values_supported:re(F()).optional(),userinfo_encryption_alg_values_supported:re(F()).optional(),userinfo_encryption_enc_values_supported:re(F()).optional(),request_object_signing_alg_values_supported:re(F()).optional(),request_object_encryption_alg_values_supported:re(F()).optional(),request_object_encryption_enc_values_supported:re(F()).optional(),token_endpoint_auth_methods_supported:re(F()).optional(),token_endpoint_auth_signing_alg_values_supported:re(F()).optional(),display_values_supported:re(F()).optional(),claim_types_supported:re(F()).optional(),claims_supported:re(F()).optional(),service_documentation:F().optional(),claims_locales_supported:re(F()).optional(),ui_locales_supported:re(F()).optional(),claims_parameter_supported:et().optional(),request_parameter_supported:et().optional(),request_uri_parameter_supported:et().optional(),require_request_uri_registration:et().optional(),op_policy_uri:zn.optional(),op_tos_uri:zn.optional(),client_id_metadata_document_supported:et().optional()}),U9=K({...B9.shape,...uR.pick({code_challenge_methods_supported:!0}).shape}),q9=K({access_token:F(),id_token:F().optional(),token_type:F(),expires_in:Yz().optional(),scope:F().optional(),refresh_token:F().optional()}).strip(),V9=K({error:F(),error_description:F().optional(),error_uri:F().optional()}),Fk=zn.optional().or(W("").transform(()=>{})),W9=K({redirect_uris:re(zn),token_endpoint_auth_method:F().optional(),grant_types:re(F()).optional(),response_types:re(F()).optional(),client_name:F().optional(),client_uri:zn.optional(),logo_uri:Fk,scope:F().optional(),contacts:re(F()).optional(),tos_uri:Fk,policy_uri:F().optional(),jwks_uri:zn.optional(),jwks:cS().optional(),software_id:F().optional(),software_version:F().optional(),software_statement:F().optional()}).strip(),G9=K({client_id:F(),client_secret:F().optional(),client_id_issued_at:je().optional(),client_secret_expires_at:je().optional()}).strip(),K9=W9.merge(G9);K({error:F(),error_description:F().optional()}).strip();K({token:F(),token_type_hint:F().optional()}).strip();function Z9(n){const e=typeof n=="string"?new URL(n):new URL(n.href);return e.hash="",e}function X9({requestedResource:n,configuredResource:e}){const t=typeof n=="string"?new URL(n):new URL(n.href),s=typeof e=="string"?new URL(e):new URL(e.href);if(t.origin!==s.origin||t.pathname.length=400&&n.status<500&&e!=="/"}async function l6(n,e,t,s){const i=new URL(n),r=(s==null?void 0:s.protocolVersion)??g0;let o;if(s!=null&&s.metadataUrl)o=new URL(s.metadataUrl);else{const l=o6(e,i.pathname);o=new URL(l,(s==null?void 0:s.metadataServerUrl)??i),o.search=i.search}let a=await Hk(o,r,t);if(!(s!=null&&s.metadataUrl)&&a6(a,i.pathname)){const l=new URL(`/.well-known/${e}`,i);a=await Hk(l,r,t)}return a}function c6(n){const e=typeof n=="string"?new URL(n):n,t=e.pathname!=="/",s=[];if(!t)return s.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),s.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),s;let i=e.pathname;return i.endsWith("/")&&(i=i.slice(0,-1)),s.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,e.origin),type:"oauth"}),s.push({url:new URL(`/.well-known/openid-configuration${i}`,e.origin),type:"oidc"}),s.push({url:new URL(`${i}/.well-known/openid-configuration`,e.origin),type:"oidc"}),s}async function pR(n,{fetchFn:e=fetch,protocolVersion:t=g0}={}){var r;const s={"MCP-Protocol-Version":t,Accept:"application/json"},i=c6(n);for(const{url:o,type:a}of i){const l=await _x(o,s,e);if(l){if(!l.ok){if(await((r=l.body)==null?void 0:r.cancel()),l.status>=400&&l.status<500)continue;throw new Error(`HTTP ${l.status} trying to load ${a==="oauth"?"OAuth":"OpenID provider"} metadata from ${o}`)}return a==="oauth"?uR.parse(await l.json()):U9.parse(await l.json())}}}async function h6(n,e){let t,s;try{t=await fR(n,{resourceMetadataUrl:e==null?void 0:e.resourceMetadataUrl},e==null?void 0:e.fetchFn),t.authorization_servers&&t.authorization_servers.length>0&&(s=t.authorization_servers[0])}catch{}s||(s=String(new URL("/",n)));const i=await pR(s,{fetchFn:e==null?void 0:e.fetchFn});return{authorizationServerUrl:s,authorizationServerMetadata:i,resourceMetadata:t}}async function u6(n,{metadata:e,clientInformation:t,redirectUrl:s,scope:i,state:r,resource:o}){let a;if(e){if(a=new URL(e.authorization_endpoint),!e.response_types_supported.includes(_v))throw new Error(`Incompatible auth server: does not support response type ${_v}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(Sv))throw new Error(`Incompatible auth server: does not support code challenge method ${Sv}`)}else a=new URL("/authorize",n);const l=await z9(),c=l.code_verifier,h=l.code_challenge;return a.searchParams.set("response_type",_v),a.searchParams.set("client_id",t.client_id),a.searchParams.set("code_challenge",h),a.searchParams.set("code_challenge_method",Sv),a.searchParams.set("redirect_uri",String(s)),r&&a.searchParams.set("state",r),i&&a.searchParams.set("scope",i),i!=null&&i.includes("offline_access")&&a.searchParams.append("prompt","consent"),o&&a.searchParams.set("resource",o.href),{authorizationUrl:a,codeVerifier:c}}function d6(n,e,t){return new URLSearchParams({grant_type:"authorization_code",code:n,code_verifier:e,redirect_uri:String(t)})}async function mR(n,{metadata:e,tokenRequestParams:t,clientInformation:s,addClientAuthentication:i,resource:r,fetchFn:o}){const a=e!=null&&e.token_endpoint?new URL(e.token_endpoint):new URL("/token",n),l=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(r&&t.set("resource",r.href),i)await i(l,t,a,e);else if(s){const h=(e==null?void 0:e.token_endpoint_auth_methods_supported)??[],u=Q9(s,h);e6(u,s,l,t)}const c=await(o??fetch)(a,{method:"POST",headers:l,body:t});if(!c.ok)throw await dR(c);return q9.parse(await c.json())}async function f6(n,{metadata:e,clientInformation:t,refreshToken:s,resource:i,addClientAuthentication:r,fetchFn:o}){const a=new URLSearchParams({grant_type:"refresh_token",refresh_token:s}),l=await mR(n,{metadata:e,tokenRequestParams:a,clientInformation:t,addClientAuthentication:r,resource:i,fetchFn:o});return{refresh_token:s,...l}}async function p6(n,e,{metadata:t,resource:s,authorizationCode:i,fetchFn:r}={}){const o=n.clientMetadata.scope;let a;if(n.prepareTokenRequest&&(a=await n.prepareTokenRequest(o)),!a){if(!i)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!n.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");const c=await n.codeVerifier();a=d6(i,c,n.redirectUrl)}const l=await n.clientInformation();return mR(e,{metadata:t,tokenRequestParams:a,clientInformation:l??void 0,addClientAuthentication:n.addClientAuthentication,resource:s,fetchFn:r})}async function m6(n,{metadata:e,clientMetadata:t,scope:s,fetchFn:i}){let r;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");r=new URL(e.registration_endpoint)}else r=new URL("/register",n);const o=await(i??fetch)(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,...s!==void 0?{scope:s}:{}})});if(!o.ok)throw await dR(o);return K9.parse(await o.json())}class kv extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const Bk=10,g6=13,qa=32;function Ev(n){}function y6(n){if(typeof n=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:e=Ev,onError:t=Ev,onRetry:s=Ev,onComment:i,maxBufferSize:r}=n,o=[];let a=0,l=!0,c,h="",u=0,d,p=!1;function m(A){if(p)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l&&(l=!1,A.charCodeAt(0)===239&&A.charCodeAt(1)===187&&A.charCodeAt(2)===191&&(A=A.slice(3))),o.length===0){const I=v(A);I!==""&&(o.push(I),a=I.length),y();return}if(A.indexOf(` -`)===-1&&A.indexOf("\r")===-1){o.push(A),a+=A.length,y();return}o.push(A);const T=o.join("");o.length=0,a=0;const C=v(T);C!==""&&(o.push(C),a=C.length),y()}function y(){r!==void 0&&(a+h.length<=r||(p=!0,o.length=0,a=0,c=void 0,h="",u=0,d=void 0,t(new kv(`Buffered data exceeded max buffer size of ${r} characters`,{type:"max-buffer-size-exceeded"}))))}function v(A){let T=0;if(A.indexOf("\r")===-1){let C=A.indexOf(` -`,T);for(;C!==-1;){if(T===C){u>0&&e({id:c,event:d,data:h}),c=void 0,h="",u=0,d=void 0,T=C+1,C=A.indexOf(` -`,T);continue}const I=A.charCodeAt(T);if(Uk(A,T,I)){const D=A.charCodeAt(T+5)===qa?T+6:T+5,H=A.slice(D,C);if(u===0&&A.charCodeAt(C+1)===Bk){e({id:c,event:d,data:H}),c=void 0,h="",d=void 0,T=C+2,C=A.indexOf(` -`,T);continue}h=u===0?H:`${h} -${H}`,u++}else qk(A,T,I)?d=A.slice(A.charCodeAt(T+6)===qa?T+7:T+6,C)||void 0:g(A,T,C);T=C+1,C=A.indexOf(` -`,T)}return A.slice(T)}for(;T20?`${A.slice(0,20)}…`:A}"`,{type:"unknown-field",field:A,value:T,line:C}));break}}function b(){u>0&&e({id:c,event:d,data:h}),c=void 0,h="",u=0,d=void 0}function x(A={}){if(A.consume&&o.length>0){const T=o.join("");g(T,0,T.length)}l=!0,c=void 0,h="",u=0,d=void 0,o.length=0,a=0,p=!1}return{feed:m,reset:x}}function Uk(n,e,t){return t===100&&n.charCodeAt(e+1)===97&&n.charCodeAt(e+2)===116&&n.charCodeAt(e+3)===97&&n.charCodeAt(e+4)===58}function qk(n,e,t){return t===101&&n.charCodeAt(e+1)===118&&n.charCodeAt(e+2)===101&&n.charCodeAt(e+3)===110&&n.charCodeAt(e+4)===116&&n.charCodeAt(e+5)===58}class v6 extends TransformStream{constructor({onError:e,onRetry:t,onComment:s,maxBufferSize:i}={}){let r;super({start(o){r=y6({onEvent:a=>{o.enqueue(a)},onError(a){typeof e=="function"&&e(a),(e==="terminate"||a.type==="max-buffer-size-exceeded")&&o.error(a)},onRetry:t,onComment:s,maxBufferSize:i})},transform(o){r.feed(o)}})}}const b6={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Fc extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}class w6{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t==null?void 0:t.requestInit,this._authProvider=t==null?void 0:t.authProvider,this._fetch=t==null?void 0:t.fetch,this._fetchWithInit=N9(t==null?void 0:t.fetch,t==null?void 0:t.requestInit),this._sessionId=t==null?void 0:t.sessionId,this._reconnectionOptions=(t==null?void 0:t.reconnectionOptions)??b6}async _authThenStart(){var t;if(!this._authProvider)throw new jc("No auth provider");let e;try{e=await Mm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(s){throw(t=this.onerror)==null||t.call(this,s),s}if(e!=="AUTHORIZED")throw new jc;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var s;const e={};if(this._authProvider){const i=await this._authProvider.tokens();i&&(e.Authorization=`Bearer ${i.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const t=Tb((s=this._requestInit)==null?void 0:s.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){var s,i,r;const{resumptionToken:t}=e;try{const o=await this._commonHeaders();o.set("Accept","text/event-stream"),t&&o.set("last-event-id",t);const a=await(this._fetch??fetch)(this._url,{method:"GET",headers:o,signal:(s=this._abortController)==null?void 0:s.signal});if(!a.ok){if(await((i=a.body)==null?void 0:i.cancel()),a.status===401&&this._authProvider)return await this._authThenStart();if(a.status===405)return;throw new Fc(a.status,`Failed to open SSE stream: ${a.statusText}`)}this._handleSseStream(a.body,e,!0)}catch(o){throw(r=this.onerror)==null||r.call(this,o),o}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const t=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,i=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(s,e),i)}_scheduleReconnection(e,t=0){var r;const s=this._reconnectionOptions.maxRetries;if(t>=s){(r=this.onerror)==null||r.call(this,new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}const i=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(o=>{var a;(a=this.onerror)==null||a.call(this,new Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`)),this._scheduleReconnection(e,t+1)})},i)}_handleSseStream(e,t,s){if(!e)return;const{onresumptiontoken:i,replayMessageId:r}=t;let o,a=!1,l=!1;(async()=>{var h,u,d,p;try{const m=e.pipeThrough(new TextDecoderStream).pipeThrough(new v6({onRetry:g=>{this._serverRetryMs=g}})).getReader();for(;;){const{value:g,done:_}=await m.read();if(_)break;if(g.id&&(o=g.id,a=!0,i==null||i(g.id)),!!g.data&&(!g.event||g.event==="message"))try{const b=rg.parse(JSON.parse(g.data));ud(b)&&(l=!0,r!==void 0&&(b.id=r)),(h=this.onmessage)==null||h.call(this,b)}catch(b){(u=this.onerror)==null||u.call(this,b)}}(s||a)&&!l&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:o,onresumptiontoken:i,replayMessageId:r},0)}catch(m){if((d=this.onerror)==null||d.call(this,new Error(`SSE stream disconnected: ${m}`)),(s||a)&&!l&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:o,onresumptiontoken:i,replayMessageId:r},0)}catch(g){(p=this.onerror)==null||p.call(this,new Error(`Failed to reconnect: ${g instanceof Error?g.message:String(g)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new jc("No auth provider");if(await Mm(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new jc("Failed to authorize")}async close(){var e,t;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(e=this._abortController)==null||e.abort(),(t=this.onclose)==null||t.call(this)}async send(e,t){var s,i,r,o,a,l;try{const{resumptionToken:c,onresumptiontoken:h}=t||{};if(c){this._startOrAuthSse({resumptionToken:c,replayMessageId:cb(e)?e.id:void 0}).catch(b=>{var x;return(x=this.onerror)==null?void 0:x.call(this,b)});return}const u=await this._commonHeaders();u.set("content-type","application/json"),u.set("accept","application/json, text/event-stream");const d={...this._requestInit,method:"POST",headers:u,body:JSON.stringify(e),signal:(s=this._abortController)==null?void 0:s.signal},p=await(this._fetch??fetch)(this._url,d),m=p.headers.get("mcp-session-id");if(m&&(this._sessionId=m),!p.ok){const b=await p.text().catch(()=>null);if(p.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Fc(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:x,scope:A}=zk(p);if(this._resourceMetadataUrl=x,this._scope=A,await Mm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new jc;return this._hasCompletedAuthFlow=!0,this.send(e)}if(p.status===403&&this._authProvider){const{resourceMetadataUrl:x,scope:A,error:T}=zk(p);if(T==="insufficient_scope"){const C=p.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===C)throw new Fc(403,"Server returned 403 after trying upscoping");if(A&&(this._scope=A),x&&(this._resourceMetadataUrl=x),this._lastUpscopingHeader=C??void 0,await Mm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new jc;return this.send(e)}}throw new Fc(p.status,`Error POSTing to endpoint: ${b}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,p.status===202){await((i=p.body)==null?void 0:i.cancel()),pH(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(b=>{var x;return(x=this.onerror)==null?void 0:x.call(this,b)});return}const v=(Array.isArray(e)?e:[e]).filter(b=>"method"in b&&"id"in b&&b.id!==void 0).length>0,g=p.headers.get("content-type"),_=O9(g);if(v)if(_==="text/event-stream")this._handleSseStream(p.body,{onresumptiontoken:h},!1);else if(_==="application/json"){const b=await p.json(),x=Array.isArray(b)?b.map(A=>rg.parse(A)):[rg.parse(b)];for(const A of x)(r=this.onmessage)==null||r.call(this,A)}else throw await((o=p.body)==null?void 0:o.cancel()),new Fc(-1,`Unexpected content type: ${g}`);else await((a=p.body)==null?void 0:a.cancel())}catch(c){throw(l=this.onerror)==null||l.call(this,c),c}}get sessionId(){return this._sessionId}async terminateSession(){var e,t,s;if(this._sessionId)try{const i=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:i,signal:(e=this._abortController)==null?void 0:e.signal},o=await(this._fetch??fetch)(this._url,r);if(await((t=o.body)==null?void 0:t.cancel()),!o.ok&&o.status!==405)throw new Fc(o.status,`Failed to terminate session: ${o.statusText}`);this._sessionId=void 0}catch(i){throw(s=this.onerror)==null||s.call(this,i),i}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t==null?void 0:t.onresumptiontoken})}}const _6="https://mcp.excalidraw.com/mcp",S6="mcp.excalidraw.com",x6="/api/v1/chat/mcp-apps/excalidraw",gR="ui://excalidraw/mcp-app.html",A6=["read_me","create_view"],yR=new Set(["export_to_excalidraw","save_checkpoint","read_checkpoint"]),k6=256*1024,E6=1024*1024,C6=1024*1024,$6=240,T6=720,P6=525;function R6(n){return!Number.isFinite(n)||n<=0?P6:Math.max($6,Math.min(T6,Math.round(n*3/4)))}const M6={excalidraw:{id:"excalidraw",endpoint:_6,hostname:S6,resourceUri:gR,modelTools:A6,appTools:yR}};function I6(n){return M6[n]}function O6(){return new URL(rn(x6),window.location.origin)}class N6{constructor(){oe(this,"client",new k9({name:"pwc-chat-mcp-app-host",version:"1"}));oe(this,"transport",new w6(O6(),{requestInit:{credentials:"include"}}));oe(this,"connected");oe(this,"bytes",0);oe(this,"closed",!1)}connect(){return this.closed?Promise.reject(new Error("App host client is closed")):(this.connected||(this.connected=this.client.connect(this.transport).then(()=>{},e=>{throw this.connected=void 0,this.retire(),e})),this.connected)}async readResource(e){if(e!==gR)throw new Error("Unapproved App resource");await this.connect();const s=(await this.client.readResource({uri:e})).contents[0];if(!s||!("text"in s)||typeof s.text!="string"||s.mimeType!=="text/html;profile=mcp-app")throw new Error("Incompatible App resource");this.consume(s.text,C6);const i=await F6(s.text);return{text:s.text,digest:i}}async callTool(e,t){if(!yR.has(e))throw new Error("Unapproved App tool");const s=JSON.stringify(t);this.consume(s);try{await this.connect();const i=await this.client.callTool({name:e,arguments:t});return this.consume(JSON.stringify(i)),i}catch(i){throw this.retire(),i}}close(){this.closed=!0,this.connected=void 0,this.transport.close()}retire(){this.close(),Sa===this&&(Sa=void 0)}consume(e,t=k6){const s=new TextEncoder().encode(e).byteLength;if(s>t||this.bytes+s>E6)throw new Error("App request exceeds host limit");this.bytes+=s}}let Sa;function L6(){return Sa??(Sa=new N6),Sa}function D6(){Sa==null||Sa.close(),Sa=void 0}function j6(n){D6()}async function F6(n){const e=new TextEncoder().encode(n),t=await crypto.subtle.digest("SHA-256",e);return[...new Uint8Array(t)].map(s=>s.toString(16).padStart(2,"0")).join("")}function z6(n,e){let t=!1,s=0;const i=()=>{t||!n.contentWindow||(t=!0,e())};n.addEventListener("load",i);const r=window.requestAnimationFrame(()=>{s=window.requestAnimationFrame(i)});return()=>{t=!0,n.removeEventListener("load",i),window.cancelAnimationFrame(r),window.cancelAnimationFrame(s)}}const H6=({block:n})=>{const e=ee.useRef(null),t=ee.useRef(null),s=ee.useRef(!1),i=ee.useRef(n),r=ee.useRef(!1);i.current=n;const[o,a]=ee.useState(),[l,c]=ee.useState("loading"),[h,u]=ee.useState(n.height),[d,p]=ee.useState(!1),[m,y]=ee.useState(0),v=ee.useRef(null),g=n.input.elements,_=!!n.permissions.clipboardWrite;r.current=d;const b=ee.useCallback(()=>{p(!1),document.fullscreenElement&&document.exitFullscreen()},[]),x=ee.useCallback(()=>{var C,I;if(d){b();return}p(!0),(I=(C=v.current)==null?void 0:C.requestFullscreen)==null||I.call(C).catch(()=>{})},[b,d]),A=ee.useCallback(()=>{j6(),a(void 0),c("loading"),y(C=>C+1)},[]);ee.useEffect(()=>{const C=v.current;if(!C)return;const I=()=>{r.current||u(R6(C.clientWidth))};I();const D=new ResizeObserver(I);return D.observe(C),()=>D.disconnect()},[]),ee.useEffect(()=>{if(!d)return;const C=v.current,I=H=>{H.key==="Escape"&&(document.fullscreenElement||b())},D=()=>{document.fullscreenElement||p(!1)};return window.addEventListener("keydown",I),document.addEventListener("fullscreenchange",D),()=>{window.removeEventListener("keydown",I),document.removeEventListener("fullscreenchange",D),document.fullscreenElement===C&&document.exitFullscreen()}},[b,d]),ee.useEffect(()=>{I6(n.provider);{c("unavailable");return}},[m,n.provider,n.resource_uri]),ee.useEffect(()=>{if(!o||l!=="ready")return;const C=e.current;if(!C)return;let I=null;const D=[],H=z6(C,()=>{C.contentWindow&&(I=new WB(null,{name:"Papers with Code",version:"1"},{serverTools:{},openLinks:{},logging:{},..._?{clipboard:{write:{}}}:{}},{hostContext:{theme:document.documentElement.dataset.theme==="dark"?"dark":"light",displayMode:d?"fullscreen":"inline"}}),I.oncalltool=async({name:j,arguments:U})=>{if(i.current.public_fork&&j!=="export_to_excalidraw")throw new Error("Shared diagrams cannot mutate owner state");return L6().callTool(j,U??{})},I.onopenlink=async({url:j})=>{const U=new URL(j);if(U.protocol!=="https:"||U.hostname!=="excalidraw.com")throw new Error("External navigation denied");if(!window.confirm("This export opens Excalidraw and uploads the diagram to its service. Continue?"))throw new Error("Export cancelled");return window.open(U.href,"_blank","noopener,noreferrer"),{}},I.onsizechange=()=>{},I.oninitialized=()=>{const j=I;if(!j){c("error");return}s.current=!0;try{const U=JSON.parse(g),B={arguments:{elements:Array.isArray(U)?tU(U):U}};for(const L of[0,50,200,750])D.push(window.setTimeout(()=>{t.current===j&&j.sendToolInput(B)},L));j.sendToolResult(i.current.result)}catch{c("error")}},t.current=I,I.connect(new qB(C.contentWindow??void 0,C.contentWindow)).catch(()=>c("error")))});return()=>{H(),D.forEach(j=>window.clearTimeout(j)),s.current=!1,I==null||I.teardownResource({}).catch(()=>{}),t.current===I&&(t.current=null)}},[o,l,d,g,_,m]),ee.useEffect(()=>{var C;l!=="ready"||!s.current||(C=t.current)==null||C.sendToolResult(n.result).catch(()=>{})},[n.result,l]);const T=l==="unavailable"||l==="incompatible"||l==="error";return S.jsxs("section",{ref:v,className:`chat-mcp-app${d?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[S.jsx("header",{children:S.jsx("button",{type:"button",onClick:x,children:d?"Exit fullscreen":"Fullscreen"})}),l==="loading"&&S.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),T&&S.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",S.jsx("button",{type:"button",onClick:A,children:"Retry diagram"})]}),o&&l==="ready"&&S.jsx("iframe",{ref:e,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:_?"clipboard-write":void 0,srcDoc:o,style:{height:h}},m)]})};var Gd={};Gd.d=(n,e)=>{for(var t in e)Gd.o(e,t)&&!Gd.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:e[t]})};Gd.o=(n,e)=>Object.prototype.hasOwnProperty.call(n,e);var Me=globalThis.pdfjsLib={};Gd.d(Me,{AbortException:()=>Tc,AnnotationEditorLayer:()=>Qw,AnnotationEditorParamsType:()=>Pe,AnnotationEditorType:()=>De,AnnotationEditorUIManager:()=>gc,AnnotationLayer:()=>FZ,AnnotationMode:()=>Uo,ColorPicker:()=>Sy,DOMSVGFactory:()=>Ix,DrawLayer:()=>s_,FeatureTest:()=>ys,GlobalWorkerOptions:()=>vo,ImageKind:()=>gg,InvalidPDFException:()=>bR,MissingPDFException:()=>$c,OPS:()=>Mi,OutputScale:()=>Wb,PDFDataRangeTransport:()=>mM,PDFDateString:()=>Ex,PDFWorker:()=>uh,PasswordResponses:()=>V6,PermissionFlag:()=>q6,PixelsPerInch:()=>Pa,RenderingCancelledException:()=>Ax,TextLayer:()=>ww,UnexpectedResponseException:()=>N0,Util:()=>Se,VerbosityLevel:()=>M0,XfaLayer:()=>yM,build:()=>bZ,createValidAbsoluteUrl:()=>Z6,fetchData:()=>D0,getDocument:()=>hZ,getFilenameFromUrl:()=>i8,getPdfFilenameFromUrl:()=>r8,getXfaPageViewport:()=>o8,isDataScheme:()=>j0,isPdfFile:()=>kx,noContextMenu:()=>xi,normalizeUnicode:()=>t8,setLayerDimensions:()=>mc,shadow:()=>Xe,version:()=>vZ});const os=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),vR=[1,0,0,1,0,0],Bb=[.001,0,0,.001,0,0],B6=1e7,Cv=1.35,ei={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Uo={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},U6="pdfjs_internal_editor_",De={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Pe={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},q6={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Jn={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},gg={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},ln={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,WIDGET:20},nd={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},M0={ERRORS:0,WARNINGS:1,INFOS:5},Mi={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},V6={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let I0=M0.WARNINGS;function W6(n){Number.isInteger(n)&&(I0=n)}function G6(){return I0}function O0(n){I0>=M0.INFOS&&console.log(`Info: ${n}`)}function qe(n){I0>=M0.WARNINGS&&console.log(`Warning: ${n}`)}function Tt(n){throw new Error(n)}function mn(n,e){n||Tt(e)}function K6(n){switch(n==null?void 0:n.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Z6(n,e=null,t=null){if(!n)return null;try{if(t&&typeof n=="string"){if(t.addDefaultProtocol&&n.startsWith("www.")){const i=n.match(/\./g);(i==null?void 0:i.length)>=2&&(n=`http://${n}`)}if(t.tryConvertEncoding)try{n=e8(n)}catch{}}const s=e?new URL(n,e):new URL(n);if(K6(s))return s}catch{}return null}function Xe(n,e,t,s=!1){return Object.defineProperty(n,e,{value:t,enumerable:!s,configurable:!0,writable:!1}),t}const ja=function(){function e(t,s){this.message=t,this.name=s}return e.prototype=new Error,e.constructor=e,e}();class Ub extends ja{constructor(e,t){super(e,"PasswordException"),this.code=t}}class qb extends ja{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}}class bR extends ja{constructor(e){super(e,"InvalidPDFException")}}class $c extends ja{constructor(e){super(e,"MissingPDFException")}}class N0 extends ja{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}}class X6 extends ja{constructor(e){super(e,"FormatError")}}class Tc extends ja{constructor(e){super(e,"AbortException")}}function wR(n){(typeof n!="object"||(n==null?void 0:n.length)===void 0)&&Tt("Invalid argument for bytesToString");const e=n.length,t=8192;if(e>24&255,n>>16&255,n>>8&255,n&255)}function Sx(n){const e=Object.create(null);for(const[t,s]of n)e[t]=s;return e}function J6(){const n=new Uint8Array(4);return n[0]=1,new Uint32Array(n.buffer,0,1)[0]===1}function Q6(){try{return new Function(""),!0}catch{return!1}}class ys{static get isLittleEndian(){return Xe(this,"isLittleEndian",J6())}static get isEvalSupported(){return Xe(this,"isEvalSupported",Q6())}static get isOffscreenCanvasSupported(){return Xe(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?Xe(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof(navigator==null?void 0:navigator.userAgent)=="string"&&navigator.userAgent.includes("Firefox")}):Xe(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var e,t;return Xe(this,"isCSSRoundSupported",(t=(e=globalThis.CSS)==null?void 0:e.supports)==null?void 0:t.call(e,"width: round(1.5px, 1px)"))}}const $v=Array.from(Array(256).keys(),n=>n.toString(16).padStart(2,"0"));var Co,yg,Vb;class Se{static makeHexColor(e,t,s){return`#${$v[e]}${$v[t]}${$v[s]}`}static scaleMinMax(e,t){let s;e[0]?(e[0]<0&&(s=t[0],t[0]=t[2],t[2]=s),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(s=t[1],t[1]=t[3],t[3]=s),t[1]*=e[3],t[3]*=e[3]):(s=t[0],t[0]=t[1],t[1]=s,s=t[2],t[2]=t[3],t[3]=s,e[1]<0&&(s=t[1],t[1]=t[3],t[3]=s),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(s=t[0],t[0]=t[2],t[2]=s),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){const s=e[0]*t[0]+e[1]*t[2]+t[4],i=e[0]*t[1]+e[1]*t[3]+t[5];return[s,i]}static applyInverseTransform(e,t){const s=t[0]*t[3]-t[1]*t[2],i=(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/s,r=(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/s;return[i,r]}static getAxialAlignedBoundingBox(e,t){const s=this.applyTransform(e,t),i=this.applyTransform(e.slice(2,4),t),r=this.applyTransform([e[0],e[3]],t),o=this.applyTransform([e[2],e[1]],t);return[Math.min(s[0],i[0],r[0],o[0]),Math.min(s[1],i[1],r[1],o[1]),Math.max(s[0],i[0],r[0],o[0]),Math.max(s[1],i[1],r[1],o[1])]}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){const t=[e[0],e[2],e[1],e[3]],s=e[0]*t[0]+e[1]*t[2],i=e[0]*t[1]+e[1]*t[3],r=e[2]*t[0]+e[3]*t[2],o=e[2]*t[1]+e[3]*t[3],a=(s+o)/2,l=Math.sqrt((s+o)**2-4*(s*o-r*i))/2,c=a+l||1,h=a-l||1;return[Math.sqrt(c),Math.sqrt(h)]}static normalizeRect(e){const t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){const s=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),i=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(s>i)return null;const r=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),o=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return r>o?null:[s,r,i,o]}static bezierBoundingBox(e,t,s,i,r,o,a,l,c){return c?(c[0]=Math.min(c[0],e,a),c[1]=Math.min(c[1],t,l),c[2]=Math.max(c[2],e,a),c[3]=Math.max(c[3],t,l)):c=[Math.min(e,a),Math.min(t,l),Math.max(e,a),Math.max(t,l)],P(this,Co,Vb).call(this,e,s,r,a,t,i,o,l,3*(-e+3*(s-r)+a),6*(e-2*s+r),3*(s-e),c),P(this,Co,Vb).call(this,e,s,r,a,t,i,o,l,3*(-t+3*(i-o)+l),6*(t-2*i+o),3*(i-t),c),c}}Co=new WeakSet,yg=function(e,t,s,i,r,o,a,l,c,h){if(c<=0||c>=1)return;const u=1-c,d=c*c,p=d*c,m=u*(u*(u*e+3*c*t)+3*d*s)+p*i,y=u*(u*(u*r+3*c*o)+3*d*a)+p*l;h[0]=Math.min(h[0],m),h[1]=Math.min(h[1],y),h[2]=Math.max(h[2],m),h[3]=Math.max(h[3],y)},Vb=function(e,t,s,i,r,o,a,l,c,h,u,d){if(Math.abs(c)<1e-12){Math.abs(h)>=1e-12&&P(this,Co,yg).call(this,e,t,s,i,r,o,a,l,-u/h,d);return}const p=h**2-4*u*c;if(p<0)return;const m=Math.sqrt(p),y=2*c;P(this,Co,yg).call(this,e,t,s,i,r,o,a,l,(-h+m)/y,d),P(this,Co,yg).call(this,e,t,s,i,r,o,a,l,(-h-m)/y,d)},M(Se,Co);function e8(n){return decodeURIComponent(escape(n))}let Tv=null,Vk=null;function t8(n){return Tv||(Tv=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,Vk=new Map([["ſt","ſt"]])),n.replaceAll(Tv,(e,t,s)=>t?t.normalize("NFKC"):Vk.get(s))}function n8(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const n=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(n);else for(let e=0;e<32;e++)n[e]=Math.floor(Math.random()*255);return wR(n)}const xx="pdfjs_internal_id_",Br={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};function s8(n){return Uint8Array.prototype.toBase64?n.toBase64():btoa(wR(n))}const qr="http://www.w3.org/2000/svg",al=class al{};oe(al,"CSS",96),oe(al,"PDF",72),oe(al,"PDF_TO_CSS_UNITS",al.CSS/al.PDF);let Pa=al;async function D0(n,e="text"){if(md(n,document.baseURI)){const t=await fetch(n);if(!t.ok)throw new Error(t.statusText);switch(e){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"json":return t.json()}return t.text()}return new Promise((t,s)=>{const i=new XMLHttpRequest;i.open("GET",n,!0),i.responseType=e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(e){case"arraybuffer":case"blob":case"json":t(i.response);return}t(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class em{constructor({viewBox:e,scale:t,rotation:s,offsetX:i=0,offsetY:r=0,dontFlip:o=!1}){this.viewBox=e,this.scale=t,this.rotation=s,this.offsetX=i,this.offsetY=r;const a=(e[2]+e[0])/2,l=(e[3]+e[1])/2;let c,h,u,d;switch(s%=360,s<0&&(s+=360),s){case 180:c=-1,h=0,u=0,d=1;break;case 90:c=0,h=1,u=1,d=0;break;case 270:c=0,h=-1,u=-1,d=0;break;case 0:c=1,h=0,u=0,d=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(u=-u,d=-d);let p,m,y,v;c===0?(p=Math.abs(l-e[1])*t+i,m=Math.abs(a-e[0])*t+r,y=(e[3]-e[1])*t,v=(e[2]-e[0])*t):(p=Math.abs(a-e[0])*t+i,m=Math.abs(l-e[1])*t+r,y=(e[2]-e[0])*t,v=(e[3]-e[1])*t),this.transform=[c*t,h*t,u*t,d*t,p-c*t*a-u*t*l,m-h*t*a-d*t*l],this.width=y,this.height=v}get rawDims(){const{viewBox:e}=this;return Xe(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new em({viewBox:this.viewBox.slice(),scale:e,rotation:t,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(e,t){return Se.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){const t=Se.applyTransform([e[0],e[1]],this.transform),s=Se.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],s[0],s[1]]}convertToPdfPoint(e,t){return Se.applyInverseTransform([e,t],this.transform)}}class Ax extends ja{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function j0(n){const e=n.length;let t=0;for(;t=1&&i<=12?i-1:0;let r=parseInt(t[3],10);r=r>=1&&r<=31?r:1;let o=parseInt(t[4],10);o=o>=0&&o<=23?o:0;let a=parseInt(t[5],10);a=a>=0&&a<=59?a:0;let l=parseInt(t[6],10);l=l>=0&&l<=59?l:0;const c=t[7]||"Z";let h=parseInt(t[8],10);h=h>=0&&h<=23?h:0;let u=parseInt(t[9],10)||0;return u=u>=0&&u<=59?u:0,c==="-"?(o+=h,a+=u):c==="+"&&(o-=h,a-=u),new Date(Date.UTC(s,i,r,o,a,l))}}wf=new WeakMap,M(Ex,wf);function o8(n,{scale:e=1,rotation:t=0}){const{width:s,height:i}=n.attributes.style,r=[0,0,parseInt(s),parseInt(i)];return new em({viewBox:r,scale:e,rotation:t})}function Cx(n){if(n.startsWith("#")){const e=parseInt(n.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}return n.startsWith("rgb(")?n.slice(4,-1).split(",").map(e=>parseInt(e)):n.startsWith("rgba(")?n.slice(5,-1).split(",").map(e=>parseInt(e)).slice(0,3):(qe(`Not a valid color format: "${n}"`),[0,0,0])}function a8(n){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const t of n.keys()){e.style.color=t;const s=window.getComputedStyle(e).color;n.set(t,Cx(s))}e.remove()}function Ht(n){const{a:e,b:t,c:s,d:i,e:r,f:o}=n.getTransform();return[e,t,s,i,r,o]}function Ur(n){const{a:e,b:t,c:s,d:i,e:r,f:o}=n.getTransform().invertSelf();return[e,t,s,i,r,o]}function mc(n,e,t=!1,s=!0){if(e instanceof em){const{pageWidth:i,pageHeight:r}=e.rawDims,{style:o}=n,a=ys.isCSSRoundSupported,l=`var(--scale-factor) * ${i}px`,c=`var(--scale-factor) * ${r}px`,h=a?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,u=a?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!t||e.rotation%180===0?(o.width=h,o.height=u):(o.width=u,o.height=h)}s&&n.setAttribute("data-main-rotation",e.rotation)}class Wb{constructor(){const e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}}var Wo,ul,Ii,dl,_f,Sf,Vy,_R,bs,SR,xR,vg,AR,Kb;const Vr=class Vr{constructor(e){M(this,bs);M(this,Wo,null);M(this,ul,null);M(this,Ii);M(this,dl,null);M(this,_f,null);$(this,Ii,e),f(Vr,Sf)||$(Vr,Sf,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"}))}render(){const e=$(this,Wo,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const t=f(this,Ii)._uiManager._signal;e.addEventListener("contextmenu",xi,{signal:t}),e.addEventListener("pointerdown",P(Vr,Vy,_R),{signal:t});const s=$(this,dl,document.createElement("div"));s.className="buttons",e.append(s);const i=f(this,Ii).toolbarPosition;if(i){const{style:r}=e,o=f(this,Ii)._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*o}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return P(this,bs,AR).call(this),e}get div(){return f(this,Wo)}hide(){var e;f(this,Wo).classList.add("hidden"),(e=f(this,ul))==null||e.hideDropdown()}show(){var e;f(this,Wo).classList.remove("hidden"),(e=f(this,_f))==null||e.shown()}async addAltText(e){const t=await e.render();P(this,bs,vg).call(this,t),f(this,dl).prepend(t,f(this,bs,Kb)),$(this,_f,e)}addColorPicker(e){$(this,ul,e);const t=e.renderButton();P(this,bs,vg).call(this,t),f(this,dl).prepend(t,f(this,bs,Kb))}remove(){var e;f(this,Wo).remove(),(e=f(this,ul))==null||e.destroy(),$(this,ul,null)}};Wo=new WeakMap,ul=new WeakMap,Ii=new WeakMap,dl=new WeakMap,_f=new WeakMap,Sf=new WeakMap,Vy=new WeakSet,_R=function(e){e.stopPropagation()},bs=new WeakSet,SR=function(e){f(this,Ii)._focusEventsAllowed=!1,e.preventDefault(),e.stopPropagation()},xR=function(e){f(this,Ii)._focusEventsAllowed=!0,e.preventDefault(),e.stopPropagation()},vg=function(e){const t=f(this,Ii)._uiManager._signal;e.addEventListener("focusin",P(this,bs,SR).bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",P(this,bs,xR).bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",xi,{signal:t})},AR=function(){const{editorType:e,_uiManager:t}=f(this,Ii),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",f(Vr,Sf)[e]),P(this,bs,vg).call(this,s),s.addEventListener("click",i=>{t.delete()},{signal:t._signal}),f(this,dl).append(s)},Kb=function(){const e=document.createElement("div");return e.className="divider",e},M(Vr,Vy),M(Vr,Sf,null);let Gb=Vr;var xf,fl,pl,La,kR,ER,CR;class l8{constructor(e){M(this,La);M(this,xf,null);M(this,fl,null);M(this,pl);$(this,pl,e)}show(e,t,s){const[i,r]=P(this,La,ER).call(this,t,s),{style:o}=f(this,fl)||$(this,fl,P(this,La,kR).call(this));e.append(f(this,fl)),o.insetInlineEnd=`${100*i}%`,o.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){f(this,fl).remove()}}xf=new WeakMap,fl=new WeakMap,pl=new WeakMap,La=new WeakSet,kR=function(){const e=$(this,fl,document.createElement("div"));e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",xi,{signal:f(this,pl)._signal});const t=$(this,xf,document.createElement("div"));return t.className="buttons",e.append(t),P(this,La,CR).call(this),e},ER=function(e,t){let s=0,i=0;for(const r of e){const o=r.y+r.height;if(os){i=a,s=o;continue}t?a>i&&(i=a):a{f(this,pl).highlightSelection("floating_button")},{signal:s}),f(this,xf).append(e)};function by(n,e,t){for(const s of t)e.addEventListener(s,n[s].bind(n))}function c8(n){return Math.round(Math.min(255,Math.max(1,255*n))).toString(16).padStart(2,"0")}var Wy;class h8{constructor(){M(this,Wy,0)}get id(){return`${U6}${hs(this,Wy)._++}`}}Wy=new WeakMap;var bh,Af,es,wh,bg;const dA=class dA{constructor(){M(this,wh);M(this,bh,n8());M(this,Af,0);M(this,es,null)}static get _isSVGFittingCanvas(){const e='data:image/svg+xml;charset=UTF-8,',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=e;const r=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return Xe(this,"_isSVGFittingCanvas",r)}async getFromFile(e){const{lastModified:t,name:s,size:i,type:r}=e;return P(this,wh,bg).call(this,`${t}_${s}_${i}_${r}`,e)}async getFromUrl(e){return P(this,wh,bg).call(this,e,e)}async getFromBlob(e,t){const s=await t;return P(this,wh,bg).call(this,e,s)}async getFromId(e){f(this,es)||$(this,es,new Map);const t=f(this,es).get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){const{blobPromise:s}=t;return delete t.blobPromise,this.getFromBlob(t.id,s)}return this.getFromUrl(t.url)}getFromCanvas(e,t){f(this,es)||$(this,es,new Map);let s=f(this,es).get(e);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(t.width,t.height);return i.getContext("2d").drawImage(t,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${f(this,bh)}_${hs(this,Af)._++}`,refCounter:1,isSvg:!1},f(this,es).set(e,s),f(this,es).set(s.id,s),s}getSvgUrl(e){const t=f(this,es).get(e);return t!=null&&t.isSvg?t.svgUrl:null}deleteId(e){var i;f(this,es)||$(this,es,new Map);const t=f(this,es).get(e);if(!t||(t.refCounter-=1,t.refCounter!==0))return;const{bitmap:s}=t;if(!t.url&&!t.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),t.blobPromise=r.convertToBlob()}(i=s.close)==null||i.call(s),t.bitmap=null}isValidId(e){return e.startsWith(`image_${f(this,bh)}_`)}};bh=new WeakMap,Af=new WeakMap,es=new WeakMap,wh=new WeakSet,bg=async function(e,t){f(this,es)||$(this,es,new Map);let s=f(this,es).get(e);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${f(this,bh)}_${hs(this,Af)._++}`,refCounter:0,isSvg:!1});let i;if(typeof t=="string"?(s.url=t,i=await D0(t,"blob")):t instanceof File?i=s.file=t:t instanceof Blob&&(i=t),i.type==="image/svg+xml"){const r=dA._isSVGFittingCanvas,o=new FileReader,a=new Image,l=new Promise((c,h)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,c()},o.onload=async()=>{const u=s.svgUrl=o.result;a.src=await r?`${u}#svgView(preserveAspectRatio(none))`:u},a.onerror=o.onerror=h});o.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return f(this,es).set(e,s),s&&f(this,es).set(s.id,s),s};let Zb=dA;var Sn,Go,kf,xn;class u8{constructor(e=128){M(this,Sn,[]);M(this,Go,!1);M(this,kf);M(this,xn,-1);$(this,kf,e)}add({cmd:e,undo:t,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:o=!1,keepUndo:a=!1}){if(i&&e(),f(this,Go))return;const l={cmd:e,undo:t,post:s,type:r};if(f(this,xn)===-1){f(this,Sn).length>0&&(f(this,Sn).length=0),$(this,xn,0),f(this,Sn).push(l);return}if(o&&f(this,Sn)[f(this,xn)].type===r){a&&(l.undo=f(this,Sn)[f(this,xn)].undo),f(this,Sn)[f(this,xn)]=l;return}const c=f(this,xn)+1;c===f(this,kf)?f(this,Sn).splice(0,1):($(this,xn,c),cr===t[o]))return Ky._colorsMapping.get(s);return t}getHexCode(e){const t=this._colors.get(e);return t?Se.makeHexColor(...t):e}};oe(Ky,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Xb=Ky;var _h,Ws,cn,Ln,Sh,Gr,xh,Oi,Ko,Ah,ml,ar,Ni,gl,Ef,Cf,kh,$f,lr,Zo,Eh,Xo,cr,Zy,Yo,Tf,Jo,yl,Pf,Rf,An,dt,Kr,vl,Mf,If,Qo,hr,Zr,Of,ci,ue,wg,Yb,TR,PR,_g,RR,MR,IR,Jb,OR,Qb,ew,NR,us,jo,LR,DR,tw,jR,gd,nw;const rh=class rh{constructor(e,t,s,i,r,o,a,l,c,h,u){M(this,ue);M(this,_h,new AbortController);M(this,Ws,null);M(this,cn,new Map);M(this,Ln,new Map);M(this,Sh,null);M(this,Gr,null);M(this,xh,null);M(this,Oi,new u8);M(this,Ko,null);M(this,Ah,0);M(this,ml,new Set);M(this,ar,null);M(this,Ni,null);M(this,gl,new Set);M(this,Ef,!1);M(this,Cf,!1);M(this,kh,!1);M(this,$f,null);M(this,lr,null);M(this,Zo,null);M(this,Eh,null);M(this,Xo,!1);M(this,cr,null);M(this,Zy,new h8);M(this,Yo,!1);M(this,Tf,!1);M(this,Jo,null);M(this,yl,null);M(this,Pf,null);M(this,Rf,null);M(this,An,De.NONE);M(this,dt,new Set);M(this,Kr,null);M(this,vl,null);M(this,Mf,null);M(this,If,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});M(this,Qo,[0,0]);M(this,hr,null);M(this,Zr,null);M(this,Of,null);M(this,ci,null);const d=this._signal=f(this,_h).signal;$(this,Zr,e),$(this,Of,t),$(this,Sh,s),this._eventBus=i,i._on("editingaction",this.onEditingAction.bind(this),{signal:d}),i._on("pagechanging",this.onPageChanging.bind(this),{signal:d}),i._on("scalechanging",this.onScaleChanging.bind(this),{signal:d}),i._on("rotationchanging",this.onRotationChanging.bind(this),{signal:d}),i._on("setpreference",this.onSetPreference.bind(this),{signal:d}),i._on("switchannotationeditorparams",p=>this.updateParams(p.type,p.value),{signal:d}),P(this,ue,RR).call(this),P(this,ue,NR).call(this),P(this,ue,Jb).call(this),$(this,Gr,r.annotationStorage),$(this,$f,r.filterFactory),$(this,vl,o),$(this,Eh,a||null),$(this,Ef,l),$(this,Cf,c),$(this,kh,h),$(this,Rf,u||null),this.viewParameters={realScale:Pa.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const e=rh.prototype,t=o=>f(o,Zr).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&o.hasSomethingToControl(),s=(o,{target:a})=>{if(a instanceof HTMLInputElement){const{type:l}=a;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return Xe(this,"_keyboardManager",new tm([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:s}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(o,{target:a})=>!(a instanceof HTMLButtonElement)&&f(o,Zr).contains(a)&&!o.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(o,{target:a})=>!(a instanceof HTMLButtonElement)&&f(o,Zr).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:t}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:t}]]))}destroy(){var e,t,s,i;(e=f(this,ci))==null||e.resolve(),$(this,ci,null),(t=f(this,_h))==null||t.abort(),$(this,_h,null),this._signal=null;for(const r of f(this,Ln).values())r.destroy();f(this,Ln).clear(),f(this,cn).clear(),f(this,gl).clear(),$(this,Ws,null),f(this,dt).clear(),f(this,Oi).destroy(),(s=f(this,Sh))==null||s.destroy(),(i=f(this,cr))==null||i.hide(),$(this,cr,null),f(this,lr)&&(clearTimeout(f(this,lr)),$(this,lr,null)),f(this,hr)&&(clearTimeout(f(this,hr)),$(this,hr,null))}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return f(this,Rf)}get useNewAltTextFlow(){return f(this,Cf)}get useNewAltTextWhenAddingImage(){return f(this,kh)}get hcmFilter(){return Xe(this,"hcmFilter",f(this,vl)?f(this,$f).addHCMFilter(f(this,vl).foreground,f(this,vl).background):"none")}get direction(){return Xe(this,"direction",getComputedStyle(f(this,Zr)).direction)}get highlightColors(){return Xe(this,"highlightColors",f(this,Eh)?new Map(f(this,Eh).split(",").map(e=>e.split("=").map(t=>t.trim()))):null)}get highlightColorNames(){return Xe(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}setMainHighlightColorPicker(e){$(this,Pf,e)}editAltText(e,t=!1){var s;(s=f(this,Sh))==null||s.editAltText(this,e,t)}switchToMode(e,t){this._eventBus.on("annotationeditormodechanged",t,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch("setpreference",{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){switch(e){case"enableNewAltTextWhenAddingImage":$(this,kh,t);break}}onPageChanging({pageNumber:e}){$(this,Ah,e-1)}focusMainContainer(){f(this,Zr).focus()}findParent(e,t){for(const s of f(this,Ln).values()){const{x:i,y:r,width:o,height:a}=s.div.getBoundingClientRect();if(e>=i&&e<=i+o&&t>=r&&t<=r+a)return s}return null}disableUserSelect(e=!1){f(this,Of).classList.toggle("noUserSelect",e)}addShouldRescale(e){f(this,gl).add(e)}removeShouldRescale(e){f(this,gl).delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*Pa.PDF_TO_CSS_UNITS;for(const t of f(this,gl))t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e=""){const t=document.getSelection();if(!t||t.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:r,focusOffset:o}=t,a=t.toString(),c=P(this,ue,wg).call(this,t).closest(".textLayer"),h=this.getSelectionBoxes(c);if(!h)return;t.empty();const u=P(this,ue,Yb).call(this,c),d=f(this,An)===De.NONE,p=()=>{u==null||u.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:h,anchorNode:s,anchorOffset:i,focusNode:r,focusOffset:o,text:a}),d&&this.showAllEditors("highlight",!0,!0)};if(d){this.switchToMode(De.HIGHLIGHT,p);return}p()}addToAnnotationStorage(e){!e.isEmpty()&&f(this,Gr)&&!f(this,Gr).has(e.id)&&f(this,Gr).setValue(e.id,e)}blur(){if(this.isShiftKeyDown=!1,f(this,Xo)&&($(this,Xo,!1),P(this,ue,_g).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const t of f(this,dt))if(t.div.contains(e)){$(this,yl,[t,e]),t._focusEventsAllowed=!1;break}}focus(){if(!f(this,yl))return;const[e,t]=f(this,yl);$(this,yl,null),t.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}addEditListeners(){P(this,ue,Jb).call(this),P(this,ue,Qb).call(this)}removeEditListeners(){P(this,ue,OR).call(this),P(this,ue,ew).call(this)}dragOver(e){for(const{type:t}of e.dataTransfer.items)for(const s of f(this,Ni))if(s.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(const t of e.dataTransfer.items)for(const s of f(this,Ni))if(s.isHandlingMimeForPasting(t.type)){s.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){var s;if(e.preventDefault(),(s=f(this,Ws))==null||s.commitOrRemove(),!this.hasSelection)return;const t=[];for(const i of f(this,dt)){const r=i.serialize(!0);r&&t.push(r)}t.length!==0&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:t}=e;for(const r of t.items)for(const o of f(this,Ni))if(o.isHandlingMimeForPasting(r.type)){o.paste(r,this.currentLayer);return}let s=t.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){qe(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const l of s){const c=await i.deserialize(l);if(!c)return;r.push(c)}const o=()=>{for(const l of r)P(this,ue,tw).call(this,l);P(this,ue,nw).call(this,r)},a=()=>{for(const l of r)l.remove()};this.addCommands({cmd:o,undo:a,mustExec:!0})}catch(r){qe(`paste: "${r.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),f(this,An)!==De.NONE&&!this.isEditorHandlingKeyboard&&rh._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,f(this,Xo)&&($(this,Xo,!1),P(this,ue,_g).call(this,"main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}setEditingState(e){e?(P(this,ue,MR).call(this),P(this,ue,Qb).call(this),P(this,ue,us).call(this,{isEditing:f(this,An)!==De.NONE,isEmpty:P(this,ue,gd).call(this),hasSomethingToUndo:f(this,Oi).hasSomethingToUndo(),hasSomethingToRedo:f(this,Oi).hasSomethingToRedo(),hasSelectedEditor:!1})):(P(this,ue,IR).call(this),P(this,ue,ew).call(this),P(this,ue,us).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!f(this,Ni)){$(this,Ni,e);for(const t of f(this,Ni))P(this,ue,jo).call(this,t.defaultPropertiesToUpdate)}}getId(){return f(this,Zy).id}get currentLayer(){return f(this,Ln).get(f(this,Ah))}getLayer(e){return f(this,Ln).get(e)}get currentPageIndex(){return f(this,Ah)}addLayer(e){f(this,Ln).set(e.pageIndex,e),f(this,Yo)?e.enable():e.disable()}removeLayer(e){f(this,Ln).delete(e.pageIndex)}async updateMode(e,t=null,s=!1){if(f(this,An)!==e&&!(f(this,ci)&&(await f(this,ci).promise,!f(this,ci)))){if($(this,ci,Promise.withResolvers()),$(this,An,e),e===De.NONE){this.setEditingState(!1),P(this,ue,DR).call(this),f(this,ci).resolve();return}this.setEditingState(!0),await P(this,ue,LR).call(this),this.unselectAll();for(const i of f(this,Ln).values())i.updateMode(e);if(!t){s&&this.addNewEditorFromKeyboard(),f(this,ci).resolve();return}for(const i of f(this,cn).values())i.annotationElementId===t?(this.setSelected(i),i.enterInEditMode()):i.unselect();f(this,ci).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==f(this,An)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){var s;if(f(this,Ni)){switch(e){case Pe.CREATE:this.currentLayer.addNewEditor();return;case Pe.HIGHLIGHT_DEFAULT_COLOR:(s=f(this,Pf))==null||s.updateColor(t);break;case Pe.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(f(this,Mf)||$(this,Mf,new Map)).set(e,t),this.showAllEditors("highlight",t);break}for(const i of f(this,dt))i.updateParams(e,t);for(const i of f(this,Ni))i.updateDefaultParams(e,t)}}showAllEditors(e,t,s=!1){var r;for(const o of f(this,cn).values())o.editorType===e&&o.show(t);(((r=f(this,Mf))==null?void 0:r.get(Pe.HIGHLIGHT_SHOW_ALL))??!0)!==t&&P(this,ue,jo).call(this,[[Pe.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(f(this,Tf)!==e){$(this,Tf,e);for(const t of f(this,Ln).values())e?t.disableClick():t.enableClick(),t.div.classList.toggle("waiting",e)}}getEditors(e){const t=[];for(const s of f(this,cn).values())s.pageIndex===e&&t.push(s);return t}getEditor(e){return f(this,cn).get(e)}addEditor(e){f(this,cn).set(e.id,e)}removeEditor(e){var t;e.div.contains(document.activeElement)&&(f(this,lr)&&clearTimeout(f(this,lr)),$(this,lr,setTimeout(()=>{this.focusMainContainer(),$(this,lr,null)},0))),f(this,cn).delete(e.id),this.unselect(e),(!e.annotationElementId||!f(this,ml).has(e.annotationElementId))&&((t=f(this,Gr))==null||t.remove(e.id))}addDeletedAnnotationElement(e){f(this,ml).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return f(this,ml).has(e)}removeDeletedAnnotationElement(e){f(this,ml).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){f(this,Ws)!==e&&($(this,Ws,e),e&&P(this,ue,jo).call(this,e.propertiesToUpdate))}updateUI(e){f(this,ue,jR)===e&&P(this,ue,jo).call(this,e.propertiesToUpdate)}toggleSelected(e){if(f(this,dt).has(e)){f(this,dt).delete(e),e.unselect(),P(this,ue,us).call(this,{hasSelectedEditor:this.hasSelection});return}f(this,dt).add(e),e.select(),P(this,ue,jo).call(this,e.propertiesToUpdate),P(this,ue,us).call(this,{hasSelectedEditor:!0})}setSelected(e){for(const t of f(this,dt))t!==e&&t.unselect();f(this,dt).clear(),f(this,dt).add(e),e.select(),P(this,ue,jo).call(this,e.propertiesToUpdate),P(this,ue,us).call(this,{hasSelectedEditor:!0})}isSelected(e){return f(this,dt).has(e)}get firstSelectedEditor(){return f(this,dt).values().next().value}unselect(e){e.unselect(),f(this,dt).delete(e),P(this,ue,us).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return f(this,dt).size!==0}get isEnterHandled(){return f(this,dt).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){f(this,Oi).undo(),P(this,ue,us).call(this,{hasSomethingToUndo:f(this,Oi).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:P(this,ue,gd).call(this)})}redo(){f(this,Oi).redo(),P(this,ue,us).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:f(this,Oi).hasSomethingToRedo(),isEmpty:P(this,ue,gd).call(this)})}addCommands(e){f(this,Oi).add(e),P(this,ue,us).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:P(this,ue,gd).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const e=[...f(this,dt)],t=()=>{for(const i of e)i.remove()},s=()=>{for(const i of e)P(this,ue,tw).call(this,i)};this.addCommands({cmd:t,undo:s,mustExec:!0})}commitOrRemove(){var e;(e=f(this,Ws))==null||e.commitOrRemove()}hasSomethingToControl(){return f(this,Ws)||this.hasSelection}selectAll(){for(const e of f(this,dt))e.commit();P(this,ue,nw).call(this,f(this,cn).values())}unselectAll(){if(!(f(this,Ws)&&(f(this,Ws).commitOrRemove(),f(this,An)!==De.NONE))&&this.hasSelection){for(const e of f(this,dt))e.unselect();f(this,dt).clear(),P(this,ue,us).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,t,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;f(this,Qo)[0]+=e,f(this,Qo)[1]+=t;const[i,r]=f(this,Qo),o=[...f(this,dt)],a=1e3;f(this,hr)&&clearTimeout(f(this,hr)),$(this,hr,setTimeout(()=>{$(this,hr,null),f(this,Qo)[0]=f(this,Qo)[1]=0,this.addCommands({cmd:()=>{for(const l of o)f(this,cn).has(l.id)&&l.translateInPage(i,r)},undo:()=>{for(const l of o)f(this,cn).has(l.id)&&l.translateInPage(-i,-r)},mustExec:!1})},a));for(const l of o)l.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),$(this,ar,new Map);for(const e of f(this,dt))f(this,ar).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!f(this,ar))return!1;this.disableUserSelect(!1);const e=f(this,ar);$(this,ar,null);let t=!1;for(const[{x:i,y:r,pageIndex:o},a]of e)a.newX=i,a.newY=r,a.newPageIndex=o,t||(t=i!==a.savedX||r!==a.savedY||o!==a.savedPageIndex);if(!t)return!1;const s=(i,r,o,a)=>{if(f(this,cn).has(i.id)){const l=f(this,Ln).get(a);l?i._setParentAndPosition(l,r,o):(i.pageIndex=a,i.x=r,i.y=o)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:o,newPageIndex:a}]of e)s(i,r,o,a)},undo:()=>{for(const[i,{savedX:r,savedY:o,savedPageIndex:a}]of e)s(i,r,o,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(f(this,ar))for(const s of f(this,ar).keys())s.drag(e,t)}rebuild(e){if(e.parent===null){const t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){var e;return((e=this.getActive())==null?void 0:e.shouldGetKeyboardEvents())||f(this,dt).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return f(this,Ws)===e}getActive(){return f(this,Ws)}getMode(){return f(this,An)}get imageManager(){return Xe(this,"imageManager",new Zb)}getSelectionBoxes(e){if(!e)return null;const t=document.getSelection();for(let c=0,h=t.rangeCount;c({x:(h-i)/o,y:1-(c+u-s)/r,width:d/o,height:u/r});break;case"180":a=(c,h,u,d)=>({x:1-(c+u-s)/r,y:1-(h+d-i)/o,width:u/r,height:d/o});break;case"270":a=(c,h,u,d)=>({x:1-(h+d-i)/o,y:(c-s)/r,width:d/o,height:u/r});break;default:a=(c,h,u,d)=>({x:(c-s)/r,y:(h-i)/o,width:u/r,height:d/o});break}const l=[];for(let c=0,h=t.rangeCount;c{d.type==="pointerup"&&d.button!==0||(c.abort(),l==null||l.toggleDrawing(!0),d.type==="pointerup"&&P(this,ue,_g).call(this,"main_toolbar"))};window.addEventListener("pointerup",u,{signal:h}),window.addEventListener("blur",u,{signal:h})}},_g=function(e=""){f(this,An)===De.HIGHLIGHT?this.highlightSelection(e):f(this,Ef)&&P(this,ue,TR).call(this)},RR=function(){document.addEventListener("selectionchange",P(this,ue,PR).bind(this),{signal:this._signal})},MR=function(){if(f(this,Zo))return;$(this,Zo,new AbortController);const e=this.combinedSignal(f(this,Zo));window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})},IR=function(){var e;(e=f(this,Zo))==null||e.abort(),$(this,Zo,null)},Jb=function(){if(f(this,Jo))return;$(this,Jo,new AbortController);const e=this.combinedSignal(f(this,Jo));window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})},OR=function(){var e;(e=f(this,Jo))==null||e.abort(),$(this,Jo,null)},Qb=function(){if(f(this,Ko))return;$(this,Ko,new AbortController);const e=this.combinedSignal(f(this,Ko));document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})},ew=function(){var e;(e=f(this,Ko))==null||e.abort(),$(this,Ko,null)},NR=function(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})},us=function(e){Object.entries(e).some(([s,i])=>f(this,If)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(f(this,If),e)}),f(this,An)===De.HIGHLIGHT&&e.hasSelectedEditor===!1&&P(this,ue,jo).call(this,[[Pe.HIGHLIGHT_FREE,!0]]))},jo=function(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})},LR=async function(){if(!f(this,Yo)){$(this,Yo,!0);const e=[];for(const t of f(this,Ln).values())e.push(t.enable());await Promise.all(e);for(const t of f(this,cn).values())t.enable()}},DR=function(){if(this.unselectAll(),f(this,Yo)){$(this,Yo,!1);for(const e of f(this,Ln).values())e.disable();for(const e of f(this,cn).values())e.disable()}},tw=function(e){const t=f(this,Ln).get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))},jR=function(){let e=null;for(e of f(this,dt));return e},gd=function(){if(f(this,cn).size===0)return!0;if(f(this,cn).size===1)for(const e of f(this,cn).values())return e.isEmpty();return!1},nw=function(e){for(const t of f(this,dt))t.unselect();f(this,dt).clear();for(const t of e)t.isEmpty()||(f(this,dt).add(t),t.select());P(this,ue,us).call(this,{hasSelectedEditor:this.hasSelection})},oe(rh,"TRANSLATE_SMALL",1),oe(rh,"TRANSLATE_BIG",10);let gc=rh;var kn,ur,Li,Ch,dr,Gs,$h,fr,Ps,Xr,bl,pr,ea,Xi,yd,Sg;const ds=class ds{constructor(e){M(this,Xi);M(this,kn,null);M(this,ur,!1);M(this,Li,null);M(this,Ch,null);M(this,dr,null);M(this,Gs,null);M(this,$h,!1);M(this,fr,null);M(this,Ps,null);M(this,Xr,null);M(this,bl,null);M(this,pr,!1);$(this,Ps,e),$(this,pr,e._uiManager.useNewAltTextFlow),f(ds,ea)||$(ds,ea,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){ds._l10n??(ds._l10n=e)}async render(){const e=$(this,Li,document.createElement("button"));e.className="altText",e.tabIndex="0";const t=$(this,Ch,document.createElement("span"));e.append(t),f(this,pr)?(e.classList.add("new"),e.setAttribute("data-l10n-id",f(ds,ea).missing),t.setAttribute("data-l10n-id",f(ds,ea)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=f(this,Ps)._uiManager._signal;e.addEventListener("contextmenu",xi,{signal:s}),e.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),f(this,Ps)._uiManager.editAltText(f(this,Ps)),f(this,pr)&&f(this,Ps)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:f(this,Xi,yd)}})};return e.addEventListener("click",i,{capture:!0,signal:s}),e.addEventListener("keydown",r=>{r.target===e&&r.key==="Enter"&&($(this,$h,!0),i(r))},{signal:s}),await P(this,Xi,Sg).call(this),e}finish(){f(this,Li)&&(f(this,Li).focus({focusVisible:f(this,$h)}),$(this,$h,!1))}isEmpty(){return f(this,pr)?f(this,kn)===null:!f(this,kn)&&!f(this,ur)}hasData(){return f(this,pr)?f(this,kn)!==null||!!f(this,Xr):this.isEmpty()}get guessedText(){return f(this,Xr)}async setGuessedText(e){f(this,kn)===null&&($(this,Xr,e),$(this,bl,await ds._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),P(this,Xi,Sg).call(this))}toggleAltTextBadge(e=!1){var t;if(!f(this,pr)||f(this,kn)){(t=f(this,fr))==null||t.remove(),$(this,fr,null);return}if(!f(this,fr)){const s=$(this,fr,document.createElement("div"));s.className="noAltTextBadge",f(this,Ps).div.append(s)}f(this,fr).classList.toggle("hidden",!e)}serialize(e){let t=f(this,kn);return!e&&f(this,Xr)===t&&(t=f(this,bl)),{altText:t,decorative:f(this,ur),guessedText:f(this,Xr),textWithDisclaimer:f(this,bl)}}get data(){return{altText:f(this,kn),decorative:f(this,ur)}}set data({altText:e,decorative:t,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&($(this,Xr,s),$(this,bl,i)),!(f(this,kn)===e&&f(this,ur)===t)&&(r||($(this,kn,e),$(this,ur,t)),P(this,Xi,Sg).call(this))}toggle(e=!1){f(this,Li)&&(!e&&f(this,Gs)&&(clearTimeout(f(this,Gs)),$(this,Gs,null)),f(this,Li).disabled=!e)}shown(){f(this,Ps)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:f(this,Xi,yd)}})}destroy(){var e,t;(e=f(this,Li))==null||e.remove(),$(this,Li,null),$(this,Ch,null),$(this,dr,null),(t=f(this,fr))==null||t.remove(),$(this,fr,null)}};kn=new WeakMap,ur=new WeakMap,Li=new WeakMap,Ch=new WeakMap,dr=new WeakMap,Gs=new WeakMap,$h=new WeakMap,fr=new WeakMap,Ps=new WeakMap,Xr=new WeakMap,bl=new WeakMap,pr=new WeakMap,ea=new WeakMap,Xi=new WeakSet,yd=function(){return f(this,kn)&&"added"||f(this,kn)===null&&this.guessedText&&"review"||"missing"},Sg=async function(){var i,r,o;const e=f(this,Li);if(!e)return;if(f(this,pr)){if(e.classList.toggle("done",!!f(this,kn)),e.setAttribute("data-l10n-id",f(ds,ea)[f(this,Xi,yd)]),(i=f(this,Ch))==null||i.setAttribute("data-l10n-id",f(ds,ea)[`${f(this,Xi,yd)}-label`]),!f(this,kn)){(r=f(this,dr))==null||r.remove();return}}else{if(!f(this,kn)&&!f(this,ur)){e.classList.remove("done"),(o=f(this,dr))==null||o.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let t=f(this,dr);if(!t){$(this,dr,t=document.createElement("span")),t.className="tooltip",t.setAttribute("role","tooltip"),t.id=`alt-text-tooltip-${f(this,Ps).id}`;const a=100,l=f(this,Ps)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(f(this,Gs)),$(this,Gs,null)},{once:!0}),e.addEventListener("mouseenter",()=>{$(this,Gs,setTimeout(()=>{$(this,Gs,null),f(this,dr).classList.add("show"),f(this,Ps)._reportTelemetry({action:"alt_text_tooltip"})},a))},{signal:l}),e.addEventListener("mouseleave",()=>{var c;f(this,Gs)&&(clearTimeout(f(this,Gs)),$(this,Gs,null)),(c=f(this,dr))==null||c.classList.remove("show")},{signal:l})}f(this,ur)?t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(t.removeAttribute("data-l10n-id"),t.textContent=f(this,kn)),t.parentNode||e.append(t);const s=f(this,Ps).getImageForAltText();s==null||s.setAttribute("aria-describedby",t.id)},M(ds,ea,null),oe(ds,"_l10n",null);let wy=ds;var wl,Di,Ft,Th,_l,Dn,Sl,ta,Nf,xl,na,Lf,Al,Yr,mr,Ph,Rh,hi,Df,Xy,He,sw,jf,iw,rw,FR,zR,ow,aw,lw,HR,cw,BR,UR,qR,hw,vd;const ht=class ht{constructor(e){M(this,He);M(this,wl,null);M(this,Di,null);M(this,Ft,null);M(this,Th,!1);M(this,_l,!1);M(this,Dn,null);M(this,Sl,null);M(this,ta,null);M(this,Nf,"");M(this,xl,!1);M(this,na,null);M(this,Lf,!1);M(this,Al,!1);M(this,Yr,!1);M(this,mr,null);M(this,Ph,0);M(this,Rh,0);M(this,hi,null);oe(this,"_editToolbar",null);oe(this,"_initialOptions",Object.create(null));oe(this,"_initialData",null);oe(this,"_isVisible",!0);oe(this,"_uiManager",null);oe(this,"_focusEventsAllowed",!0);M(this,Df,!1);M(this,Xy,ht._zIndex++);this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;const{rotation:t,rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:o}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,o];const[a,l]=this.parentDimensions;this.x=e.x/a,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=ht.prototype._resizeWithKeyboard,t=gc.TRANSLATE_SMALL,s=gc.TRANSLATE_BIG;return Xe(this,"_resizerKeyboardManager",new tm([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,s]}],[["Escape","mac+Escape"],ht.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return Xe(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const t=new d8({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){if(ht._l10n??(ht._l10n=e),ht._l10nResizer||(ht._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),ht._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);ht._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){Tt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return f(this,Df)}set _isDraggable(e){var t;$(this,Df,e),(t=this.div)==null||t.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){const[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=f(this,Xy)}setParent(e){e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):P(this,He,vd).call(this),this.parent=e}focusin(e){this._focusEventsAllowed&&(f(this,xl)?$(this,xl,!1):this.parent.setSelected(this))}focusout(e){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const t=e.relatedTarget;t!=null&&t.closest(`#${this.id}`)||(e.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,s,i){const[r,o]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(e+s)/r,this.y=(t+i)/o,this.fixAndSetPosition()}translate(e,t){P(this,He,sw).call(this,this.parentDimensions,e,t)}translateInPage(e,t){f(this,na)||$(this,na,[this.x,this.y]),P(this,He,sw).call(this,this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}drag(e,t){f(this,na)||$(this,na,[this.x,this.y]);const[s,i]=this.parentDimensions;if(this.x+=e/s,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:c,y:h}=this.div.getBoundingClientRect();this.parent.findNewParent(this,c,h)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:o}=this;const[a,l]=this.getBaseTranslation();r+=a,o+=l,this.div.style.left=`${(100*r).toFixed(2)}%`,this.div.style.top=`${(100*o).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!f(this,na)&&(f(this,na)[0]!==this.x||f(this,na)[1]!==this.y)}getBaseTranslation(){const[e,t]=this.parentDimensions,{_borderLineWidth:s}=ht,i=s/e,r=s/t;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const[t,s]=this.pageDimensions;let{x:i,y:r,width:o,height:a}=this;if(o*=t,a*=s,i*=t,r*=s,this._mustFixPosition)switch(e){case 0:i=Math.max(0,Math.min(t-o,i)),r=Math.max(0,Math.min(s-a,r));break;case 90:i=Math.max(0,Math.min(t-a,i)),r=Math.min(s,Math.max(o,r));break;case 180:i=Math.min(t,Math.max(o,i)),r=Math.min(s,Math.max(a,r));break;case 270:i=Math.min(t,Math.max(a,i)),r=Math.max(0,Math.min(s-o,r));break}this.x=i/=t,this.y=r/=s;const[l,c]=this.getBaseTranslation();i+=l,r+=c;const{style:h}=this.div;h.left=`${(100*i).toFixed(2)}%`,h.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,t){var s;return P(s=ht,jf,iw).call(s,e,t,this.parentRotation)}pageTranslationToScreen(e,t){var s;return P(s=ht,jf,iw).call(s,e,t,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[t,s]}=this;return[t*e,s*e]}setDims(e,t){const[s,i]=this.parentDimensions;this.div.style.width=`${(100*e/s).toFixed(2)}%`,f(this,_l)||(this.div.style.height=`${(100*t/i).toFixed(2)}%`)}fixDims(){const{style:e}=this.div,{height:t,width:s}=e,i=s.endsWith("%"),r=!f(this,_l)&&t.endsWith("%");if(i&&r)return;const[o,a]=this.parentDimensions;i||(e.width=`${(100*parseFloat(s)/o).toFixed(2)}%`),!f(this,_l)&&!r&&(e.height=`${(100*parseFloat(t)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var e;(e=f(this,Ft))==null||e.finish()}async addEditToolbar(){return this._editToolbar||f(this,Al)?this._editToolbar:(this._editToolbar=new Gb(this),this.div.append(this._editToolbar.render()),f(this,Ft)&&await this._editToolbar.addAltText(f(this,Ft)),this._editToolbar)}removeEditToolbar(){var e;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(e=f(this,Ft))==null||e.destroy())}addContainer(e){var s;const t=(s=this._editToolbar)==null?void 0:s.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){f(this,Ft)||(wy.initialize(ht._l10n),$(this,Ft,new wy(this)),f(this,wl)&&(f(this,Ft).data=f(this,wl),$(this,wl,null)),await this.addEditToolbar())}get altTextData(){var e;return(e=f(this,Ft))==null?void 0:e.data}set altTextData(e){f(this,Ft)&&(f(this,Ft).data=e)}get guessedAltText(){var e;return(e=f(this,Ft))==null?void 0:e.guessedText}async setGuessedAltText(e){var t;await((t=f(this,Ft))==null?void 0:t.setGuessedText(e))}serializeAltText(e){var t;return(t=f(this,Ft))==null?void 0:t.serialize(e)}hasAltText(){return!!f(this,Ft)&&!f(this,Ft).isEmpty()}hasAltTextData(){var e;return((e=f(this,Ft))==null?void 0:e.hasData())??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=f(this,Th)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),P(this,He,cw).call(this);const[e,t]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`);const[s,i]=this.getInitialTranslation();return this.translate(s,i),by(this,this.div,["pointerdown"]),this.div}pointerdown(e){const{isMac:t}=ys.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if($(this,xl,!0),this._isDraggable){P(this,He,HR).call(this,e);return}P(this,He,lw).call(this,e)}get isSelected(){return this._uiManager.isSelected(this)}moveInDOM(){f(this,mr)&&clearTimeout(f(this,mr)),$(this,mr,setTimeout(()=>{var e;$(this,mr,null),(e=this.parent)==null||e.moveEditorInDOM(this)},0))}_setParentAndPosition(e,t,s){e.changeParent(this),this.x=t,this.y=s,this.fixAndSetPosition()}getRect(e,t,s=this.rotation){const i=this.parentScale,[r,o]=this.pageDimensions,[a,l]=this.pageTranslation,c=e/i,h=t/i,u=this.x*r,d=this.y*o,p=this.width*r,m=this.height*o;switch(s){case 0:return[u+c+a,o-d-h-m+l,u+c+p+a,o-d-h+l];case 90:return[u+h+a,o-d+c+l,u+h+m+a,o-d+c+p+l];case 180:return[u-c-p+a,o-d+h+l,u-c+a,o-d+h+m+l];case 270:return[u-h-m+a,o-d-c-p+l,u-h+a,o-d-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){const[s,i,r,o]=e,a=r-s,l=o-i;switch(this.rotation){case 0:return[s,t-o,a,l];case 90:return[s,t-i,l,a];case 180:return[r,t-i,a,l];case 270:return[r,t-o,l,a];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){$(this,Al,!0)}disableEditMode(){$(this,Al,!1)}isInEditMode(){return f(this,Al)}shouldGetKeyboardEvents(){return f(this,Yr)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){P(this,He,cw).call(this)}rotate(e){}serializeDeleted(){var e;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((e=this._initialData)==null?void 0:e.popupRef)||""}}serialize(e=!1,t=null){Tt("An editor must be serializable")}static async deserialize(e,t,s){const i=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:s});i.rotation=e.rotation,$(i,wl,e.accessibilityData);const[r,o]=i.pageDimensions,[a,l,c,h]=i.getRectInCurrentCoords(e.rect,o);return i.x=a/r,i.y=l/o,i.width=c/r,i.height=h/o,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var e;if((e=f(this,ta))==null||e.abort(),$(this,ta,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),f(this,mr)&&(clearTimeout(f(this,mr)),$(this,mr,null)),P(this,He,vd).call(this),this.removeEditToolbar(),f(this,hi)){for(const t of f(this,hi).values())clearTimeout(t);$(this,hi,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(P(this,He,FR).call(this),f(this,Dn).classList.remove("hidden"),by(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),$(this,Sl,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const t=f(this,Dn).children;if(!f(this,Di)){$(this,Di,Array.from(t));const o=P(this,He,BR).bind(this),a=P(this,He,UR).bind(this),l=this._uiManager._signal;for(const c of f(this,Di)){const h=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",o,{signal:l}),c.addEventListener("blur",a,{signal:l}),c.addEventListener("focus",P(this,He,qR).bind(this,h),{signal:l}),c.setAttribute("data-l10n-id",ht._l10nResizer[h])}}const s=f(this,Di)[0];let i=0;for(const o of t){if(o===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(f(this,Di).length/4);if(r!==i){if(ri)for(let a=0;a{var i,r;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(t=this._editToolbar)==null||t.show(),(s=f(this,Ft))==null||s.toggleAltTextBadge(!1)}unselect(){var e,t,s,i,r;(e=f(this,Dn))==null||e.classList.add("hidden"),(t=this.div)==null||t.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(r=f(this,Ft))==null||r.toggleAltTextBadge(!0)}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return f(this,Lf)}set isEditing(e){$(this,Lf,e),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){$(this,_l,!0);const s=e/t,{style:i}=this.div;i.aspectRatio=s,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){f(this,hi)||$(this,hi,new Map);const{action:s}=e;let i=f(this,hi).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(e),f(this,hi).delete(s),f(this,hi).size===0&&$(this,hi,null)},ht._telemetryTimeout),f(this,hi).set(s,i);return}e.type||(e.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),$(this,Th,!1)}disable(){this.div&&(this.div.tabIndex=-1),$(this,Th,!0)}renderAnnotationElement(e){let t=e.container.querySelector(".annotationContent");if(!t)t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.container.prepend(t);else if(t.nodeName==="CANVAS"){const s=t;t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),s.before(t)}return t}resetAnnotationElement(e){const{firstChild:t}=e.container;(t==null?void 0:t.nodeName)==="DIV"&&t.classList.contains("annotationContent")&&t.remove()}};wl=new WeakMap,Di=new WeakMap,Ft=new WeakMap,Th=new WeakMap,_l=new WeakMap,Dn=new WeakMap,Sl=new WeakMap,ta=new WeakMap,Nf=new WeakMap,xl=new WeakMap,na=new WeakMap,Lf=new WeakMap,Al=new WeakMap,Yr=new WeakMap,mr=new WeakMap,Ph=new WeakMap,Rh=new WeakMap,hi=new WeakMap,Df=new WeakMap,Xy=new WeakMap,He=new WeakSet,sw=function([e,t],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/e,this.y+=i/t,this.fixAndSetPosition()},jf=new WeakSet,iw=function(e,t,s){switch(s){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}},rw=function(e){switch(e){case 90:{const[t,s]=this.pageDimensions;return[0,-t/s,s/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,s]=this.pageDimensions;return[0,t/s,-s/t,0]}default:return[1,0,0,1]}},FR=function(){if(f(this,Dn))return;$(this,Dn,document.createElement("div")),f(this,Dn).classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(const s of e){const i=document.createElement("div");f(this,Dn).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",P(this,He,zR).bind(this,s),{signal:t}),i.addEventListener("contextmenu",xi,{signal:t}),i.tabIndex=-1}this.div.prepend(f(this,Dn))},zR=function(e,t){var m;t.preventDefault();const{isMac:s}=ys.platform;if(t.button!==0||t.ctrlKey&&s)return;(m=f(this,Ft))==null||m.toggle(!1);const i=this._isDraggable;this._isDraggable=!1;const r=new AbortController,o=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",P(this,He,aw).bind(this,e),{passive:!0,capture:!0,signal:o}),window.addEventListener("contextmenu",xi,{signal:o});const a=this.x,l=this.y,c=this.width,h=this.height,u=this.parent.div.style.cursor,d=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const p=()=>{var y;r.abort(),this.parent.togglePointerEvents(!0),(y=f(this,Ft))==null||y.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=u,this.div.style.cursor=d,P(this,He,ow).call(this,a,l,c,h)};window.addEventListener("pointerup",p,{signal:o}),window.addEventListener("blur",p,{signal:o})},ow=function(e,t,s,i){const r=this.x,o=this.y,a=this.width,l=this.height;r===e&&o===t&&a===s&&l===i||this.addCommands({cmd:()=>{this.width=a,this.height=l,this.x=r,this.y=o;const[c,h]=this.parentDimensions;this.setDims(c*a,h*l),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=e,this.y=t;const[c,h]=this.parentDimensions;this.setDims(c*s,h*i),this.fixAndSetPosition()},mustExec:!0})},aw=function(e,t){const[s,i]=this.parentDimensions,r=this.x,o=this.y,a=this.width,l=this.height,c=ht.MIN_SIZE/s,h=ht.MIN_SIZE/i,u=J=>Math.round(J*1e4)/1e4,d=P(this,He,rw).call(this,this.rotation),p=(J,Y)=>[d[0]*J+d[2]*Y,d[1]*J+d[3]*Y],m=P(this,He,rw).call(this,360-this.rotation),y=(J,Y)=>[m[0]*J+m[2]*Y,m[1]*J+m[3]*Y];let v,g,_=!1,b=!1;switch(e){case"topLeft":_=!0,v=(J,Y)=>[0,0],g=(J,Y)=>[J,Y];break;case"topMiddle":v=(J,Y)=>[J/2,0],g=(J,Y)=>[J/2,Y];break;case"topRight":_=!0,v=(J,Y)=>[J,0],g=(J,Y)=>[0,Y];break;case"middleRight":b=!0,v=(J,Y)=>[J,Y/2],g=(J,Y)=>[0,Y/2];break;case"bottomRight":_=!0,v=(J,Y)=>[J,Y],g=(J,Y)=>[0,0];break;case"bottomMiddle":v=(J,Y)=>[J/2,Y],g=(J,Y)=>[J/2,0];break;case"bottomLeft":_=!0,v=(J,Y)=>[0,Y],g=(J,Y)=>[J,0];break;case"middleLeft":b=!0,v=(J,Y)=>[0,Y/2],g=(J,Y)=>[J,Y/2];break}const x=v(a,l),A=g(a,l);let T=p(...A);const C=u(r+T[0]),I=u(o+T[1]);let D=1,H=1,[j,U]=this.screenToPageTranslation(t.movementX,t.movementY);if([j,U]=y(j/s,U/i),_){const J=Math.hypot(a,l);D=H=Math.max(Math.min(Math.hypot(A[0]-x[0]-j,A[1]-x[1]-U)/J,1/a,1/l),c/a,h/l)}else b?D=Math.max(c,Math.min(1,Math.abs(A[0]-x[0]-j)))/a:H=Math.max(h,Math.min(1,Math.abs(A[1]-x[1]-U)))/l;const B=u(a*D),L=u(l*H);T=p(...g(B,L));const X=C-T[0],se=I-T[1];this.width=B,this.height=L,this.x=X,this.y=se,this.setDims(s*B,i*L),this.fixAndSetPosition()},lw=function(e){const{isMac:t}=ys.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)},HR=function(e){const{isSelected:t}=this;this._uiManager.setUpDragSession();const s=new AbortController,i=this._uiManager.combinedSignal(s);if(t){this.div.classList.add("moving"),$(this,Ph,e.clientX),$(this,Rh,e.clientY);const o=a=>{const{clientX:l,clientY:c}=a,[h,u]=this.screenToPageTranslation(l-f(this,Ph),c-f(this,Rh));$(this,Ph,l),$(this,Rh,c),this._uiManager.dragSelectedEditors(h,u)};window.addEventListener("pointermove",o,{passive:!0,capture:!0,signal:i})}const r=()=>{s.abort(),t&&this.div.classList.remove("moving"),$(this,xl,!1),this._uiManager.endDragSession()||P(this,He,lw).call(this,e)};window.addEventListener("pointerup",r,{signal:i}),window.addEventListener("blur",r,{signal:i})},cw=function(){if(f(this,ta)||!this.div)return;$(this,ta,new AbortController);const e=this._uiManager.combinedSignal(f(this,ta));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})},BR=function(e){ht._resizerKeyboardManager.exec(this,e)},UR=function(e){var t;f(this,Yr)&&((t=e.relatedTarget)==null?void 0:t.parentNode)!==f(this,Dn)&&P(this,He,vd).call(this)},qR=function(e){$(this,Nf,f(this,Yr)?e:"")},hw=function(e){if(f(this,Di))for(const t of f(this,Di))t.tabIndex=e},vd=function(){if($(this,Yr,!1),P(this,He,hw).call(this,-1),f(this,Sl)){const{savedX:e,savedY:t,savedWidth:s,savedHeight:i}=f(this,Sl);P(this,He,ow).call(this,e,t,s,i),$(this,Sl,null)}},M(ht,jf),oe(ht,"_l10n",null),oe(ht,"_l10nResizer",null),oe(ht,"_borderLineWidth",-1),oe(ht,"_colorManager",new Xb),oe(ht,"_zIndex",1),oe(ht,"_telemetryTimeout",1e3);let pt=ht;class d8 extends pt{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Kk=3285377520,li=4294901760,nr=65535;class VR{constructor(e){this.h1=e?e&4294967295:Kk,this.h2=e?e&4294967295:Kk}update(e){let t,s;if(typeof e=="string"){t=new Uint8Array(e.length*2),s=0;for(let y=0,v=e.length;y>>8,t[s++]=g&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),s=t.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,r=s-i*4,o=new Uint32Array(t.buffer,0,i);let a=0,l=0,c=this.h1,h=this.h2;const u=3432918353,d=461845907,p=u&nr,m=d&nr;for(let y=0;y>>17,a=a*d&li|a*m&nr,c^=a,c=c<<13|c>>>19,c=c*5+3864292196):(l=o[y],l=l*u&li|l*p&nr,l=l<<15|l>>>17,l=l*d&li|l*m&nr,h^=l,h=h<<13|h>>>19,h=h*5+3864292196);switch(a=0,r){case 3:a^=t[i*4+2]<<16;case 2:a^=t[i*4+1]<<8;case 1:a^=t[i*4],a=a*u&li|a*p&nr,a=a<<15|a>>>17,a=a*d&li|a*m&nr,i&1?c^=a:h^=a}this.h1=c,this.h2=h}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&li|e*36045&nr,t=t*4283543511&li|((t<<16|e>>>16)*2950163797&li)>>>16,e^=t>>>1,e=e*444984403&li|e*60499&nr,t=t*3301882366&li|((t<<16|e>>>16)*3120437893&li)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}const uw=Object.freeze({map:null,hash:"",transfer:void 0});var kl,El,En,Yy,WR;class $x{constructor(){M(this,Yy);M(this,kl,!1);M(this,El,null);M(this,En,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){const s=f(this,En).get(e);return s===void 0?t:Object.assign(t,s)}getRawValue(e){return f(this,En).get(e)}remove(e){if(f(this,En).delete(e),f(this,En).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const t of f(this,En).values())if(t instanceof pt)return;this.onAnnotationEditor(null)}}setValue(e,t){const s=f(this,En).get(e);let i=!1;if(s!==void 0)for(const[r,o]of Object.entries(t))s[r]!==o&&(i=!0,s[r]=o);else i=!0,f(this,En).set(e,t);i&&P(this,Yy,WR).call(this),t instanceof pt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(t.constructor._type)}has(e){return f(this,En).has(e)}getAll(){return f(this,En).size>0?Sx(f(this,En)):null}setAll(e){for(const[t,s]of Object.entries(e))this.setValue(t,s)}get size(){return f(this,En).size}resetModified(){f(this,kl)&&($(this,kl,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new GR(this)}get serializable(){if(f(this,En).size===0)return uw;const e=new Map,t=new VR,s=[],i=Object.create(null);let r=!1;for(const[o,a]of f(this,En)){const l=a instanceof pt?a.serialize(!1,i):a;l&&(e.set(o,l),t.update(`${o}:${JSON.stringify(l)}`),r||(r=!!l.bitmap))}if(r)for(const o of e.values())o.bitmap&&s.push(o.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:s}:uw}get editorStats(){let e=null;const t=new Map;for(const s of f(this,En).values()){if(!(s instanceof pt))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:r}=i;t.has(r)||t.set(r,Object.getPrototypeOf(s).constructor),e||(e=Object.create(null));const o=e[r]||(e[r]=new Map);for(const[a,l]of Object.entries(i)){if(a==="type")continue;let c=o.get(a);c||(c=new Map,o.set(a,c));const h=c.get(l)??0;c.set(l,h+1)}}for(const[s,i]of t)e[s]=i.computeTelemetryFinalData(e[s]);return e}resetModifiedIds(){$(this,El,null)}get modifiedIds(){if(f(this,El))return f(this,El);const e=[];for(const t of f(this,En).values())!(t instanceof pt)||!t.annotationElementId||!t.serialize()||e.push(t.annotationElementId);return $(this,El,{ids:new Set(e),hash:e.join(",")})}}kl=new WeakMap,El=new WeakMap,En=new WeakMap,Yy=new WeakSet,WR=function(){f(this,kl)||($(this,kl,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var Ff;class GR extends $x{constructor(t){super();M(this,Ff);const{map:s,hash:i,transfer:r}=t.serializable,o=structuredClone(s,r?{transfer:r}:null);$(this,Ff,{map:o,hash:i,transfer:r})}get print(){Tt("Should not call PrintAnnotationStorage.print")}get serializable(){return f(this,Ff)}get modifiedIds(){return Xe(this,"modifiedIds",{ids:new Set,hash:""})}}Ff=new WeakMap;var Mh;class f8{constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){M(this,Mh,new Set);this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),f(this,Mh).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,_inspectFont:t}){if(!(!e||f(this,Mh).has(e.loadedName))){if(mn(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:r}=e,o=new FontFace(s,i,r);this.addNativeFontFace(o);try{await o.load(),f(this,Mh).add(s),t==null||t(e)}catch{qe(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}Tt("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){const s=e.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw qe(`Failed to load font '${s.family}': '${i}'.`),e.disableFontFace=!0,i}}return}const t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(e,i)})}}get isFontLoadingAPISupported(){var t;const e=!!((t=this._document)!=null&&t.fonts);return Xe(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){let e=!1;return(os||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),Xe(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){function t(){for(mn(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:t,callback:e};return s.push(i),i}get _loadTestFont(){const e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return Xe(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,t){function s(x,A){return x.charCodeAt(A)<<24|x.charCodeAt(A+1)<<16|x.charCodeAt(A+2)<<8|x.charCodeAt(A+3)&255}function i(x,A,T,C){const I=x.substring(0,A),D=x.substring(A+T);return I+C+D}let r,o;const a=this._document.createElement("canvas");a.width=1,a.height=1;const l=a.getContext("2d");let c=0;function h(x,A){if(++c>30){qe("Load test font never loaded."),A();return}if(l.font="30px "+x,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){A();return}setTimeout(h.bind(null,x,A))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let d=this._loadTestFont;d=i(d,976,u.length,u);const m=16,y=1482184792;let v=s(d,m);for(r=0,o=u.length-3;r{b.remove(),t.complete()})}}Mh=new WeakMap;class p8{constructor(e,{disableFontFace:t=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const i in e)this[i]=e[i];this.disableFontFace=t===!0,this._inspectFont=s}createNativeFontFace(){var t;if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(t=this._inspectFont)==null||t.call(this,this),e}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${s8(this.data)});`;let t;if(!this.cssFontInfo)t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}return(s=this._inspectFont)==null||s.call(this,this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let s;try{s=e.get(this.loadedName+"_path_"+t)}catch(r){qe(`getPathGenerator - ignoring character: "${r}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[t]=function(r,o){};const i=[];for(let r=0,o=s.length;rp.bezierCurveTo(a,l,c,h,u,d)),r+=6}break;case Br.MOVE_TO:{const[a,l]=s.slice(r,r+2);i.push(c=>c.moveTo(a,l)),r+=2}break;case Br.LINE_TO:{const[a,l]=s.slice(r,r+2);i.push(c=>c.lineTo(a,l)),r+=2}break;case Br.QUADRATIC_CURVE_TO:{const[a,l,c,h]=s.slice(r,r+4);i.push(u=>u.quadraticCurveTo(a,l,c,h)),r+=4}break;case Br.RESTORE:i.push(a=>a.restore());break;case Br.SAVE:i.push(a=>a.save());break;case Br.SCALE:mn(i.length===2,"Scale command is only valid at the third position.");break;case Br.TRANSFORM:{const[a,l,c,h,u,d]=s.slice(r,r+6);i.push(p=>p.transform(a,l,c,h,u,d)),r+=6}break;case Br.TRANSLATE:{const[a,l]=s.slice(r,r+2);i.push(c=>c.translate(a,l)),r+=2}break}return this.compiledGlyphs[t]=function(o,a){i[0](o),i[1](o),o.scale(a,-a);for(let l=2,c=i.length;l({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)})}async _fetch(e){Tt("Abstract method `_fetch` called.")}}class XR extends ZR{async _fetch(e){const t=await D0(e,this.isCompressed?"arraybuffer":"text");return t instanceof ArrayBuffer?new Uint8Array(t):L0(t)}}class YR{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,t,s,i,r){return"none"}destroy(e=!1){}}var Cl,$l,gr,Jr,ts,Jy,Tl,me,Qn,Bc,Uc,xg,qc,JR,dw,Vc,bd,wd,fw,_d;class g8 extends YR{constructor({docId:t,ownerDocument:s=globalThis.document}){super();M(this,me);M(this,Cl);M(this,$l);M(this,gr);M(this,Jr);M(this,ts);M(this,Jy);M(this,Tl,0);$(this,Jr,t),$(this,ts,s)}addFilter(t){if(!t)return"none";let s=f(this,me,Qn).get(t);if(s)return s;const[i,r,o]=P(this,me,xg).call(this,t),a=t.length===1?i:`${i}${r}${o}`;if(s=f(this,me,Qn).get(a),s)return f(this,me,Qn).set(t,s),s;const l=`g_${f(this,Jr)}_transfer_map_${hs(this,Tl)._++}`,c=P(this,me,qc).call(this,l);f(this,me,Qn).set(t,c),f(this,me,Qn).set(a,c);const h=P(this,me,Vc).call(this,l);return P(this,me,wd).call(this,i,r,o,h),c}addHCMFilter(t,s){var m;const i=`${t}-${s}`,r="base";let o=f(this,me,Bc).get(r);if((o==null?void 0:o.key)===i||(o?((m=o.filter)==null||m.remove(),o.key=i,o.url="none",o.filter=null):(o={key:i,url:"none",filter:null},f(this,me,Bc).set(r,o)),!t||!s))return o.url;const a=P(this,me,_d).call(this,t);t=Se.makeHexColor(...a);const l=P(this,me,_d).call(this,s);if(s=Se.makeHexColor(...l),f(this,me,Uc).style.color="",t==="#000000"&&s==="#ffffff"||t===s)return o.url;const c=new Array(256);for(let y=0;y<=255;y++){const v=y/255;c[y]=v<=.03928?v/12.92:((v+.055)/1.055)**2.4}const h=c.join(","),u=`g_${f(this,Jr)}_hcm_filter`,d=o.filter=P(this,me,Vc).call(this,u);P(this,me,wd).call(this,h,h,h,d),P(this,me,dw).call(this,d);const p=(y,v)=>{const g=a[y]/255,_=l[y]/255,b=new Array(v+1);for(let x=0;x<=v;x++)b[x]=g+x/v*(_-g);return b.join(",")};return P(this,me,wd).call(this,p(0,5),p(1,5),p(2,5),d),o.url=P(this,me,qc).call(this,u),o.url}addAlphaFilter(t){let s=f(this,me,Qn).get(t);if(s)return s;const[i]=P(this,me,xg).call(this,[t]),r=`alpha_${i}`;if(s=f(this,me,Qn).get(r),s)return f(this,me,Qn).set(t,s),s;const o=`g_${f(this,Jr)}_alpha_map_${hs(this,Tl)._++}`,a=P(this,me,qc).call(this,o);f(this,me,Qn).set(t,a),f(this,me,Qn).set(r,a);const l=P(this,me,Vc).call(this,o);return P(this,me,fw).call(this,i,l),a}addLuminosityFilter(t){let s=f(this,me,Qn).get(t||"luminosity");if(s)return s;let i,r;if(t?([i]=P(this,me,xg).call(this,[t]),r=`luminosity_${i}`):r="luminosity",s=f(this,me,Qn).get(r),s)return f(this,me,Qn).set(t,s),s;const o=`g_${f(this,Jr)}_luminosity_map_${hs(this,Tl)._++}`,a=P(this,me,qc).call(this,o);f(this,me,Qn).set(t,a),f(this,me,Qn).set(r,a);const l=P(this,me,Vc).call(this,o);return P(this,me,JR).call(this,l),t&&P(this,me,fw).call(this,i,l),a}addHighlightHCMFilter(t,s,i,r,o){var _;const a=`${s}-${i}-${r}-${o}`;let l=f(this,me,Bc).get(t);if((l==null?void 0:l.key)===a||(l?((_=l.filter)==null||_.remove(),l.key=a,l.url="none",l.filter=null):(l={key:a,url:"none",filter:null},f(this,me,Bc).set(t,l)),!s||!i))return l.url;const[c,h]=[s,i].map(P(this,me,_d).bind(this));let u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[p,m]=[r,o].map(P(this,me,_d).bind(this));d{const T=new Array(256),C=(d-u)/A,I=b/255,D=(x-b)/(255*A);let H=0;for(let j=0;j<=A;j++){const U=Math.round(u+j*C),B=I+j*D;for(let L=H;L<=U;L++)T[L]=B;H=U+1}for(let j=H;j<256;j++)T[j]=T[H-1];return T.join(",")},v=`g_${f(this,Jr)}_hcm_${t}_filter`,g=l.filter=P(this,me,Vc).call(this,v);return P(this,me,dw).call(this,g),P(this,me,wd).call(this,y(p[0],m[0],5),y(p[1],m[1],5),y(p[2],m[2],5),g),l.url=P(this,me,qc).call(this,v),l.url}destroy(t=!1){t&&f(this,me,Bc).size!==0||(f(this,gr)&&(f(this,gr).parentNode.parentNode.remove(),$(this,gr,null)),f(this,$l)&&(f(this,$l).clear(),$(this,$l,null)),$(this,Tl,0))}}Cl=new WeakMap,$l=new WeakMap,gr=new WeakMap,Jr=new WeakMap,ts=new WeakMap,Jy=new WeakMap,Tl=new WeakMap,me=new WeakSet,Qn=function(){return f(this,$l)||$(this,$l,new Map)},Bc=function(){return f(this,Jy)||$(this,Jy,new Map)},Uc=function(){if(!f(this,gr)){const t=f(this,ts).createElement("div"),{style:s}=t;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=f(this,ts).createElementNS(qr,"svg");i.setAttribute("width",0),i.setAttribute("height",0),$(this,gr,f(this,ts).createElementNS(qr,"defs")),t.append(i),i.append(f(this,gr)),f(this,ts).body.append(t)}return f(this,gr)},xg=function(t){if(t.length===1){const c=t[0],h=new Array(256);for(let d=0;d<256;d++)h[d]=c[d]/255;const u=h.join(",");return[u,u,u]}const[s,i,r]=t,o=new Array(256),a=new Array(256),l=new Array(256);for(let c=0;c<256;c++)o[c]=s[c]/255,a[c]=i[c]/255,l[c]=r[c]/255;return[o.join(","),a.join(","),l.join(",")]},qc=function(t){if(f(this,Cl)===void 0){$(this,Cl,"");const s=f(this,ts).URL;s!==f(this,ts).baseURI&&(j0(s)?qe('#createUrl: ignore "data:"-URL for performance reasons.'):$(this,Cl,s.split("#",1)[0]))}return`url(${f(this,Cl)}#${t})`},JR=function(t){const s=f(this,ts).createElementNS(qr,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(s)},dw=function(t){const s=f(this,ts).createElementNS(qr,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(s)},Vc=function(t){const s=f(this,ts).createElementNS(qr,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",t),f(this,me,Uc).append(s),s},bd=function(t,s,i){const r=f(this,ts).createElementNS(qr,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),t.append(r)},wd=function(t,s,i,r){const o=f(this,ts).createElementNS(qr,"feComponentTransfer");r.append(o),P(this,me,bd).call(this,o,"feFuncR",t),P(this,me,bd).call(this,o,"feFuncG",s),P(this,me,bd).call(this,o,"feFuncB",i)},fw=function(t,s){const i=f(this,ts).createElementNS(qr,"feComponentTransfer");s.append(i),P(this,me,bd).call(this,i,"feFuncA",t)},_d=function(t){return f(this,me,Uc).style.color=t,Cx(getComputedStyle(f(this,me,Uc)).getPropertyValue("color"))};class QR{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");const t=`${this.baseUrl}${e}`;return this._fetch(t).catch(s=>{throw new Error(`Unable to load font data at: ${t}`)})}async _fetch(e){Tt("Abstract method `_fetch` called.")}}class eM extends QR{async _fetch(e){const t=await D0(e,"arraybuffer");return new Uint8Array(t)}}if(os){var pw=Promise.withResolvers(),Kd=null;(async()=>{const e=await gm(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),t=await gm(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),s=await gm(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),i=await gm(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);let r,o;return new Map(Object.entries({fs:e,http:t,https:s,url:i,canvas:r,path2d:o}))})().then(e=>{Kd=e,pw.resolve()},e=>{qe(`loadPackages: ${e}`),Kd=new Map,pw.resolve()})}class Ra{static get promise(){return pw.promise}static get(e){return Kd==null?void 0:Kd.get(e)}}async function tM(n){const t=await Ra.get("fs").promises.readFile(n);return new Uint8Array(t)}class y8 extends YR{}class v8 extends KR{_createCanvas(e,t){return Ra.get("canvas").createCanvas(e,t)}}class b8 extends ZR{async _fetch(e){return tM(e)}}class w8 extends QR{async _fetch(e){return tM(e)}}const gs={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function mw(n,e){if(!e)return;const t=e[2]-e[0],s=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],t,s),n.clip(i)}class Tx{getPattern(){Tt("Abstract method `getPattern` called.")}}class _8 extends Tx{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;this._type==="axial"?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)t.addColorStop(s[0],s[1]);return t}getPattern(e,t,s,i){let r;if(i===gs.STROKE||i===gs.FILL){const o=t.current.getClippedPathBoundingBox(i,Ht(e))||[0,0,0,0],a=Math.ceil(o[2]-o[0])||1,l=Math.ceil(o[3]-o[1])||1,c=t.cachedCanvases.getCanvas("pattern",a,l),h=c.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-o[0],-o[1]),s=Se.transform(s,[1,0,0,1,o[0],o[1]]),h.transform(...t.baseTransform),this.matrix&&h.transform(...this.matrix),mw(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),r=e.createPattern(c.canvas,"no-repeat");const u=new DOMMatrix(s);r.setTransform(u)}else mw(e,this._bbox),r=this._createGradient(e);return r}}function Pv(n,e,t,s,i,r,o,a){const l=e.coords,c=e.colors,h=n.data,u=n.width*4;let d;l[t+1]>l[s+1]&&(d=t,t=s,s=d,d=r,r=o,o=d),l[s+1]>l[i+1]&&(d=s,s=i,i=d,d=o,o=a,a=d),l[t+1]>l[s+1]&&(d=t,t=s,s=d,d=r,r=o,o=d);const p=(l[t]+e.offsetX)*e.scaleX,m=(l[t+1]+e.offsetY)*e.scaleY,y=(l[s]+e.offsetX)*e.scaleX,v=(l[s+1]+e.offsetY)*e.scaleY,g=(l[i]+e.offsetX)*e.scaleX,_=(l[i+1]+e.offsetY)*e.scaleY;if(m>=_)return;const b=c[r],x=c[r+1],A=c[r+2],T=c[o],C=c[o+1],I=c[o+2],D=c[a],H=c[a+1],j=c[a+2],U=Math.round(m),B=Math.round(_);let L,X,se,J,Y,ge,z,E;for(let O=U;O<=B;O++){if(O_?G=1:v===_?G=0:G=(v-O)/(v-_),L=y-(y-g)*G,X=T-(T-D)*G,se=C-(C-H)*G,J=I-(I-j)*G}let R;O_?R=1:R=(m-O)/(m-_),Y=p-(p-g)*R,ge=b-(b-D)*R,z=x-(x-H)*R,E=A-(A-j)*R;const w=Math.round(Math.min(L,Y)),k=Math.round(Math.max(L,Y));let N=u*O+w*4;for(let G=w;G<=k;G++)R=(L-G)/(L-Y),R<0?R=0:R>1&&(R=1),h[N++]=X-(X-ge)*R|0,h[N++]=se-(se-z)*R|0,h[N++]=J-(J-E)*R|0,h[N++]=255}}function S8(n,e,t){const s=e.coords,i=e.colors;let r,o;switch(e.type){case"lattice":const a=e.verticesPerRow,l=Math.floor(s.length/a)-1,c=a-1;for(r=0;r=H?x=l:T=!0,D>=j?A=c:C=!0;const U=this.getSizeAndScale(x,this.ctx.canvas.width,_),B=this.getSizeAndScale(A,this.ctx.canvas.height,b),L=e.cachedCanvases.getCanvas("pattern",U.size,B.size),X=L.context,se=a.createCanvasGraphics(X);if(se.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(se,i,o),X.translate(-U.scale*h,-B.scale*u),se.transform(U.scale,0,0,B.scale,0,0),X.save(),this.clipBbox(se,h,u,d,p),se.baseTransform=Ht(se.ctx),se.executeOperatorList(s),se.endDrawing(),X.restore(),T||C){const J=L.canvas;T&&(x=l),C&&(A=c);const Y=this.getSizeAndScale(x,this.ctx.canvas.width,_),ge=this.getSizeAndScale(A,this.ctx.canvas.height,b),z=Y.size,E=ge.size,O=e.cachedCanvases.getCanvas("pattern-workaround",z,E),R=O.context,w=T?Math.floor(m/l):0,k=C?Math.floor(y/c):0;for(let N=0;N<=w;N++)for(let G=0;G<=k;G++)R.drawImage(J,z*N,E*G,z,E,0,0,z,E);return{canvas:O.canvas,scaleX:Y.scale,scaleY:ge.scale,offsetX:h,offsetY:u}}return{canvas:L.canvas,scaleX:U.scale,scaleY:B.scale,offsetX:h,offsetY:u}}getSizeAndScale(e,t,s){const i=Math.max(Qy.MAX_PATTERN_SIZE,t);let r=Math.ceil(e*s);return r>=i?r=i:s=r/e,{scale:s,size:r}}clipBbox(e,t,s,i,r){const o=i-t,a=r-s;e.ctx.rect(t,s,o,a),e.current.updateRectMinMax(Ht(e.ctx),[t,s,i,r]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,s){const i=e.ctx,r=e.current;switch(t){case Zk.COLORED:const o=this.ctx;i.fillStyle=o.fillStyle,i.strokeStyle=o.strokeStyle,r.fillColor=o.fillStyle,r.strokeColor=o.strokeStyle;break;case Zk.UNCOLORED:const a=Se.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,r.fillColor=a,r.strokeColor=a;break;default:throw new X6(`Unsupported paint type: ${t}`)}}getPattern(e,t,s,i){let r=s;i!==gs.SHADING&&(r=Se.transform(r,t.baseTransform),this.matrix&&(r=Se.transform(r,this.matrix)));const o=this.createPatternCanvas(t);let a=new DOMMatrix(r);a=a.translate(o.offsetX,o.offsetY),a=a.scale(1/o.scaleX,1/o.scaleY);const l=e.createPattern(o.canvas,"repeat");return l.setTransform(a),l}};oe(Qy,"MAX_PATTERN_SIZE",3e3);let gw=Qy;function E8({src:n,srcPos:e=0,dest:t,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:o=!1}){const a=ys.isLittleEndian?4278190080:255,[l,c]=o?[r,a]:[a,r],h=s>>3,u=s&7,d=n.length;t=new Uint32Array(t.buffer);let p=0;for(let m=0;m{n.save=n.__originalSave,n.restore=n.__originalRestore,n.rotate=n.__originalRotate,n.scale=n.__originalScale,n.translate=n.__originalTranslate,n.transform=n.__originalTransform,n.setTransform=n.__originalSetTransform,n.resetTransform=n.__originalResetTransform,n.clip=n.__originalClip,n.moveTo=n.__originalMoveTo,n.lineTo=n.__originalLineTo,n.bezierCurveTo=n.__originalBezierCurveTo,n.rect=n.__originalRect,n.closePath=n.__originalClosePath,n.beginPath=n.__originalBeginPath,delete n._removeMirroring},n.save=function(){e.save(),this.__originalSave()},n.restore=function(){e.restore(),this.__originalRestore()},n.translate=function(s,i){e.translate(s,i),this.__originalTranslate(s,i)},n.scale=function(s,i){e.scale(s,i),this.__originalScale(s,i)},n.transform=function(s,i,r,o,a,l){e.transform(s,i,r,o,a,l),this.__originalTransform(s,i,r,o,a,l)},n.setTransform=function(s,i,r,o,a,l){e.setTransform(s,i,r,o,a,l),this.__originalSetTransform(s,i,r,o,a,l)},n.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},n.rotate=function(s){e.rotate(s),this.__originalRotate(s)},n.clip=function(s){e.clip(s),this.__originalClip(s)},n.moveTo=function(t,s){e.moveTo(t,s),this.__originalMoveTo(t,s)},n.lineTo=function(t,s){e.lineTo(t,s),this.__originalLineTo(t,s)},n.bezierCurveTo=function(t,s,i,r,o,a){e.bezierCurveTo(t,s,i,r,o,a),this.__originalBezierCurveTo(t,s,i,r,o,a)},n.rect=function(t,s,i,r){e.rect(t,s,i,r),this.__originalRect(t,s,i,r)},n.closePath=function(){e.closePath(),this.__originalClosePath()},n.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}class T8{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,s){let i;return this.cache[e]!==void 0?(i=this.cache[e],this.canvasFactory.reset(i,t,s)):(i=this.canvasFactory.create(t,s),this.cache[e]=i),i}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}}function Im(n,e,t,s,i,r,o,a,l,c){const[h,u,d,p,m,y]=Ht(n);if(u===0&&d===0){const _=o*h+m,b=Math.round(_),x=a*p+y,A=Math.round(x),T=(o+l)*h+m,C=Math.abs(Math.round(T)-b)||1,I=(a+c)*p+y,D=Math.abs(Math.round(I)-A)||1;return n.setTransform(Math.sign(h),0,0,Math.sign(p),b,A),n.drawImage(e,t,s,i,r,0,0,C,D),n.setTransform(h,u,d,p,m,y),[C,D]}if(h===0&&p===0){const _=a*d+m,b=Math.round(_),x=o*u+y,A=Math.round(x),T=(a+c)*d+m,C=Math.abs(Math.round(T)-b)||1,I=(o+l)*u+y,D=Math.abs(Math.round(I)-A)||1;return n.setTransform(0,Math.sign(u),Math.sign(d),0,b,A),n.drawImage(e,t,s,i,r,0,0,D,C),n.setTransform(h,u,d,p,m,y),[D,C]}n.drawImage(e,t,s,i,r,o,a,l,c);const v=Math.hypot(h,u),g=Math.hypot(d,p);return[v*l,g*c]}function P8(n){const{width:e,height:t}=n;if(e>Qk||t>Qk)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),r=e+1;let o=new Uint8Array(r*(t+1)),a,l,c;const h=e+7&-8;let u=new Uint8Array(h*t),d=0;for(const g of n.data){let _=128;for(;_>0;)u[d++]=g&_?0:255,_>>=1}let p=0;for(d=0,u[d]!==0&&(o[0]=1,++p),l=1;l>2)+(u[d+1]?4:0)+(u[d-h+1]?8:0),i[g]&&(o[c+l]=i[g],++p),d++;if(u[d-h]!==u[d]&&(o[c+l]=u[d]?2:4,++p),p>s)return null}for(d=h*(t-1),c=a*r,u[d]!==0&&(o[c]=8,++p),l=1;ls)return null;const m=new Int32Array([0,r,-1,0,-r,0,0,0,1]),y=new Path2D;for(a=0;p&&a<=t;a++){let g=a*r;const _=g+e;for(;g<_&&!o[g];)g++;if(g===_)continue;y.moveTo(g%r,a);const b=g;let x=o[g];do{const A=m[x];do g+=A;while(!o[g]);const T=o[g];T!==5&&T!==10?(x=T,o[g]=0):(x=T&51*x>>4,o[g]&=x>>2|x<<2),y.lineTo(g%r,g/r|0),o[g]||--p}while(b!==g);--a}return u=null,o=null,function(g){g.save(),g.scale(1/e,-1/t),g.translate(0,-t),g.fill(y),g.beginPath(),g.restore()}}class eE{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=vR,this.textMatrixScale=1,this.fontMatrix=Bb,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=Jn.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,s){[t,s]=Se.applyTransform([t,s],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(e,t){const s=Se.applyTransform(t,e),i=Se.applyTransform(t.slice(2),e),r=Se.applyTransform([t[0],t[3]],e),o=Se.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,s[0],i[0],r[0],o[0]),this.minY=Math.min(this.minY,s[1],i[1],r[1],o[1]),this.maxX=Math.max(this.maxX,s[0],i[0],r[0],o[0]),this.maxY=Math.max(this.maxY,s[1],i[1],r[1],o[1])}updateScalingPathMinMax(e,t){Se.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.minY=Math.min(this.minY,t[1]),this.maxX=Math.max(this.maxX,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,s,i,r,o,a,l,c,h){const u=Se.bezierBoundingBox(t,s,i,r,o,a,l,c,h);h||this.updateRectMinMax(e,u)}getPathBoundingBox(e=gs.FILL,t=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(e===gs.STROKE){t||Tt("Stroke bounding box must include transform.");const i=Se.singularValueDecompose2dScale(t),r=i[0]*this.lineWidth/2,o=i[1]*this.lineWidth/2;s[0]-=r,s[1]-=o,s[2]+=r,s[3]+=o}return s}updateClipFromPath(){const e=Se.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=gs.FILL,t=null){return Se.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function tE(n,e){if(typeof ImageData<"u"&&e instanceof ImageData){n.putImageData(e,0,0);return}const t=e.height,s=e.width,i=t%Ns,r=(t-i)/Ns,o=i===0?r:r+1,a=n.createImageData(s,Ns);let l=0,c;const h=e.data,u=a.data;let d,p,m,y;if(e.kind===gg.GRAYSCALE_1BPP){const v=h.byteLength,g=new Uint32Array(u.buffer,0,u.byteLength>>2),_=g.length,b=s+7>>3,x=4294967295,A=ys.isLittleEndian?4278190080:255;for(d=0;db?s:T*8-7,D=I&-8;let H=0,j=0;for(;C>=1}for(;c<_;)g[c++]=0;n.putImageData(a,0,d*Ns)}}else if(e.kind===gg.RGBA_32BPP){for(p=0,y=s*Ns*4,d=0;d=r&&(m=i,y=s*m),c=0,p=y;p--;)u[c++]=h[l++],u[c++]=h[l++],u[c++]=h[l++],u[c++]=255;n.putImageData(a,0,d*Ns)}else throw new Error(`bad image kind: ${e.kind}`)}function nE(n,e){if(e.bitmap){n.drawImage(e.bitmap,0,0);return}const t=e.height,s=e.width,i=t%Ns,r=(t-i)/Ns,o=i===0?r:r+1,a=n.createImageData(s,Ns);let l=0;const c=e.data,h=a.data;for(let u=0;uJk&&typeof s=="function",h=c?Date.now()+C8:0;let u=0;const d=this.commonObjs,p=this.objs;let m;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,s),a;if(m=o[a],m!==Mi.dependency)this[m].apply(this,r[a]);else for(const y of r[a]){const v=y.startsWith("g_")?d:p;if(!v.has(y))return v.get(y,s),a}if(a++,a===l)return a;if(c&&++u>Jk){if(Date.now()>h)return s(),a;u=0}}}endDrawing(){P(this,Da,yw).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const t of e.values())typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),P(this,Da,vw).call(this)}_scaleImage(e,t){const s=e.width??e.displayWidth,i=e.height??e.displayHeight;let r=Math.max(Math.hypot(t[0],t[1]),1),o=Math.max(Math.hypot(t[2],t[3]),1),a=s,l=i,c="prescale1",h,u;for(;r>2&&a>1||o>2&&l>1;){let d=a,p=l;r>2&&a>1&&(d=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),r/=a/d),o>2&&l>1&&(p=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,o/=l/p),h=this.cachedCanvases.getCanvas(c,d,p),u=h.context,u.clearRect(0,0,d,p),u.drawImage(e,0,0,a,l,0,0,d,p),e=h.canvas,a=d,l=p,c=c==="prescale1"?"prescale2":"prescale1"}return{img:e,paintWidth:a,paintHeight:l}}_createMaskCanvas(e){const t=this.ctx,{width:s,height:i}=e,r=this.current.fillColor,o=this.current.patternFill,a=Ht(t);let l,c,h,u;if((e.bitmap||e.data)&&e.count>1){const I=e.bitmap||e.data.buffer;c=JSON.stringify(o?a:[a.slice(0,4),r]),l=this._cachedBitmapsMap.get(I),l||(l=new Map,this._cachedBitmapsMap.set(I,l));const D=l.get(c);if(D&&!o){const H=Math.round(Math.min(a[0],a[2])+a[4]),j=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:D,offsetX:H,offsetY:j}}h=D}h||(u=this.cachedCanvases.getCanvas("maskCanvas",s,i),nE(u.context,e));let d=Se.transform(a,[1/s,0,0,-1/i,0,0]);d=Se.transform(d,[1,0,0,1,0,-i]);const[p,m,y,v]=Se.getAxialAlignedBoundingBox([0,0,s,i],d),g=Math.round(y-p)||1,_=Math.round(v-m)||1,b=this.cachedCanvases.getCanvas("fillCanvas",g,_),x=b.context,A=p,T=m;x.translate(-A,-T),x.transform(...d),h||(h=this._scaleImage(u.canvas,Ur(x)),h=h.img,l&&o&&l.set(c,h)),x.imageSmoothingEnabled=sE(Ht(x),e.interpolate),Im(x,h,0,0,h.width,h.height,0,0,s,i),x.globalCompositeOperation="source-in";const C=Se.transform(Ur(x),[1,0,0,1,-A,-T]);return x.fillStyle=o?r.getPattern(t,this,C,gs.FILL):r,x.fillRect(0,0,s,i),l&&!o&&(this.cachedCanvases.delete("fillCanvas"),l.set(c,b.canvas)),{canvas:b.canvas,offsetX:Math.round(A),offsetY:Math.round(T)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=R8[e]}setLineJoin(e){this.ctx.lineJoin=M8[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(e),s.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[t,s]of e)switch(t){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,t=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,e,t);this.suspendedCtx=this.ctx,this.ctx=i.context;const r=this.ctx;r.setTransform(...Ht(this.suspendedCtx)),sd(this.suspendedCtx,r),$8(r,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),sd(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,s,i){const r=i[0],o=i[1],a=i[2]-r,l=i[3]-o;a===0||l===0||(this.genericComposeSMask(t.context,s,a,l,t.subtype,t.backdrop,t.transferMap,r,o,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(s.canvas,0,0),e.restore())}genericComposeSMask(e,t,s,i,r,o,a,l,c,h,u){let d=e.canvas,p=l-h,m=c-u;if(o){const v=Se.makeHexColor(...o);if(p<0||m<0||p+s>d.width||m+i>d.height){const g=this.cachedCanvases.getCanvas("maskExtension",s,i),_=g.context;_.drawImage(d,-p,-m),_.globalCompositeOperation="destination-atop",_.fillStyle=v,_.fillRect(0,0,s,i),_.globalCompositeOperation="source-over",d=g.canvas,p=m=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const g=new Path2D;g.rect(p,m,s,i),e.clip(g),e.globalCompositeOperation="destination-atop",e.fillStyle=v,e.fillRect(p,m,s,i),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),r==="Alpha"&&a?t.filter=this.filterFactory.addAlphaFilter(a):r==="Luminosity"&&(t.filter=this.filterFactory.addLuminosityFilter(a));const y=new Path2D;y.rect(l,c,s,i),t.clip(y),t.globalCompositeOperation="destination-in",t.drawImage(d,p,m,s,i,l,c,s,i),t.restore()}save(){this.inSMaskMode?(sd(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),sd(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,s,i,r,o){this.ctx.transform(e,t,s,i,r,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,s){const i=this.ctx,r=this.current;let o=r.x,a=r.y,l,c;const h=Ht(i),u=h[0]===0&&h[3]===0||h[1]===0&&h[2]===0,d=u?s.slice(0):null;for(let p=0,m=0,y=e.length;pYk&&(c=Yk),this.current.fontSizeScale=t/c,this.ctx.font=`${l} ${a} ${c}px ${o}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,s,i,r,o){this.current.textMatrix=[e,t,s,i,r,o],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,t,s,i){const r=this.ctx,o=this.current,a=o.font,l=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,h=l&Jn.FILL_STROKE_MASK,u=!!(l&Jn.ADD_TO_PATH_FLAG),d=o.patternFill&&!a.missingFile;let p;(a.disableFontFace||u||d)&&(p=a.getPathGenerator(this.commonObjs,e)),a.disableFontFace||d?(r.save(),r.translate(t,s),r.beginPath(),p(r,c),i&&r.setTransform(...i),(h===Jn.FILL||h===Jn.FILL_STROKE)&&r.fill(),(h===Jn.STROKE||h===Jn.FILL_STROKE)&&r.stroke(),r.restore()):((h===Jn.FILL||h===Jn.FILL_STROKE)&&r.fillText(e,t,s),(h===Jn.STROKE||h===Jn.FILL_STROKE)&&r.strokeText(e,t,s)),u&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Ht(r),x:t,y:s,fontSize:c,addToPath:p})}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);const t=e.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i0&&t[i]<255){s=!0;break}return Xe(this,"isFontSubpixelAAEnabled",s)}showText(e){const t=this.current,s=t.font;if(s.isType3Font)return this.showType3Text(e);const i=t.fontSize;if(i===0)return;const r=this.ctx,o=t.fontSizeScale,a=t.charSpacing,l=t.wordSpacing,c=t.fontDirection,h=t.textHScale*c,u=e.length,d=s.vertical,p=d?1:-1,m=s.defaultVMetrics,y=i*t.fontMatrix[0],v=t.textRenderingMode===Jn.FILL&&!s.disableFontFace&&!t.patternFill;r.save(),r.transform(...t.textMatrix),r.translate(t.x,t.y+t.textRise),c>0?r.scale(h,-1):r.scale(h,1);let g;if(t.patternFill){r.save();const T=t.fillColor.getPattern(r,this,Ur(r),gs.FILL);g=Ht(r),r.restore(),r.fillStyle=T}let _=t.lineWidth;const b=t.textMatrixScale;if(b===0||_===0){const T=t.textRenderingMode&Jn.FILL_STROKE_MASK;(T===Jn.STROKE||T===Jn.FILL_STROKE)&&(_=this.getSinglePixelWidth())}else _/=b;if(o!==1&&(r.scale(o,o),_/=o),r.lineWidth=_,s.isInvalidPDFjsFont){const T=[];let C=0;for(const I of e)T.push(I.unicode),C+=I.width;r.fillText(T.join(""),0,0),t.x+=C*y*h,r.restore(),this.compose();return}let x=0,A;for(A=0;A0){const X=r.measureText(D).width*1e3/i*o;if(Bnew fA(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new gw(e,s,this.ctx,r,i)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,s){this.ctx.strokeStyle=this.current.strokeColor=Se.makeHexColor(e,t,s)}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent"}setFillRGBColor(e,t,s){this.ctx.fillStyle=this.current.fillColor=Se.makeHexColor(e,t,s),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,t=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=k8(this.getObject(e)),this.cachedPatterns.set(e,s)),t&&(s.matrix=t),s}shadingFill(e){if(!this.contentVisible)return;const t=this.ctx;this.save();const s=this._getPattern(e);t.fillStyle=s.getPattern(t,this,Ur(t),gs.SHADING);const i=Ur(t);if(i){const{width:r,height:o}=t.canvas,[a,l,c,h]=Se.getAxialAlignedBoundingBox([0,0,r,o],i);this.ctx.fillRect(a,l,c-a,h-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Tt("Should not call beginInlineImage")}beginImageData(){Tt("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=Ht(this.ctx),t)){const s=t[2]-t[0],i=t[3]-t[1];this.ctx.rect(t[0],t[1],s,i),this.current.updateRectMinMax(Ht(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const t=this.ctx;e.isolated||O0("TODO: Support non-isolated groups."),e.knockout&&qe("Knockout groups not supported.");const s=Ht(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let i=Se.getAxialAlignedBoundingBox(e.bbox,Ht(t));const r=[0,0,t.canvas.width,t.canvas.height];i=Se.intersect(i,r)||[0,0,0,0];const o=Math.floor(i[0]),a=Math.floor(i[1]),l=Math.max(Math.ceil(i[2])-o,1),c=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,l,c]);let h="groupAt"+this.groupLevel;e.smask&&(h+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(h,l,c),d=u.context;d.translate(-o,-a),d.transform(...s),e.smask?this.smaskStack.push({canvas:u.canvas,context:d,offsetX:o,offsetY:a,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(o,a),t.save()),sd(t,d),this.ctx=d,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;const t=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=Ht(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const r=Se.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],i);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(r)}}beginAnnotation(e,t,s,i,r){if(P(this,Da,yw).call(this),Om(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){const o=t[2]-t[0],a=t[3]-t[1];if(r&&this.annotationCanvasMap){s=s.slice(),s[4]-=t[0],s[5]-=t[1],t=t.slice(),t[0]=t[1]=0,t[2]=o,t[3]=a;const[l,c]=Se.singularValueDecompose2dScale(Ht(this.ctx)),{viewportScale:h}=this,u=Math.ceil(o*this.outputScaleX*h),d=Math.ceil(a*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(u,d);const{canvas:p,context:m}=this.annotationCanvas;this.annotationCanvasMap.set(e,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=m,this.ctx.save(),this.ctx.setTransform(l,0,0,-c,0,a*c),Om(this.ctx)}else Om(this.ctx),this.endPath(),this.ctx.rect(t[0],t[1],o,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new eE(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),P(this,Da,vw).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;const t=e.count;e=this.getObject(e.data,e),e.count=t;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=P8(e)),i.compiled)){i.compiled(s);return}const r=this._createMaskCanvas(e),o=r.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(o,r.offsetX,r.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,s=0,i=0,r,o){if(!this.contentVisible)return;e=this.getObject(e.data,e);const a=this.ctx;a.save();const l=Ht(a);a.transform(t,s,i,r,0,0);const c=this._createMaskCanvas(e);a.setTransform(1,0,0,1,c.offsetX-l[4],c.offsetY-l[5]);for(let h=0,u=o.length;hu?h/u:1,a=c>u?c/u:1}}this._cachedScaleForStroking[0]=o,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(e){const{ctx:t}=this,{lineWidth:s}=this.current,[i,r]=this.getScaleForStroking();if(t.lineWidth=s||1,i===1&&r===1){t.stroke();return}const o=t.getLineDash();if(e&&t.save(),t.scale(i,r),o.length>0){const a=Math.max(i,r);t.setLineDash(o.map(l=>l/a)),t.lineDashOffset/=a}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};Da=new WeakSet,yw=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},vw=function(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!=="none"){const t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}};let hh=fA;for(const n in Mi)hh.prototype[n]!==void 0&&(hh.prototype[Mi[n]]=hh.prototype[n]);var Hf,Bf;class vo{static get workerPort(){return f(this,Hf)}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw new Error("Invalid `workerPort` type.");$(this,Hf,e)}static get workerSrc(){return f(this,Bf)}static set workerSrc(e){if(typeof e!="string")throw new Error("Invalid `workerSrc` type.");$(this,Bf,e)}}Hf=new WeakMap,Bf=new WeakMap,M(vo,Hf,null),M(vo,Bf,"");const Nm={DATA:1,ERROR:2},nn={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function qs(n){switch(n instanceof Error||typeof n=="object"&&n!==null||Tt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),n.name){case"AbortException":return new Tc(n.message);case"MissingPDFException":return new $c(n.message);case"PasswordException":return new Ub(n.message,n.code);case"UnexpectedResponseException":return new N0(n.message,n.status);case"UnknownErrorException":return new qb(n.message,n.details);default:return new qb(n.message,n.toString())}}var Ih,Si,nM,sM,iM,Ag;class Sd{constructor(e,t,s){M(this,Si);M(this,Ih,new AbortController);this.sourceName=e,this.targetName=t,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",P(this,Si,nM).bind(this),{signal:f(this,Ih).signal})}on(e,t){const s=this.actionHandler;if(s[e])throw new Error(`There is already an actionName called "${e}"`);s[e]=t}send(e,t,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},s)}sendWithPromise(e,t,s){const i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},s)}catch(o){r.reject(o)}return r.promise}sendWithStream(e,t,s,i){const r=this.streamId++,o=this.sourceName,a=this.targetName,l=this.comObj;return new ReadableStream({start:c=>{const h=Promise.withResolvers();return this.streamControllers[r]={controller:c,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:o,targetName:a,action:e,streamId:r,data:t,desiredSize:c.desiredSize},i),h.promise},pull:c=>{const h=Promise.withResolvers();return this.streamControllers[r].pullCall=h,l.postMessage({sourceName:o,targetName:a,stream:nn.PULL,streamId:r,desiredSize:c.desiredSize}),h.promise},cancel:c=>{mn(c instanceof Error,"cancel must have a valid reason");const h=Promise.withResolvers();return this.streamControllers[r].cancelCall=h,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:o,targetName:a,stream:nn.CANCEL,streamId:r,reason:qs(c)}),h.promise}},s)}destroy(){var e;(e=f(this,Ih))==null||e.abort(),$(this,Ih,null)}}Ih=new WeakMap,Si=new WeakSet,nM=function({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){P(this,Si,iM).call(this,e);return}if(e.callback){const s=e.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],e.callback===Nm.DATA)i.resolve(e.data);else if(e.callback===Nm.ERROR)i.reject(qs(e.reason));else throw new Error("Unexpected callback case");return}const t=this.actionHandler[e.action];if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const s=this.sourceName,i=e.sourceName,r=this.comObj;new Promise(function(o){o(t(e.data))}).then(function(o){r.postMessage({sourceName:s,targetName:i,callback:Nm.DATA,callbackId:e.callbackId,data:o})},function(o){r.postMessage({sourceName:s,targetName:i,callback:Nm.ERROR,callbackId:e.callbackId,reason:qs(o)})});return}if(e.streamId){P(this,Si,sM).call(this,e);return}t(e.data)},sM=function(e){const t=e.streamId,s=this.sourceName,i=e.sourceName,r=this.comObj,o=this,a=this.actionHandler[e.action],l={enqueue(c,h=1,u){if(this.isCancelled)return;const d=this.desiredSize;this.desiredSize-=h,d>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:nn.ENQUEUE,streamId:t,chunk:c},u)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:nn.CLOSE,streamId:t}),delete o.streamSinks[t])},error(c){mn(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:nn.ERROR,streamId:t,reason:qs(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[t]=l,new Promise(function(c){c(a(e.data,l))}).then(function(){r.postMessage({sourceName:s,targetName:i,stream:nn.START_COMPLETE,streamId:t,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:nn.START_COMPLETE,streamId:t,reason:qs(c)})})},iM=function(e){const t=e.streamId,s=this.sourceName,i=e.sourceName,r=this.comObj,o=this.streamControllers[t],a=this.streamSinks[t];switch(e.stream){case nn.START_COMPLETE:e.success?o.startCall.resolve():o.startCall.reject(qs(e.reason));break;case nn.PULL_COMPLETE:e.success?o.pullCall.resolve():o.pullCall.reject(qs(e.reason));break;case nn.PULL:if(!a){r.postMessage({sourceName:s,targetName:i,stream:nn.PULL_COMPLETE,streamId:t,success:!0});break}a.desiredSize<=0&&e.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=e.desiredSize,new Promise(function(l){var c;l((c=a.onPull)==null?void 0:c.call(a))}).then(function(){r.postMessage({sourceName:s,targetName:i,stream:nn.PULL_COMPLETE,streamId:t,success:!0})},function(l){r.postMessage({sourceName:s,targetName:i,stream:nn.PULL_COMPLETE,streamId:t,reason:qs(l)})});break;case nn.ENQUEUE:if(mn(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(e.chunk);break;case nn.CLOSE:if(mn(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),P(this,Si,Ag).call(this,o,t);break;case nn.ERROR:mn(o,"error should have stream controller"),o.controller.error(qs(e.reason)),P(this,Si,Ag).call(this,o,t);break;case nn.CANCEL_COMPLETE:e.success?o.cancelCall.resolve():o.cancelCall.reject(qs(e.reason)),P(this,Si,Ag).call(this,o,t);break;case nn.CANCEL:if(!a)break;new Promise(function(l){var c;l((c=a.onCancel)==null?void 0:c.call(a,qs(e.reason)))}).then(function(){r.postMessage({sourceName:s,targetName:i,stream:nn.CANCEL_COMPLETE,streamId:t,success:!0})},function(l){r.postMessage({sourceName:s,targetName:i,stream:nn.CANCEL_COMPLETE,streamId:t,reason:qs(l)})}),a.sinkCapability.reject(qs(e.reason)),a.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}},Ag=async function(e,t){var s,i,r;await Promise.allSettled([(s=e.startCall)==null?void 0:s.promise,(i=e.pullCall)==null?void 0:i.promise,(r=e.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[t]};var Pl,Uf;class O8{constructor({parsedData:e,rawData:t}){M(this,Pl);M(this,Uf);$(this,Pl,e),$(this,Uf,t)}getRaw(){return f(this,Uf)}get(e){return f(this,Pl).get(e)??null}getAll(){return Sx(f(this,Pl))}has(e){return f(this,Pl).has(e)}}Pl=new WeakMap,Uf=new WeakMap;const Wc=Symbol("INTERNAL");var qf,Vf,Wf,Oh;class N8{constructor(e,{name:t,intent:s,usage:i,rbGroups:r}){M(this,qf,!1);M(this,Vf,!1);M(this,Wf,!1);M(this,Oh,!0);$(this,qf,!!(e&ei.DISPLAY)),$(this,Vf,!!(e&ei.PRINT)),this.name=t,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(f(this,Wf))return f(this,Oh);if(!f(this,Oh))return!1;const{print:e,view:t}=this.usage;return f(this,qf)?(t==null?void 0:t.viewState)!=="OFF":f(this,Vf)?(e==null?void 0:e.printState)!=="OFF":!0}_setVisible(e,t,s=!1){e!==Wc&&Tt("Internal method `_setVisible` called."),$(this,Wf,s),$(this,Oh,t)}}qf=new WeakMap,Vf=new WeakMap,Wf=new WeakMap,Oh=new WeakMap;var sa,ft,Nh,Lh,Gf,bw;class L8{constructor(e,t=ei.DISPLAY){M(this,Gf);M(this,sa,null);M(this,ft,new Map);M(this,Nh,null);M(this,Lh,null);if(this.renderingIntent=t,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,$(this,Lh,e.order);for(const s of e.groups)f(this,ft).set(s.id,new N8(t,s));if(e.baseState==="OFF")for(const s of f(this,ft).values())s._setVisible(Wc,!1);for(const s of e.on)f(this,ft).get(s)._setVisible(Wc,!0);for(const s of e.off)f(this,ft).get(s)._setVisible(Wc,!1);$(this,Nh,this.getHash())}}isVisible(e){if(f(this,ft).size===0)return!0;if(!e)return O0("Optional content group not defined."),!0;if(e.type==="OCG")return f(this,ft).has(e.id)?f(this,ft).get(e.id).visible:(qe(`Optional content group not found: ${e.id}`),!0);if(e.type==="OCMD"){if(e.expression)return P(this,Gf,bw).call(this,e.expression);if(!e.policy||e.policy==="AnyOn"){for(const t of e.ids){if(!f(this,ft).has(t))return qe(`Optional content group not found: ${t}`),!0;if(f(this,ft).get(t).visible)return!0}return!1}else if(e.policy==="AllOn"){for(const t of e.ids){if(!f(this,ft).has(t))return qe(`Optional content group not found: ${t}`),!0;if(!f(this,ft).get(t).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(const t of e.ids){if(!f(this,ft).has(t))return qe(`Optional content group not found: ${t}`),!0;if(!f(this,ft).get(t).visible)return!0}return!1}else if(e.policy==="AllOff"){for(const t of e.ids){if(!f(this,ft).has(t))return qe(`Optional content group not found: ${t}`),!0;if(f(this,ft).get(t).visible)return!1}return!0}return qe(`Unknown optional content policy ${e.policy}.`),!0}return qe(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,s=!0){var r;const i=f(this,ft).get(e);if(!i){qe(`Optional content group not found: ${e}`);return}if(s&&t&&i.rbGroups.length)for(const o of i.rbGroups)for(const a of o)a!==e&&((r=f(this,ft).get(a))==null||r._setVisible(Wc,!1,!0));i._setVisible(Wc,!!t,!0),$(this,sa,null)}setOCGState({state:e,preserveRB:t}){let s;for(const i of e){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const r=f(this,ft).get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,t);break;case"OFF":this.setVisibility(i,!1,t);break;case"Toggle":this.setVisibility(i,!r.visible,t);break}}$(this,sa,null)}get hasInitialVisibility(){return f(this,Nh)===null||this.getHash()===f(this,Nh)}getOrder(){return f(this,ft).size?f(this,Lh)?f(this,Lh).slice():[...f(this,ft).keys()]:null}getGroups(){return f(this,ft).size>0?Sx(f(this,ft)):null}getGroup(e){return f(this,ft).get(e)||null}getHash(){if(f(this,sa)!==null)return f(this,sa);const e=new VR;for(const[t,s]of f(this,ft))e.update(`${t}:${s.visible}`);return $(this,sa,e.hexdigest())}}sa=new WeakMap,ft=new WeakMap,Nh=new WeakMap,Lh=new WeakMap,Gf=new WeakSet,bw=function(e){const t=e.length;if(t<2)return!0;const s=e[0];for(let i=1;i0){const l=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!s,this._isRangeSupported=!t,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((l,c)=>{this._onReceiveData({begin:l,chunk:c})}),e.addProgressListener((l,c)=>{this._onProgress({loaded:l,total:c})}),e.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:t}){const s=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;if(e===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(r){return r._begin!==e?!1:(r._enqueue(s),!0)});mn(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}_onProgress(e){var t,s,i,r;e.total===void 0?(s=(t=this._rangeReaders[0])==null?void 0:t.onProgress)==null||s.call(t,{loaded:e.loaded}):(r=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||r.call(i,{loaded:e.loaded,total:e.total})}_onProgressiveDone(){var e;(e=this._fullRequestReader)==null||e.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){mn(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new j8(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const s=new F8(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(s),s}cancelAllRequests(e){var t;(t=this._fullRequestReader)==null||t.cancel(e);for(const s of this._rangeReaders.slice(0))s.cancel(e);this._pdfDataRangeTransport.abort()}}class j8{constructor(e,t,s=!1,i=null){this._stream=e,this._done=s||!1,this._filename=kx(i)?i:null,this._queuedChunks=t||[],this._loaded=0;for(const r of this._queuedChunks)this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class F8{constructor(e,t,s){this._stream=e,this._begin=t,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length===0)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function z8(n){let e=!0,t=s("filename\\*","i").exec(n);if(t){t=t[1];let h=a(t);return h=unescape(h),h=l(h),h=c(h),r(h)}if(t=o(n),t){const h=c(t);return r(h)}if(t=s("filename","i").exec(n),t){t=t[1];let h=a(t);return h=c(h),r(h)}function s(h,u){return new RegExp("(?:^|;)\\s*"+h+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function i(h,u){if(h){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const d=new TextDecoder(h,{fatal:!0}),p=L0(u);u=d.decode(p),e=!1}catch{}}return u}function r(h){return e&&/[\x80-\xff]/.test(h)&&(h=i("utf-8",h),e&&(h=i("iso-8859-1",h))),h}function o(h){const u=[];let d;const p=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(d=p.exec(h))!==null;){let[,y,v,g]=d;if(y=parseInt(y,10),y in u){if(y===0)break;continue}u[y]=[v,g]}const m=[];for(let y=0;y{if(!rM(r.status))throw F0(r.status,i);this._reader=r.body.getReader(),this._headersCapability.resolve();const o=r.headers,{allowRangeRequests:a,suggestedLength:l}=Rx({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=l||this._contentLength,this._filename=Mx(o),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Tc("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:aM(e),done:!1})}cancel(e){var t;(t=this._reader)==null||t.cancel(e),this._abortController.abort()}}class B8{constructor(e,t,s){this._stream=e,this._reader=null,this._loaded=0;const i=e.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;const r=new Headers(e.headers);r.append("Range",`bytes=${t}-${s-1}`);const o=i.url;fetch(o,oM(r,this._withCredentials,this._abortController)).then(a=>{if(!rM(a.status))throw F0(a.status,o);this._readCapability.resolve(),this._reader=a.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:aM(e),done:!1})}cancel(e){var t;(t=this._reader)==null||t.cancel(e),this._abortController.abort()}}const Rv=200,Mv=206;function U8(n){const e=n.response;return typeof e!="string"?e:L0(e).buffer}class q8{constructor({url:e,httpHeaders:t,withCredentials:s}){this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=Px(this.isHttp,t),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(e,t,s){const i={begin:e,end:t};for(const r in s)i[r]=s[r];return this.request(i)}requestFull(e){return this.request(e)}request(e){const t=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:t};t.open("GET",this.url),t.withCredentials=this.withCredentials;for(const[r,o]of this.headers)t.setRequestHeader(r,o);return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.expectedStatus=Mv):i.expectedStatus=Rv,t.responseType="arraybuffer",e.onError&&(t.onerror=function(r){e.onError(t.status)}),t.onreadystatechange=this.onStateChange.bind(this,s),t.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=e.onHeadersReceived,i.onDone=e.onDone,i.onError=e.onError,i.onProgress=e.onProgress,t.send(null),s}onProgress(e,t){var i;const s=this.pendingRequests[e];s&&((i=s.onProgress)==null||i.call(s,t))}onStateChange(e,t){var l,c,h;const s=this.pendingRequests[e];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],i.status===0&&this.isHttp){(l=s.onError)==null||l.call(s,i.status);return}const r=i.status||Rv;if(!(r===Rv&&s.expectedStatus===Mv)&&r!==s.expectedStatus){(c=s.onError)==null||c.call(s,i.status);return}const a=U8(i);if(r===Mv){const u=i.getResponseHeader("Content-Range"),d=/bytes (\d+)-(\d+)\/(\d+)/.exec(u);s.onDone({begin:parseInt(d[1],10),chunk:a})}else a?s.onDone({begin:0,chunk:a}):(h=s.onError)==null||h.call(s,i.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}class V8{constructor(e){this._source=e,this._manager=new q8(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return mn(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new W8(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){const s=new G8(this._manager,e,t);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(e){var t;(t=this._fullRequestReader)==null||t.cancel(e);for(const s of this._rangeRequestReaders.slice(0))s.cancel(e)}}class W8{constructor(e,t){this._manager=e;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._fullRequestId=e.requestFull(s),this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,t=this._manager.getRequestXhr(e),s=new Headers(t.getAllResponseHeaders().trim().split(/[\r\n]+/).map(o=>{const[a,...l]=o.split(": ");return[a,l.join(": ")]})),{allowRangeRequests:i,suggestedLength:r}=Rx({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=Mx(s),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=F0(e,this._url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){var t;(t=this.onProgress)==null||t.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class G8{constructor(e,t,s){this._manager=e;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._requestId=e.requestRange(t,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var e;(e=this.onClosed)==null||e.call(this,this)}_onDone(e){const t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError=F0(e,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){var t;this.isStreamingSupported||(t=this.onProgress)==null||t.call(this,{loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const K8=/^[a-z][a-z0-9\-+.]+:/i;function Z8(n){if(K8.test(n))return new URL(n);const e=Ra.get("url");return new URL(e.pathToFileURL(n))}function lM(n,e,t){return n.protocol==="http:"?Ra.get("http").request(n,{headers:e},t):Ra.get("https").request(n,{headers:e},t)}class X8{constructor(e){this.source=e,this.url=Z8(e.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.headers=Px(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}getFullReader(){return mn(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new Q8(this):new Y8(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const s=this.isFsUrl?new eZ(this,e,t):new J8(this,e,t);return this._rangeRequestReaders.push(s),s}cancelAllRequests(e){var t;(t=this._fullRequestReader)==null||t.cancel(e);for(const s of this._rangeRequestReaders.slice(0))s.cancel(e)}}class cM{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Tc("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class hM{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const t=e.source;this._isStreamingSupported=!t.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}class Y8 extends cM{constructor(e){super(e);const t=Object.fromEntries(e.headers),s=i=>{if(i.statusCode===404){const l=new $c(`Missing PDF "${this._url}".`);this._storedError=l,this._headersCapability.reject(l);return}this._headersCapability.resolve(),this._setReadableStream(i);const r=new Headers(this._readableStream.headers),{allowRangeRequests:o,suggestedLength:a}=Rx({responseHeaders:r,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=a||this._contentLength,this._filename=Mx(r)};this._request=lM(this._url,t,s),this._request.on("error",i=>{this._storedError=i,this._headersCapability.reject(i)}),this._request.end()}}class J8 extends hM{constructor(e,t,s){super(e);const i=Object.fromEntries(e.headers);i.Range=`bytes=${t}-${s-1}`;const r=o=>{if(o.statusCode===404){const a=new $c(`Missing PDF "${this._url}".`);this._storedError=a;return}this._setReadableStream(o)};this._request=lM(this._url,i,r),this._request.on("error",o=>{this._storedError=o}),this._request.end()}}class Q8 extends cM{constructor(e){super(e);const t=Ra.get("fs");t.promises.lstat(this._url).then(s=>{this._contentLength=s.size,this._setReadableStream(t.createReadStream(this._url)),this._headersCapability.resolve()},s=>{s.code==="ENOENT"&&(s=new $c(`Missing PDF "${this._url}".`)),this._storedError=s,this._headersCapability.reject(s)})}}class eZ extends hM{constructor(e,t,s){super(e);const i=Ra.get("fs");this._setReadableStream(i.createReadStream(this._url,{start:t,end:s-1}))}}const tZ=1e5,$s=30,nZ=.8;var GC,ia,Rs,Kf,Zf,Rl,Qr,Xf,Yf,Ml,Dh,jh,ra,Fh,Jf,zh,Il,Qf,ep,Wt,Ol,Nl,tp,oa,Hh,Po,uM,dM,_w,ii,kg,Sw,fM,pM;let ww=(Wt=class{constructor({textContentSource:e,container:t,viewport:s}){M(this,Po);M(this,ia,Promise.withResolvers());M(this,Rs,null);M(this,Kf,!1);M(this,Zf,!!((GC=globalThis.FontInspector)!=null&&GC.enabled));M(this,Rl,null);M(this,Qr,null);M(this,Xf,0);M(this,Yf,0);M(this,Ml,null);M(this,Dh,null);M(this,jh,0);M(this,ra,0);M(this,Fh,Object.create(null));M(this,Jf,[]);M(this,zh,null);M(this,Il,[]);M(this,Qf,new WeakMap);M(this,ep,null);var l;if(e instanceof ReadableStream)$(this,zh,e);else if(typeof e=="object")$(this,zh,new ReadableStream({start(c){c.enqueue(e),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');$(this,Rs,$(this,Dh,t)),$(this,ra,s.scale*(globalThis.devicePixelRatio||1)),$(this,jh,s.rotation),$(this,Qr,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:r,pageX:o,pageY:a}=s.rawDims;$(this,ep,[1,0,0,-1,-o,a+r]),$(this,Yf,i),$(this,Xf,r),P(l=Wt,ii,fM).call(l),mc(t,s),f(this,ia).promise.finally(()=>{f(Wt,Hh).delete(this),$(this,Qr,null),$(this,Fh,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:e,isFirefox:t}=ys.platform;return Xe(this,"fontFamilyMap",new Map([["sans-serif",`${e&&t?"Calibri, ":""}sans-serif`],["monospace",`${e&&t?"Lucida Console, ":""}monospace`]]))}render(){const e=()=>{f(this,Ml).read().then(({value:t,done:s})=>{if(s){f(this,ia).resolve();return}f(this,Rl)??$(this,Rl,t.lang),Object.assign(f(this,Fh),t.styles),P(this,Po,uM).call(this,t.items),e()},f(this,ia).reject)};return $(this,Ml,f(this,zh).getReader()),f(Wt,Hh).add(this),e(),f(this,ia).promise}update({viewport:e,onBefore:t=null}){var r;const s=e.scale*(globalThis.devicePixelRatio||1),i=e.rotation;if(i!==f(this,jh)&&(t==null||t(),$(this,jh,i),mc(f(this,Dh),{rotation:i})),s!==f(this,ra)){t==null||t(),$(this,ra,s);const o={div:null,properties:null,ctx:P(r=Wt,ii,kg).call(r,f(this,Rl))};for(const a of f(this,Il))o.properties=f(this,Qf).get(a),o.div=a,P(this,Po,_w).call(this,o)}}cancel(){var t;const e=new Tc("TextLayer task cancelled.");(t=f(this,Ml))==null||t.cancel(e).catch(()=>{}),$(this,Ml,null),f(this,ia).reject(e)}get textDivs(){return f(this,Il)}get textContentItemsStr(){return f(this,Jf)}static cleanup(){if(!(f(this,Hh).size>0)){f(this,Ol).clear();for(const{canvas:e}of f(this,Nl).values())e.remove();f(this,Nl).clear()}}},ia=new WeakMap,Rs=new WeakMap,Kf=new WeakMap,Zf=new WeakMap,Rl=new WeakMap,Qr=new WeakMap,Xf=new WeakMap,Yf=new WeakMap,Ml=new WeakMap,Dh=new WeakMap,jh=new WeakMap,ra=new WeakMap,Fh=new WeakMap,Jf=new WeakMap,zh=new WeakMap,Il=new WeakMap,Qf=new WeakMap,ep=new WeakMap,Ol=new WeakMap,Nl=new WeakMap,tp=new WeakMap,oa=new WeakMap,Hh=new WeakMap,Po=new WeakSet,uM=function(e){var i,r;if(f(this,Kf))return;(r=f(this,Qr)).ctx??(r.ctx=P(i=Wt,ii,kg).call(i,f(this,Rl)));const t=f(this,Il),s=f(this,Jf);for(const o of e){if(t.length>tZ){qe("Ignoring additional textDivs for performance reasons."),$(this,Kf,!0);return}if(o.str===void 0){if(o.type==="beginMarkedContentProps"||o.type==="beginMarkedContent"){const a=f(this,Rs);$(this,Rs,document.createElement("span")),f(this,Rs).classList.add("markedContent"),o.id!==null&&f(this,Rs).setAttribute("id",`${o.id}`),a.append(f(this,Rs))}else o.type==="endMarkedContent"&&$(this,Rs,f(this,Rs).parentNode);continue}s.push(o.str),P(this,Po,dM).call(this,o)}},dM=function(e){var y;const t=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};f(this,Il).push(t);const i=Se.transform(f(this,ep),e.transform);let r=Math.atan2(i[1],i[0]);const o=f(this,Fh)[e.fontName];o.vertical&&(r+=Math.PI/2);let a=f(this,Zf)&&o.fontSubstitution||o.fontFamily;a=Wt.fontFamilyMap.get(a)||a;const l=Math.hypot(i[2],i[3]),c=l*P(y=Wt,ii,pM).call(y,a,f(this,Rl));let h,u;r===0?(h=i[4],u=i[5]-c):(h=i[4]+c*Math.sin(r),u=i[5]-c*Math.cos(r));const d="calc(var(--scale-factor)*",p=t.style;f(this,Rs)===f(this,Dh)?(p.left=`${(100*h/f(this,Yf)).toFixed(2)}%`,p.top=`${(100*u/f(this,Xf)).toFixed(2)}%`):(p.left=`${d}${h.toFixed(2)}px)`,p.top=`${d}${u.toFixed(2)}px)`),p.fontSize=`${d}${(f(Wt,oa)*l).toFixed(2)}px)`,p.fontFamily=a,s.fontSize=l,t.setAttribute("role","presentation"),t.textContent=e.str,t.dir=e.dir,f(this,Zf)&&(t.dataset.fontName=o.fontSubstitutionLoadedName||e.fontName),r!==0&&(s.angle=r*(180/Math.PI));let m=!1;if(e.str.length>1)m=!0;else if(e.str!==" "&&e.transform[0]!==e.transform[3]){const v=Math.abs(e.transform[0]),g=Math.abs(e.transform[3]);v!==g&&Math.max(v,g)/Math.min(v,g)>1.5&&(m=!0)}if(m&&(s.canvasWidth=o.vertical?e.height:e.width),f(this,Qf).set(t,s),f(this,Qr).div=t,f(this,Qr).properties=s,P(this,Po,_w).call(this,f(this,Qr)),s.hasText&&f(this,Rs).append(t),s.hasEOL){const v=document.createElement("br");v.setAttribute("role","presentation"),f(this,Rs).append(v)}},_w=function(e){var a;const{div:t,properties:s,ctx:i}=e,{style:r}=t;let o="";if(f(Wt,oa)>1&&(o=`scale(${1/f(Wt,oa)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=r,{canvasWidth:c,fontSize:h}=s;P(a=Wt,ii,Sw).call(a,i,h*f(this,ra),l);const{width:u}=i.measureText(t.textContent);u>0&&(o=`scaleX(${c*f(this,ra)/u}) ${o}`)}s.angle!==0&&(o=`rotate(${s.angle}deg) ${o}`),o.length>0&&(r.transform=o)},ii=new WeakSet,kg=function(e=null){let t=f(this,Nl).get(e||(e=""));if(!t){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=e,document.body.append(s),t=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),f(this,Nl).set(e,t),f(this,tp).set(t,{size:0,family:""})}return t},Sw=function(e,t,s){const i=f(this,tp).get(e);t===i.size&&s===i.family||(e.font=`${t}px ${s}`,i.size=t,i.family=s)},fM=function(){if(f(this,oa)!==null)return;const e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),$(this,oa,e.getBoundingClientRect().height),e.remove()},pM=function(e,t){const s=f(this,Ol).get(e);if(s)return s;const i=P(this,ii,kg).call(this,t);i.canvas.width=i.canvas.height=$s,P(this,ii,Sw).call(this,i,$s,e);const r=i.measureText("");let o=r.fontBoundingBoxAscent,a=Math.abs(r.fontBoundingBoxDescent);if(o){const h=o/(o+a);return f(this,Ol).set(e,h),i.canvas.width=i.canvas.height=0,h}i.strokeStyle="red",i.clearRect(0,0,$s,$s),i.strokeText("g",0,0);let l=i.getImageData(0,0,$s,$s).data;a=0;for(let h=l.length-1-3;h>=0;h-=4)if(l[h]>0){a=Math.ceil(h/4/$s);break}i.clearRect(0,0,$s,$s),i.strokeText("A",0,$s),l=i.getImageData(0,0,$s,$s).data,o=0;for(let h=0,u=l.length;h0){o=$s-Math.floor(h/4/$s);break}i.canvas.width=i.canvas.height=0;const c=o?o/(o+a):nZ;return f(this,Ol).set(e,c),c},M(Wt,ii),M(Wt,Ol,new Map),M(Wt,Nl,new Map),M(Wt,tp,new WeakMap),M(Wt,oa,null),M(Wt,Hh,new Set),Wt);class cf{static textContent(e){const t=[],s={items:t,styles:Object.create(null)};function i(r){var l;if(!r)return;let o=null;const a=r.name;if(a==="#text")o=r.value;else if(cf.shouldBuildText(a))(l=r==null?void 0:r.attributes)!=null&&l.textContent?o=r.attributes.textContent:r.value&&(o=r.value);else return;if(o!==null&&t.push({str:o}),!!r.children)for(const c of r.children)i(c)}return i(e),s}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}}const sZ=65536,iZ=100,rZ=5e3,oZ=os?v8:m8,aZ=os?b8:XR,lZ=os?y8:g8,cZ=os?w8:eM;function hZ(n={}){typeof n=="string"||n instanceof URL?n={url:n}:(n instanceof ArrayBuffer||ArrayBuffer.isView(n))&&(n={data:n});const e=new xw,{docId:t}=e,s=n.url?uZ(n.url):null,i=n.data?dZ(n.data):null,r=n.httpHeaders||null,o=n.withCredentials===!0,a=n.password??null,l=n.range instanceof mM?n.range:null,c=Number.isInteger(n.rangeChunkSize)&&n.rangeChunkSize>0?n.rangeChunkSize:sZ;let h=n.worker instanceof uh?n.worker:null;const u=n.verbosity,d=typeof n.docBaseUrl=="string"&&!j0(n.docBaseUrl)?n.docBaseUrl:null,p=typeof n.cMapUrl=="string"?n.cMapUrl:null,m=n.cMapPacked!==!1,y=n.CMapReaderFactory||aZ,v=typeof n.standardFontDataUrl=="string"?n.standardFontDataUrl:null,g=n.StandardFontDataFactory||cZ,_=n.stopAtErrors!==!0,b=Number.isInteger(n.maxImageSize)&&n.maxImageSize>-1?n.maxImageSize:-1,x=n.isEvalSupported!==!1,A=typeof n.isOffscreenCanvasSupported=="boolean"?n.isOffscreenCanvasSupported:!os,T=typeof n.isChrome=="boolean"?n.isChrome:!ys.platform.isFirefox&&typeof window<"u"&&!!(window!=null&&window.chrome),C=Number.isInteger(n.canvasMaxAreaInBytes)?n.canvasMaxAreaInBytes:-1,I=typeof n.disableFontFace=="boolean"?n.disableFontFace:os,D=n.fontExtraProperties===!0,H=n.enableXfa===!0,j=n.ownerDocument||globalThis.document,U=n.disableRange===!0,B=n.disableStream===!0,L=n.disableAutoFetch===!0,X=n.pdfBug===!0,se=n.CanvasFactory||oZ,J=n.FilterFactory||lZ,Y=n.enableHWA===!0,ge=l?l.length:n.length??NaN,z=typeof n.useSystemFonts=="boolean"?n.useSystemFonts:!os&&!I,E=typeof n.useWorkerFetch=="boolean"?n.useWorkerFetch:y===XR&&g===eM&&p&&v&&md(p,document.baseURI)&&md(v,document.baseURI);n.canvasFactory&&Gk("`canvasFactory`-instance option, please use `CanvasFactory` instead."),n.filterFactory&&Gk("`filterFactory`-instance option, please use `FilterFactory` instead.");const O=null;W6(u);const R={canvasFactory:new se({ownerDocument:j,enableHWA:Y}),filterFactory:new J({docId:t,ownerDocument:j}),cMapReaderFactory:E?null:new y({baseUrl:p,isCompressed:m}),standardFontDataFactory:E?null:new g({baseUrl:v})};if(!h){const N={verbosity:u,port:vo.workerPort};h=N.port?uh.fromPort(N):new uh(N),e._worker=h}const w={docId:t,apiVersion:"4.8.69",data:i,password:a,disableAutoFetch:L,rangeChunkSize:c,length:ge,docBaseUrl:d,enableXfa:H,evaluatorOptions:{maxImageSize:b,disableFontFace:I,ignoreErrors:_,isEvalSupported:x,isOffscreenCanvasSupported:A,isChrome:T,canvasMaxAreaInBytes:C,fontExtraProperties:D,useSystemFonts:z,cMapUrl:E?p:null,standardFontDataUrl:E?v:null}},k={disableFontFace:I,fontExtraProperties:D,ownerDocument:j,pdfBug:X,styleElement:O,loadingParams:{disableAutoFetch:L,enableXfa:H}};return h.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const N=h.messageHandler.sendWithPromise("GetDocRequest",w,i?[i.buffer]:null);let G;if(l)G=new D8(l,{disableRange:U,disableStream:B});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let Z;os?Z=typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&md(s)?rE:X8:Z=md(s)?rE:V8,G=new Z({url:s,length:ge,httpHeaders:r,withCredentials:o,rangeChunkSize:c,disableRange:U,disableStream:B})}return N.then(Z=>{if(e.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const ae=new Sd(t,Z,h.port),ie=new gZ(ae,e,G,k,R);e._transport=ie,ae.send("Ready",null)})}).catch(e._capability.reject),e}function uZ(n){if(n instanceof URL)return n.href;try{return new URL(n,window.location).href}catch{if(os&&typeof n=="string")return n}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function dZ(n){if(os&&typeof Buffer<"u"&&n instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength)return n;if(typeof n=="string")return L0(n);if(n instanceof ArrayBuffer||ArrayBuffer.isView(n)||typeof n=="object"&&!isNaN(n==null?void 0:n.length))return new Uint8Array(n);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function oE(n){return typeof n=="object"&&Number.isInteger(n==null?void 0:n.num)&&n.num>=0&&Number.isInteger(n==null?void 0:n.gen)&&n.gen>=0}var e0;const t0=class t0{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${hs(t0,e0)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var e,t,s;this.destroyed=!0;try{(e=this._worker)!=null&&e.port&&(this._worker._pendingDestroy=!0),await((t=this._transport)==null?void 0:t.destroy())}catch(i){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,i}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};e0=new WeakMap,M(t0,e0,0);let xw=t0,mM=class{constructor(e,t,s=!1,i=null){this.length=e,this.initialData=t,this.progressiveDone=s,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(const s of this._rangeListeners)s(e,t)}onDataProgress(e,t){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(e,t)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(const t of this._progressiveReadListeners)t(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){Tt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class fZ{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Xe(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var aa,eo,yi,Gc,Eg;class pZ{constructor(e,t,s,i=!1){M(this,yi);M(this,aa,null);M(this,eo,!1);this._pageIndex=e,this._pageInfo=t,this._transport=s,this._stats=i?new Wk:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new gM,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new em({viewBox:this.view,scale:e,rotation:t,offsetX:s,offsetY:i,dontFlip:r})}getAnnotations({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Xe(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var e;return((e=this._transport._htmlForXfa)==null?void 0:e.children[this._pageIndex])||null}render({canvasContext:e,viewport:t,intent:s="display",annotationMode:i=Uo.ENABLE,transform:r=null,background:o=null,optionalContentConfigPromise:a=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:h=null,isEditing:u=!1}){var x,A;(x=this._stats)==null||x.time("Overall");const d=this._transport.getRenderingIntent(s,i,h,u),{renderingIntent:p,cacheKey:m}=d;$(this,eo,!1),P(this,yi,Eg).call(this),a||(a=this._transport.getOptionalContentConfig(p));let y=this._intentStates.get(m);y||(y=Object.create(null),this._intentStates.set(m,y)),y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);const v=!!(p&ei.PRINT);y.displayReadyCapability||(y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(A=this._stats)==null||A.time("Page Request"),this._pumpOperatorList(d));const g=T=>{var C;y.renderTasks.delete(_),(this._maybeCleanupAfterRender||v)&&$(this,eo,!0),P(this,yi,Gc).call(this,!v),T?(_.capability.reject(T),this._abortOperatorList({intentState:y,reason:T instanceof Error?T:new Error(T)})):_.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(C=globalThis.Stats)!=null&&C.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},_=new kw({callback:g,params:{canvasContext:e,viewport:t,transform:r,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:y.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:c});(y.renderTasks||(y.renderTasks=new Set)).add(_);const b=_.task;return Promise.all([y.displayReadyCapability.promise,a]).then(([T,C])=>{var I;if(this.destroyed){g();return}if((I=this._stats)==null||I.time("Rendering"),!(C.renderingIntent&p))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:T,optionalContentConfig:C}),_.operatorListChanged()}).catch(g),b}getOperatorList({intent:e="display",annotationMode:t=Uo.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var c;function r(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(l))}const o=this._transport.getRenderingIntent(e,t,s,i,!0);let a=this._intentStates.get(o.cacheKey);a||(a=Object.create(null),this._intentStates.set(o.cacheKey,a));let l;return a.opListReadCapability||(l=Object.create(null),l.operatorListChanged=r,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||(a.renderTasks=new Set)).add(l),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(o)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:t===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>cf.textContent(s));const t=this.streamTextContent(e);return new Promise(function(s,i){function r(){o.read().then(function({value:l,done:c}){if(c){s(a);return}a.lang??(a.lang=l.lang),Object.assign(a.styles,l.styles),a.items.push(...l.items),r()},i)}const o=t.getReader(),a={items:[],styles:Object.create(null),lang:null};r()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(const s of t.renderTasks)e.push(s.completed),s.cancel();return this.objs.clear(),$(this,eo,!1),P(this,yi,Eg).call(this),Promise.all(e)}cleanup(e=!1){$(this,eo,!0);const t=P(this,yi,Gc).call(this,!1);return e&&t&&this._stats&&(this._stats=new Wk),t}_startRenderPage(e,t){var i,r;const s=this._intentStates.get(t);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(e))}_renderPageChunk(e,t){for(let s=0,i=e.length;s{l.read().then(({value:u,done:d})=>{if(d){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,c),h())},u=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const d of c.renderTasks)d.operatorListChanged();P(this,yi,Gc).call(this,!0)}if(c.displayReadyCapability)c.displayReadyCapability.reject(u);else if(c.opListReadCapability)c.opListReadCapability.reject(u);else throw u}})};h()}_abortOperatorList({intentState:e,reason:t,force:s=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!s){if(e.renderTasks.size>0)return;if(t instanceof Ax){let i=iZ;t.extraDelay>0&&t.extraDelay<1e3&&(i+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},i);return}}if(e.streamReader.cancel(new Tc(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===e){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}aa=new WeakMap,eo=new WeakMap,yi=new WeakSet,Gc=function(e=!1){if(P(this,yi,Eg).call(this),!f(this,eo)||this.destroyed)return!1;if(e)return $(this,aa,setTimeout(()=>{$(this,aa,null),P(this,yi,Gc).call(this,!1)},rZ)),!1;for(const{renderTasks:t,operatorList:s}of this._intentStates.values())if(t.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),$(this,eo,!1),!0},Eg=function(){f(this,aa)&&(clearTimeout(f(this,aa)),$(this,aa,null))};var to,n0;class mZ{constructor(){M(this,to,new Map);M(this,n0,Promise.resolve())}postMessage(e,t){const s={data:structuredClone(e,t?{transfer:t}:null)};f(this,n0).then(()=>{for(const[i]of f(this,to))i.call(this,s)})}addEventListener(e,t,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){qe("LoopbackPort - cannot use an `aborted` signal.");return}const o=()=>this.removeEventListener(e,t);i=()=>r.removeEventListener("abort",o),r.addEventListener("abort",o)}f(this,to).set(t,i)}removeEventListener(e,t){const s=f(this,to).get(t);s==null||s(),f(this,to).delete(t)}terminate(){for(const[,e]of f(this,to))e==null||e();f(this,to).clear()}}to=new WeakMap,n0=new WeakMap;var s0,Ll,Dl,Bh,Cg,Uh,$g;const Mt=class Mt{constructor({name:e=null,port:t=null,verbosity:s=G6()}={}){M(this,Bh);var i;if(this.name=e,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,t){if((i=f(Mt,Dl))!=null&&i.has(t))throw new Error("Cannot use more than one PDFWorker per port.");(f(Mt,Dl)||$(Mt,Dl,new WeakMap)).set(t,this),this._initializeFromPort(t);return}this._initialize()}get promise(){return os?Promise.all([Ra.promise,this._readyCapability.promise]):this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new Sd("main","worker",e),this._messageHandler.on("ready",function(){}),P(this,Bh,Cg).call(this)}_initialize(){if(f(Mt,Ll)||f(Mt,Uh,$g)){this._setupFakeWorker();return}let{workerSrc:e}=Mt;try{Mt._isSameOrigin(window.location.href,e)||(e=Mt._createCDNWrapper(new URL(e,window.location).href));const t=new Worker(e,{type:"module"}),s=new Sd("main","worker",t),i=()=>{r.abort(),s.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;t.addEventListener("error",()=>{this._webWorker||i()},{signal:r.signal}),s.on("test",a=>{if(r.abort(),this.destroyed||!a){i();return}this._messageHandler=s,this._port=t,this._webWorker=t,P(this,Bh,Cg).call(this)}),s.on("ready",a=>{if(r.abort(),this.destroyed){i();return}try{o()}catch{this._setupFakeWorker()}});const o=()=>{const a=new Uint8Array;s.send("test",a,[a.buffer])};o();return}catch{O0("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){f(Mt,Ll)||(qe("Setting up fake worker."),$(Mt,Ll,!0)),Mt._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const t=new mZ;this._port=t;const s=`fake${hs(Mt,s0)._++}`,i=new Sd(s+"_worker",s,t);e.setup(i,t),this._messageHandler=new Sd(s,s+"_worker",t),P(this,Bh,Cg).call(this)}).catch(e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){var e;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(e=f(Mt,Dl))==null||e.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(e){var s;if(!(e!=null&&e.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const t=(s=f(this,Dl))==null?void 0:s.get(e.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new Mt(e)}static get workerSrc(){if(vo.workerSrc)return vo.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return Xe(this,"_setupFakeWorkerGlobal",(async()=>f(this,Uh,$g)?f(this,Uh,$g):(await import(this.workerSrc)).WorkerMessageHandler)())}};s0=new WeakMap,Ll=new WeakMap,Dl=new WeakMap,Bh=new WeakSet,Cg=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Uh=new WeakSet,$g=function(){var e;try{return((e=globalThis.pdfjsWorker)==null?void 0:e.WorkerMessageHandler)||null}catch{return null}},M(Mt,Uh),M(Mt,s0,0),M(Mt,Ll,!1),M(Mt,Dl),os&&($(Mt,Ll,!0),vo.workerSrc||(vo.workerSrc="./pdf.worker.mjs")),Mt._isSameOrigin=(e,t)=>{let s;try{if(s=new URL(e),!s.origin||s.origin==="null")return!1}catch{return!1}const i=new URL(t,s);return s.origin===i.origin},Mt._createCDNWrapper=e=>{const t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};let uh=Mt;var no,yr,qh,Vh,vr,jl,xd;class gZ{constructor(e,t,s,i,r){M(this,jl);M(this,no,new Map);M(this,yr,new Map);M(this,qh,new Map);M(this,Vh,new Map);M(this,vr,null);this.messageHandler=e,this.loadingTask=t,this.commonObjs=new gM,this.fontLoader=new f8({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return Xe(this,"annotationStorage",new $x)}getRenderingIntent(e,t=Uo.ENABLE,s=null,i=!1,r=!1){let o=ei.DISPLAY,a=uw;switch(e){case"any":o=ei.ANY;break;case"display":break;case"print":o=ei.PRINT;break;default:qe(`getRenderingIntent - invalid intent: ${e}`)}const l=o&ei.PRINT&&s instanceof GR?s:this.annotationStorage;switch(t){case Uo.DISABLE:o+=ei.ANNOTATIONS_DISABLE;break;case Uo.ENABLE:break;case Uo.ENABLE_FORMS:o+=ei.ANNOTATIONS_FORMS;break;case Uo.ENABLE_STORAGE:o+=ei.ANNOTATIONS_STORAGE,a=l.serializable;break;default:qe(`getRenderingIntent - invalid annotationMode: ${t}`)}i&&(o+=ei.IS_EDITING),r&&(o+=ei.OPLIST);const{ids:c,hash:h}=l.modifiedIds,u=[o,a.hash,h];return{renderingIntent:o,cacheKey:u.join("_"),annotationStorageSerializable:a,modifiedIds:c}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=f(this,vr))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const i of f(this,yr).values())e.push(i._destroy());f(this,yr).clear(),f(this,qh).clear(),f(this,Vh).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then(()=>{var i;this.commonObjs.clear(),this.fontLoader.clear(),f(this,no).clear(),this.filterFactory.destroy(),ww.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new Tc("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(s,i)=>{mn(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},i.onPull=()=>{this._fullReader.read().then(function({value:r,done:o}){if(o){i.close();return}mn(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{this._fullReader.cancel(r),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),e.on("ReaderHeadersReady",async s=>{var a;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:o}=this._fullReader;return(!i||!r)&&(this._lastProgress&&((a=t.onProgress)==null||a.call(t,this._lastProgress)),this._fullReader.onProgress=l=>{var c;(c=t.onProgress)==null||c.call(t,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:i,isRangeSupported:r,contentLength:o}}),e.on("GetRangeReader",(s,i)=>{mn(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const r=this._networkStream.getRangeReader(s.begin,s.end);if(!r){i.close();return}i.onPull=()=>{r.read().then(function({value:o,done:a}){if(a){i.close();return}mn(o instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(o),1,[o])}).catch(o=>{i.error(o)})},i.onCancel=o=>{r.cancel(o),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),e.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,t._capability.resolve(new fZ(s,this))}),e.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new Ub(s.message,s.code);break;case"InvalidPDFException":i=new bR(s.message);break;case"MissingPDFException":i=new $c(s.message);break;case"UnexpectedResponseException":i=new N0(s.message,s.status);break;case"UnknownErrorException":i=new qb(s.message,s.details);break;default:Tt("DocException - expected a valid Error.")}t._capability.reject(i)}),e.on("PasswordRequest",s=>{if($(this,vr,Promise.withResolvers()),t.onPassword){const i=r=>{r instanceof Error?f(this,vr).reject(r):f(this,vr).resolve({password:r})};try{t.onPassword(i,s.code)}catch(r){f(this,vr).reject(r)}}else f(this,vr).reject(new Ub(s.message,s.code));return f(this,vr).promise}),e.on("DataLoaded",s=>{var i;(i=t.onProgress)==null||i.call(t,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),e.on("StartRenderPage",s=>{if(this.destroyed)return;f(this,yr).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),e.on("commonobj",([s,i,r])=>{var o;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:a,fontExtraProperties:l,pdfBug:c}=this._params;if("error"in r){const p=r.error;qe(`Error during font loading: ${p}`),this.commonObjs.resolve(s,p);break}const h=c&&((o=globalThis.FontInspector)!=null&&o.enabled)?(p,m)=>globalThis.FontInspector.fontAdded(p,m):null,u=new p8(r,{disableFontFace:a,inspectFont:h});this.fontLoader.bind(u).catch(()=>e.sendWithPromise("FontFallback",{id:s})).finally(()=>{!l&&u.data&&(u.data=null),this.commonObjs.resolve(s,u)});break;case"CopyLocalImage":const{imageRef:d}=r;mn(d,"The imageRef must be defined.");for(const p of f(this,yr).values())for(const[,m]of p.objs)if((m==null?void 0:m.ref)===d)return m.dataLen?(this.commonObjs.resolve(s,structuredClone(m)),m.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,r);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),e.on("obj",([s,i,r,o])=>{var l;if(this.destroyed)return;const a=f(this,yr).get(i);if(!a.objs.has(s)){if(a._intentStates.size===0){(l=o==null?void 0:o.bitmap)==null||l.close();return}switch(r){case"Image":a.objs.resolve(s,o),(o==null?void 0:o.dataLen)>B6&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(s,o);break;default:throw new Error(`Got unknown object type ${r}`)}}}),e.on("DocProgress",s=>{var i;this.destroyed||(i=t.onProgress)==null||i.call(t,{loaded:s.loaded,total:s.total})}),e.on("FetchBuiltInCMap",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(s)}),e.on("FetchStandardFontData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&qe("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:((s=this._fullReader)==null?void 0:s.filename)??null},t).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const t=e-1,s=f(this,qh).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&f(this,Vh).set(r.refStr,e);const o=new pZ(t,r,this,this._params.pdfBug);return f(this,yr).set(t,o),o});return f(this,qh).set(t,i),i}getPageIndex(e){return oE(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return P(this,jl,xd).call(this,"GetFieldObjects")}hasJSActions(){return P(this,jl,xd).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return typeof e!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return P(this,jl,xd).call(this,"GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return P(this,jl,xd).call(this,"GetOptionalContentConfig").then(t=>new L8(t,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",t=f(this,no).get(e);if(t)return t;const s=this.messageHandler.sendWithPromise(e,null).then(i=>{var r,o;return{info:i[0],metadata:i[1]?new O8(i[1]):null,contentDispositionFilename:((r=this._fullReader)==null?void 0:r.filename)??null,contentLength:((o=this._fullReader)==null?void 0:o.contentLength)??null}});return f(this,no).set(e,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of f(this,yr).values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),f(this,no).clear(),this.filterFactory.destroy(!0),ww.cleanup()}}cachedPageNumber(e){if(!oE(e))return null;const t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return f(this,Vh).get(t)??null}}no=new WeakMap,yr=new WeakMap,qh=new WeakMap,Vh=new WeakMap,vr=new WeakMap,jl=new WeakSet,xd=function(e,t=null){const s=f(this,no).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise(e,t);return f(this,no).set(e,i),i};const Lm=Symbol("INITIAL_DATA");var ji,np,Aw;class gM{constructor(){M(this,np);M(this,ji,Object.create(null))}get(e,t=null){if(t){const i=P(this,np,Aw).call(this,e);return i.promise.then(()=>t(i.data)),null}const s=f(this,ji)[e];if(!s||s.data===Lm)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return s.data}has(e){const t=f(this,ji)[e];return!!t&&t.data!==Lm}resolve(e,t=null){const s=P(this,np,Aw).call(this,e);s.data=t,s.resolve()}clear(){var e;for(const t in f(this,ji)){const{data:s}=f(this,ji)[t];(e=s==null?void 0:s.bitmap)==null||e.close()}$(this,ji,Object.create(null))}*[Symbol.iterator](){for(const e in f(this,ji)){const{data:t}=f(this,ji)[e];t!==Lm&&(yield[e,t])}}}ji=new WeakMap,np=new WeakSet,Aw=function(e){var t;return(t=f(this,ji))[e]||(t[e]={...Promise.withResolvers(),data:Lm})};var la;class yZ{constructor(e){M(this,la,null);$(this,la,e),this.onContinue=null}get promise(){return f(this,la).capability.promise}cancel(e=0){f(this,la).cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=f(this,la).operatorList;if(!e)return!1;const{annotationCanvasMap:t}=f(this,la);return e.form||e.canvas&&(t==null?void 0:t.size)>0}}la=new WeakMap;var ca,Fl;const ll=class ll{constructor({callback:e,params:t,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:o,pageIndex:a,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:u=!1,pageColors:d=null}){M(this,ca,null);this.callback=e,this.params=t,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=a,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new yZ(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){var a,l;if(this.cancelled)return;if(this._canvas){if(f(ll,Fl).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");f(ll,Fl).add(this._canvas)}this._pdfBug&&((a=globalThis.StepperManager)!=null&&a.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:r,background:o}=this.params;this.gfx=new hh(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:r,viewport:i,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,(l=this.graphicsReadyCallback)==null||l.call(this)}cancel(e=null,t=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),f(this,ca)&&(window.cancelAnimationFrame(f(this,ca)),$(this,ca,null)),f(ll,Fl).delete(this._canvas),this.callback(e||new Ax(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){var e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(e=this.stepper)==null||e.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?$(this,ca,window.requestAnimationFrame(()=>{$(this,ca,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),f(ll,Fl).delete(this._canvas),this.callback())))}};ca=new WeakMap,Fl=new WeakMap,M(ll,Fl,new WeakSet);let kw=ll;const vZ="4.8.69",bZ="3634dab10";function aE(n){return Math.floor(Math.max(0,Math.min(1,n))*255).toString(16).padStart(2,"0")}function id(n){return Math.max(0,Math.min(255,255*n))}class lE{static CMYK_G([e,t,s,i]){return["G",1-Math.min(1,.3*e+.59*s+.11*t+i)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return e=id(e),[e,e,e]}static G_HTML([e]){const t=aE(e);return`#${t}${t}${t}`}static RGB_G([e,t,s]){return["G",.3*e+.59*t+.11*s]}static RGB_rgb(e){return e.map(id)}static RGB_HTML(e){return`#${e.map(aE).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,s,i]){return["RGB",1-Math.min(1,e+i),1-Math.min(1,s+i),1-Math.min(1,t+i)]}static CMYK_rgb([e,t,s,i]){return[id(1-Math.min(1,e+i)),id(1-Math.min(1,s+i)),id(1-Math.min(1,t+i))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,s]){const i=1-e,r=1-t,o=1-s,a=Math.min(i,r,o);return["CMYK",i,r,o,a]}}class wZ{create(e,t,s=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${e}px`),i.setAttribute("height",`${t}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${e} ${t}`),i}createElement(e){if(typeof e!="string")throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){Tt("Abstract method `_createSVG` called.")}}class Ix extends wZ{_createSVG(e){return document.createElementNS(qr,e)}}class yM{static setupStorage(e,t,s,i,r){const o=i.getValue(t,{value:null});switch(s.name){case"textarea":if(o.value!==null&&(e.textContent=o.value),r==="print")break;e.addEventListener("input",a=>{i.setValue(t,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(o.value===s.attributes.xfaOn?e.setAttribute("checked",!0):o.value===s.attributes.xfaOff&&e.removeAttribute("checked"),r==="print")break;e.addEventListener("change",a=>{i.setValue(t,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(o.value!==null&&e.setAttribute("value",o.value),r==="print")break;e.addEventListener("input",a=>{i.setValue(t,{value:a.target.value})})}break;case"select":if(o.value!==null){e.setAttribute("value",o.value);for(const a of s.children)a.attributes.value===o.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}e.addEventListener("input",a=>{const l=a.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(t,{value:c})});break}}static setAttributes({html:e,element:t,storage:s=null,intent:i,linkService:r}){const{attributes:o}=t,a=e instanceof HTMLAnchorElement;o.type==="radio"&&(o.name=`${o.name}-${i}`);for(const[l,c]of Object.entries(o))if(c!=null)switch(l){case"class":c.length&&e.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",c);break;case"style":Object.assign(e.style,c);break;case"textContent":e.textContent=c;break;default:(!a||l!=="href"&&l!=="newWindow")&&e.setAttribute(l,c)}a&&r.addLinkAttributes(e,o.href,o.newWindow),s&&o.dataId&&this.setupStorage(e,o.dataId,t,s)}static render(e){var u,d;const t=e.annotationStorage,s=e.linkService,i=e.xfaHtml,r=e.intent||"display",o=document.createElement(i.name);i.attributes&&this.setAttributes({html:o,element:i,intent:r,linkService:s});const a=r!=="richText",l=e.div;if(l.append(o),e.viewport){const p=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=p}a&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const p=document.createTextNode(i.value);o.append(p),a&&cf.shouldBuildText(i.name)&&c.push(p)}return{textDivs:c}}const h=[[i,-1,o]];for(;h.length>0;){const[p,m,y]=h.at(-1);if(m+1===p.children.length){h.pop();continue}const v=p.children[++h.at(-1)[1]];if(v===null)continue;const{name:g}=v;if(g==="#text"){const b=document.createTextNode(v.value);c.push(b),y.append(b);continue}const _=(u=v==null?void 0:v.attributes)!=null&&u.xmlns?document.createElementNS(v.attributes.xmlns,g):document.createElement(g);if(y.append(_),v.attributes&&this.setAttributes({html:_,element:v,storage:t,intent:r,linkService:s}),((d=v.children)==null?void 0:d.length)>0)h.push([v,-1,_]);else if(v.value){const b=document.createTextNode(v.value);a&&cf.shouldBuildText(g)&&c.push(b),_.append(b)}}for(const p of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))p.setAttribute("readOnly",!0);return{textDivs:c}}static update(e){const t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}}const nm=1e3,_Z=9,yc=new WeakSet;function ko(n){return{width:n[2]-n[0],height:n[3]-n[1]}}class SZ{static create(e){switch(e.data.annotationType){case ln.LINK:return new vM(e);case ln.TEXT:return new xZ(e);case ln.WIDGET:switch(e.data.fieldType){case"Tx":return new AZ(e);case"Btn":return e.data.radioButton?new _M(e):e.data.checkBox?new EZ(e):new CZ(e);case"Ch":return new $Z(e);case"Sig":return new kZ(e)}return new Pc(e);case ln.POPUP:return new Cw(e);case ln.FREETEXT:return new EM(e);case ln.LINE:return new PZ(e);case ln.SQUARE:return new RZ(e);case ln.CIRCLE:return new MZ(e);case ln.POLYLINE:return new CM(e);case ln.CARET:return new OZ(e);case ln.INK:return new Ox(e);case ln.POLYGON:return new IZ(e);case ln.HIGHLIGHT:return new $M(e);case ln.UNDERLINE:return new NZ(e);case ln.SQUIGGLY:return new LZ(e);case ln.STRIKEOUT:return new DZ(e);case ln.STAMP:return new TM(e);case ln.FILEATTACHMENT:return new jZ(e);default:return new tn(e)}}}var zl,Wh,Gh,sp,Ew;const pA=class pA{constructor(e,{isRenderable:t=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){M(this,sp);M(this,zl,null);M(this,Wh,!1);M(this,Gh,null);this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:s}){return!!(e!=null&&e.str||t!=null&&t.str||s!=null&&s.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return pA._hasPopupData(this.data)}updateEdited(e){var s;if(!this.container)return;f(this,zl)||$(this,zl,{rect:this.data.rect.slice(0)});const{rect:t}=e;t&&P(this,sp,Ew).call(this,t),(s=f(this,Gh))==null||s.popup.updateEdited(e)}resetEdited(){var e;f(this,zl)&&(P(this,sp,Ew).call(this,f(this,zl).rect),(e=f(this,Gh))==null||e.popup.resetEdited(),$(this,zl,null))}_createContainer(e){const{data:t,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",t.id),this instanceof Pc||(r.tabIndex=nm);const{style:o}=r;if(o.zIndex=this.parent.zIndex++,t.alternativeText&&(r.title=t.alternativeText),t.noRotate&&r.classList.add("norotate"),!t.rect||this instanceof Cw){const{rotation:y}=t;return!t.hasOwnCanvas&&y!==0&&this.setRotation(y,r),r}const{width:a,height:l}=ko(t.rect);if(!e&&t.borderStyle.width>0){o.borderWidth=`${t.borderStyle.width}px`;const y=t.borderStyle.horizontalCornerRadius,v=t.borderStyle.verticalCornerRadius;if(y>0||v>0){const _=`calc(${y}px * var(--scale-factor)) / calc(${v}px * var(--scale-factor))`;o.borderRadius=_}else if(this instanceof _M){const _=`calc(${a}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;o.borderRadius=_}switch(t.borderStyle.style){case nd.SOLID:o.borderStyle="solid";break;case nd.DASHED:o.borderStyle="dashed";break;case nd.BEVELED:qe("Unimplemented border style: beveled");break;case nd.INSET:qe("Unimplemented border style: inset");break;case nd.UNDERLINE:o.borderBottomStyle="solid";break}const g=t.borderColor||null;g?($(this,Wh,!0),o.borderColor=Se.makeHexColor(g[0]|0,g[1]|0,g[2]|0)):o.borderWidth=0}const c=Se.normalizeRect([t.rect[0],s.view[3]-t.rect[1]+s.view[1],t.rect[2],s.view[3]-t.rect[3]+s.view[1]]),{pageWidth:h,pageHeight:u,pageX:d,pageY:p}=i.rawDims;o.left=`${100*(c[0]-d)/h}%`,o.top=`${100*(c[1]-p)/u}%`;const{rotation:m}=t;return t.hasOwnCanvas||m===0?(o.width=`${100*a/h}%`,o.height=`${100*l/u}%`):this.setRotation(m,r),r}setRotation(e,t=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:r,height:o}=ko(this.data.rect);let a,l;e%180===0?(a=100*r/s,l=100*o/i):(a=100*o/s,l=100*r/i),t.style.width=`${a}%`,t.style.height=`${l}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(t,s,i)=>{const r=i.detail[t],o=r[0],a=r.slice(1);i.target.style[s]=lE[`${o}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:lE[`${o}_rgb`](a)})};return Xe(this,"_commonActions",{display:t=>{const{display:s}=t.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:s}=t.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:t=>{const s=t.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(e,t){const s=this._commonActions;for(const i of Object.keys(t.detail)){const r=e[i]||s[i];r==null||r(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;const s=this._commonActions;for(const[i,r]of Object.entries(t)){const o=s[i];if(o){const a={detail:{[i]:r},target:e};o(a),delete t[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[t,s,i,r]=this.data.rect.map(y=>Math.fround(y));if(e.length===8){const[y,v,g,_]=e.subarray(2,6);if(i===y&&r===v&&t===g&&s===_)return}const{style:o}=this.container;let a;if(f(this,Wh)){const{borderColor:y,borderWidth:v}=o;o.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'',``],this.container.classList.add("hasBorder")}const l=i-t,c=r-s,{svgFactory:h}=this,u=h.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0);const d=h.createElement("defs");u.append(d);const p=h.createElement("clipPath"),m=`clippath_${this.data.id}`;p.setAttribute("id",m),p.setAttribute("clipPathUnits","objectBoundingBox"),d.append(p);for(let y=2,v=e.length;y`)}f(this,Wh)&&(a.push("')"),o.backgroundImage=a.join("")),this.container.append(u),this.container.style.clipPath=`url(#${m})`}_createPopup(){const{data:e}=this,t=$(this,Gh,new Cw({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(t.render())}render(){Tt("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[e];if(i)for(const{page:r,id:o,exportValues:a}of i){if(r===-1||o===t)continue;const l=typeof a=="string"?a:null,c=document.querySelector(`[data-element-id="${o}"]`);if(c&&!yc.has(c)){qe(`_getElementsByName - element not allowed: ${o}`);continue}s.push({id:o,exportValue:l,domElement:c})}return s}for(const i of document.getElementsByName(e)){const{exportValue:r}=i,o=i.getAttribute("data-element-id");o!==t&&yc.has(i)&&s.push({id:o,exportValue:r,domElement:i})}return s}show(){var e;this.container&&(this.container.hidden=!1),(e=this.popup)==null||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),(e=this.popup)==null||e.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t})})}};zl=new WeakMap,Wh=new WeakMap,Gh=new WeakMap,sp=new WeakSet,Ew=function(e){const{container:{style:t},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:o,pageX:a,pageY:l}}}}=this;s==null||s.splice(0,4,...e);const{width:c,height:h}=ko(e);t.left=`${100*(e[0]-a)/r}%`,t.top=`${100*(o-e[3]+l)/o}%`,i===0?(t.width=`${100*c/r}%`,t.height=`${100*h/o}%`):this.setRotation(i)};let tn=pA;var ni,Za,bM,wM;class vM extends tn{constructor(t,s=null){super(t,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});M(this,ni);this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let r=!1;return t.url?(s.addLinkAttributes(i,t.url,t.newWindow),r=!0):t.action?(this._bindNamedAction(i,t.action),r=!0):t.attachment?(P(this,ni,bM).call(this,i,t.attachment,t.attachmentDest),r=!0):t.setOCGState?(P(this,ni,wM).call(this,i,t.setOCGState),r=!0):t.dest?(this._bindLink(i,t.dest),r=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),r=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(i,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(i),this.container}_bindLink(t,s){t.href=this.linkService.getDestinationHash(s),t.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&P(this,ni,Za).call(this)}_bindNamedAction(t,s){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(s),!1),P(this,ni,Za).call(this)}_bindJSAction(t,s){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const o=i.get(r);o&&(t[o]=()=>{var a;return(a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}t.onclick||(t.onclick=()=>!1),P(this,ni,Za).call(this)}_bindResetFormAction(t,s){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),P(this,ni,Za).call(this),!this._fieldObjects){qe('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{var u;i==null||i();const{fields:r,refs:o,include:a}=s,l=[];if(r.length!==0||o.length!==0){const d=new Set(o);for(const p of r){const m=this._fieldObjects[p]||[];for(const{id:y}of m)d.add(y)}for(const p of Object.values(this._fieldObjects))for(const m of p)d.has(m.id)===a&&l.push(m)}else for(const d of Object.values(this._fieldObjects))l.push(...d);const c=this.annotationStorage,h=[];for(const d of l){const{id:p}=d;switch(h.push(p),d.type){case"text":{const y=d.defaultValue||"";c.setValue(p,{value:y});break}case"checkbox":case"radiobutton":{const y=d.defaultValue===d.exportValues;c.setValue(p,{value:y});break}case"combobox":case"listbox":{const y=d.defaultValue||"";c.setValue(p,{value:y});break}default:continue}const m=document.querySelector(`[data-element-id="${p}"]`);if(m){if(!yc.has(m)){qe(`_bindResetFormAction - element not allowed: ${p}`);continue}}else continue;m.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((u=this.linkService.eventBus)==null||u.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}})),!1}}}ni=new WeakSet,Za=function(){this.container.setAttribute("data-internal-link","")},bM=function(t,s,i=null){t.href=this.linkService.getAnchorUrl(""),s.description&&(t.title=s.description),t.onclick=()=>{var r;return(r=this.downloadManager)==null||r.openOrDownloadData(s.content,s.filename,i),!1},P(this,ni,Za).call(this)},wM=function(t,s){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(s),!1),P(this,ni,Za).call(this)};class xZ extends tn{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}}class Pc extends tn{render(){return this.container}showElementAndHideCanvas(e){var t;this.data.hasOwnCanvas&&(((t=e.previousSibling)==null?void 0:t.nodeName)==="CANVAS"&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return ys.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,s,i,r){s.includes("mouse")?e.addEventListener(s,o=>{var a;(a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(o),shift:o.shiftKey,modifier:this._getKeyModifier(o)}})}):e.addEventListener(s,o=>{var a;if(s==="blur"){if(!t.focused||!o.relatedTarget)return;t.focused=!1}else if(s==="focus"){if(t.focused)return;t.focused=!0}r&&((a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(o)}}))})}_setEventListeners(e,t,s,i){var r,o,a;for(const[l,c]of s)(c==="Action"||(r=this.data.actions)!=null&&r[c])&&((c==="Focus"||c==="Blur")&&(t||(t={focused:!1})),this._setEventListener(e,t,l,c,i),c==="Focus"&&!((o=this.data.actions)!=null&&o.Blur)?this._setEventListener(e,t,"blur","Blur",null):c==="Blur"&&!((a=this.data.actions)!=null&&a.Focus)&&this._setEventListener(e,t,"focus","Focus",null))}_setBackgroundColor(e){const t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?"transparent":Se.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){const t=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||_Z,r=e.style;let o;const a=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-a),h=Math.round(c/(Cv*i))||1,u=c/h;o=Math.min(i,l(u/Cv))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-a);o=Math.min(i,l(c/Cv))}r.fontSize=`calc(${o}px * var(--scale-factor))`,r.color=Se.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(r.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class AZ extends Pc{constructor(e){const t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,s,i){const r=this.annotationStorage;for(const o of this._getElementsByName(e.name,e.id))o.domElement&&(o.domElement[t]=s),r.setValue(o.id,{[i]:s})}render(){var i,r;const e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const o=e.getValue(t,{value:this.data.fieldValue});let a=o.value||"";const l=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;l&&a.length>l&&(a=a.slice(0,l));let c=o.formattedValue||((i=this.data.textContent)==null?void 0:i.join(` -`))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const h={userValue:a,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=c??a,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",c??a),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),yc.add(s),s.setAttribute("data-element-id",t),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=nm,this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",d=>{e.setValue(t,{value:d.target.value}),this.setPropertyOnSiblings(s,"value",d.target.value,"value"),h.formattedValue=null}),s.addEventListener("resetform",d=>{const p=this.data.defaultFieldValue??"";s.value=h.userValue=p,h.formattedValue=null});let u=d=>{const{formattedValue:p}=h;p!=null&&(d.target.value=p),d.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",p=>{var y;if(h.focused)return;const{target:m}=p;h.userValue&&(m.value=h.userValue),h.lastCommittedValue=m.value,h.commitKey=1,(y=this.data.actions)!=null&&y.Focus||(h.focused=!0)}),s.addEventListener("updatefromsandbox",p=>{this.showElementAndHideCanvas(p.target);const m={value(y){h.userValue=y.detail.value??"",e.setValue(t,{value:h.userValue.toString()}),y.target.value=h.userValue},formattedValue(y){const{formattedValue:v}=y.detail;h.formattedValue=v,v!=null&&y.target!==document.activeElement&&(y.target.value=v),e.setValue(t,{formattedValue:v})},selRange(y){y.target.setSelectionRange(...y.detail.selRange)},charLimit:y=>{var b;const{charLimit:v}=y.detail,{target:g}=y;if(v===0){g.removeAttribute("maxLength");return}g.setAttribute("maxLength",v);let _=h.userValue;!_||_.length<=v||(_=_.slice(0,v),g.value=h.userValue=_,e.setValue(t,{value:_}),(b=this.linkService.eventBus)==null||b.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:_,willCommit:!0,commitKey:1,selStart:g.selectionStart,selEnd:g.selectionEnd}}))}};this._dispatchEventFromSandbox(m,p)}),s.addEventListener("keydown",p=>{var v;h.commitKey=1;let m=-1;if(p.key==="Escape"?m=0:p.key==="Enter"&&!this.data.multiLine?m=2:p.key==="Tab"&&(h.commitKey=3),m===-1)return;const{value:y}=p.target;h.lastCommittedValue!==y&&(h.lastCommittedValue=y,h.userValue=y,(v=this.linkService.eventBus)==null||v.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:y,willCommit:!0,commitKey:m,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}}))});const d=u;u=null,s.addEventListener("blur",p=>{var y,v;if(!h.focused||!p.relatedTarget)return;(y=this.data.actions)!=null&&y.Blur||(h.focused=!1);const{value:m}=p.target;h.userValue=m,h.lastCommittedValue!==m&&((v=this.linkService.eventBus)==null||v.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:m,willCommit:!0,commitKey:h.commitKey,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}})),d(p)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",p=>{var A;h.lastCommittedValue=null;const{data:m,target:y}=p,{value:v,selectionStart:g,selectionEnd:_}=y;let b=g,x=_;switch(p.inputType){case"deleteWordBackward":{const T=v.substring(0,g).match(/\w*[^\w]*$/);T&&(b-=T[0].length);break}case"deleteWordForward":{const T=v.substring(g).match(/^[^\w]*\w*/);T&&(x+=T[0].length);break}case"deleteContentBackward":g===_&&(b-=1);break;case"deleteContentForward":g===_&&(x+=1);break}p.preventDefault(),(A=this.linkService.eventBus)==null||A.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:v,change:m||"",willCommit:!1,selStart:b,selEnd:x}})}),this._setEventListeners(s,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],p=>p.target.value)}if(u&&s.addEventListener("blur",u),this.data.comb){const p=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${p}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class kZ extends Pc{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class EZ extends Pc{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,t=this.data,s=t.id;let i=e.getValue(s,{value:t.exportValue===t.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",e.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return yc.add(r),r.setAttribute("data-element-id",s),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=t.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",t.exportValue),r.tabIndex=nm,r.addEventListener("change",o=>{const{name:a,checked:l}=o.target;for(const c of this._getElementsByName(a,s)){const h=l&&c.exportValue===t.exportValue;c.domElement&&(c.domElement.checked=h),e.setValue(c.id,{value:h})}e.setValue(s,{value:l})}),r.addEventListener("resetform",o=>{const a=t.defaultFieldValue||"Off";o.target.checked=a===t.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",o=>{const a={value(l){l.target.checked=l.detail.value!=="Off",e.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(a,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class _M extends Pc{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,t=this.data,s=t.id;let i=e.getValue(s,{value:t.fieldValue===t.buttonValue}).value;if(typeof i=="string"&&(i=i!==t.buttonValue,e.setValue(s,{value:i})),i)for(const o of this._getElementsByName(t.fieldName,s))e.setValue(o.id,{value:!1});const r=document.createElement("input");if(yc.add(r),r.setAttribute("data-element-id",s),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=t.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=nm,r.addEventListener("change",o=>{const{name:a,checked:l}=o.target;for(const c of this._getElementsByName(a,s))e.setValue(c.id,{value:!1});e.setValue(s,{value:l})}),r.addEventListener("resetform",o=>{const a=t.defaultFieldValue;o.target.checked=a!=null&&a===t.buttonValue}),this.enableScripting&&this.hasJSActions){const o=t.buttonValue;r.addEventListener("updatefromsandbox",a=>{const l={value:c=>{const h=o===c.detail.value;for(const u of this._getElementsByName(c.target.name)){const d=h&&u.id===s;u.domElement&&(u.domElement.checked=d),e.setValue(u.id,{value:d})}}};this._dispatchEventFromSandbox(l,a)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class CZ extends vM{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),e}}class $Z extends Pc{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,t=this.data.id,s=e.getValue(t,{value:this.data.fieldValue}),i=document.createElement("select");yc.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=nm;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",h=>{const u=this.data.defaultFieldValue;for(const d of i.options)d.selected=d.value===u});for(const h of this.data.options){const u=document.createElement("option");u.textContent=h.displayValue,u.value=h.exportValue,s.value.includes(h.exportValue)&&(u.setAttribute("selected",!0),r=!1),i.append(u)}let o=null;if(r){const h=document.createElement("option");h.value=" ",h.setAttribute("hidden",!0),h.setAttribute("selected",!0),i.prepend(h),o=()=>{h.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}const a=h=>{const u=h?"value":"textContent",{options:d,multiple:p}=i;return p?Array.prototype.filter.call(d,m=>m.selected).map(m=>m[u]):d.selectedIndex===-1?null:d[d.selectedIndex][u]};let l=a(!1);const c=h=>{const u=h.target.options;return Array.prototype.map.call(u,d=>({displayValue:d.textContent,exportValue:d.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",h=>{const u={value(d){o==null||o();const p=d.detail.value,m=new Set(Array.isArray(p)?p:[p]);for(const y of i.options)y.selected=m.has(y.value);e.setValue(t,{value:a(!0)}),l=a(!1)},multipleSelection(d){i.multiple=!0},remove(d){const p=i.options,m=d.detail.remove;p[m].selected=!1,i.remove(m),p.length>0&&Array.prototype.findIndex.call(p,v=>v.selected)===-1&&(p[0].selected=!0),e.setValue(t,{value:a(!0),items:c(d)}),l=a(!1)},clear(d){for(;i.length!==0;)i.remove(0);e.setValue(t,{value:null,items:[]}),l=a(!1)},insert(d){const{index:p,displayValue:m,exportValue:y}=d.detail.insert,v=i.children[p],g=document.createElement("option");g.textContent=m,g.value=y,v?v.before(g):i.append(g),e.setValue(t,{value:a(!0),items:c(d)}),l=a(!1)},items(d){const{items:p}=d.detail;for(;i.length!==0;)i.remove(0);for(const m of p){const{displayValue:y,exportValue:v}=m,g=document.createElement("option");g.textContent=y,g.value=v,i.append(g)}i.options.length>0&&(i.options[0].selected=!0),e.setValue(t,{value:a(!0),items:c(d)}),l=a(!1)},indices(d){const p=new Set(d.detail.indices);for(const m of d.target.options)m.selected=p.has(m.index);e.setValue(t,{value:a(!0)}),l=a(!1)},editable(d){d.target.disabled=!d.detail.editable}};this._dispatchEventFromSandbox(u,h)}),i.addEventListener("input",h=>{var p;const u=a(!0),d=a(!1);e.setValue(t,{value:u}),h.preventDefault(),(p=this.linkService.eventBus)==null||p.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:l,change:d,changeEx:u,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],h=>h.target.value)):i.addEventListener("input",function(h){e.setValue(t,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Cw extends tn{constructor(e){const{data:t,elements:s}=e;super(e,{isRenderable:tn._hasPopupData(t)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const e=this.popup=new TZ({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(const s of this.elements)s.popup=e,s.container.ariaHasPopup="dialog",t.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",t.map(s=>`${xx}${s}`).join(",")),this.container}}var Kh,i0,r0,Zh,Hl,Vt,so,Xh,ip,rp,Yh,io,Fi,ro,op,oo,ap,Bl,Ul,gt,Tg,$w,SM,xM,AM,kM,Pg,Rg,Tw;class TZ{constructor({container:e,color:t,elements:s,titleObj:i,modificationDate:r,contentsObj:o,richText:a,parent:l,rect:c,parentRect:h,open:u}){M(this,gt);M(this,Kh,P(this,gt,AM).bind(this));M(this,i0,P(this,gt,Tw).bind(this));M(this,r0,P(this,gt,Rg).bind(this));M(this,Zh,P(this,gt,Pg).bind(this));M(this,Hl,null);M(this,Vt,null);M(this,so,null);M(this,Xh,null);M(this,ip,null);M(this,rp,null);M(this,Yh,null);M(this,io,!1);M(this,Fi,null);M(this,ro,null);M(this,op,null);M(this,oo,null);M(this,ap,null);M(this,Bl,null);M(this,Ul,!1);var d;$(this,Vt,e),$(this,ap,i),$(this,so,o),$(this,oo,a),$(this,rp,l),$(this,Hl,t),$(this,op,c),$(this,Yh,h),$(this,ip,s),$(this,Xh,Ex.toDateObject(r)),this.trigger=s.flatMap(p=>p.getElementsToTriggerPopup());for(const p of this.trigger)p.addEventListener("click",f(this,Zh)),p.addEventListener("mouseenter",f(this,r0)),p.addEventListener("mouseleave",f(this,i0)),p.classList.add("popupTriggerArea");for(const p of s)(d=p.container)==null||d.addEventListener("keydown",f(this,Kh));f(this,Vt).hidden=!0,u&&P(this,gt,Pg).call(this)}render(){if(f(this,Fi))return;const e=$(this,Fi,document.createElement("div"));if(e.className="popup",f(this,Hl)){const r=e.style.outlineColor=Se.makeHexColor(...f(this,Hl));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?e.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`:e.style.backgroundColor=Se.makeHexColor(...f(this,Hl).map(a=>Math.floor(.7*(255-a)+a)))}const t=document.createElement("span");t.className="header";const s=document.createElement("h1");if(t.append(s),{dir:s.dir,str:s.textContent}=f(this,ap),e.append(t),f(this,Xh)){const r=document.createElement("span");r.classList.add("popupDate"),r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:f(this,Xh).valueOf()})),t.append(r)}const i=f(this,gt,Tg);if(i)yM.render({xfaHtml:i,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const r=this._formatContents(f(this,so));e.append(r)}f(this,Vt).append(e)}_formatContents({str:e,dir:t}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=t;const i=e.split(/(?:\r\n?|\n)/);for(let r=0,o=i.length;r{o.key==="Enter"&&(r?o.metaKey:o.ctrlKey)&&P(this,pp,Pw).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return f(this,fp)}addHighlightArea(){this.container.classList.add("highlightArea")}}fp=new WeakMap,pp=new WeakSet,Pw=function(){var t;(t=this.downloadManager)==null||t.openOrDownloadData(this.content,this.filename)};var mp,ql,Vl,gp,kc,PM,Rw,KC;let FZ=(KC=class{constructor({div:e,accessibilityManager:t,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:o,structTreeLayer:a}){M(this,kc);M(this,mp,null);M(this,ql,null);M(this,Vl,new Map);M(this,gp,null);this.div=e,$(this,mp,t),$(this,ql,s),$(this,gp,a||null),this.page=r,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return f(this,Vl).size>0}async render(e){var o;const{annotations:t}=e,s=this.div;mc(s,this.viewport);const i=new Map,r={data:null,layer:s,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:e.renderForms!==!1,svgFactory:new Ix,annotationStorage:e.annotationStorage||new $x,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const a of t){if(a.noHTML)continue;const l=a.annotationType===ln.POPUP;if(l){const u=i.get(a.id);if(!u)continue;r.elements=u}else{const{width:u,height:d}=ko(a.rect);if(u<=0||d<=0)continue}r.data=a;const c=SZ.create(r);if(!c.isRenderable)continue;if(!l&&a.popupRef){const u=i.get(a.popupRef);u?u.push(c):i.set(a.popupRef,[c])}const h=c.render();a.hidden&&(h.style.visibility="hidden"),await P(this,kc,PM).call(this,h,a.id),c._isEditable&&(f(this,Vl).set(c.data.id,c),(o=this._annotationEditorUIManager)==null||o.renderAnnotationElement(c))}P(this,kc,Rw).call(this)}update({viewport:e}){const t=this.div;this.viewport=e,mc(t,{rotation:e.rotation}),P(this,kc,Rw).call(this),t.hidden=!1}getEditableAnnotations(){return Array.from(f(this,Vl).values())}getEditableAnnotation(e){return f(this,Vl).get(e)}},mp=new WeakMap,ql=new WeakMap,Vl=new WeakMap,gp=new WeakMap,kc=new WeakSet,PM=async function(e,t){var o,a;const s=e.firstChild||e,i=s.id=`${xx}${t}`,r=await((o=f(this,gp))==null?void 0:o.getAriaAttributes(i));if(r)for(const[l,c]of r)s.setAttribute(l,c);this.div.append(e),(a=f(this,mp))==null||a.moveElementInDOM(this.div,e,s,!1)},Rw=function(){if(!f(this,ql))return;const e=this.div;for(const[t,s]of f(this,ql)){const i=e.querySelector(`[data-annotation-id="${t}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:r}=i;r?r.nodeName==="CANVAS"?r.replaceWith(s):r.classList.contains("annotationContent")?r.after(s):r.before(s):i.append(s)}f(this,ql).clear()},KC);const Dm=/\r\n?|\n/g;var zi,Ks,yp,Wl,Zs,on,RM,MM,IM,Mg,$o,Ig,Og,OM,Iw,NM;const kt=class kt extends pt{constructor(t){super({...t,name:"freeTextEditor"});M(this,on);M(this,zi);M(this,Ks,"");M(this,yp,`${this.id}-editor`);M(this,Wl,null);M(this,Zs);$(this,zi,t.color||kt._defaultColor||pt._defaultLineColor),$(this,Zs,t.fontSize||kt._defaultFontSize)}static get _keyboardManager(){const t=kt.prototype,s=o=>o.isEmpty(),i=gc.TRANSLATE_SMALL,r=gc.TRANSLATE_BIG;return Xe(this,"_keyboardManager",new tm([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-r,0],checker:s}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[r,0],checker:s}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:s}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,r],checker:s}]]))}static initialize(t,s){pt.initialize(t,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,s){switch(t){case Pe.FREETEXT_SIZE:kt._defaultFontSize=s;break;case Pe.FREETEXT_COLOR:kt._defaultColor=s;break}}updateParams(t,s){switch(t){case Pe.FREETEXT_SIZE:P(this,on,RM).call(this,s);break;case Pe.FREETEXT_COLOR:P(this,on,MM).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Pe.FREETEXT_SIZE,kt._defaultFontSize],[Pe.FREETEXT_COLOR,kt._defaultColor||pt._defaultLineColor]]}get propertiesToUpdate(){return[[Pe.FREETEXT_SIZE,f(this,Zs)],[Pe.FREETEXT_COLOR,f(this,zi)]]}_translateEmpty(t,s){this._uiManager.translateSelectedEditors(t,s,!0)}getInitialTranslation(){const t=this.parentScale;return[-kt._internalPadding*t,-(kt._internalPadding+f(this,Zs))*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(De.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),$(this,Wl,new AbortController);const t=this._uiManager.combinedSignal(f(this,Wl));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){var t;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",f(this,yp)),this._isDraggable=!0,(t=f(this,Wl))==null||t.abort(),$(this,Wl,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var t;this.width||(this.enableEditMode(),this.editorDiv.focus(),(t=this._initialOptions)!=null&&t.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=f(this,Ks),s=$(this,Ks,P(this,on,IM).call(this).trimEnd());if(t===s)return;const i=r=>{if($(this,Ks,r),!r){this.remove();return}P(this,on,Og).call(this),this._uiManager.rebuild(this),P(this,on,Mg).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(t)},mustExec:!1}),P(this,on,Mg).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){kt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,s;this.width&&(t=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",f(this,yp)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${f(this,Zs)}px * var(--scale-factor))`,i.color=f(this,zi),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),by(this,this.div,["dblclick","keydown"]),this.width){const[r,o]=this.parentDimensions;if(this.annotationElementId){const{position:a}=this._initialData;let[l,c]=this.getInitialTranslation();[l,c]=this.pageTranslationToScreen(l,c);const[h,u]=this.pageDimensions,[d,p]=this.pageTranslation;let m,y;switch(this.rotation){case 0:m=t+(a[0]-d)/h,y=s+this.height-(a[1]-p)/u;break;case 90:m=t+(a[0]-d)/h,y=s-(a[1]-p)/u,[l,c]=[c,-l];break;case 180:m=t-this.width+(a[0]-d)/h,y=s-(a[1]-p)/u,[l,c]=[-l,-c];break;case 270:m=t+(a[0]-d-this.height*u)/h,y=s+(a[1]-p-this.width*h)/u,[l,c]=[-c,l];break}this.setAt(m*r,y*o,l,c)}else this.setAt(t*r,s*o,this.width*r,this.height*o);P(this,on,Og).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){var m,y,v;const s=t.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;t.preventDefault();const r=P(m=kt,$o,Iw).call(m,s.getData("text")||"").replaceAll(Dm,` -`);if(!r)return;const o=window.getSelection();if(!o.rangeCount)return;this.editorDiv.normalize(),o.deleteFromDocument();const a=o.getRangeAt(0);if(!r.includes(` -`)){a.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),o.collapseToStart();return}const{startContainer:l,startOffset:c}=a,h=[],u=[];if(l.nodeType===Node.TEXT_NODE){const g=l.parentElement;if(u.push(l.nodeValue.slice(c).replaceAll(Dm,"")),g!==this.editorDiv){let _=h;for(const b of this.editorDiv.childNodes){if(b===g){_=u;continue}_.push(P(y=kt,$o,Ig).call(y,b))}}h.push(l.nodeValue.slice(0,c).replaceAll(Dm,""))}else if(l===this.editorDiv){let g=h,_=0;for(const b of this.editorDiv.childNodes)_++===c&&(g=u),g.push(P(v=kt,$o,Ig).call(v,b))}$(this,Ks,`${h.join(` -`)}${r}${u.join(` -`)}`),P(this,on,Og).call(this);const d=new Range;let p=h.reduce((g,_)=>g+_.length,0);for(const{firstChild:g}of this.editorDiv.childNodes)if(g.nodeType===Node.TEXT_NODE){const _=g.nodeValue.length;if(p<=_){d.setStart(g,p),d.setEnd(g,p);break}p-=_}o.removeAllRanges(),o.addRange(d)}get contentDiv(){return this.editorDiv}static async deserialize(t,s,i){var a;let r=null;if(t instanceof EM){const{data:{defaultAppearanceData:{fontSize:l,fontColor:c},rect:h,rotation:u,id:d,popupRef:p},textContent:m,textPosition:y,parent:{page:{pageNumber:v}}}=t;if(!m||m.length===0)return null;r=t={annotationType:De.FREETEXT,color:Array.from(c),fontSize:l,value:m.join(` -`),position:y,pageIndex:v-1,rect:h.slice(0),rotation:u,id:d,deleted:!1,popupRef:p}}const o=await super.deserialize(t,s,i);return $(o,Zs,t.fontSize),$(o,zi,Se.makeHexColor(...t.color)),$(o,Ks,P(a=kt,$o,Iw).call(a,t.value)),o.annotationElementId=t.id||null,o._initialData=r,o}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=kt._internalPadding*this.parentScale,i=this.getRect(s,s),r=pt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:f(this,zi)),o={annotationType:De.FREETEXT,color:r,fontSize:f(this,Zs),value:P(this,on,OM).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!P(this,on,NM).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(t){const s=super.renderAnnotationElement(t);if(this.deleted)return s;const{style:i}=s;i.fontSize=`calc(${f(this,Zs)}px * var(--scale-factor))`,i.color=f(this,zi),s.replaceChildren();for(const o of f(this,Ks).split(` -`)){const a=document.createElement("div");a.append(o?document.createTextNode(o):document.createElement("br")),s.append(a)}const r=kt._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(r,r),popupContent:f(this,Ks)}),s}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};zi=new WeakMap,Ks=new WeakMap,yp=new WeakMap,Wl=new WeakMap,Zs=new WeakMap,on=new WeakSet,RM=function(t){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--scale-factor))`,this.translate(0,-(r-f(this,Zs))*this.parentScale),$(this,Zs,r),P(this,on,Mg).call(this)},i=f(this,Zs);this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Pe.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},MM=function(t){const s=r=>{$(this,zi,this.editorDiv.style.color=r)},i=f(this,zi);this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Pe.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},IM=function(){var i;const t=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(t.push(P(i=kt,$o,Ig).call(i,r)),s=r);return t.join(` -`)},Mg=function(){const[t,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:r,div:o}=this,a=o.style.display,l=o.classList.contains("hidden");o.classList.remove("hidden"),o.style.display="hidden",r.div.append(this.div),i=o.getBoundingClientRect(),o.remove(),o.style.display=a,o.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/t,this.height=i.height/s):(this.width=i.height/t,this.height=i.width/s),this.fixAndSetPosition()},$o=new WeakSet,Ig=function(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Dm,"")},Og=function(){if(this.editorDiv.replaceChildren(),!!f(this,Ks))for(const t of f(this,Ks).split(` -`)){const s=document.createElement("div");s.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(s)}},OM=function(){return f(this,Ks).replaceAll(" "," ")},Iw=function(t){return t.replaceAll(" "," ")},NM=function(t){const{value:s,fontSize:i,color:r,pageIndex:o}=this._initialData;return this._hasBeenMoved||t.value!==s||t.fontSize!==i||t.color.some((a,l)=>a!==r[l])||t.pageIndex!==o},M(kt,$o),oe(kt,"_freeTextDefaultContent",""),oe(kt,"_internalPadding",0),oe(kt,"_defaultColor",null),oe(kt,"_defaultFontSize",10),oe(kt,"_type","freetext"),oe(kt,"_editorType",De.FREETEXT);let Mw=kt;class LM{toSVGPath(){Tt("Abstract method `toSVGPath` must be implemented.")}get box(){Tt("Abstract getter `box` must be implemented.")}serialize(e,t){Tt("Abstract method `serialize` must be implemented.")}get classNamesForDrawing(){Tt("Abstract getter `classNamesForDrawing` must be implemented.")}get classNamesForOutlining(){Tt("Abstract getter `classNamesForOutlining` must be implemented.")}get mustRemoveSelfIntersections(){return!1}}var Xs,Hi,Jh,Qh,br,Ve,Gl,Kl,vp,bp,eu,tu,ha,wp,o0,a0,vn,Ad,DM,jM,FM,zM,HM,BM;const Wr=class Wr{constructor({x:e,y:t},s,i,r,o,a=0){M(this,vn);M(this,Xs);M(this,Hi,[]);M(this,Jh);M(this,Qh);M(this,br,[]);M(this,Ve,new Float64Array(18));M(this,Gl);M(this,Kl);M(this,vp);M(this,bp);M(this,eu);M(this,tu);M(this,ha,[]);$(this,Xs,s),$(this,tu,r*i),$(this,Qh,o),f(this,Ve).set([NaN,NaN,NaN,NaN,e,t],6),$(this,Jh,a),$(this,bp,f(Wr,wp)*i),$(this,vp,f(Wr,a0)*i),$(this,eu,i),f(this,ha).push(e,t)}isEmpty(){return isNaN(f(this,Ve)[8])}add({x:e,y:t}){var D;$(this,Gl,e),$(this,Kl,t);const[s,i,r,o]=f(this,Xs);let[a,l,c,h]=f(this,Ve).subarray(8,12);const u=e-c,d=t-h,p=Math.hypot(u,d);if(p=6;i-=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);return P(this,vn,jM).call(this,s),s.join(" ")}newFreeDrawOutline(e,t,s,i,r,o){return new UM(e,t,s,i,r,o)}getOutlines(){var u;const e=f(this,br),t=f(this,Hi),s=f(this,Ve),[i,r,o,a]=f(this,Xs),l=new Float64Array((((u=f(this,ha))==null?void 0:u.length)??0)+2);for(let d=0,p=l.length-2;d=6;d-=6)for(let p=0;p<6;p+=2){if(isNaN(t[d+p])){c[h]=c[h+1]=NaN,h+=2;continue}c[h]=t[d+p],c[h+1]=t[d+p+1],h+=2}return P(this,vn,HM).call(this,c,h),this.newFreeDrawOutline(c,l,f(this,Xs),f(this,eu),f(this,Jh),f(this,Qh))}};Xs=new WeakMap,Hi=new WeakMap,Jh=new WeakMap,Qh=new WeakMap,br=new WeakMap,Ve=new WeakMap,Gl=new WeakMap,Kl=new WeakMap,vp=new WeakMap,bp=new WeakMap,eu=new WeakMap,tu=new WeakMap,ha=new WeakMap,wp=new WeakMap,o0=new WeakMap,a0=new WeakMap,vn=new WeakSet,Ad=function(){const e=f(this,Ve).subarray(4,6),t=f(this,Ve).subarray(16,18),[s,i,r,o]=f(this,Xs);return[(f(this,Gl)+(e[0]-t[0])/2-s)/r,(f(this,Kl)+(e[1]-t[1])/2-i)/o,(f(this,Gl)+(t[0]-e[0])/2-s)/r,(f(this,Kl)+(t[1]-e[1])/2-i)/o]},DM=function(){const[e,t,s,i]=f(this,Xs),[r,o,a,l]=P(this,vn,Ad).call(this);return`M${(f(this,Ve)[2]-e)/s} ${(f(this,Ve)[3]-t)/i} L${(f(this,Ve)[4]-e)/s} ${(f(this,Ve)[5]-t)/i} L${r} ${o} L${a} ${l} L${(f(this,Ve)[16]-e)/s} ${(f(this,Ve)[17]-t)/i} L${(f(this,Ve)[14]-e)/s} ${(f(this,Ve)[15]-t)/i} Z`},jM=function(e){const t=f(this,Hi);e.push(`L${t[4]} ${t[5]} Z`)},FM=function(e){const[t,s,i,r]=f(this,Xs),o=f(this,Ve).subarray(4,6),a=f(this,Ve).subarray(16,18),[l,c,h,u]=P(this,vn,Ad).call(this);e.push(`L${(o[0]-t)/i} ${(o[1]-s)/r} L${l} ${c} L${h} ${u} L${(a[0]-t)/i} ${(a[1]-s)/r}`)},zM=function(e){const t=f(this,Ve),[s,i,r,o]=f(this,Xs),[a,l,c,h]=P(this,vn,Ad).call(this),u=new Float64Array(36);return u.set([NaN,NaN,NaN,NaN,(t[2]-s)/r,(t[3]-i)/o,NaN,NaN,NaN,NaN,(t[4]-s)/r,(t[5]-i)/o,NaN,NaN,NaN,NaN,a,l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(t[16]-s)/r,(t[17]-i)/o,NaN,NaN,NaN,NaN,(t[14]-s)/r,(t[15]-i)/o],0),this.newFreeDrawOutline(u,e,f(this,Xs),f(this,eu),f(this,Jh),f(this,Qh))},HM=function(e,t){const s=f(this,Hi);return e.set([NaN,NaN,NaN,NaN,s[4],s[5]],t),t+=6},BM=function(e,t){const s=f(this,Ve).subarray(4,6),i=f(this,Ve).subarray(16,18),[r,o,a,l]=f(this,Xs),[c,h,u,d]=P(this,vn,Ad).call(this);return e.set([NaN,NaN,NaN,NaN,(s[0]-r)/a,(s[1]-o)/l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,(i[0]-r)/a,(i[1]-o)/l],t),t+=24},M(Wr,wp,8),M(Wr,o0,2),M(Wr,a0,f(Wr,wp)+f(Wr,o0));let _y=Wr;var nu,Zl,ao,_p,Ys,Sp,Yt,zs,kd,Ed,qM;class UM extends LM{constructor(t,s,i,r,o,a){super();M(this,zs);M(this,nu);M(this,Zl,null);M(this,ao);M(this,_p);M(this,Ys);M(this,Sp);M(this,Yt);$(this,Yt,t),$(this,Ys,s),$(this,nu,i),$(this,Sp,r),$(this,ao,o),$(this,_p,a),P(this,zs,qM).call(this,a);const{x:l,y:c,width:h,height:u}=f(this,Zl);for(let d=0,p=t.length;dt[0]-s[0]||t[1]-s[1]||t[2]-s[2]);const e=[];for(const t of f(this,ua))t[3]?(e.push(...P(this,ws,Ow).call(this,t)),P(this,ws,WM).call(this,t)):(P(this,ws,GM).call(this,t),e.push(...P(this,ws,Ow).call(this,t)));return P(this,ws,VM).call(this,e)}}xp=new WeakMap,ua=new WeakMap,Bi=new WeakMap,ws=new WeakSet,VM=function(e){const t=[],s=new Set;for(const o of e){const[a,l,c]=o;t.push([a,l,o],[a,c,o])}t.sort((o,a)=>o[1]-a[1]||o[0]-a[0]);for(let o=0,a=t.length;o0;){const o=s.values().next().value;let[a,l,c,h,u]=o;s.delete(o);let d=a,p=l;for(r=[a,c],i.push(r);;){let m;if(s.has(h))m=h;else if(s.has(u))m=u;else break;s.delete(m),[a,l,c,h,u]=m,d!==a&&(r.push(d,p,a,p===l?l:c),d=a),p=p===l?c:l}r.push(d,p)}return new zZ(i,f(this,xp))},Ng=function(e){const t=f(this,Bi);let s=0,i=t.length-1;for(;s<=i;){const r=s+i>>1,o=t[r][0];if(o===e)return r;o=0;i--){const[r,o]=f(this,Bi)[i];if(r!==e)break;if(r===e&&o===t){f(this,Bi).splice(i,1);return}}},Ow=function(e){const[t,s,i]=e,r=[[t,s,i]],o=P(this,ws,Ng).call(this,i);for(let a=0;a=l){if(p>c)r[h][1]=c;else{if(u===1)return[];r.splice(h,1),h--,u--}continue}r[h][2]=l,p>c&&r.push([t,c,p])}}}return r};var Ap,su;class zZ extends LM{constructor(t,s){super();M(this,Ap);M(this,su);$(this,su,t),$(this,Ap,s)}toSVGPath(){const t=[];for(const s of f(this,su)){let[i,r]=s;t.push(`M${i} ${r}`);for(let o=2;o-1?($(this,Ms,!0),P(this,Oe,Lg).call(this,t),P(this,Oe,Ya).call(this)):f(this,lo)&&($(this,au,t.anchorNode),$(this,Tp,t.anchorOffset),$(this,Pp,t.focusNode),$(this,Rp,t.focusOffset),P(this,Oe,Fw).call(this),P(this,Oe,Ya).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const t=ot.prototype;return Xe(this,"_keyboardManager",new tm([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:f(this,Ms)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:f(this,di),methodOfCreation:f(this,Mp)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,s){var i;pt.initialize(t,s),ot._defaultColor||(ot._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(t,s){switch(t){case Pe.HIGHLIGHT_DEFAULT_COLOR:ot._defaultColor=s;break;case Pe.HIGHLIGHT_THICKNESS:ot._defaultThickness=s;break}}translateInPage(t,s){}get toolbarPosition(){return f(this,cu)}updateParams(t,s){switch(t){case Pe.HIGHLIGHT_COLOR:P(this,Oe,ZM).call(this,s);break;case Pe.HIGHLIGHT_THICKNESS:P(this,Oe,XM).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Pe.HIGHLIGHT_DEFAULT_COLOR,ot._defaultColor],[Pe.HIGHLIGHT_THICKNESS,ot._defaultThickness]]}get propertiesToUpdate(){return[[Pe.HIGHLIGHT_COLOR,this.color||ot._defaultColor],[Pe.HIGHLIGHT_THICKNESS,f(this,di)||ot._defaultThickness],[Pe.HIGHLIGHT_FREE,f(this,Ms)]]}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&($(this,lu,new Sy({editor:this})),t.addColorPicker(f(this,lu))),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(P(this,Oe,Cd).call(this))}getBaseTranslation(){return[0,0]}getRect(t,s){return super.getRect(t,s,P(this,Oe,Cd).call(this))}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){P(this,Oe,zw).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(P(this,Oe,Ya).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var i;let s=!1;this.parent&&!t?P(this,Oe,zw).call(this):t&&(P(this,Oe,Ya).call(this,t),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),s&&this.select()}rotate(t){var r,o,a;const{drawLayer:s}=this.parent;let i;f(this,Ms)?(t=(t-this.rotation+360)%360,i=P(r=ot,vi,Kc).call(r,f(this,Vi).box,t)):i=P(o=ot,vi,Kc).call(o,this,t),s.rotate(f(this,ns),t),s.rotate(f(this,un),t),s.updateBox(f(this,ns),i),s.updateBox(f(this,un),P(a=ot,vi,Kc).call(a,f(this,ui).box,t))}render(){if(this.div)return this.div;const t=super.render();f(this,hu)&&(t.setAttribute("aria-label",f(this,hu)),t.setAttribute("role","mark")),f(this,Ms)?t.classList.add("free"):this.div.addEventListener("keydown",P(this,Oe,JM).bind(this),{signal:this._uiManager._signal});const s=$(this,Jl,document.createElement("div"));t.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=f(this,Yl);const[i,r]=this.parentDimensions;return this.setDims(this.width*i,this.height*r),by(this,f(this,Jl),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent.drawLayer.addClass(f(this,un),"hovered")}pointerleave(){this.isSelected||this.parent.drawLayer.removeClass(f(this,un),"hovered")}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:P(this,Oe,Dg).call(this,!0);break;case 1:case 3:P(this,Oe,Dg).call(this,!1);break}}select(){var t,s;super.select(),f(this,un)&&((t=this.parent)==null||t.drawLayer.removeClass(f(this,un),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(f(this,un),"selected"))}unselect(){var t;super.unselect(),f(this,un)&&((t=this.parent)==null||t.drawLayer.removeClass(f(this,un),"selected"),f(this,Ms)||P(this,Oe,Dg).call(this,!1))}get _mustFixPosition(){return!f(this,Ms)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(f(this,ns),t),this.parent.drawLayer.show(f(this,un),t))}static startHighlighting(t,s,{target:i,x:r,y:o}){const{x:a,y:l,width:c,height:h}=i.getBoundingClientRect(),u=new AbortController,d=t.combinedSignal(u),p=y=>{y.preventDefault(),y.stopPropagation()},m=y=>{u.abort(),P(this,vi,nI).call(this,t,y)};window.addEventListener("blur",m,{signal:d}),window.addEventListener("pointerup",m,{signal:d}),window.addEventListener("pointerdown",p,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",xi,{signal:d}),i.addEventListener("pointermove",P(this,vi,tI).bind(this,t),{signal:d}),this._freeHighlight=new Nw({x:r,y:o},[a,l,c,h],t.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static async deserialize(t,s,i){var y,v,g,_;let r=null;if(t instanceof $M){const{data:{quadPoints:b,rect:x,rotation:A,id:T,color:C,opacity:I,popupRef:D},parent:{page:{pageNumber:H}}}=t;r=t={annotationType:De.HIGHLIGHT,color:Array.from(C),opacity:I,quadPoints:b,boxes:null,pageIndex:H-1,rect:x.slice(0),rotation:A,id:T,deleted:!1,popupRef:D}}else if(t instanceof Ox){const{data:{inkLists:b,rect:x,rotation:A,id:T,color:C,borderStyle:{rawWidth:I},popupRef:D},parent:{page:{pageNumber:H}}}=t;r=t={annotationType:De.HIGHLIGHT,color:Array.from(C),thickness:I,inkLists:b,boxes:null,pageIndex:H-1,rect:x.slice(0),rotation:A,id:T,deleted:!1,popupRef:D}}const{color:o,quadPoints:a,inkLists:l,opacity:c}=t,h=await super.deserialize(t,s,i);h.color=Se.makeHexColor(...o),$(h,co,c||1),l&&$(h,di,t.thickness),h.annotationElementId=t.id||null,h._initialData=r;const[u,d]=h.pageDimensions,[p,m]=h.pageTranslation;if(a){const b=$(h,lo,[]);for(let x=0;x=0)$(this,ns,s),$(this,Yl,i),this.parent.drawLayer.finalizeLine(s,t),$(this,un,this.parent.drawLayer.drawOutline(f(this,ui)));else if(this.parent){const p=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(f(this,ns),t),this.parent.drawLayer.updateBox(f(this,ns),P(u=ot,vi,Kc).call(u,f(this,Vi).box,(p-this.rotation+360)%360)),this.parent.drawLayer.updateLine(f(this,un),f(this,ui)),this.parent.drawLayer.updateBox(f(this,un),P(d=ot,vi,Kc).call(d,f(this,ui).box,p))}const{x:o,y:a,width:l,height:c}=t.box;switch(this.rotation){case 0:this.x=o,this.y=a,this.width=l,this.height=c;break;case 90:{const[p,m]=this.parentDimensions;this.x=a,this.y=1-o,this.width=l*m/p,this.height=c*p/m;break}case 180:this.x=1-o,this.y=1-a,this.width=l,this.height=c;break;case 270:{const[p,m]=this.parentDimensions;this.x=1-a,this.y=o,this.width=l*m/p,this.height=c*p/m;break}}const{lastPoint:h}=f(this,ui).box;$(this,cu,[(h[0]-o)/l,(h[1]-a)/c])},ZM=function(t){const s=(o,a)=>{var l,c,h;this.color=o,(l=this.parent)==null||l.drawLayer.changeColor(f(this,ns),o),(c=f(this,lu))==null||c.updateColor(o),$(this,co,a),(h=this.parent)==null||h.drawLayer.changeOpacity(f(this,ns),a)},i=this.color,r=f(this,co);this.addCommands({cmd:s.bind(this,t,ot._defaultOpacity),undo:s.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Pe.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)},XM=function(t){const s=f(this,di),i=r=>{$(this,di,r),P(this,Oe,YM).call(this,r)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Pe.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},YM=function(t){if(!f(this,Ms))return;P(this,Oe,Lg).call(this,{highlightOutlines:f(this,Vi).getNewOutline(t/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},zw=function(){f(this,ns)===null||!this.parent||(this.parent.drawLayer.remove(f(this,ns)),$(this,ns,null),this.parent.drawLayer.remove(f(this,un)),$(this,un,null))},Ya=function(t=this.parent){f(this,ns)===null&&({id:hs(this,ns)._,clipPathId:hs(this,Yl)._}=t.drawLayer.draw(f(this,Vi),this.color,f(this,co)),$(this,un,t.drawLayer.drawOutline(f(this,ui))),f(this,Jl)&&(f(this,Jl).style.clipPath=f(this,Yl)))},vi=new WeakSet,Kc=function({x:t,y:s,width:i,height:r},o){switch(o){case 90:return{x:1-s-r,y:t,width:r,height:i};case 180:return{x:1-t-i,y:1-s-r,width:i,height:r};case 270:return{x:s,y:1-t-i,width:r,height:i}}return{x:t,y:s,width:i,height:r}},JM=function(t){ot._keyboardManager.exec(this,t)},Dg=function(t){if(!f(this,au))return;const s=window.getSelection();t?s.setPosition(f(this,au),f(this,Tp)):s.setPosition(f(this,Pp),f(this,Rp))},Cd=function(){return f(this,Ms)?this.rotation:0},QM=function(){if(f(this,Ms))return null;const[t,s]=this.pageDimensions,[i,r]=this.pageTranslation,o=f(this,lo),a=new Float32Array(o.length*8);let l=0;for(const{x:c,y:h,width:u,height:d}of o){const p=c*t+i,m=(1-h-d)*s+r;a[l]=a[l+4]=p,a[l+1]=a[l+3]=m,a[l+2]=a[l+6]=p+u*t,a[l+5]=a[l+7]=m+d*s,l+=8}return a},eI=function(t){return f(this,Vi).serialize(t,P(this,Oe,Cd).call(this))},tI=function(t,s){this._freeHighlight.add(s)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},nI=function(t,s){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},sI=function(t){const{color:s}=this._initialData;return t.color.some((i,r)=>i!==s[r])},M(ot,vi),oe(ot,"_defaultColor",null),oe(ot,"_defaultOpacity",1),oe(ot,"_defaultThickness",12),oe(ot,"_type","highlight"),oe(ot,"_editorType",De.HIGHLIGHT),oe(ot,"_freeHighlightId",-1),oe(ot,"_freeHighlight",null),oe(ot,"_freeHighlightClipId","");let xy=ot;var Ql,ec,wr,ho,fi,tc,nc,sc,uo,uu,ic,rc,fa,ce,iI,rI,oI,aI,Bw,lI,Uw,cI,hI,uI,dI,fI,Ja,qw,Vw,Ww,jg,Fg,Zc,Gw,zg,Ro,pI,Kw,mI,gI,Zw,Hg,$d;const jt=class jt extends pt{constructor(t){super({...t,name:"inkEditor"});M(this,ce);M(this,Ql,0);M(this,ec,0);M(this,wr,null);M(this,ho,new Path2D);M(this,fi,!1);M(this,tc,null);M(this,nc,!1);M(this,sc,!1);M(this,uo,null);M(this,uu,null);M(this,ic,0);M(this,rc,0);M(this,fa,null);this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(t,s){pt.initialize(t,s)}static updateDefaultParams(t,s){switch(t){case Pe.INK_THICKNESS:jt._defaultThickness=s;break;case Pe.INK_COLOR:jt._defaultColor=s;break;case Pe.INK_OPACITY:jt._defaultOpacity=s/100;break}}updateParams(t,s){switch(t){case Pe.INK_THICKNESS:P(this,ce,iI).call(this,s);break;case Pe.INK_COLOR:P(this,ce,rI).call(this,s);break;case Pe.INK_OPACITY:P(this,ce,oI).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Pe.INK_THICKNESS,jt._defaultThickness],[Pe.INK_COLOR,jt._defaultColor||pt._defaultLineColor],[Pe.INK_OPACITY,Math.round(jt._defaultOpacity*100)]]}get propertiesToUpdate(){return[[Pe.INK_THICKNESS,this.thickness||jt._defaultThickness],[Pe.INK_COLOR,this.color||jt._defaultColor||pt._defaultLineColor],[Pe.INK_OPACITY,Math.round(100*(this.opacity??jt._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(P(this,ce,jg).call(this),P(this,ce,Fg).call(this)),this.isAttachedToDOM||(this.parent.add(this),P(this,ce,Zc).call(this)),P(this,ce,$d).call(this)))}remove(){var t;this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,f(this,wr)&&(clearTimeout(f(this,wr)),$(this,wr,null)),(t=f(this,uo))==null||t.disconnect(),$(this,uo,null),super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&t===null&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,s]=this.parentDimensions,i=this.width*t,r=this.height*s;this.setDimensions(i,r)}enableEditMode(){f(this,fi)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,P(this,ce,qw).call(this))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),P(this,ce,Vw).call(this))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){f(this,fi)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),$(this,fi,!0),this.div.classList.add("disabled"),P(this,ce,$d).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),this.enableEditMode())}canvasPointerdown(t){t.button!==0||!this.isInEditMode()||f(this,fi)||(this.setInForeground(),t.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),P(this,ce,lI).call(this,t.offsetX,t.offsetY))}canvasPointermove(t){t.preventDefault(),P(this,ce,Uw).call(this,t.offsetX,t.offsetY)}canvasPointerup(t){t.preventDefault(),P(this,ce,Ww).call(this,t)}canvasPointerleave(t){P(this,ce,Ww).call(this,t)}get isResizable(){return!this.isEmpty()&&f(this,fi)}render(){if(this.div)return this.div;let t,s;this.width&&(t=this.x,s=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,r,o,a]=P(this,ce,aI).call(this);if(this.setAt(i,r,0,0),this.setDims(o,a),P(this,ce,jg).call(this),this.width){const[l,c]=this.parentDimensions;this.setAspectRatio(this.width*l,this.height*c),this.setAt(t*l,s*c,this.width*l,this.height*c),$(this,sc,!0),P(this,ce,Zc).call(this),this.setDims(this.width*l,this.height*c),P(this,ce,Ja).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return P(this,ce,Fg).call(this),this.div}setDimensions(t,s){const i=Math.round(t),r=Math.round(s);if(f(this,ic)===i&&f(this,rc)===r)return;$(this,ic,i),$(this,rc,r),this.canvas.style.visibility="hidden";const[o,a]=this.parentDimensions;this.width=t/o,this.height=s/a,this.fixAndSetPosition(),f(this,fi)&&P(this,ce,Gw).call(this,t,s),P(this,ce,Zc).call(this),P(this,ce,Ja).call(this),this.canvas.style.visibility="visible",this.fixDims()}static async deserialize(t,s,i){var v,g,_;if(t instanceof Ox)return null;const r=await super.deserialize(t,s,i);r.thickness=t.thickness,r.color=Se.makeHexColor(...t.color),r.opacity=t.opacity;const[o,a]=r.pageDimensions,l=r.width*o,c=r.height*a,h=r.parentScale,u=t.thickness/2;$(r,fi,!0),$(r,ic,Math.round(l)),$(r,rc,Math.round(c));const{paths:d,rect:p,rotation:m}=t;for(let{bezier:b}of d){b=P(v=jt,Ro,mI).call(v,b,p,m);const x=[];r.paths.push(x);let A=h*(b[0]-u),T=h*(b[1]-u);for(let I=2,D=b.length;I{this.thickness=r,P(this,ce,$d).call(this)},i=this.thickness;this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Pe.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},rI=function(t){const s=r=>{this.color=r,P(this,ce,Ja).call(this)},i=this.color;this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Pe.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},oI=function(t){const s=r=>{this.opacity=r,P(this,ce,Ja).call(this)};t/=100;const i=this.opacity;this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Pe.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},aI=function(){const{parentRotation:t,parentDimensions:[s,i]}=this;switch(t){case 90:return[0,i,i,s];case 180:return[s,i,s,i];case 270:return[s,0,i,s];default:return[0,0,s,i]}},Bw=function(){const{ctx:t,color:s,opacity:i,thickness:r,parentScale:o,scaleFactor:a}=this;t.lineWidth=r*o/a,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${s}${c8(i)}`},lI=function(t,s){this.canvas.addEventListener("contextmenu",xi,{signal:this._uiManager._signal}),P(this,ce,Vw).call(this),$(this,tc,new AbortController);const i=this._uiManager.combinedSignal(f(this,tc));this.canvas.addEventListener("pointerleave",this.canvasPointerleave.bind(this),{signal:i}),this.canvas.addEventListener("pointermove",this.canvasPointermove.bind(this),{signal:i}),this.canvas.addEventListener("pointerup",this.canvasPointerup.bind(this),{signal:i}),this.isEditing=!0,f(this,sc)||($(this,sc,!0),P(this,ce,Zc).call(this),this.thickness||(this.thickness=jt._defaultThickness),this.color||(this.color=jt._defaultColor||pt._defaultLineColor),this.opacity??(this.opacity=jt._defaultOpacity)),this.currentPath.push([t,s]),$(this,nc,!1),P(this,ce,Bw).call(this),$(this,fa,()=>{P(this,ce,uI).call(this),f(this,fa)&&window.requestAnimationFrame(f(this,fa))}),window.requestAnimationFrame(f(this,fa))},Uw=function(t,s){const[i,r]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===i&&s===r)return;const o=this.currentPath;let a=f(this,ho);if(o.push([t,s]),$(this,nc,!0),o.length<=2){a.moveTo(...o[0]),a.lineTo(t,s);return}o.length===3&&($(this,ho,a=new Path2D),a.moveTo(...o[0])),P(this,ce,dI).call(this,a,...o.at(-3),...o.at(-2),t,s)},cI=function(){if(this.currentPath.length===0)return;const t=this.currentPath.at(-1);f(this,ho).lineTo(...t)},hI=function(t,s){$(this,fa,null),t=Math.min(Math.max(t,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),P(this,ce,Uw).call(this,t,s),P(this,ce,cI).call(this);let i;if(this.currentPath.length!==1)i=P(this,ce,fI).call(this);else{const c=[t,s];i=[[c,c.slice(),c.slice(),c]]}const r=f(this,ho),o=this.currentPath;this.currentPath=[],$(this,ho,new Path2D);const a=()=>{this.allRawPaths.push(o),this.paths.push(i),this.bezierPath2D.push(r),this._uiManager.rebuild(this)},l=()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(P(this,ce,jg).call(this),P(this,ce,Fg).call(this)),P(this,ce,$d).call(this))};this.addCommands({cmd:a,undo:l,mustExec:!0})},uI=function(){if(!f(this,nc))return;$(this,nc,!1);const t=Math.ceil(this.thickness*this.parentScale),s=this.currentPath.slice(-3),i=s.map(a=>a[0]),r=s.map(a=>a[1]);Math.min(...i)-t,Math.max(...i)+t,Math.min(...r)-t,Math.max(...r)+t;const{ctx:o}=this;o.save(),o.clearRect(0,0,this.canvas.width,this.canvas.height);for(const a of this.bezierPath2D)o.stroke(a);o.stroke(f(this,ho)),o.restore()},dI=function(t,s,i,r,o,a,l){const c=(s+r)/2,h=(i+o)/2,u=(r+a)/2,d=(o+l)/2;t.bezierCurveTo(c+2*(r-c)/3,h+2*(o-h)/3,u+2*(r-u)/3,d+2*(o-d)/3,u,d)},fI=function(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const s=[];let i,[r,o]=t[0];for(i=1;i{$(this,wr,null),this.canvas.removeEventListener("contextmenu",xi)},10)),P(this,ce,hI).call(this,t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackground()},jg=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},Fg=function(){$(this,uo,new ResizeObserver(t=>{const s=t[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),f(this,uo).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var t;(t=f(this,uo))==null||t.disconnect(),$(this,uo,null)},{once:!0})},Zc=function(){if(!f(this,sc))return;const[t,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*s),P(this,ce,zg).call(this)},Gw=function(t,s){const i=P(this,ce,Hg).call(this),r=(t-i)/f(this,ec),o=(s-i)/f(this,Ql);this.scaleFactor=Math.min(r,o)},zg=function(){const t=P(this,ce,Hg).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)},Ro=new WeakSet,pI=function(t){const s=new Path2D;for(let i=0,r=t.length;i`image/${s}`))}static get supportedTypesStr(){return Xe(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,s){s.pasteEditor(De.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!!((t=this.altTextData)!=null&&t.altText)}}static computeTelemetryFinalData(t){const s=t.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(t=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:o,height:a}=t||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:r,width:o,height:a,channels:r.length/(o*a)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const c=l.output;return await this.setGuessedAltText(c),s&&!this.hasAltTextData()&&(this.altTextData={alt:c,decorative:!1}),c}remove(){var t,s;f(this,jn)&&($(this,zt,null),this._uiManager.imageManager.deleteId(f(this,jn)),(t=f(this,_r))==null||t.remove(),$(this,_r,null),(s=f(this,po))==null||s.disconnect(),$(this,po,null),f(this,Sr)&&(clearTimeout(f(this,Sr)),$(this,Sr,null))),super.remove()}rebuild(){if(!this.parent){f(this,jn)&&P(this,Ze,Bg).call(this);return}super.rebuild(),this.div!==null&&(f(this,jn)&&f(this,_r)===null&&P(this,Ze,Bg).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(f(this,pa)||f(this,zt)||f(this,fo)||f(this,ma)||f(this,jn))}get isResizable(){return!0}render(){if(this.div)return this.div;let t,s;if(this.width&&(t=this.x,s=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),f(this,zt)?P(this,Ze,Yw).call(this):P(this,Ze,Bg).call(this),this.width&&!this.annotationElementId){const[i,r]=this.parentDimensions;this.setAt(t*i,s*r,this.width*i,this.height*r)}return this.div}copyCanvas(t,s,i=!1){var p;t||(t=224);const{width:r,height:o}=f(this,zt),a=new Wb;let l=f(this,zt),c=r,h=o,u=null;if(s){if(r>s||o>s){const I=Math.min(s/r,s/o);c=Math.floor(r*I),h=Math.floor(o*I)}u=document.createElement("canvas");const m=u.width=Math.ceil(c*a.sx),y=u.height=Math.ceil(h*a.sy);f(this,Js)||(l=P(this,Ze,Ug).call(this,m,y));const v=u.getContext("2d");v.filter=this._uiManager.hcmFilter;let g="white",_="#cfcfd8";this._uiManager.hcmFilter!=="none"?_="black":(p=window.matchMedia)!=null&&p.call(window,"(prefers-color-scheme: dark)").matches&&(g="#8f8f9d",_="#42414d");const b=15,x=b*a.sx,A=b*a.sy,T=new OffscreenCanvas(x*2,A*2),C=T.getContext("2d");C.fillStyle=g,C.fillRect(0,0,x*2,A*2),C.fillStyle=_,C.fillRect(0,0,x,A),C.fillRect(x,A,x,A),v.fillStyle=v.createPattern(T,"repeat"),v.fillRect(0,0,m,y),v.drawImage(l,0,0,l.width,l.height,0,0,m,y)}let d=null;if(i){let m,y;if(a.symmetric&&l.widtht||o>t){const _=Math.min(t/r,t/o);m=Math.floor(r*_),y=Math.floor(o*_),f(this,Js)||(l=P(this,Ze,Ug).call(this,m,y))}const g=new OffscreenCanvas(m,y).getContext("2d",{willReadFrequently:!0});g.drawImage(l,0,0,l.width,l.height,0,0,m,y),d={width:m,height:y,data:g.getImageData(0,0,m,y).data}}return{canvas:u,width:c,height:h,imageData:d}}getImageForAltText(){return f(this,_r)}static async deserialize(t,s,i){var y;let r=null;if(t instanceof TM){const{data:{rect:v,rotation:g,id:_,structParent:b,popupRef:x},container:A,parent:{page:{pageNumber:T}}}=t,C=A.querySelector("canvas"),I=i.imageManager.getFromCanvas(A.id,C);C.remove();const D=((y=await s._structTree.getAriaAttributes(`${xx}${_}`))==null?void 0:y.get("aria-label"))||"";r=t={annotationType:De.STAMP,bitmapId:I.id,bitmap:I.bitmap,pageIndex:T-1,rect:v.slice(0),rotation:g,id:_,deleted:!1,accessibilityData:{decorative:!1,altText:D},isSvg:!1,structParent:b,popupRef:x}}const o=await super.deserialize(t,s,i),{rect:a,bitmap:l,bitmapUrl:c,bitmapId:h,isSvg:u,accessibilityData:d}=t;h&&i.imageManager.isValidId(h)?($(o,jn,h),l&&$(o,zt,l)):$(o,fo,c),$(o,Js,u);const[p,m]=o.pageDimensions;return o.width=(a[2]-a[0])/p,o.height=(a[3]-a[1])/m,o.annotationElementId=t.id||null,d&&(o.altTextData=d),o._initialData=r,$(o,fu,!!r),o}serialize(t=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:De.STAMP,bitmapId:f(this,jn),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:f(this,Js),structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=P(this,Ze,qg).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:r,altText:o}=this.serializeAltText(!1);if(!r&&o&&(i.accessibilityData={type:"Figure",alt:o}),this.annotationElementId){const l=P(this,Ze,bI).call(this,i);if(l.isSame)return null;l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,s===null)return i;s.stamps||(s.stamps=new Map);const a=f(this,Js)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(f(this,jn)))s.stamps.set(f(this,jn),{area:a,serialized:i}),i.bitmap=P(this,Ze,qg).call(this,!1);else if(f(this,Js)){const l=s.stamps.get(f(this,jn));a>l.area&&(l.area=a,l.serialized.bitmap.close(),l.serialized.bitmap=P(this,Ze,qg).call(this,!1))}return i}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}};zt=new WeakMap,jn=new WeakMap,pa=new WeakMap,fo=new WeakMap,ma=new WeakMap,du=new WeakMap,_r=new WeakMap,po=new WeakMap,Sr=new WeakMap,Js=new WeakMap,fu=new WeakMap,Ze=new WeakSet,Td=function(t,s=!1){if(!t){this.remove();return}$(this,zt,t.bitmap),s||($(this,jn,t.id),$(this,Js,t.isSvg)),t.file&&$(this,du,t.file.name),P(this,Ze,Yw).call(this)},Pd=function(){if($(this,pa,null),this._uiManager.enableWaiting(!1),!!f(this,_r)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&f(this,zt)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&f(this,zt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Bg=function(){if(f(this,jn)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(f(this,jn)).then(i=>P(this,Ze,Td).call(this,i,!0)).finally(()=>P(this,Ze,Pd).call(this));return}if(f(this,fo)){const i=f(this,fo);$(this,fo,null),this._uiManager.enableWaiting(!0),$(this,pa,this._uiManager.imageManager.getFromUrl(i).then(r=>P(this,Ze,Td).call(this,r)).finally(()=>P(this,Ze,Pd).call(this)));return}if(f(this,ma)){const i=f(this,ma);$(this,ma,null),this._uiManager.enableWaiting(!0),$(this,pa,this._uiManager.imageManager.getFromFile(i).then(r=>P(this,Ze,Td).call(this,r)).finally(()=>P(this,Ze,Pd).call(this)));return}const t=document.createElement("input");t.type="file",t.accept=tf.supportedTypesStr;const s=this._uiManager._signal;$(this,pa,new Promise(i=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),P(this,Ze,Td).call(this,r)}i()},{signal:s}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>P(this,Ze,Pd).call(this))),t.click()},Yw=function(){const{div:t}=this;let{width:s,height:i}=f(this,zt);const[r,o]=this.pageDimensions,a=.75;if(this.width)s=this.width*r,i=this.height*o;else if(s>a*r||i>a*o){const u=Math.min(a*r/s,a*o/i);s*=u,i*=u}const[l,c]=this.parentDimensions;this.setDims(s*l/r,i*c/o),this._uiManager.enableWaiting(!1);const h=$(this,_r,document.createElement("canvas"));h.setAttribute("role","img"),this.addContainer(h),(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),P(this,Ze,Jw).call(this,s,i),P(this,Ze,vI).call(this),f(this,fu)||(this.parent.addUndoableEditor(this),$(this,fu,!0)),this._reportTelemetry({action:"inserted_image"}),f(this,du)&&h.setAttribute("aria-label",f(this,du))},yI=function(t,s){var a;const[i,r]=this.parentDimensions;this.width=t/i,this.height=s/r,(a=this._initialOptions)!=null&&a.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,f(this,Sr)!==null&&clearTimeout(f(this,Sr)),$(this,Sr,setTimeout(()=>{$(this,Sr,null),P(this,Ze,Jw).call(this,t,s)},200))},Ug=function(t,s){const{width:i,height:r}=f(this,zt);let o=i,a=r,l=f(this,zt);for(;o>2*t||a>2*s;){const c=o,h=a;o>2*t&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2)),a>2*s&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const u=new OffscreenCanvas(o,a);u.getContext("2d").drawImage(l,0,0,c,h,0,0,o,a),l=u.transferToImageBitmap()}return l},Jw=function(t,s){const i=new Wb,r=Math.ceil(t*i.sx),o=Math.ceil(s*i.sy),a=f(this,_r);if(!a||a.width===r&&a.height===o)return;a.width=r,a.height=o;const l=f(this,Js)?f(this,zt):P(this,Ze,Ug).call(this,r,o),c=a.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(l,0,0,l.width,l.height,0,0,r,o)},qg=function(t){if(t){if(f(this,Js)){const r=this._uiManager.imageManager.getSvgUrl(f(this,jn));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=f(this,zt),s.getContext("2d").drawImage(f(this,zt),0,0),s.toDataURL()}if(f(this,Js)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*Pa.PDF_TO_CSS_UNITS),o=Math.round(this.height*i*Pa.PDF_TO_CSS_UNITS),a=new OffscreenCanvas(r,o);return a.getContext("2d").drawImage(f(this,zt),0,0,f(this,zt).width,f(this,zt).height,0,0,r,o),a.transferToImageBitmap()}return structuredClone(f(this,zt))},vI=function(){this._uiManager._signal&&($(this,po,new ResizeObserver(t=>{const s=t[0].contentRect;s.width&&s.height&&P(this,Ze,yI).call(this,s.width,s.height)})),f(this,po).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var t;(t=f(this,po))==null||t.disconnect(),$(this,po,null)},{once:!0}))},bI=function(t){var c;const{rect:s,pageIndex:i,accessibilityData:{altText:r}}=this._initialData,o=t.rect.every((h,u)=>Math.abs(h-s[u])<1),a=t.pageIndex===i,l=(((c=t.accessibilityData)==null?void 0:c.alt)||"")===r;return{isSame:o&&a&&l,isSameAltText:l}},oe(tf,"_type","stamp"),oe(tf,"_editorType",De.STAMP);let Xw=tf;var oc,pu,xr,ga,mo,Qs,ya,mu,gu,ss,go,ke,va,Wn,wI,e_,t_,n_,Vg;const Ri=class Ri{constructor({uiManager:e,pageIndex:t,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:o,drawLayer:a,textLayer:l,viewport:c,l10n:h}){M(this,Wn);M(this,oc);M(this,pu,!1);M(this,xr,null);M(this,ga,null);M(this,mo,null);M(this,Qs,new Map);M(this,ya,!1);M(this,mu,!1);M(this,gu,!1);M(this,ss,null);M(this,go,null);M(this,ke);const u=[...f(Ri,va).values()];if(!Ri._initialized){Ri._initialized=!0;for(const d of u)d.initialize(h,e)}e.registerEditorTypes(u),$(this,ke,e),this.pageIndex=t,this.div=s,$(this,oc,r),$(this,xr,o),this.viewport=c,$(this,ss,l),this.drawLayer=a,this._structTree=i,f(this,ke).addLayer(this)}get isEmpty(){return f(this,Qs).size===0}get isInvisible(){return this.isEmpty&&f(this,ke).getMode()===De.NONE}updateToolbar(e){f(this,ke).updateToolbar(e)}updateMode(e=f(this,ke).getMode()){switch(P(this,Wn,Vg).call(this),e){case De.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case De.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case De.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:t}=this.div;for(const s of f(Ri,va).values())t.toggle(`${s._type}Editing`,e===s._editorType);this.div.hidden=!1}hasTextLayer(e){var t;return e===((t=f(this,ss))==null?void 0:t.div)}addInkEditorIfNeeded(e){if(f(this,ke).getMode()!==De.INK)return;if(!e){for(const s of f(this,Qs).values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(e){f(this,ke).setEditingState(e)}addCommands(e){f(this,ke).addCommands(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){var t;(t=f(this,xr))==null||t.div.classList.toggle("disabled",!e)}async enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const e=new Set;for(const s of f(this,Qs).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(f(this,ke).removeChangedExistingAnnotation(s),e.add(s.annotationElementId));if(!f(this,xr))return;const t=f(this,xr).getEditableAnnotations();for(const s of t){if(s.hide(),f(this,ke).isDeletedAnnotationElement(s.data.id)||e.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){var i;$(this,gu,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,t=new Map;for(const r of f(this,Qs).values())if(r.disableEditing(),!!r.annotationElementId){if(r.serialize()!==null){e.set(r.annotationElementId,r);continue}else t.set(r.annotationElementId,r);(i=this.getEditableAnnotation(r.annotationElementId))==null||i.show(),r.remove()}if(f(this,xr)){const r=f(this,xr).getEditableAnnotations();for(const o of r){const{id:a}=o.data;if(f(this,ke).isDeletedAnnotationElement(a))continue;let l=t.get(a);if(l){l.resetAnnotationElement(o),l.show(!1),o.show();continue}l=e.get(a),l&&(f(this,ke).addChangedExistingAnnotation(l),l.renderAnnotationElement(o)&&l.show(!1)),o.show()}}P(this,Wn,Vg).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of f(Ri,va).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),$(this,gu,!1)}getEditableAnnotation(e){var t;return((t=f(this,xr))==null?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){f(this,ke).getActive()!==e&&f(this,ke).setActiveEditor(e)}enableTextSelection(){var e;if(this.div.tabIndex=-1,(e=f(this,ss))!=null&&e.div&&!f(this,go)){$(this,go,new AbortController);const t=f(this,ke).combinedSignal(f(this,go));f(this,ss).div.addEventListener("pointerdown",P(this,Wn,wI).bind(this),{signal:t}),f(this,ss).div.classList.add("highlighting")}}disableTextSelection(){var e;this.div.tabIndex=0,(e=f(this,ss))!=null&&e.div&&f(this,go)&&(f(this,go).abort(),$(this,go,null),f(this,ss).div.classList.remove("highlighting"))}enableClick(){if(f(this,ga))return;$(this,ga,new AbortController);const e=f(this,ke).combinedSignal(f(this,ga));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:e})}disableClick(){var e;(e=f(this,ga))==null||e.abort(),$(this,ga,null)}attach(e){f(this,Qs).set(e.id,e);const{annotationElementId:t}=e;t&&f(this,ke).isDeletedAnnotationElement(t)&&f(this,ke).removeDeletedAnnotationElement(e)}detach(e){var t;f(this,Qs).delete(e.id),(t=f(this,oc))==null||t.removePointerInTextLayer(e.contentDiv),!f(this,gu)&&e.annotationElementId&&f(this,ke).addDeletedAnnotationElement(e)}remove(e){this.detach(e),f(this,ke).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1,f(this,mu)||this.addInkEditorIfNeeded(!1)}changeParent(e){var t;e.parent!==this&&(e.parent&&e.annotationElementId&&(f(this,ke).addDeletedAnnotationElement(e.annotationElementId),pt.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),(t=e.parent)==null||t.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(!(e.parent===this&&e.isAttachedToDOM)){if(this.changeParent(e),f(this,ke).addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(),f(this,ke).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var s;if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&!f(this,mo)&&(e._focusEventsAllowed=!1,$(this,mo,setTimeout(()=>{$(this,mo,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:f(this,ke)._signal}),t.focus())},0))),e._structTreeParentId=(s=f(this,oc))==null?void 0:s.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||(e.parent=this),e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){const t=()=>e._uiManager.rebuild(e),s=()=>{e.remove()};this.addCommands({cmd:t,undo:s,mustExec:!1})}getNextId(){return f(this,ke).getId()}combinedSignal(e){return f(this,ke).combinedSignal(e)}canCreateNewEmptyEditor(){var e;return(e=f(this,Wn,e_))==null?void 0:e.canCreateNewEmptyEditor()}pasteEditor(e,t){f(this,ke).updateToolbar(e),f(this,ke).updateMode(e);const{offsetX:s,offsetY:i}=P(this,Wn,n_).call(this),r=this.getNextId(),o=P(this,Wn,t_).call(this,{parent:this,id:r,x:s,y:i,uiManager:f(this,ke),isCentered:!0,...t});o&&this.add(o)}async deserialize(e){var t;return await((t=f(Ri,va).get(e.annotationType??e.annotationEditorType))==null?void 0:t.deserialize(e,this,f(this,ke)))||null}createAndAddNewEditor(e,t,s={}){const i=this.getNextId(),r=P(this,Wn,t_).call(this,{parent:this,id:i,x:e.offsetX,y:e.offsetY,uiManager:f(this,ke),isCentered:t,...s});return r&&this.add(r),r}addNewEditor(){this.createAndAddNewEditor(P(this,Wn,n_).call(this),!0)}setSelected(e){f(this,ke).setSelected(e)}toggleSelected(e){f(this,ke).toggleSelected(e)}unselect(e){f(this,ke).unselect(e)}pointerup(e){const{isMac:t}=ys.platform;if(!(e.button!==0||e.ctrlKey&&t)&&e.target===this.div&&f(this,ya)){if($(this,ya,!1),!f(this,pu)){$(this,pu,!0);return}if(f(this,ke).getMode()===De.STAMP){f(this,ke).unselectAll();return}this.createAndAddNewEditor(e,!1)}}pointerdown(e){if(f(this,ke).getMode()===De.HIGHLIGHT&&this.enableTextSelection(),f(this,ya)){$(this,ya,!1);return}const{isMac:t}=ys.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div)return;$(this,ya,!0);const s=f(this,ke).getActive();$(this,pu,!s||s.isEmpty())}findNewParent(e,t,s){const i=f(this,ke).findParent(t,s);return i===null||i===this?!1:(i.changeParent(e),!0)}destroy(){var e,t;((e=f(this,ke).getActive())==null?void 0:e.parent)===this&&(f(this,ke).commitOrRemove(),f(this,ke).setActiveEditor(null)),f(this,mo)&&(clearTimeout(f(this,mo)),$(this,mo,null));for(const s of f(this,Qs).values())(t=f(this,oc))==null||t.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,f(this,Qs).clear(),f(this,ke).removeLayer(this)}render({viewport:e}){this.viewport=e,mc(this.div,e);for(const t of f(this,ke).getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:e}){f(this,ke).commitOrRemove(),P(this,Wn,Vg).call(this);const t=this.viewport.rotation,s=e.rotation;if(this.viewport=e,mc(this.div,{rotation:s}),t!==s)for(const i of f(this,Qs).values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return f(this,ke).viewParameters.realScale}};oc=new WeakMap,pu=new WeakMap,xr=new WeakMap,ga=new WeakMap,mo=new WeakMap,Qs=new WeakMap,ya=new WeakMap,mu=new WeakMap,gu=new WeakMap,ss=new WeakMap,go=new WeakMap,ke=new WeakMap,va=new WeakMap,Wn=new WeakSet,wI=function(e){f(this,ke).unselectAll();const{target:t}=e;if(t===f(this,ss).div||(t.getAttribute("role")==="img"||t.classList.contains("endOfContent"))&&f(this,ss).div.contains(t)){const{isMac:s}=ys.platform;if(e.button!==0||e.ctrlKey&&s)return;f(this,ke).showAllEditors("highlight",!0,!0),f(this,ss).div.classList.add("free"),this.toggleDrawing(),xy.startHighlighting(this,f(this,ke).direction==="ltr",{target:f(this,ss).div,x:e.x,y:e.y}),f(this,ss).div.addEventListener("pointerup",()=>{f(this,ss).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:f(this,ke)._signal}),e.preventDefault()}},e_=function(){return f(Ri,va).get(f(this,ke).getMode())},t_=function(e){const t=f(this,Wn,e_);return t?new t.prototype.constructor(e):null},n_=function(){const{x:e,y:t,width:s,height:i}=this.div.getBoundingClientRect(),r=Math.max(0,e),o=Math.max(0,t),a=Math.min(window.innerWidth,e+s),l=Math.min(window.innerHeight,t+i),c=(r+a)/2-e,h=(o+l)/2-t,[u,d]=this.viewport.rotation%180===0?[c,h]:[h,c];return{offsetX:u,offsetY:d}},Vg=function(){$(this,mu,!0);for(const e of f(this,Qs).values())e.isEmpty()&&e.remove();$(this,mu,!1)},oe(Ri,"_initialized",!1),M(Ri,va,new Map([Mw,Hw,Xw,xy].map(e=>[e._editorType,e])));let Qw=Ri;var Ar,Ip,sn,yo,Op,i_,Ec,r_,_I;const Nn=class Nn{constructor({pageIndex:e}){M(this,Ec);M(this,Ar,null);M(this,Ip,0);M(this,sn,new Map);M(this,yo,new Map);this.pageIndex=e}setParent(e){if(!f(this,Ar)){$(this,Ar,e);return}if(f(this,Ar)!==e){if(f(this,sn).size>0)for(const t of f(this,sn).values())t.remove(),e.append(t);$(this,Ar,e)}}static get _svgFactory(){return Xe(this,"_svgFactory",new Ix)}draw(e,t,s,i=!1){const r=hs(this,Ip)._++,o=P(this,Ec,r_).call(this,e.box);o.classList.add(...e.classNamesForDrawing);const a=Nn._svgFactory.createElement("defs");o.append(a);const l=Nn._svgFactory.createElement("path");a.append(l);const c=`path_p${this.pageIndex}_${r}`;l.setAttribute("id",c),l.setAttribute("d",e.toSVGPath()),i&&f(this,yo).set(r,l);const h=P(this,Ec,_I).call(this,a,c),u=Nn._svgFactory.createElement("use");return o.append(u),o.setAttribute("fill",t),o.setAttribute("fill-opacity",s),u.setAttribute("href",`#${c}`),f(this,sn).set(r,o),{id:r,clipPathId:`url(#${h})`}}drawOutline(e){const t=hs(this,Ip)._++,s=P(this,Ec,r_).call(this,e.box);s.classList.add(...e.classNamesForOutlining);const i=Nn._svgFactory.createElement("defs");s.append(i);const r=Nn._svgFactory.createElement("path");i.append(r);const o=`path_p${this.pageIndex}_${t}`;r.setAttribute("id",o),r.setAttribute("d",e.toSVGPath()),r.setAttribute("vector-effect","non-scaling-stroke");let a;if(e.mustRemoveSelfIntersections){const h=Nn._svgFactory.createElement("mask");i.append(h),a=`mask_p${this.pageIndex}_${t}`,h.setAttribute("id",a),h.setAttribute("maskUnits","objectBoundingBox");const u=Nn._svgFactory.createElement("rect");h.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const d=Nn._svgFactory.createElement("use");h.append(d),d.setAttribute("href",`#${o}`),d.setAttribute("stroke","none"),d.setAttribute("fill","black"),d.setAttribute("fill-rule","nonzero"),d.classList.add("mask")}const l=Nn._svgFactory.createElement("use");s.append(l),l.setAttribute("href",`#${o}`),a&&l.setAttribute("mask",`url(#${a})`);const c=l.cloneNode();return s.append(c),l.classList.add("mainOutline"),c.classList.add("secondaryOutline"),f(this,sn).set(t,s),t}finalizeLine(e,t){const s=f(this,yo).get(e);f(this,yo).delete(e),this.updateBox(e,t.box),s.setAttribute("d",t.toSVGPath())}updateLine(e,t){f(this,sn).get(e).firstChild.firstChild.setAttribute("d",t.toSVGPath())}updatePath(e,t){f(this,yo).get(e).setAttribute("d",t.toSVGPath())}updateBox(e,t){var s;P(s=Nn,Op,i_).call(s,f(this,sn).get(e),t)}show(e,t){f(this,sn).get(e).classList.toggle("hidden",!t)}rotate(e,t){f(this,sn).get(e).setAttribute("data-main-rotation",t)}changeColor(e,t){f(this,sn).get(e).setAttribute("fill",t)}changeOpacity(e,t){f(this,sn).get(e).setAttribute("fill-opacity",t)}addClass(e,t){f(this,sn).get(e).classList.add(t)}removeClass(e,t){f(this,sn).get(e).classList.remove(t)}getSVGRoot(e){return f(this,sn).get(e)}remove(e){f(this,yo).delete(e),f(this,Ar)!==null&&(f(this,sn).get(e).remove(),f(this,sn).delete(e))}destroy(){$(this,Ar,null);for(const e of f(this,sn).values())e.remove();f(this,sn).clear(),f(this,yo).clear()}};Ar=new WeakMap,Ip=new WeakMap,sn=new WeakMap,yo=new WeakMap,Op=new WeakSet,i_=function(e,{x:t=0,y:s=0,width:i=1,height:r=1}={}){const{style:o}=e;o.top=`${100*s}%`,o.left=`${100*t}%`,o.width=`${100*i}%`,o.height=`${100*r}%`},Ec=new WeakSet,r_=function(e){var s;const t=Nn._svgFactory.create(1,1,!0);return f(this,Ar).append(t),t.setAttribute("aria-hidden",!0),P(s=Nn,Op,i_).call(s,t,e),t},_I=function(e,t){const s=Nn._svgFactory.createElement("clipPath");e.append(s);const i=`clip_${t}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=Nn._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${t}`),r.classList.add("clip"),i},M(Nn,Op);let s_=Nn;Me.AbortException;Me.AnnotationEditorLayer;Me.AnnotationEditorParamsType;Me.AnnotationEditorType;Me.AnnotationEditorUIManager;var SI=Me.AnnotationLayer,xI=Me.AnnotationMode;Me.ColorPicker;Me.DOMSVGFactory;Me.DrawLayer;Me.FeatureTest;var z0=Me.GlobalWorkerOptions;Me.ImageKind;Me.InvalidPDFException;Me.MissingPDFException;Me.OPS;Me.OutputScale;var BZ=Me.PDFDataRangeTransport;Me.PDFDateString;Me.PDFWorker;Me.PasswordResponses;Me.PermissionFlag;Me.PixelsPerInch;Me.RenderingCancelledException;var AI=Me.TextLayer;Me.UnexpectedResponseException;Me.Util;Me.VerbosityLevel;Me.XfaLayer;Me.build;Me.createValidAbsoluteUrl;Me.fetchData;var kI=Me.getDocument;Me.getFilenameFromUrl;Me.getPdfFilenameFromUrl;Me.getXfaPageViewport;Me.isDataScheme;Me.isPdfFile;Me.noContextMenu;Me.normalizeUnicode;Me.setLayerDimensions;Me.shadow;var o_=Me.version;const UZ=Object.freeze(Object.defineProperty({__proto__:null,AnnotationLayer:SI,AnnotationMode:xI,GlobalWorkerOptions:z0,PDFDataRangeTransport:BZ,TextLayer:AI,getDocument:kI,version:o_},Symbol.toStringTag,{value:"Module"}));var _n=function(n,e,t){if(t||arguments.length===2)for(var s=0,i=e.length,r;s{vt(this.pdfDocument),vt(e),typeof e=="string"?this.pdfDocument.getDestination(e).then(t):Array.isArray(e)?t(e):e.then(t)}).then(t=>{vt(Array.isArray(t));const s=t[0];new Promise(i=>{vt(this.pdfDocument),s instanceof Object?this.pdfDocument.getPageIndex(s).then(r=>{i(r)}).catch(()=>{vt(!1)}):typeof s=="number"?i(s):vt(!1)}).then(i=>{const r=i+1;vt(this.pdfViewer),vt(r>=1&&r<=this.pagesCount),this.pdfViewer.scrollPageIntoView({dest:t,pageIndex:i,pageNumber:r})})})}navigateTo(e){this.goToDestination(e)}goToPage(e){const t=e-1;vt(this.pdfViewer),vt(e>=1&&e<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:t,pageNumber:e})}addLinkAttributes(e,t,s){e.href=t,e.rel=this.externalLinkRel||dX,e.target=s?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const dE={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},H0=typeof window<"u",$I=H0&&window.location.protocol==="file:";function pX(n){return typeof n<"u"}function Va(n){return pX(n)&&n!==null}function mX(n){return typeof n=="string"}function gX(n){return n instanceof ArrayBuffer}function yX(n){return vt(H0),n instanceof Blob}function a_(n){return mX(n)&&/^data:/.test(n)}function fE(n){vt(a_(n));const[e="",t=""]=n.split(",");return e.split(";").indexOf("base64")!==-1?atob(t):unescape(t)}function vX(){return H0&&window.devicePixelRatio||1}const TI="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function pE(){rs(!$I,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${TI}`)}function bX(){rs(!$I,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${TI}`)}function vc(n){n!=null&&n.cancel&&n.cancel()}function l_(n,e){return Object.defineProperty(n,"width",{get(){return this.view[2]*e},configurable:!0}),Object.defineProperty(n,"height",{get(){return this.view[3]*e},configurable:!0}),Object.defineProperty(n,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(n,"originalHeight",{get(){return this.view[3]},configurable:!0}),n}function wX(n){return n.name==="RenderingCancelledException"}function _X(n){return new Promise((e,t)=>{const s=new FileReader;s.onload=()=>{if(!s.result)return t(new Error("Error while reading a file."));e(s.result)},s.onerror=i=>{if(!i.target)return t(new Error("Error while reading a file."));const{error:r}=i.target;if(!r)return t(new Error("Error while reading a file."));switch(r.code){case r.NOT_FOUND_ERR:return t(new Error("Error while reading a file: File not found."));case r.SECURITY_ERR:return t(new Error("Error while reading a file: Security error."));case r.ABORT_ERR:return t(new Error("Error while reading a file: Aborted."));default:return t(new Error("Error while reading a file."))}},s.readAsArrayBuffer(n)})}function SX(n,e){switch(e.type){case"RESOLVE":return{value:e.value,error:void 0};case"REJECT":return{value:!1,error:e.error};case"RESET":return{value:void 0,error:void 0};default:return n}}function xu(){return q.useReducer(SX,{value:void 0,error:void 0})}var xX=function(n,e,t,s){function i(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function a(h){try{c(s.next(h))}catch(u){o(u)}}function l(h){try{c(s.throw(h))}catch(u){o(u)}}function c(h){h.done?r(h.value):i(h.value).then(a,l)}c((s=s.apply(n,e||[])).next())})},mE=function(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i{switch(e){case dE.NEED_PASSWORD:{const t=prompt("Enter the password to open this PDF file.");n(t);break}case dE.INCORRECT_PASSWORD:{const t=prompt("Invalid password. Please try again.");n(t);break}}};function gE(n){return typeof n=="object"&&n!==null&&("data"in n||"range"in n||"url"in n)}const EX=q.forwardRef(function(e,t){var{children:s,className:i,error:r="Failed to load PDF file.",externalLinkRel:o,externalLinkTarget:a,file:l,inputRef:c,imageResourcesPath:h,loading:u="Loading PDF…",noData:d="No PDF file specified.",onItemClick:p,onLoadError:m,onLoadProgress:y,onLoadSuccess:v,onPassword:g=kX,onSourceError:_,onSourceSuccess:b,options:x,renderMode:A,rotate:T}=e,C=mE(e,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[I,D]=xu(),{value:H,error:j}=I,[U,B]=xu(),{value:L,error:X}=U,se=q.useRef(new fX),J=q.useRef([]),Y=q.useRef(void 0),ge=q.useRef(void 0);l&&l!==Y.current&&gE(l)&&(rs(!dh(l,Y.current),`File prop passed to changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.`),Y.current=l),x&&x!==ge.current&&(rs(!dh(x,ge.current),`Options prop passed to changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.`),ge.current=x);const z=q.useRef({scrollPageIntoView:Ie=>{const{dest:Fe,pageNumber:Je,pageIndex:it=Je-1}=Ie;if(p){p({dest:Fe,pageIndex:it,pageNumber:Je});return}const bn=J.current[it];if(bn){bn.scrollIntoView();return}rs(!1,`An internal link leading to page ${Je} was clicked, but neither was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to and handle navigating by yourself or ensure that all pages are rendered within .`)}});q.useImperativeHandle(t,()=>({linkService:se,pages:J,viewer:z}),[]);function E(){b&&b()}function O(){j&&(rs(!1,j.toString()),_&&_(j))}function R(){D({type:"RESET"})}q.useEffect(R,[l,D]);const w=q.useCallback(()=>xX(this,void 0,void 0,function*(){if(!l)return null;if(typeof l=="string")return a_(l)?{data:fE(l)}:(pE(),{url:l});if(l instanceof AX)return{range:l};if(gX(l))return{data:l};if(H0&&yX(l))return{data:yield _X(l)};if(vt(typeof l=="object"),vt(gE(l)),"url"in l&&typeof l.url=="string"){if(a_(l.url)){const{url:Ie}=l,Fe=mE(l,["url"]),Je=fE(Ie);return Object.assign({data:Je},Fe)}pE()}return l}),[l]);q.useEffect(()=>{const Ie=sm(w());return Ie.promise.then(Fe=>{D({type:"RESOLVE",value:Fe})}).catch(Fe=>{D({type:"REJECT",error:Fe})}),()=>{vc(Ie)}},[w,D]),q.useEffect(()=>{if(!(typeof H>"u")){if(H===!1){O();return}E()}},[H]);function k(){L&&(v&&v(L),J.current=new Array(L.numPages),se.current.setDocument(L))}function N(){X&&(rs(!1,X.toString()),m&&m(X))}q.useEffect(function(){B({type:"RESET"})},[B,H]),q.useEffect(function(){if(!H)return;const Fe=x?Object.assign(Object.assign({},H),x):H,Je=kI(Fe);y&&(Je.onProgress=y),g&&(Je.onPassword=g);const it=Je,bn=it.promise.then(ut=>{B({type:"RESOLVE",value:ut})}).catch(ut=>{it.destroyed||B({type:"REJECT",error:ut})});return()=>{bn.finally(()=>it.destroy())}},[x,B,H]),q.useEffect(()=>{if(!(typeof L>"u")){if(L===!1){N();return}k()}},[L]),q.useEffect(function(){se.current.setViewer(z.current),se.current.setExternalLinkRel(o),se.current.setExternalLinkTarget(a)},[o,a]);const G=q.useCallback((Ie,Fe)=>{J.current[Ie]=Fe},[]),Z=q.useCallback(Ie=>{delete J.current[Ie]},[]),ae=q.useMemo(()=>({imageResourcesPath:h,linkService:se.current,onItemClick:p,pdf:L,registerPage:G,renderMode:A,rotate:T,unregisterPage:Z}),[h,p,L,G,A,T,Z]),ie=q.useMemo(()=>EI(C,()=>L),[C,L]);function Ae(){return S.jsx(CI.Provider,{value:ae,children:s})}function ct(){return l?L==null?S.jsx(fh,{type:"loading",children:typeof u=="function"?u():u}):L===!1?S.jsx(fh,{type:"error",children:typeof r=="function"?r():r}):Ae():S.jsx(fh,{type:"no-data",children:typeof d=="function"?d():d})}return S.jsx("div",Object.assign({className:l0("react-pdf__Document",i),ref:c,style:{"--scale-factor":"1"}},ie,{children:ct()}))});function PI(){return q.useContext(CI)}function RI(){for(var n=[],e=0;ePX(e),[e]),s=q.useMemo(()=>!B0(e)||OI(e)?null:e.children.map((i,r)=>S.jsx(LI,{node:i},r)),[e]);return S.jsx("span",Object.assign({className:n},t,{children:s}))}function U0(){return q.useContext(MI)}function RX(){const n=U0();vt(n);const{onGetStructTreeError:e,onGetStructTreeSuccess:t}=n,[s,i]=xu(),{value:r,error:o}=s,{customTextRenderer:a,page:l}=n;function c(){r&&t&&t(r)}function h(){o&&(rs(!1,o.toString()),e&&e(o))}return q.useEffect(function(){i({type:"RESET"})},[i,l]),q.useEffect(function(){if(a||!l)return;const d=sm(l.getStructTree()),p=d;return d.promise.then(m=>{i({type:"RESOLVE",value:m})}).catch(m=>{i({type:"REJECT",error:m})}),()=>vc(p)},[a,l,i]),q.useEffect(()=>{if(r!==void 0){if(r===!1){h();return}c()}},[r]),r?S.jsx(LI,{className:"react-pdf__Page__structTree structTree",node:r}):null}const yE=xI;function MX(n){const e=U0();vt(e);const t=Object.assign(Object.assign({},e),n),{_className:s,canvasBackground:i,devicePixelRatio:r=vX(),onRenderError:o,onRenderSuccess:a,page:l,renderForms:c,renderTextLayer:h,rotate:u,scale:d}=t,{canvasRef:p}=n;vt(l);const m=q.useRef(null);function y(){l&&a&&a(l_(l,d))}function v(x){wX(x)||(rs(!1,x.toString()),o&&o(x))}const g=q.useMemo(()=>l.getViewport({scale:d*r,rotation:u}),[r,l,u,d]),_=q.useMemo(()=>l.getViewport({scale:d,rotation:u}),[l,u,d]);q.useEffect(function(){if(!l)return;l.cleanup();const{current:A}=m;if(!A)return;A.width=g.width,A.height=g.height,A.style.width=`${Math.floor(_.width)}px`,A.style.height=`${Math.floor(_.height)}px`,A.style.visibility="hidden";const T={annotationMode:c?yE.ENABLE_FORMS:yE.ENABLE,canvasContext:A.getContext("2d",{alpha:!1}),viewport:g};i&&(T.background=i);const C=l.render(T),I=C;return C.promise.then(()=>{A.style.visibility="",y()}).catch(v),()=>vc(I)},[i,l,c,g,_]);const b=q.useCallback(()=>{const{current:x}=m;x&&(x.width=0,x.height=0)},[]);return q.useEffect(()=>b,[b]),S.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:RI(p,m),style:{display:"block",userSelect:"none"},children:h?S.jsx(RX,{}):null})}function IX(n){return"str"in n}function OX(){const n=U0();vt(n);const{customTextRenderer:e,onGetTextError:t,onGetTextSuccess:s,onRenderTextLayerError:i,onRenderTextLayerSuccess:r,page:o,pageIndex:a,pageNumber:l,rotate:c,scale:h}=n;vt(o);const[u,d]=xu(),{value:p,error:m}=u,y=q.useRef(null);rs(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10)===1,"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer");function v(){p&&s&&s(p)}function g(){m&&(rs(!1,m.toString()),t&&t(m))}q.useEffect(function(){d({type:"RESET"})},[o,d]),q.useEffect(function(){if(!o)return;const I=sm(o.getTextContent()),D=I;return I.promise.then(H=>{d({type:"RESOLVE",value:H})}).catch(H=>{d({type:"REJECT",error:H})}),()=>vc(D)},[o,d]),q.useEffect(()=>{if(p!==void 0){if(p===!1){g();return}v()}},[p]);const _=q.useCallback(()=>{r&&r()},[r]),b=q.useCallback(C=>{rs(!1,C.toString()),i&&i(C)},[i]);function x(){const C=y.current;C&&C.classList.add("selecting")}function A(){const C=y.current;C&&C.classList.remove("selecting")}const T=q.useMemo(()=>o.getViewport({scale:h,rotation:c}),[o,c,h]);return q.useLayoutEffect(function(){if(!o||!p)return;const{current:I}=y;if(!I)return;I.innerHTML="";const D=o.streamTextContent({includeMarkedContent:!0}),H={container:I,textContentSource:D,viewport:T},j=new AI(H),U=j;return j.render().then(()=>{const B=document.createElement("div");B.className="endOfContent",I.append(B);const L=I.querySelectorAll('[role="presentation"]');if(e){let X=0;p.items.forEach((se,J)=>{if(!IX(se))return;const Y=L[X];if(!Y)return;const ge=e(Object.assign({pageIndex:a,pageNumber:l,itemIndex:J},se));Y.innerHTML=ge,X+=se.str&&se.hasEOL?2:1})}_()}).catch(b),()=>vc(U)},[e,b,_,o,a,l,p,T]),S.jsx("div",{className:l0("react-pdf__Page__textContent","textLayer"),onMouseUp:A,onMouseDown:x,ref:y})}function NX(){const n=PI(),e=U0();vt(e);const t=Object.assign(Object.assign({},n),e),{imageResourcesPath:s,linkService:i,onGetAnnotationsError:r,onGetAnnotationsSuccess:o,onRenderAnnotationLayerError:a,onRenderAnnotationLayerSuccess:l,page:c,pdf:h,renderForms:u,rotate:d,scale:p=1}=t;vt(h),vt(c),vt(i);const[m,y]=xu(),{value:v,error:g}=m,_=q.useRef(null);rs(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10)===1,"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations");function b(){v&&o&&o(v)}function x(){g&&(rs(!1,g.toString()),r&&r(g))}q.useEffect(function(){y({type:"RESET"})},[y,c]),q.useEffect(function(){if(!c)return;const D=sm(c.getAnnotations()),H=D;return D.promise.then(j=>{y({type:"RESOLVE",value:j})}).catch(j=>{y({type:"REJECT",error:j})}),()=>{vc(H)}},[y,c]),q.useEffect(()=>{if(v!==void 0){if(v===!1){x();return}b()}},[v]);function A(){l&&l()}function T(I){rs(!1,`${I}`),a&&a(I)}const C=q.useMemo(()=>c.getViewport({scale:p,rotation:d}),[c,d,p]);return q.useEffect(function(){if(!h||!c||!i||!v)return;const{current:D}=_;if(!D)return;const H=C.clone({dontFlip:!0}),j={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:D,l10n:null,page:c,structTreeLayer:null,viewport:H},U={annotations:v,annotationStorage:h.annotationStorage,div:D,imageResourcesPath:s,linkService:i,page:c,renderForms:u,viewport:H};D.innerHTML="";try{new SI(j).render(U),A()}catch(B){T(B)}return()=>{}},[v,s,i,c,h,u,C]),S.jsx("div",{className:l0("react-pdf__Page__annotations","annotationLayer"),ref:_})}var LX=function(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i{if(!ie)return null;let Kt=1;const Zn=w??vE;if(N||p){const an=ie.getViewport({scale:1,rotation:Je});N?Kt=N/an.width:p&&(Kt=p/an.height)}return Zn*Kt},[p,ie,Je,w,N]);q.useEffect(function(){return()=>{Va(Ie)&&i&&k&&k(Ie)}},[i,J,Ie,k]);function bn(){if(I){if(!ie||!it)return;I(l_(ie,it))}if(i&&Y){if(!Va(Ie)||!ct.current)return;Y(Ie,ct.current)}}function ut(){Ae&&(rs(!1,Ae.toString()),C&&C(Ae))}q.useEffect(function(){ae({type:"RESET"})},[ae,J,Ie]),q.useEffect(function(){if(!J||!Fe)return;const Zn=sm(J.getPage(Fe)),an=Zn;return Zn.promise.then(Es=>{ae({type:"RESOLVE",value:Es})}).catch(Es=>{ae({type:"REJECT",error:Es})}),()=>vc(an)},[ae,J,Fe]),q.useEffect(()=>{if(ie!==void 0){if(ie===!1){ut();return}bn()}},[ie,it]);const Ss=q.useMemo(()=>ie&&Va(Ie)&&Fe&&Va(Je)&&Va(it)?{_className:s,canvasBackground:r,customTextRenderer:h,devicePixelRatio:u,onGetAnnotationsError:g,onGetAnnotationsSuccess:_,onGetStructTreeError:b,onGetStructTreeSuccess:x,onGetTextError:A,onGetTextSuccess:T,onRenderAnnotationLayerError:D,onRenderAnnotationLayerSuccess:H,onRenderError:j,onRenderSuccess:U,onRenderTextLayerError:B,onRenderTextLayerSuccess:L,page:ie,pageIndex:Ie,pageNumber:Fe,renderForms:z,renderTextLayer:O,rotate:Je,scale:it}:null,[s,r,h,u,g,_,b,x,A,T,D,H,j,U,B,L,ie,Ie,Fe,z,O,Je,it]),xs=q.useMemo(()=>EI(G,()=>ie&&(it?l_(ie,it):void 0)),[G,ie,it]),Pn=`${Ie}@${it}/${Je}`;function ls(){switch(E){case"custom":return vt(c),S.jsx(c,{},`${Pn}_custom`);case"none":return null;case"canvas":default:return S.jsx(MX,{canvasRef:o},`${Pn}_canvas`)}}function As(){return O?S.jsx(OX,{},`${Pn}_text`):null}function ks(){return ge?S.jsx(NX,{},`${Pn}_annotations`):null}function cs(){return S.jsxs(MI.Provider,{value:Ss,children:[ls(),As(),ks(),a]})}function wn(){return Fe?J===null||ie===void 0||ie===null?S.jsx(fh,{type:"loading",children:typeof y=="function"?y():y}):J===!1||ie===!1?S.jsx(fh,{type:"error",children:typeof d=="function"?d():d}):cs():S.jsx(fh,{type:"no-data",children:typeof v=="function"?v():v})}return S.jsx("div",Object.assign({className:l0(s,l),"data-page-number":Fe,ref:RI(m,ct),style:{"--scale-factor":`${it}`,backgroundColor:r||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},xs,{children:wn()}))}bX();z0.workerSrc="pdf.worker.mjs";const jX="/assets/pdf.worker.min-GB3t0DcA.js";z0.workerSrc=jX;function FX(){if(!z0.workerSrc)throw new Error("The bundled PDF worker is not configured.");if(o_!=="4.8.69")throw new Error(`PDF runtime version mismatch (${o_}).`)}const zX=280,HX=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","A"]);function BX({enabled:n,pagesRoot:e,routeId:t,paperVersion:s,numPages:i,resetKey:r,onSelect:o,onError:a}){const l=q.useRef(!1),c=q.useRef(!1),h=q.useRef(""),u=q.useRef(0),d=q.useRef(0),p=q.useRef(""),m=q.useRef(o),y=q.useRef(a);m.current=o,y.current=a,q.useEffect(()=>{l.current=!1,c.current=!1,h.current="",p.current="",window.clearTimeout(u.current),cancelAnimationFrame(d.current),d.current=0},[t,s,r]),q.useEffect(()=>{if(!n){l.current=!1,c.current=!1,window.clearTimeout(u.current),cancelAnimationFrame(d.current),d.current=0;return}const v=()=>{var D,H;const C=FL({selection:window.getSelection(),pagesRoot:e.current,routeId:t,paperVersion:s,numPages:i});if(!C.ok){C.error&&((D=y.current)==null||D.call(y,C.error));return}const I=zL(C.selection);I!==h.current&&(h.current=I,(H=m.current)==null||H.call(m,C.selection))},g=()=>{window.clearTimeout(u.current),cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=0,v()})},_=C=>{const I=e.current;!I||!C.isPrimary||C.pointerType==="mouse"&&C.button!==0||!(C.target instanceof Node)||!I.contains(C.target)||(l.current=!0,c.current=!1,h.current="",window.clearTimeout(u.current),cancelAnimationFrame(d.current),d.current=0)},b=C=>{!l.current||!C.isPrimary||(l.current=!1,g())},x=C=>{!l.current||!C.isPrimary||(l.current=!1,c.current=!0,p.current="",window.clearTimeout(u.current),cancelAnimationFrame(d.current),d.current=0)},A=C=>{var j,U;const I=e.current;if(!I||l.current||!(C.target instanceof Node&&!!((U=(j=C.target instanceof Element?C.target:C.target.parentElement)==null?void 0:j.closest)!=null&&U.call(j,".textLayer, .reader-web-document")&&I.contains(C.target))))return;const H=(C.key==="a"||C.key==="A")&&(C.metaKey||C.ctrlKey);(C.shiftKey||HX.has(C.key)||H)&&(c.current=!1,h.current="",g())},T=()=>{if(l.current||c.current)return;const C=window.getSelection(),I=C&&C.rangeCount===1?`${C.toString()}\0${C.anchorNode?1:0}\0${C.focusNode?1:0}`:"";p.current=I,window.clearTimeout(u.current),u.current=window.setTimeout(()=>{p.current===I&&v()},zX)};return document.addEventListener("pointerdown",_,!0),document.addEventListener("pointerup",b,!0),document.addEventListener("pointercancel",x,!0),document.addEventListener("keyup",A,!0),document.addEventListener("selectionchange",T),()=>{document.removeEventListener("pointerdown",_,!0),document.removeEventListener("pointerup",b,!0),document.removeEventListener("pointercancel",x,!0),document.removeEventListener("keyup",A,!0),document.removeEventListener("selectionchange",T),window.clearTimeout(u.current),cancelAnimationFrame(d.current)}},[n,i,e,s,t])}const UX=.25,qX=4,bE=[.25,.33,.5,.67,.75,.9,1,1.1,1.25,1.5,1.75,2,2.5,3,4];function c_(n){return Math.max(UX,Math.min(qX,n))}function jm(n,e){const t=e>0?bE:[...bE].reverse();return t.find(s=>(s-n)*e>.005)??t[t.length-1]}function VX({paperTitle:n,paperHref:e,resources:t,label:s,children:i}){const r=q.useRef(null);return q.useLayoutEffect(()=>{const o=r.current,a=document.querySelector(".app-header .brand-mark");if(!o||!a)return;const l=()=>{const h=a.getBoundingClientRect().left-o.getBoundingClientRect().left;o.style.setProperty("--reader-title-inset",`${Math.max(10,h)}px`)};l();const c=new ResizeObserver(l);return c.observe(o),c.observe(a),()=>c.disconnect()},[]),S.jsxs("div",{ref:r,className:"pdf-toolbar","aria-label":s,children:[S.jsxs("div",{className:"pdf-toolbar-paper",children:[S.jsxs(Nd,{className:"pdf-toolbar-back",to:e,"aria-label":"Back",children:[S.jsx(nD,{size:15,strokeWidth:1.8,"aria-hidden":"true"}),S.jsx("span",{children:"Back"})]}),S.jsx(Nd,{className:"pdf-toolbar-title",to:e,title:n,"aria-label":`${n} — open paper page`,children:n}),(t==null?void 0:t.repository)&&S.jsxs("a",{className:"pdf-toolbar-resource",href:t.repository.href,target:"_blank",rel:"noopener noreferrer",title:"Official GitHub repository","aria-label":"Open official GitHub repository",children:[S.jsx(h0,{size:15,strokeWidth:1.8,"aria-hidden":"true"}),S.jsxs("span",{"aria-label":`${t.repository.stars} GitHub stars`,children:["★ ",t.repository.stars.toLocaleString()]})]}),(t==null?void 0:t.projectPage)&&S.jsxs("a",{className:"pdf-toolbar-resource",href:t.projectPage.href,target:"_blank",rel:"noopener noreferrer",title:t.projectPage.href,"aria-label":`Open project page at ${t.projectPage.label}`,children:[S.jsx(n$,{size:14,strokeWidth:1.8,"aria-hidden":"true"}),S.jsx("span",{children:t.projectPage.label})]}),(t==null?void 0:t.huggingFace)&&S.jsxs("a",{className:"pdf-toolbar-resource",href:t.huggingFace.href,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${t.huggingFace.count} Hugging Face ${t.huggingFace.count===1?"artifact":"artifacts"}`,children:[S.jsx("span",{"aria-hidden":"true",children:"🤗"}),S.jsxs("span",{children:[t.huggingFace.count," HF ",t.huggingFace.count===1?"artifact":"artifacts"]})]})]}),i]})}function WX({paperTitle:n,paperHref:e,resources:t,page:s,pages:i,zoomPercent:r,searchOpen:o,searchQuery:a,searchMatch:l,searchCount:c,searching:h,onPage:u,onZoom:d,onZoomIn:p,onZoomOut:m,onToggleSearch:y,onCloseSearch:v,onSearchQuery:g,onSearch:_}){const b=A=>{A.preventDefault();const T=Number(new FormData(A.currentTarget).get("page"));Number.isInteger(T)&&u(T)},x=A=>{A.preventDefault();const T=A.currentTarget.elements.namedItem("zoom"),C=Number.parseFloat(T.value),I=Number.isFinite(C)&&C>0?c_(C/100):r/100;T.value=`${Math.round(I*100)}%`,d(I)};return S.jsxs(VX,{paperTitle:n,paperHref:e,resources:t,label:"PDF controls",children:[S.jsxs("div",{className:"pdf-toolbar-controls",children:[S.jsxs("div",{className:"pdf-toolbar-group",children:[S.jsx("button",{type:"button",onClick:()=>u(s-1),disabled:s<=1,"aria-label":"Previous page",children:S.jsx(aD,{size:16,"aria-hidden":"true"})}),S.jsxs("form",{onSubmit:b,className:"pdf-page-form",children:[S.jsx("label",{className:"sr-only",htmlFor:"pdf-current-page",children:"Current page"}),S.jsx("input",{id:"pdf-current-page",name:"page",type:"number",min:1,max:i||1,defaultValue:s,"aria-label":`Page ${s} of ${i||"unknown"}`},s),S.jsxs("span",{"aria-hidden":"true",children:["/ ",i||"—"]})]}),S.jsx("button",{type:"button",onClick:()=>u(s+1),disabled:!i||s>=i,"aria-label":"Next page",children:S.jsx(RL,{size:16,"aria-hidden":"true"})})]}),S.jsxs("div",{className:"pdf-toolbar-group",children:[S.jsx("button",{type:"button",onClick:m,"aria-label":"Zoom out",children:S.jsx(hD,{size:15,"aria-hidden":"true"})}),S.jsx("form",{onSubmit:x,className:"pdf-zoom-form",children:S.jsx("input",{className:"pdf-zoom-value",name:"zoom",inputMode:"decimal",defaultValue:`${r}%`,onFocus:A=>A.currentTarget.select(),onBlur:A=>{var T;return(T=A.currentTarget.form)==null?void 0:T.requestSubmit()},"aria-label":`Zoom ${r}%`},r)}),S.jsx("button",{type:"button",onClick:p,"aria-label":"Zoom in",children:S.jsx(sD,{size:15,"aria-hidden":"true"})})]}),S.jsxs("button",{type:"button",className:"pdf-toolbar-search",onClick:y,"aria-label":"Search","aria-expanded":o,"aria-controls":"pdf-search-controls",children:[S.jsx(iD,{size:14,strokeWidth:2,"aria-hidden":"true"}),S.jsx("span",{children:"Search"})]})]}),o&&S.jsxs("div",{id:"pdf-search-controls",className:"pdf-search-controls",children:[S.jsx("label",{className:"sr-only",htmlFor:"pdf-search-input",children:"Search document"}),S.jsx("input",{id:"pdf-search-input",autoFocus:!0,value:a,onChange:A=>g(A.target.value),placeholder:"Search document"}),S.jsx("span",{role:"status",children:h&&!c?"Searching…":a?`${c?l+1:0} of ${c}${h?"+":""}`:""}),S.jsx("button",{type:"button",onClick:()=>_(-1),disabled:!c,"aria-label":"Previous match",children:S.jsx(s$,{size:16,"aria-hidden":"true"})}),S.jsx("button",{type:"button",onClick:()=>_(1),disabled:!c,"aria-label":"Next match",children:S.jsx(i$,{size:16,"aria-hidden":"true"})}),S.jsx("button",{type:"button",onClick:v,"aria-label":"Close search",title:"Close search",children:S.jsx(c0,{size:16,"aria-hidden":"true"})})]})]})}function wE(n){let e;try{e=new URL(n)}catch{return null}if(!["http:","https:"].includes(e.protocol)||!/^(www\.)?arxiv\.org$/i.test(e.hostname))return null;const t=e.pathname.match(/^\/(?:abs|pdf|html)\/(\d{4}\.\d{4,5}|[a-z-]+(?:\.[A-Z]{2})?\/\d{7})(?:v\d+)?(?:\.pdf)?\/?$/i);return(t==null?void 0:t[1])??null}const GX=8,KX=12,ZX=300,XX=6;function YX(n){const e=n.replace(/^\s*\[[^\]]{1,6}\]\s*/,"").split(/[.?!](?=\s|$|[A-Z])/).map(o=>o.replace(/\s+/g," ").trim()).filter(Boolean),t=o=>o.length<=ZX&&o.split(" ").length>=3&&/[a-z]/i.test(o)&&!/https?:\/\//i.test(o)&&!/^arxiv preprint/i.test(o),s=(o,a)=>a.length-o.length,i=e.filter(t).sort(s),r=e.slice(0,-1).map((o,a)=>`${o}. ${e[a+1]}`).filter(t).sort(s);return[...new Set([...i,...r])].slice(0,GX)}function JX(n){const e=[];let t;for(const s of n){if(!("str"in s))continue;const i=s.transform[5];(!t||Math.abs(i-t.baseline)>1)&&(t={text:"",x:s.transform[4],baseline:i},e.push(t)),t.text+=s.str,s.hasEOL&&(t=void 0)}return e.map(s=>({...s,text:s.text.trim()})).filter(s=>s.text)}function h_([n,e,t,s]){return{x:i=>Math.round((i-n)/(t-n)*1e3),y:i=>Math.round((s-i)/(s-e)*1e3)}}const QX=/\[(\d{1,3}(?:\s*[,;\u2013-]\s*\d{1,3})*)\]/g;function eY(n){return n.split(/[,;]/).flatMap(e=>{const[t,s=t]=e.split(/[\u2013-]/).map(Number);return s>=t&&s-t<50?Array.from({length:s-t+1},(i,r)=>t+r):[t]})}function tY(n,e){const t=h_(e),s=new Map,i=[];let r;for(const o of n)"str"in o&&((!r||Math.abs(o.transform[5]-r.parts[0].item.transform[5])>1)&&(r={text:"",parts:[]},i.push(r)),r.parts.push({start:r.text.length,item:o}),r.text+=o.str,o.hasEOL&&(r=void 0));for(const{text:o,parts:a}of i){const l=h=>a.filter(u=>u.start<=h).pop()??a[0],c=h=>{const{start:u,item:d}=l(h);return d.transform[4]+d.width*Math.min(1,(h-u)/Math.max(d.str.length,1))};for(const h of o.matchAll(QX)){const u=h.index??0,{item:d}=l(u),p=d.transform[5],m=d.height||Math.abs(d.transform[3]),y=[t.x(c(u)),t.y(p+m),t.x(c(u+h[0].length)),t.y(p)+3];for(const v of eY(h[1]))s.set(v,[...s.get(v)??[],y])}}return s}function nY(n,e){let t;const s=new Map,i=new Map,r=new Map;let o,a;const l=x=>{let A=i.get(x);return A||(A=n.getPage(x).then(async T=>({view:T.view,content:await T.getTextContent()})),i.set(x,A)),A},c=x=>{let A=s.get(x);return A||(A=n.getPage(x).then(T=>T.getAnnotations()),s.set(x,A)),A},h=()=>t??(t=(async()=>{var T;const x=await n.getDestinations(),A=[];for(const[C,I]of Object.entries(x)){if(!/^cite[.:]/i.test(C)||((T=I[1])==null?void 0:T.name)!=="XYZ"||typeof I[2]!="number"||typeof I[3]!="number")continue;const D=typeof I[0]=="number"?I[0]+1:await n.getPageIndex(I[0])+1;A.push({name:C,page:D,x:I[2],y:I[3]})}return A.length?A:u()})()),u=async()=>{var T;const x=[];for(let C=Math.max(1,n.numPages-KX+1);C<=n.numPages;C++)x.push(...JX((await l(C)).content.items).map(I=>({...I,page:C})));const A=x.flatMap((C,I)=>/^(?:[\dIVX]+\.?\s*)?(?:references|bibliography)$/i.test(C.text)?[I]:[]);for(const C of A.reverse()){const I=[];let D=0;for(const H of x.slice(C+1)){const j=Number((T=H.text.match(/^\[(\d{1,3})\]/))==null?void 0:T[1]);j>D&&j<=D+3&&(D=j,I.push({name:`text:${j}`,page:H.page,x:H.x,y:H.baseline}))}if(I.length)return I}return[]},d=x=>{let A=r.get(x);return A||(A=(async()=>{const T=await h(),C=T.find(E=>E.name===x);if(!C)return null;const I=T.filter(E=>E.page===C.page),D=I.filter(E=>Math.abs(E.x-C.x)<24),H=Math.max(0,...D.filter(E=>E.yE.y)),j=Math.min(1/0,...I.filter(E=>E.x>C.x+24).map(E=>E.x-4)),U=new Set,B=(E,O)=>E>=C.x-4&&EH;for(const E of await c(C.page)){if(!E.url||!E.rect)continue;const O=wE(E.url);if(!O)continue;const[R,w,k,N]=E.rect;B((R+k)/2,(w+N)/2)&&U.add(O)}const{view:L,content:X}=await l(C.page),se=X.items.filter(E=>"str"in E&&B(E.transform[4],E.transform[5])),J=se.map(E=>E.str+(E.hasEOL?" ":"")).join(""),Y=se.filter(E=>E.str.trim()).sort((E,O)=>O.transform[5]-E.transform[5]),ge=Y.findIndex((E,O)=>O>0&&Y[O-1].transform[5]-E.transform[5]>2.5*Math.max(Math.abs(E.transform[3]),1));ge>0&&(Y.length=ge);let z=null;if(Y.length){const{x:E,y:O}=h_(L);z=[E(Math.min(...Y.map(R=>R.transform[4]))),O(Math.max(...Y.map(R=>R.transform[5]+R.height))),E(Math.max(...Y.map(R=>R.transform[4]+R.width))),O(Math.min(...Y.map(R=>R.transform[5])))+3]}for(const E of J.replace(/\s/g,"").matchAll(/(?:arxiv:|arxiv\.org\/(?:abs|pdf|html)\/)(\d{4}\.\d{4,5}|[a-z-]+(?:\.[A-Z]{2})?\/\d{7})(?:v\d+)?/gi))U.add(E[1]);return{arxivId:U.size===1?[...U][0]:null,titles:YX(J),box:z}})(),r.set(x,A)),A},p=()=>o??(o=(async()=>{const x=new Map;if(!e)return x;try{const A=await h(),T=[];for(const C of A){const I=await d(C.name);I&&(I.arxivId||I.titles.length)&&T.push({key:C.name,arxiv_id:I.arxivId,titles:I.titles})}return T.length?await e(T):x}catch{return x}})()),m=()=>a??(a=(async()=>{const x=new Map,A=(B,L,X)=>{const se=x.get(B)??[],J=se[se.length-1],Y=J==null?void 0:J[J.length-1];(Y==null?void 0:Y.page)===L&&Math.abs(Y.bbox[1]-X[1])<5&&X[0]>=Y.bbox[0]&&X[0]-Y.bbox[2]<15?Y.bbox=[Y.bbox[0],Math.min(Y.bbox[1],X[1]),Math.max(Y.bbox[2],X[2]),Math.max(Y.bbox[3],X[3])]:(Y==null?void 0:Y.page)===L&&X[1]>Y.bbox[1]&&X[1]-Y.bbox[3]<10&&X[0]{if(I){const{view:J,content:Y}=await l(B),ge=B"str"in z&&z.transform[5]>C.y+1);return[...tY(ge,J)].flatMap(([z,E])=>E.map(O=>[`text:${z}`,O]))}const L=(await c(B)).filter(J=>typeof J.dest=="string"&&/^cite[.:]/i.test(J.dest));if(!L.length)return[];const{x:X,y:se}=h_((await n.getPage(B)).view);return L.flatMap(({dest:J,rect:Y})=>Y?[[J,[X(Y[0]),se(Y[3]),X(Y[2]),se(Y[1])]]]:[])},H=I?C.page:n.numPages,j=[],U=B=>j[B]??(j[B]=D(B).catch(()=>[]));for(let B=1;B<=H;B++){for(let L=B+1;L<=Math.min(H,B+XX);L++)U(L);for(const[L,X]of await U(B))A(L,B,X)}return x})());e&&p();const y=async x=>{const A=await d(x);return A?A.arxivId??(await p()).get(x)??null:null};return Object.assign(async x=>x.url?wE(x.url):typeof x.dest!="string"||!/^cite[.:]/i.test(x.dest)?null:y(x.dest),{bibliographyLinks:async x=>{const A=(await h()).filter(C=>C.page===x);return(await Promise.all(A.map(async({name:C})=>{const[I,D]=await Promise.all([d(C),y(C)]);return I!=null&&I.box&&D?{name:C,routeId:D,box:I.box}:null}))).filter(C=>C!==null)},citationsOf:async x=>(await m()).get(x)??[],referenceOf:async x=>{var C;const A=(await h()).find(I=>I.name===x),T=A&&((C=await d(x))==null?void 0:C.box);return T?{page:A.page,bbox:T}:null}})}function sY({anchor:n,routeId:e,internal:t,dest:s,onShowReference:i}){q.useEffect(()=>{const a=n.style.display;return n.style.display="none",()=>{n.style.display=a}},[n]);const r=n.parentElement;if(!r)return null;const o=()=>{if(!s||!i)return n.click();i(s).then(a=>{a||n.click()})};return ML.createPortal(S.jsx(u0,{routeId:e,to:n.href,target:t?void 0:"_blank",className:"pdf-paper-preview-link",title:/^\d+$/.test(e)?"Preview paper":`Preview arXiv:${e}`,ariaLabel:`${t?"Citation":"arXiv paper"} ${e}`,cardOpensPaper:!0,onClick:t?a=>{a.preventDefault(),o()}:void 0,previewFooter:()=>S.jsxs("div",{className:"pdf-paper-preview-actions",children:[S.jsx("a",{href:`/paper/${encodeURIComponent(e)}`,target:"_blank",rel:"noopener noreferrer",children:"Open paper ↗"}),t&&S.jsx("button",{type:"button",onClick:o,children:"Jump to reference"})]}),children:null}),r)}function iY({routeId:n,box:[e,t,s,i],citations:r=[],onShowCitations:o}){return S.jsx("div",{className:"pdf-bibliography-link",style:{left:`${e/10}%`,top:`${t/10}%`,width:`${(s-e)/10}%`,height:`${(i-t)/10}%`},children:S.jsx(u0,{routeId:n,to:`/paper/${encodeURIComponent(n)}`,target:"_blank",className:"pdf-paper-preview-link",title:/^\d+$/.test(n)?"Preview paper":`Preview arXiv:${n}`,ariaLabel:`Reference ${n}`,cardOpensPaper:!0,previewFooter:()=>S.jsxs("div",{className:"pdf-paper-preview-actions",children:[S.jsx("a",{href:`/paper/${encodeURIComponent(n)}`,target:"_blank",rel:"noopener noreferrer",children:"Open paper ↗"}),r.length>0&&o&&S.jsx("button",{type:"button",onClick:()=>o(r),children:r.length>1?`Jump to citations (${r.length})`:"Jump to citation"})]}),children:null})})}const rY=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function oY({id:n,name:e,avatarUrl:t,box:[s,i,r,o]}){var p,m,y,v;const[a,l]=q.useState(!1),c=`/authors/${encodeURIComponent(n)}`,h=wo({queryKey:["author",n],queryFn:()=>oD.getAuthor(n),enabled:a,staleTime:5*60*1e3,retry:!1}),u=(p=h.data)==null?void 0:p.paper_count,d=(m=h.data)==null?void 0:m.hf_username;return S.jsx("div",{className:"pdf-author-link",style:{left:`${s/10}%`,top:`${i/10}%`,width:`${(r-s)/10}%`,height:`${(o-i)/10}%`},children:S.jsxs(Np,{open:a,onOpenChange:g=>{(!g||!rY())&&l(g)},openDelay:150,closeDelay:100,children:[S.jsx(Lp,{asChild:!0,children:S.jsx(Nd,{to:c,target:"_blank",rel:"noopener noreferrer","aria-label":`Author ${e}`,onClick:()=>l(!1)})}),S.jsxs(Dp,{className:"paper-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:[S.jsxs(Nd,{className:"pdf-author-card",to:c,target:"_blank",rel:"noopener noreferrer",onClick:()=>l(!1),children:[S.jsx(rD,{url:((y=h.data)==null?void 0:y.hf_avatar_url)??t,className:"pdf-author-card-avatar"}),S.jsxs("div",{className:"pdf-author-card-meta",children:[S.jsx("div",{className:"paper-preview-title",children:((v=h.data)==null?void 0:v.full_name)??e}),S.jsxs("div",{className:"paper-preview-auth",children:[u!=null&&`${u.toLocaleString()} ${u===1?"paper":"papers"}`,u!=null&&d&&" · ",d&&`@${d}`]})]})]}),S.jsx("div",{className:"pdf-paper-preview-actions",children:S.jsx(Nd,{to:c,target:"_blank",rel:"noopener noreferrer",onClick:()=>l(!1),children:"Open author page ↗"})})]})]})})}const _E=0,aY=1,Xc=2,Rd=3,lY=4,cY=2,hY={ł:"l",ø:"o",đ:"d",ð:"d",ı:"i",ß:"ss",æ:"ae",œ:"oe",þ:"th"};function Nx(n){return n.normalize("NFKD").toLocaleLowerCase().replace(/[^\p{L}]/gu,"").replace(/[łøđðıßæœþ]/g,e=>hY[e])}function uY(n){return/[\p{M}\p{Sk}'’ʼ\-‐‑]/u.test(n)?aY:/[\s.]/u.test(n)?Xc:Rd}function dY(n){const e=n.map(s=>({letters:Nx(s),capitalized:new RegExp("^\\P{L}*\\p{Lu}","u").test(s)})).filter(s=>s.letters),t=e.reduce((s,i)=>s+i.letters.length,0);return e.length>=2&&t>=lY?e:null}function fY(n){const e=new Map;for(const t of n){const s=t.name.split(/[\s.]+/).filter(Boolean),i=s.filter((o,a)=>a===0||a===s.length-1||Nx(o).length>1),r=new Set;for(const o of[s,i]){const a=dY(o);if(!a)continue;const l=a.map(h=>h.letters).join(" ");if(r.has(l))continue;r.add(l);const c=e.get(l);e.set(l,c===void 0?{authorId:t.id,words:a}:(c==null?void 0:c.authorId)===t.id?c:null)}}return[...e.values()].filter(t=>t!==null)}function pY(n,e){const t=fY(e);if(!t.length)return[];const s=[],i=[],r=[],o=[],a=[],l=[];let c=Rd,h=!1;n.forEach((v,g)=>{g>0&&v.item!==n[g-1].item&&(c=Math.max(c,Xc));for(let _=0;_{if(!u.startsWith(g.letters,v)||g.capitalized&&!i[v])return!1;for(let _=v+1;_r[v]===Xc&&i[v]&&r[v+1]===Xc,m=(v,g)=>{if(r[g]0){if(r[_]===_E||r[_]===Rd)return-1;for(let A=0;A=Xc&&!o[_]?_:-1},y=[];for(const v of t){const g=v.words[0].letters;for(let _=u.indexOf(g);_>=0;_=u.indexOf(g,_+1)){const b=m(v,_);b>_&&!y.some(x=>x.authorId===v.authorId&&x.from===_)&&y.push({authorId:v.authorId,start:a[_],end:l[b-1],from:_,to:b})}}return y.filter(v=>!y.some(g=>g.authorId!==v.authorId&&g.from=v.to-v.from)).sort((v,g)=>v.from-g.from).map(({authorId:v,start:g,end:_})=>({authorId:v,start:g,end:_}))}function mY(n,e){const t=n.querySelector(".textLayer");if(!t||!e.length)return[];const s=[],i=[],r=new Map,o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let c=o.nextNode();c;c=o.nextNode()){const h=c.parentElement,u=(h==null?void 0:h.tagName)==="MARK"?h.parentElement:h;u&&(r.has(u)||r.set(u,r.size),s.push(c),i.push({text:c.data,item:r.get(u)}))}const a=n.getBoundingClientRect();if(!a.width||!a.height)return[];const l=(c,h,u)=>Math.round((c-h)/u*1e3);return pY(i,e).flatMap(({authorId:c,start:h,end:u})=>{const d=document.createRange();d.setStart(s[h.run],h.offset),d.setEnd(s[u.run],u.offset);const p=[];for(const m of d.getClientRects()){if(!m.width||!m.height)continue;const y=p.find(v=>m.top({authorId:c,box:[l(m.left,a.left,a.width),l(m.top,a.top,a.height),l(m.right,a.left,a.width),l(m.bottom,a.top,a.height)]}))})}function gY(n,e,t,s){const i=q.useRef([]),r=q.useRef(0),[o,a]=q.useState([]);q.useEffect(()=>()=>{r.current+=1},[]);const l=q.useCallback(h=>{i.current=h},[]),c=q.useCallback(()=>{var d;const h=++r.current;if(a([]),!t)return;const u=new Map(Array.from(((d=n.current)==null?void 0:d.querySelectorAll("[data-annotation-id] a:not(.pdf-paper-preview-link)"))??[]).map(p=>{var m;return[(m=p.parentElement)==null?void 0:m.dataset.annotationId,p]}));Promise.all(i.current.map(async p=>{const m=u.get(p.id);if(!m)return null;const y=await t(p).catch(()=>null);return y?{anchor:m,routeId:y,internal:!p.url,dest:typeof p.dest=="string"?p.dest:void 0}:null})).then(p=>{if(r.current!==h)return;const m=p.filter(y=>y!==null&&y.anchor.isConnected);m.length&&(s==null||s([...new Set(m.map(y=>y.routeId))])),a(m)})},[s,n,t]);return q.useEffect(()=>{const h=n.current;if(!h||!e||!t)return;let u=requestAnimationFrame(c);const d=new MutationObserver(p=>{p.some(m=>[...m.addedNodes].some(y=>y instanceof Element&&y.matches(".linkAnnotation")))&&(cancelAnimationFrame(u),u=requestAnimationFrame(c))});return d.observe(h,{childList:!0,subtree:!0}),()=>{d.disconnect(),cancelAnimationFrame(u),r.current+=1}},[c,n,t,e]),{paperLinks:o,onAnnotations:l}}const yY=3,vY=6;function bY(n,e){let t=0,s=0;return n.querySelectorAll(".pdf-outline-tick").forEach((i,r)=>{const o=i.getBoundingClientRect(),a=o.top+o.height/2;(r===0||Math.abs(a-e){if(!i)return;const b=x=>{x.key==="Escape"&&(x.preventDefault(),r(!1))};return window.addEventListener("keydown",b,{capture:!0}),()=>window.removeEventListener("keydown",b,{capture:!0})},[i]);const u=o==null?void 0:o.position;if(q.useEffect(()=>{const b=h.current,x=u===void 0?null:b==null?void 0:b.querySelectorAll("li")[u];!b||!x||(b.scrollTop=x.offsetTop+x.offsetHeight/2-b.clientHeight/2)},[u]),!n.length)return null;const d=b=>{const{position:x,center:A}=bY(b.currentTarget,b.clientY),T=A-b.currentTarget.parentElement.getBoundingClientRect().top;a({position:x,top:T,dragged:c.current})},p=()=>{l.current=null,a(null)},m=b=>{var x,A;c.current=!1,b.pointerType!=="mouse"&&((A=(x=b.currentTarget).setPointerCapture)==null||A.call(x,b.pointerId),l.current=b.clientY,d(b))},y=b=>{if(b.pointerType!=="mouse"){if(l.current===null)return;Math.abs(b.clientY-l.current)>vY&&(c.current=!0)}d(b)},v=b=>{b.pointerType!=="mouse"&&(c.current&&o&&(b.currentTarget.blur(),r(!1),t(n[o.position])),p())},g=b=>o?Math.max(0,1-Math.abs(b-o.position)/yY):0,_=o!=null&&o.dragged&&!i?n[o.position]:null;return S.jsxs("nav",{className:`pdf-outline${i?" is-pinned":""}`,"aria-label":"Paper sections",children:[S.jsx("button",{type:"button",className:"pdf-outline-rail","aria-label":"Table of contents","aria-expanded":i,"aria-controls":s,onClick:()=>{if(c.current){c.current=!1;return}r(b=>!b)},onPointerDown:m,onPointerMove:y,onPointerUp:v,onPointerCancel:()=>{c.current=!1,p()},onPointerLeave:b=>{b.pointerType==="mouse"&&p()},children:n.map((b,x)=>S.jsx("span",{className:`pdf-outline-tick level-${b.level}${b.index===e?" is-active":""}${(o==null?void 0:o.position)===x?" is-scrubbed":""}`,style:{"--pop":g(x)}},b.index))}),_&&S.jsx("span",{className:"pdf-outline-scrub-label",style:{top:o.top},"aria-hidden":"true",children:_.title}),S.jsx("div",{id:s,ref:h,className:"pdf-outline-panel",children:S.jsx("ol",{children:n.map((b,x)=>S.jsx("li",{className:`level-${b.level}`,children:S.jsx("a",{className:(o==null?void 0:o.position)===x?"is-scrubbed":void 0,href:`#pdf-section-${b.index}`,"aria-current":b.index===e?"location":void 0,onClick:A=>{A.preventDefault(),A.currentTarget.blur(),r(!1),t(b)},children:b.title})},b.index))})})]})}function _Y({index:n,count:e,onStep:t,onClose:s}){return S.jsxs("div",{className:"pdf-citation-steps",role:"group","aria-label":"Citations of this reference",children:[S.jsxs("span",{role:"status",children:["Citation ",n+1," of ",e]}),S.jsx("button",{type:"button",onClick:()=>t(-1),"aria-label":"Previous citation",title:"Previous citation",children:S.jsx(s$,{size:16,"aria-hidden":"true"})}),S.jsx("button",{type:"button",onClick:()=>t(1),"aria-label":"Next citation",title:"Next citation",children:S.jsx(i$,{size:16,"aria-hidden":"true"})}),S.jsx("button",{type:"button",onClick:s,"aria-label":"Close citations",title:"Close citations",children:S.jsx(c0,{size:16,"aria-hidden":"true"})})]})}const SY=/^#pdf-section-(\d+)$/,xY=2;function AY(n){const e=SY.exec(n);return e?Number(e[1]):void 0}function kY(n,e){let t=-1;return n.forEach((s,i)=>{s<=e&&(t=i)}),t}async function EY(n,e){return typeof e=="string"?n.getDestination(e):Array.isArray(e)?e:null}async function CY(n,e){const[t,s,,i]=e;let r;if(typeof t=="number")r=t;else if(t&&typeof t=="object"&&"num"in t)r=await n.getPageIndex(t);else return null;if(!Number.isInteger(r)||r<0||r>=n.numPages)return null;const o=r+1;if((s==null?void 0:s.name)!=="XYZ"||typeof i!="number")return{page:o,offset:0};const a=(await n.getPage(o)).view,[,l,,c]=a,h=c-l;return h>0?{page:o,offset:Math.min(1,Math.max(0,(c-i)/h))}:{page:o,offset:0}}async function $Y(n){const e=await n.getOutline(),t=[],s=async(i,r)=>{var o;for(const a of i){const l=a.title.replace(/\s+/g," ").trim(),c=await EY(n,a.dest).catch(()=>null),h=c?await CY(n,c).catch(()=>null):null;l&&h&&t.push({index:t.length,title:l,level:r,...h}),r+1{let r=e.get(i);return r||(r=n.getPage(i).then(o=>o.getTextContent()).then(o=>o.items.map(a=>"str"in a?a.str:"").join(" ").toLocaleLowerCase()),r.catch(()=>e.delete(i)),e.set(i,r)),r};async function*s(){for(let i=1;i<=n.numPages;i+=1){const r=Math.min(n.numPages,i+TY);for(let o=i+1;o<=r;o+=1)t(o).catch(()=>{});yield[i,await t(i).catch(()=>"")]}}return{pageText:t,pages:s}}function RY(n,e){let t=0;for(let s=n.indexOf(e);s>=0;s=n.indexOf(e,s+e.length))t+=1;return t}const MY=8,IY=24,OY=72,SE=1.35,NY=16e6;function LY(n,e){const t=Math.sqrt(NY/(n*n*e));return Math.min(window.devicePixelRatio||1,2,t)}function Iv(n,e){const t=n.getBoundingClientRect().top,s=e??t+n.clientHeight/2;for(const i of n.querySelectorAll("[data-page]")){const r=i.getBoundingClientRect();if(r.bottom"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e]??e)}function jY(n,e,t){const s=e.trim().toLocaleLowerCase();if(!s)return rd(n);const i=n.toLocaleLowerCase(),r=`pdf-search-highlight${t?" is-active":""}`;let o=0,a=i.indexOf(s);if(a<0)return rd(n);let l="";for(;a>=0;)l+=rd(n.slice(o,a)),l+=`${rd(n.slice(a,a+s.length))}`,o=a+s.length,a=i.indexOf(s,o);return l+rd(n.slice(o))}function FY({page:n,width:e,aspect:t,searchQuery:s,activeSearchPage:i,resolveCitation:r,warmPreviews:o,highlightBoxes:a,highlightKey:l,highlightBrief:c,onShowCitations:h,onShowReference:u,authors:d}){const p=q.useRef(null),[m,y]=q.useState(n<=2),{paperLinks:v,onAnnotations:g}=gY(p,m,r,o),[_,b]=q.useState([]);q.useEffect(()=>{if(!m||!r)return;let E=!0;return r.bibliographyLinks(n).then(async O=>{if(!E||(O.length&&(o==null||o([...new Set(O.map(w=>w.routeId))])),b(O),!O.length))return;const R=await Promise.all(O.map(w=>r.citationsOf(w.name)));E&&b(O.map((w,k)=>({...w,citations:R[k]})))}).catch(()=>{}),()=>{E=!1}},[n,r,m,o]);const x=n===i,A=q.useMemo(()=>s?({str:E})=>jY(E,s,x):void 0,[x,s]),[T,C]=q.useState(e);!m&&T!==e&&C(e);const[I,D]=q.useState(0),H=q.useCallback(()=>D(E=>E+1),[]),[j,U]=q.useState([]);q.useEffect(()=>{var O;if(!(d!=null&&d.length))return U([]);const E=(O=p.current)==null?void 0:O.querySelector(".pdf-page-layer:not(.is-pending)");E!=null&&E.querySelector(".textLayer")&&U(mY(E,d))},[d,I]);const B=T===e?[e]:[T,e],[L,X]=q.useState(),[se,J]=q.useState(!1);!m&&se&&J(!1);const Y=q.useRef(),ge=q.useRef(0),z=q.useCallback(E=>{var w;J(!0);const O=++ge.current,R=(w=p.current)==null?void 0:w.querySelector(`[data-layer-width="${E}"] canvas`);R==null||R.toBlob(k=>{!k||O!==ge.current||(Y.current&&URL.revokeObjectURL(Y.current),Y.current=URL.createObjectURL(k),X(Y.current))},"image/webp",.9)},[]);return q.useEffect(()=>()=>{ge.current+=1,Y.current&&URL.revokeObjectURL(Y.current)},[]),q.useEffect(()=>{const E=p.current;if(!E)return;const O=E.closest(".pdf-scroll"),R=new IntersectionObserver(([k])=>{k.isIntersecting&&y(!0)},{root:O,rootMargin:"250% 0px"}),w=new IntersectionObserver(([k])=>{k.isIntersecting||y(!1)},{root:O,rootMargin:"600% 0px"});return R.observe(E),w.observe(E),()=>{R.disconnect(),w.disconnect()}},[]),S.jsxs("div",{ref:p,className:"pdf-page","data-page":n,style:{minHeight:Math.round(e*t)},children:[m&&B.map(E=>{const O=E===T,R=O?()=>z(E):()=>{C(E),z(E)};return S.jsx("div",{"data-layer-width":E,className:O?"pdf-page-layer":"pdf-page-layer is-pending",style:O&&E!==e?{"--pdf-layer-scale":e/E}:void 0,"aria-hidden":O?void 0:!0,children:S.jsx(DX,{pageNumber:n,width:E,devicePixelRatio:LY(E,t),renderTextLayer:O,renderAnnotationLayer:O,onGetAnnotationsSuccess:g,onRenderSuccess:R,onRenderError:O?void 0:()=>C(E),onRenderTextLayerSuccess:O&&d?H:void 0,loading:null,customTextRenderer:A})},E)}),L&&!se&&S.jsx("img",{className:"pdf-page-snapshot",src:L,alt:"","aria-hidden":"true"}),m&&v.map(E=>{var O;return S.jsx(sY,{...E,onShowReference:u},(O=E.anchor.parentElement)==null?void 0:O.dataset.annotationId)}),m&&r&&_.map(E=>S.jsx(iY,{...E,onShowCitations:h},E.name)),m&&d&&j.map(({authorId:E,box:O})=>{const R=d.find(w=>w.id===E);return R&&S.jsx(oY,{...R,box:O},`${E}-${O.join(",")}`)}),a==null?void 0:a.map(([E,O,R,w],k)=>S.jsx("div",{className:`pdf-citation-highlight${c?" is-brief":""}`,"aria-hidden":"true",style:{left:`${E/10}%`,top:`${O/10}%`,width:`${(R-E)/10}%`,height:`${(w-O)/10}%`}},`${l}-${k}`))]})}function zY({downloadUrl:n,page:e,pages:t,zoomPercent:s,onPage:i,onZoomIn:r,onZoomOut:o,onFitWidth:a}){const l=c=>{c.preventDefault();const h=Number(new FormData(c.currentTarget).get("page"));Number.isInteger(h)&&i(h)};return S.jsxs("div",{className:"paper-pdf-toolbar","aria-label":"Paper preview controls",children:[S.jsxs("div",{className:"paper-pdf-toolbar-group",children:[S.jsx("button",{type:"button",onClick:()=>i(e-1),disabled:e<=1,"aria-label":"Previous page",children:"Previous"}),S.jsxs("form",{onSubmit:l,children:[S.jsx("label",{className:"sr-only",htmlFor:"paper-pdf-current-page",children:"Current page"}),S.jsx("input",{id:"paper-pdf-current-page",name:"page",type:"number",min:1,max:t||1,defaultValue:e,"aria-label":`Page ${e} of ${t||"unknown"}`},e)]}),S.jsxs("span",{role:"status","aria-live":"polite",children:["Page ",e," of ",t||"—"]}),S.jsx("button",{type:"button",onClick:()=>i(e+1),disabled:!t||e>=t,"aria-label":"Next page",children:"Next"})]}),S.jsxs("div",{className:"paper-pdf-toolbar-group",children:[S.jsx("button",{type:"button",onClick:o,"aria-label":"Zoom out",children:"−"}),S.jsxs("output",{"aria-live":"polite",children:[s,"%"]}),S.jsx("button",{type:"button",onClick:r,"aria-label":"Zoom in",children:"+"}),S.jsx("button",{type:"button",onClick:a,children:"Fit to width"}),S.jsx("a",{href:n,download:!0,children:"Download PDF"})]})]})}function HY({url:n,downloadUrl:e=n,paperKey:t,paperTitle:s,paperHref:i,resources:r,initialPage:o=1,resizeActive:a=!1,selectionEnabled:l=!1,paperVersion:c="",onPaperSelection:h,onPaperSelectionError:u,onPageChange:d,onClose:p,loadErrorMessage:m,chrome:y="reader",highlight:v,authors:g}){const _=q.useRef(null),b=q.useRef(null),x=q.useRef(null),[A,T]=q.useState(),[C,I]=q.useState();q.useEffect(()=>{T(void 0),I(void 0)},[v==null?void 0:v.nonce,n]);const D=A??v,H=D&&`${A?"jump":"cited"}-${D.nonce}`,[j,U]=q.useState(),B=A&&j!==H?void 0:D,L=q.useCallback(ne=>{T(le=>({boxes:ne,nonce:((le==null?void 0:le.nonce)??0)+1}))},[]),X=q.useCallback(ne=>{I({citations:ne,index:0}),L(ne[0])},[L]),se=!!(C&&C.citations.length>1),J=ne=>{if(!C)return;const{citations:le}=C,Ue=(C.index+ne+le.length)%le.length;I({citations:le,index:Ue}),L(le[Ue])},Y=q.useRef(null),ge=q.useRef(),[z,E]=q.useState(),O=q.useCallback(async ne=>{const le=await(z==null?void 0:z.referenceOf(ne).catch(()=>null));return le&&L([le]),!!le},[z,L]),R=ZC(),w=q.useMemo(()=>XL(R),[R]),k=q.useRef(()=>{}),N=q.useRef(0),G=q.useRef(!1),Z=q.useRef(),ae=q.useRef(0),ie=q.useRef(),Ae=q.useRef(0),ct=q.useRef(0),Ie=q.useRef(1),Fe=q.useRef(1),Je=q.useRef(1),[it,bn]=q.useState(0),[ut,Ss]=q.useState(0),[xs,Pn]=q.useState(SE),[ls,As]=q.useState([]),[ks,cs]=q.useState(-1),[wn,Kt]=q.useState(),Zn=q.useRef(()=>{}),[an,Es]=q.useState(o),[qu,Io]=q.useState(),[V,ye]=q.useState(700),[Ce,rt]=q.useState(1),[qt,zr]=q.useState(""),[Cs,sv]=q.useState(!1),[um,iv]=q.useState(""),[xL,dm]=q.useState(""),[AL,Vu]=q.useState(!1),[Rc,Wu]=q.useState([]),[rv,fm]=q.useState(0),ov=Math.max(120,Math.round(V*Ce)),kL=q.useMemo(()=>y==="canvas"?{withCredentials:!0}:{disableStream:!0,disableAutoFetch:!0},[y]);BX({enabled:l&&!!c,pagesRoot:x,routeId:t,paperVersion:c,numPages:ut||void 0,resetKey:`${t}-${it}`,onSelect:h,onError:u}),q.useEffect(()=>{FX()},[]),q.useEffect(()=>{var ne;cancelAnimationFrame(Ae.current),window.clearTimeout(ct.current),Ae.current=0,ct.current=0,ae.current=0,Ss(0),Pn(SE),As([]),cs(-1),Kt(void 0),E(void 0),Es(o),Io(void 0),rt(1),Ie.current=1,Fe.current=1,Je.current=1,(ne=x.current)==null||ne.style.setProperty("--pdf-live-scale","1"),zr(""),ge.current=void 0,iv(""),dm(""),Wu([])},[o,t,it]),q.useEffect(()=>{const ne=b.current;if(!ne)return;const le=()=>{var yt;const Lt=Math.max(240,ne.clientWidth-10);Je.current=a?Lt/V:1,a?(yt=x.current)==null||yt.style.setProperty("--pdf-live-scale",String(Je.current)):ye(Lt)};le();const Ue=new ResizeObserver(le);return Ue.observe(ne),()=>Ue.disconnect()},[V,a]),q.useLayoutEffect(()=>{var le;Ie.current=Ce,(le=x.current)==null||le.style.setProperty("--pdf-live-scale",String(Je.current));const ne=b.current;ne&&Z.current&&xE(ne,Z.current),Z.current=void 0,G.current&&(ne&&(ne.scrollLeft=Math.max(0,(ne.scrollWidth-ne.clientWidth)/2)),G.current=!1)},[ov,a,Ce]);const Mc=q.useCallback(ne=>{window.clearTimeout(ct.current);const le=c_(ne(Fe.current));Fe.current=le,G.current=le!==Ie.current,G.current&&b.current&&(Z.current=Iv(b.current)),rt(le)},[]);q.useEffect(()=>{const ne=b.current;if(!ne)return;const le=Ue=>{Ue.ctrlKey&&(Ue.preventDefault(),ae.current+=Ue.deltaY,ie.current=Ue.clientY,!Ae.current&&(Ae.current=requestAnimationFrame(()=>{var Dt;const Lt=ae.current;ae.current=0,Ae.current=0;const yt=c_(Fe.current*Math.exp(-Lt*.002));Fe.current=yt;const Rn=Iv(ne,ie.current);(Dt=x.current)==null||Dt.style.setProperty("--pdf-live-scale",String(Je.current*yt/Ie.current)),Rn&&xE(ne,Rn),window.clearTimeout(ct.current),ct.current=window.setTimeout(()=>{G.current=yt!==Ie.current,G.current&&(Z.current=Iv(ne,ie.current)),rt(Fe.current)},180)})))};return ne.addEventListener("wheel",le,{passive:!1}),()=>{ne.removeEventListener("wheel",le),cancelAnimationFrame(Ae.current),window.clearTimeout(ct.current),Ae.current=0,ct.current=0,ae.current=0}},[]);const Gu=q.useCallback(ne=>{const le=Math.max(1,Math.min(ut||1,ne));Es(le),d==null||d(le)},[d,ut]),pm=q.useCallback(()=>{N.current+=1,sv(!1),iv(""),dm(""),Wu([]),fm(0),Vu(!1)},[]);q.useEffect(()=>{const ne=b.current;if(!ne||!ut)return;let le=0,Ue=0;const Lt=(Dt=!1)=>{window.clearTimeout(Ue),cancelAnimationFrame(le),le=requestAnimationFrame(()=>{const Mn=ne.getBoundingClientRect().top,Us=Mn+ne.clientHeight/2;let Zu=an,mm=Number.POSITIVE_INFINITY;const Xu=new Map;ne.querySelectorAll("[data-page]").forEach(Ic=>{const Hr=Ic.getBoundingClientRect();Xu.set(Number(Ic.dataset.page),Hr);const gA=Us>=Hr.top&&Us<=Hr.bottom?0:Math.min(Math.abs(Us-Hr.top),Math.abs(Us-Hr.bottom));gA{const Hr=Xu.get(Ic.page);return Hr?Hr.top+Hr.height*Ic.offset:Number.POSITIVE_INFINITY});cs(kY($L,Mn+IY))})},yt=()=>{cancelAnimationFrame(le),window.clearTimeout(Ue),Ue=window.setTimeout(()=>Lt(!0),150)},Rn=()=>Lt(!0);return ne.addEventListener("scroll",yt,{passive:!0}),ne.addEventListener("scrollend",Rn),Lt(),()=>{ne.removeEventListener("scroll",yt),ne.removeEventListener("scrollend",Rn),window.clearTimeout(Ue),cancelAnimationFrame(le)}},[ls,an,ov,ut,Gu]),q.useEffect(()=>{const ne=le=>{le.defaultPrevented||((le.ctrlKey||le.metaKey)&&le.key.toLowerCase()==="f"?(le.preventDefault(),sv(!0)):le.key==="Escape"&&Cs?(le.preventDefault(),pm()):le.key==="Escape"&&se?(le.preventDefault(),I(void 0)):le.key==="Escape"&&!le.repeat&&p&&(le.preventDefault(),p()))};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[se,pm,p,Cs]),q.useEffect(()=>{const ne=ge.current;if(!Cs||!ne)return;const le=ne.pages();(async()=>{for(;ge.current===ne&&!(await le.next()).done;);})().catch(()=>{})},[ut,Cs]),q.useEffect(()=>{const ne=ge.current,le=um.trim().toLocaleLowerCase(),Ue=++N.current;if(!ne||!le){dm(""),Wu([]),fm(0),Vu(!1);return}Vu(!0);const Lt=window.setTimeout(()=>void(async()=>{dm(um.trim()),Wu([]),fm(0);const yt=[];for await(const[Rn,Dt]of ne.pages()){if(N.current!==Ue)return;const Mn=RY(Dt,le);if(Mn){yt.length||Ku(Rn);for(let Us=0;Us{N.current===Ue&&Vu(!1)}),120);return()=>window.clearTimeout(Lt)},[um,ut]);const Ku=ne=>{var Lt,yt;const le=Math.max(1,Math.min(ut||1,ne)),Ue=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth";Io(Ue==="smooth"?le:void 0),(yt=(Lt=b.current)==null?void 0:Lt.querySelector(`[data-page="${le}"]`))==null||yt.scrollIntoView({block:"start",behavior:Ue}),Ue==="instant"&&Gu(le)};q.useEffect(()=>{const ne=D==null?void 0:D.boxes[0],le=b.current,Ue=ne&&(le==null?void 0:le.querySelector(`[data-page="${ne.page}"]`));if(!ne||!le||!Ue)return;const Lt=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",yt=Ue.getBoundingClientRect(),Rn=yt.top-le.getBoundingClientRect().top+le.scrollTop+yt.height*ne.bbox[1]/1e3;Io(Lt==="smooth"?ne.page:void 0),le.scrollTo({top:Math.max(0,Rn-OY),behavior:Lt}),Lt==="instant"&&Gu(ne.page);let Dt=0;const Mn=()=>{window.clearTimeout(Dt),U(H)},Us=()=>{window.clearTimeout(Dt),Dt=window.setTimeout(Mn,150)};return Us(),le.addEventListener("scroll",Us,{passive:!0}),le.addEventListener("scrollend",Mn),()=>{window.clearTimeout(Dt),le.removeEventListener("scroll",Us),le.removeEventListener("scrollend",Mn)}},[H,ut,xs]);const mA=(ne,le)=>{const Ue=b.current,Lt=Ue==null?void 0:Ue.querySelector(`[data-page="${ne.page}"]`);if(!Ue||!Lt)return;const yt=le??(window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"),Rn=Lt.getBoundingClientRect(),Dt=Rn.top-Ue.getBoundingClientRect().top+Ue.scrollTop+Rn.height*ne.offset;Io(yt==="smooth"?ne.page:void 0),Kt(yt==="smooth"?ne.index:void 0),Ue.scrollTo({top:Math.max(0,Dt-MY),behavior:yt}),yt==="instant"&&Gu(ne.page),y==="reader"&&window.history.replaceState(window.history.state,"",`#pdf-section-${ne.index}`)};q.useLayoutEffect(()=>{k.current=Ku,Zn.current=mA});const EL=ne=>{if(!Rc.length)return;const le=(rv+ne+Rc.length)%Rc.length;fm(le),Ku(Rc[le])},CL=q.useMemo(()=>Array.from({length:ut},(ne,le)=>le+1),[ut]);return S.jsxs("div",{ref:_,className:"pdf-viewer",children:[y==="canvas"?S.jsx(zY,{downloadUrl:e,page:qu??an,pages:ut,zoomPercent:Math.round(Ce*100),onPage:Ku,onZoomIn:()=>Mc(ne=>jm(ne,1)),onZoomOut:()=>Mc(ne=>jm(ne,-1)),onFitWidth:()=>Mc(()=>1)}):S.jsx(WX,{paperTitle:s,paperHref:i,resources:r,page:qu??an,pages:ut,zoomPercent:Math.round(Ce*100),searchOpen:Cs,searchQuery:um,searchMatch:rv,searchCount:Rc.length,searching:AL,onPage:Ku,onZoom:ne=>Mc(()=>ne),onZoomIn:()=>Mc(ne=>jm(ne,1)),onZoomOut:()=>Mc(ne=>jm(ne,-1)),onToggleSearch:()=>Cs?pm():sv(!0),onCloseSearch:pm,onSearchQuery:iv,onSearch:EL}),S.jsxs("div",{className:"pdf-scroll-frame",children:[S.jsx("div",{ref:b,className:"pdf-scroll",role:"region","aria-label":y==="canvas"?`${s} PDF preview`:"Paper PDF",children:qt?S.jsxs("div",{className:"pdf-error",role:"alert",children:[S.jsx("p",{children:qt}),S.jsxs("div",{children:[S.jsx("button",{type:"button",onClick:()=>bn(ne=>ne+1),children:"Retry"})," ",S.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:"Open PDF"})]})]}):S.jsx(EX,{file:n,options:kL,loading:S.jsx("div",{className:"pdf-loading",role:"status",children:y==="canvas"?"Loading paper preview…":"Loading paper…"}),onLoadSuccess:ne=>{Y.current=ne,ge.current=PY(ne),y==="reader"&&E(()=>nY(ne,w.lookup)),Ss(ne.numPages),zr("");const le=ne.getPage(1).then(Dt=>{const[Mn,Us,Zu,mm]=Dt.view,Xu=(mm-Us)/(Zu-Mn);Y.current===ne&&Xu>0&&Pn(Xu)},()=>{}),Ue=Math.max(1,Math.min(ne.numPages,o)),Lt=()=>{var Dt,Mn;Ue<=1||((Mn=(Dt=b.current)==null?void 0:Dt.querySelector(`[data-page="${Ue}"]`))==null||Mn.scrollIntoView({block:"start"}),Es(Ue),d==null||d(Ue))},yt=Dt=>void le.then(()=>{requestAnimationFrame(()=>requestAnimationFrame(()=>{Y.current===ne&&Dt()}))}),Rn=y==="reader"?AY(window.location.hash):void 0;Rn===void 0&&yt(Lt),$Y(ne).catch(()=>[]).then(Dt=>{if(Y.current!==ne||(As(Dt),Rn===void 0))return;const Mn=Dt[Rn];yt(()=>Mn?Zn.current(Mn,"instant"):Lt())})},onLoadError:ne=>zr(m||DY(ne)),externalLinkTarget:"_blank",onItemClick:({pageNumber:ne})=>k.current(ne),children:S.jsx("div",{ref:x,className:"pdf-pages",style:{"--pdf-live-scale":Je.current},children:CL.map(ne=>S.jsx(FY,{page:ne,width:ov,aspect:xs,searchQuery:xL,activeSearchPage:Rc[rv],resolveCitation:z,warmPreviews:w.warm,highlightBoxes:B==null?void 0:B.boxes.filter(le=>le.page===ne).map(le=>le.bbox),highlightKey:H,highlightBrief:!!A,onShowCitations:X,onShowReference:O,authors:ne===1&&y==="reader"?g:void 0},ne))})},`${t}-${it}`)}),C&&se&&S.jsx(_Y,{index:C.index,count:C.citations.length,onStep:J,onClose:()=>I(void 0)}),S.jsx(wY,{entries:ls,activeIndex:wn??ks,onSelect:mA})]})]})}let u_=[],DI=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(n=DI[s])e=s+1;else return!0;if(e==t)return!1}}function AE(n){return n>=127462&&n<=127487}const kE=8205;function UY(n,e,t=!0,s=!0){return(t?jI:qY)(n,e,s)}function jI(n,e,t){if(e==n.length)return e;e&&FI(n.charCodeAt(e))&&zI(n.charCodeAt(e-1))&&e--;let s=Ov(n,e);for(e+=EE(s);e=0&&AE(Ov(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function qY(n,e,t){for(;e>1;){let s=jI(n,e-2,t);if(s=56320&&n<57344}function zI(n){return n>=55296&&n<56320}function EE(n){return n<65536?1:2}let lt=class HI{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,s){[e,t]=Au(this,e,t);let i=[];return this.decompose(0,e,i,2),s.length&&s.decompose(0,s.length,i,3),this.decompose(t,this.length,i,1),Cr.from(i,this.length-(t-e)+s.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Au(this,e,t);let s=[];return this.decompose(e,t,s,0),Cr.from(s,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),s=this.length-this.scanIdentical(e,-1),i=new Zd(this),r=new Zd(e);for(let o=t,a=t;;){if(i.next(o),r.next(o),o=0,i.lineBreak!=r.lineBreak||i.done!=r.done||i.value!=r.value)return!1;if(a+=i.value.length,i.done||a>=s)return!0}}iter(e=1){return new Zd(this,e)}iterRange(e,t=this.length){return new BI(this,e,t)}iterLines(e,t){let s;if(e==null)s=this.iter();else{t==null&&(t=this.lines+1);let i=this.line(e).from;s=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new UI(s)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?HI.empty:e.length<=32?new Jt(e):Cr.from(Jt.split(e,[]))}};class Jt extends lt{constructor(e,t=VY(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,s,i){for(let r=0;;r++){let o=this.text[r],a=i+o.length;if((t?s:a)>=e)return new WY(i,a,s,o);i=a+1,s++}}decompose(e,t,s,i){let r=e<=0&&t>=this.length?this:new Jt(CE(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(i&1){let o=s.pop(),a=Wg(r.text,o.text.slice(),0,r.length);if(a.length<=32)s.push(new Jt(a,o.length+r.length));else{let l=a.length>>1;s.push(new Jt(a.slice(0,l)),new Jt(a.slice(l)))}}else s.push(r)}replace(e,t,s){if(!(s instanceof Jt))return super.replace(e,t,s);[e,t]=Au(this,e,t);let i=Wg(this.text,Wg(s.text,CE(this.text,0,e)),t),r=this.length+s.length-(t-e);return i.length<=32?new Jt(i,r):Cr.from(Jt.split(i,[]),r)}sliceString(e,t=this.length,s=` -`){[e,t]=Au(this,e,t);let i="";for(let r=0,o=0;r<=t&&oe&&o&&(i+=s),er&&(i+=a.slice(Math.max(0,e-r),t-r)),r=l+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let s=[],i=-1;for(let r of e)s.push(r),i+=r.length+1,s.length==32&&(t.push(new Jt(s,i)),s=[],i=-1);return i>-1&&t.push(new Jt(s,i)),t}}class Cr extends lt{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let s of e)this.lines+=s.lines}lineInner(e,t,s,i){for(let r=0;;r++){let o=this.children[r],a=i+o.length,l=s+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,s,i);i=a+1,s=l+1}}decompose(e,t,s,i){for(let r=0,o=0;o<=t&&r=o){let c=i&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!c?s.push(a):a.decompose(e-o,t-o,s,c)}o=l+1}}replace(e,t,s){if([e,t]=Au(this,e,t),s.lines=r&&t<=a){let l=o.replace(e-r,t-r,s),c=this.lines-o.lines+l.lines;if(l.lines>4&&l.lines>c>>6){let h=this.children.slice();return h[i]=l,new Cr(h,this.length-(t-e)+s.length)}return super.replace(r,a,l)}r=a+1}return super.replace(e,t,s)}sliceString(e,t=this.length,s=` -`){[e,t]=Au(this,e,t);let i="";for(let r=0,o=0;re&&r&&(i+=s),eo&&(i+=a.sliceString(e-o,t-o,s)),o=l+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Cr))return 0;let s=0,[i,r,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,r+=t){if(i==o||r==a)return s;let l=this.children[i],c=e.children[r];if(l!=c)return s+l.scanIdentical(c,t);s+=l.length+1}}static from(e,t=e.reduce((s,i)=>s+i.length+1,-1)){let s=0;for(let p of e)s+=p.lines;if(s<32){let p=[];for(let m of e)m.flatten(p);return new Jt(p,t)}let i=Math.max(32,s>>5),r=i<<1,o=i>>1,a=[],l=0,c=-1,h=[];function u(p){let m;if(p.lines>r&&p instanceof Cr)for(let y of p.children)u(y);else p.lines>o&&(l>o||!l)?(d(),a.push(p)):p instanceof Jt&&l&&(m=h[h.length-1])instanceof Jt&&p.lines+m.lines<=32?(l+=p.lines,c+=p.length+1,h[h.length-1]=new Jt(m.text.concat(p.text),m.length+1+p.length)):(l+p.lines>i&&d(),l+=p.lines,c+=p.length+1,h.push(p))}function d(){l!=0&&(a.push(h.length==1?h[0]:Cr.from(h,c)),c=-1,l=h.length=0)}for(let p of e)u(p);return d(),a.length==1?a[0]:new Cr(a,t)}}lt.empty=new Jt([""],0);function VY(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Wg(n,e,t=0,s=1e9){for(let i=0,r=0,o=!0;r=t&&(l>s&&(a=a.slice(0,s-i)),i0?1:(e instanceof Jt?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let s=this.nodes.length-1,i=this.nodes[s],r=this.offsets[s],o=r>>1,a=i instanceof Jt?i.text.length:i.children.length;if(o==(t>0?a:0)){if(s==0)return this.done=!0,this.value="",this;t>0&&this.offsets[s-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[s]+=t,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(i instanceof Jt){let l=i.text[o+(t<0?-1:0)];if(this.offsets[s]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=i.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[s]+=t):(t<0&&this.offsets[s]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof Jt?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class BI{constructor(e,t,s){this.value="",this.done=!1,this.cursor=new Zd(e,t>s?-1:1),this.pos=t>s?e.length:0,this.from=Math.min(t,s),this.to=Math.max(t,s)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let s=t<0?this.pos-this.from:this.to-this.pos;e>s&&(e=s),s-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=s?i:t<0?i.slice(i.length-s):i.slice(0,s),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class UI{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:s,value:i}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):s?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(lt.prototype[Symbol.iterator]=function(){return this.iter()},Zd.prototype[Symbol.iterator]=BI.prototype[Symbol.iterator]=UI.prototype[Symbol.iterator]=function(){return this});class WY{constructor(e,t,s,i){this.from=e,this.to=t,this.number=s,this.text=i}get length(){return this.to-this.from}}function Au(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function $n(n,e,t=!0,s=!0){return UY(n,e,t,s)}function GY(n){return n>=56320&&n<57344}function KY(n){return n>=55296&&n<56320}function qI(n,e){let t=n.charCodeAt(e);if(!KY(t)||e+1==n.length)return t;let s=n.charCodeAt(e+1);return GY(s)?(t-55296<<10)+(s-56320)+65536:t}function ZY(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function VI(n){return n<65536?1:2}const d_=/\r\n?|\n/;var si=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(si||(si={}));class Lr{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-i);r+=a}else{if(s!=si.Simple&&c>=e&&(s==si.TrackDel&&ie||s==si.TrackBefore&&ie))return null;if(c>e||c==e&&t<0&&!a)return e==i||t<0?r:r+l;r+=l}i=c}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return r}touchesRange(e,t=e){for(let s=0,i=0;s=0&&i<=t&&a>=e)return it?"cover":!0;i=a}return!1}toString(){let e="";for(let t=0;t=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Lr(e)}static create(e){return new Lr(e)}}class pn extends Lr{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return f_(this,(t,s,i,r,o)=>e=e.replace(i,i+(s-t),o),!1),e}mapDesc(e,t=!1){return p_(this,e,t,!0)}invert(e){let t=this.sections.slice(),s=[];for(let i=0,r=0;i=0){t[i]=a,t[i+1]=o;let l=i>>1;for(;s.length0&&xa(s,t,r.text),r.forward(h),a+=h}let c=e[o++];for(;a>1].toJSON()))}return e}static of(e,t,s){let i=[],r=[],o=0,a=null;function l(h=!1){if(!h&&!i.length)return;od||u<0||d>t)throw new RangeError(`Invalid change range ${u} to ${d} (in doc of length ${t})`);let m=p?typeof p=="string"?lt.of(p.split(s||d_)):p:lt.empty,y=m.length;if(u==d&&y==0)return;uo&&is(i,u-o,-1),is(i,d-u,y),xa(r,i,m),o=d}}return c(e),l(!a),a}static empty(e){return new pn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],s=[];for(let i=0;ia&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;s.length=0&&t<=0&&t==n[i+1]?n[i]+=e:i>=0&&e==0&&n[i]==0?n[i+1]+=t:s?(n[i]+=e,n[i+1]+=t):n.push(e,t)}function xa(n,e,t){if(t.length==0)return;let s=e.length-2>>1;if(s>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)a=n.sections[o++],l=n.sections[o++];e(i,c,r,h,u),i=c,r=h}}}function p_(n,e,t,s=!1){let i=[],r=s?[]:null,o=new hf(n),a=new hf(e);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let c=Math.min(o.len,a.len);is(i,c,-1),o.forward(c),a.forward(c)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len=0&&l=0){let c=0,h=o.len;for(;h;)if(a.ins==-1){let u=Math.min(h,a.len);c+=u,h-=u,a.forward(u)}else if(a.ins==0&&a.lenl||o.ins>=0&&o.len>l)&&(a||s.length>c),r.forward2(l),o.forward(l)}}}}class hf{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?lt.empty:e[t]}textBit(e){let{inserted:t}=this.set,s=this.i-2>>1;return s>=t.length&&!e?lt.empty:t[s].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class qo{constructor(e,t,s,i){this.from=e,this.to=t,this.flags=s,this.goalColumn=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let s,i;return this.empty?s=i=e.mapPos(this.from,t):(s=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),s==this.from&&i==this.to?this:new qo(s,i,this.flags,this.goalColumn)}extend(e,t=e,s=0){if(e<=this.anchor&&t>=this.anchor)return te.range(e,t,void 0,void 0,s);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return te.range(this.anchor,i,void 0,void 0,s)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return te.range(e.anchor,e.head)}static create(e,t,s,i){return new qo(e,t,s,i)}}class te{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:te.create(this.ranges.map(s=>s.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let s=0;se.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new te(e.ranges.map(t=>qo.fromJSON(t)),e.main)}static single(e,t=e){return new te([te.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let s=0,i=0;ii.from-r.from),t=e.indexOf(s);for(let i=1;ir.head?te.range(l,a):te.range(a,l))}}return new te(e,t)}}function GI(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Lx=0;class be{constructor(e,t,s,i,r){this.combine=e,this.compareInput=t,this.compare=s,this.isStatic=i,this.id=Lx++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new be(e.combine||(t=>t),e.compareInput||((t,s)=>t===s),e.compare||(e.combine?(t,s)=>t===s:Dx),!!e.static,e.enables)}of(e){return new Gg([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Gg(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Gg(e,this,2,t)}from(e,t){return t||(t=s=>s),this.compute([e],s=>t(s.field(e)))}}function Dx(n,e){return n==e||n.length==e.length&&n.every((t,s)=>t===e[s])}class Gg{constructor(e,t,s,i){this.dependencies=e,this.facet=t,this.type=s,this.value=i,this.id=Lx++}dynamicSlot(e){var t;let s=this.value,i=this.facet.compareInput,r=this.id,o=e[r]>>1,a=this.type==2,l=!1,c=!1,h=[];for(let u of this.dependencies)u=="doc"?l=!0:u=="selection"?c=!0:((t=e[u.id])!==null&&t!==void 0?t:1)&1||h.push(e[u.id]);return{create(u){return u.values[o]=s(u),1},update(u,d){if(l&&d.docChanged||c&&(d.docChanged||d.selection)||m_(u,h)){let p=s(u);if(a?!$E(p,u.values[o],i):!i(p,u.values[o]))return u.values[o]=p,1}return 0},reconfigure:(u,d)=>{let p,m=d.config.address[r];if(m!=null){let y=ky(d,m);if(this.dependencies.every(v=>v instanceof be?d.facet(v)===u.facet(v):v instanceof Fr?d.field(v,!1)==u.field(v,!1):!0)||(a?$E(p=s(u),y,i):i(p=s(u),y)))return u.values[o]=y,0}else p=s(u);return u.values[o]=p,1}}}get extension(){return this}}function $E(n,e,t){if(n.length!=e.length)return!1;for(let s=0;sn[l.id]),i=t.map(l=>l.type),r=s.filter(l=>!(l&1)),o=n[e.id]>>1;function a(l){let c=[];for(let h=0;hs===i),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Fm).find(s=>s.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:s=>(s.values[t]=this.create(s),1),update:(s,i)=>{let r=s.values[t],o=this.updateF(r,i);return this.compareF(r,o)?0:(s.values[t]=o,1)},reconfigure:(s,i)=>{let r=s.facet(Fm),o=i.facet(Fm),a;return(a=r.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(s.values[t]=a.create(s),1):i.config.address[this.id]!=null?(s.values[t]=i.field(this),0):(s.values[t]=this.create(s),1)}}}init(e){return[this,Fm.of({field:this,create:e})]}get extension(){return this}}const ol={lowest:4,low:3,default:2,high:1,highest:0};function od(n){return e=>new KI(e,n)}const q0={highest:od(ol.highest),high:od(ol.high),default:od(ol.default),low:od(ol.low),lowest:od(ol.lowest)};class KI{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class im{of(e){return new g_(this,e)}reconfigure(e){return im.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class g_{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class Ay{constructor(e,t,s,i,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=s,this.address=i,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,s){let i=[],r=Object.create(null),o=new Map;for(let d of YY(e,t,o))d instanceof Fr?i.push(d):(r[d.facet.id]||(r[d.facet.id]=[])).push(d);let a=Object.create(null),l=[],c=[];for(let d of i)a[d.id]=c.length<<1,c.push(p=>d.slot(p));let h=s==null?void 0:s.config.facets;for(let d in r){let p=r[d],m=p[0].facet,y=h&&h[d]||[];if(p.every(v=>v.type==0))if(a[m.id]=l.length<<1|1,Dx(y,p))l.push(s.facet(m));else{let v=m.combine(p.map(g=>g.value));l.push(s&&m.compare(v,s.facet(m))?s.facet(m):v)}else{for(let v of p)v.type==0?(a[v.id]=l.length<<1|1,l.push(v.value)):(a[v.id]=c.length<<1,c.push(g=>v.dynamicSlot(g)));a[m.id]=c.length<<1,c.push(v=>XY(v,m,p))}}let u=c.map(d=>d(a));return new Ay(e,o,u,a,l,r)}}function YY(n,e,t){let s=[[],[],[],[],[]],i=new Map;function r(o,a){let l=i.get(o);if(l!=null){if(l<=a)return;let c=s[l].indexOf(o);c>-1&&s[l].splice(c,1),o instanceof g_&&t.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let c of o)r(c,a);else if(o instanceof g_){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),r(c,a)}else if(o instanceof KI)r(o.inner,o.prec);else if(o instanceof Fr)s[a].push(o),o.provides&&r(o.provides,a);else if(o instanceof Gg)s[a].push(o),o.facet.extensions&&r(o.facet.extensions,ol.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(c==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(c,a)}}return r(n,ol.default),s.reduce((o,a)=>o.concat(a))}function Xd(n,e){if(e&1)return 2;let t=e>>1,s=n.status[t];if(s==4)throw new Error("Cyclic dependency between fields and/or facets");if(s&2)return s;n.status[t]=4;let i=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|i}function ky(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const ZI=be.define(),y_=be.define({combine:n=>n.some(e=>e),static:!0}),XI=be.define({combine:n=>n.length?n[0]:void 0,static:!0}),YI=be.define(),JI=be.define(),QI=be.define(),eO=be.define({combine:n=>n.length?n[0]:!1});class Fa{constructor(e,t){this.type=e,this.value=t}static define(){return new JY}}class JY{of(e){return new Fa(this,e)}}class QY{constructor(e){this.map=e}of(e){return new St(this,e)}}class St{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new St(this.type,t)}is(e){return this.type==e}static define(e={}){return new QY(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let s=[];for(let i of e){let r=i.map(t);r&&s.push(r)}return s}}St.reconfigure=St.define();St.appendConfig=St.define();class yn{constructor(e,t,s,i,r,o){this.startState=e,this.changes=t,this.selection=s,this.effects=i,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,s&&GI(s,t.newLength),r.some(a=>a.type==yn.time)||(this.annotations=r.concat(yn.time.of(Date.now())))}static create(e,t,s,i,r,o){return new yn(e,t,s,i,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(yn.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}yn.time=Fa.define();yn.userEvent=Fa.define();yn.addToHistory=Fa.define();yn.remote=Fa.define();function e7(n,e){let t=[];for(let s=0,i=0;;){let r,o;if(s=n[s]))r=n[s++],o=n[s++];else if(i=0;i--){let r=s[i](n);r instanceof yn?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof yn?n=r[0]:n=nO(e,ph(r),!1)}return n}function n7(n){let e=n.startState,t=e.facet(QI),s=n;for(let i=t.length-1;i>=0;i--){let r=t[i](n);r&&Object.keys(r).length&&(s=tO(s,v_(e,r,n.changes.newLength),!0))}return s==n?n:yn.create(e,n.changes,n.selection,s.effects,s.annotations,s.scrollIntoView)}const s7=[];function ph(n){return n==null?s7:Array.isArray(n)?n:[n]}var en=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(en||(en={}));const i7=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let b_;try{b_=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function r7(n){if(b_)return b_.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||i7.test(t)))return!0}return!1}function o7(n){return e=>{if(!/\S/.test(e))return en.Space;if(r7(e))return en.Word;for(let t=0;t-1)return en.Word;return en.Other}}class at{constructor(e,t,s,i,r,o){this.config=e,this.doc=t,this.selection=s,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let a=0;ai.set(c,l)),t=null),i.set(a.value.compartment,a.value.extension)):a.is(St.reconfigure)?(t=null,s=a.value):a.is(St.appendConfig)&&(t=null,s=ph(s).concat(a.value));let r;t?r=e.startState.values.slice():(t=Ay.resolve(s,i,this),r=new at(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let o=e.startState.facet(y_)?e.newSelection:e.newSelection.asSingle();new at(t,e.newDoc,o,r,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:te.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,s=e(t.ranges[0]),i=this.changes(s.changes),r=[s.range],o=ph(s.effects);for(let a=1;ao.spec.fromJSON(a,l)))}}return at.create({doc:e.doc,selection:te.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=Ay.resolve(e.extensions||[],new Map),s=e.doc instanceof lt?e.doc:lt.of((e.doc||"").split(t.staticFacet(at.lineSeparator)||d_)),i=e.selection?e.selection instanceof te?e.selection:te.single(e.selection.anchor,e.selection.head):te.single(0);return GI(i,s.length),t.staticFacet(y_)||(i=i.asSingle()),new at(t,s,i,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(at.tabSize)}get lineBreak(){return this.facet(at.lineSeparator)||` -`}get readOnly(){return this.facet(eO)}phrase(e,...t){for(let s of this.facet(at.phrases))if(Object.prototype.hasOwnProperty.call(s,e)){e=s[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(s,i)=>{if(i=="$")return"$";let r=+(i||1);return!r||r>t.length?s:t[r-1]})),e}languageDataAt(e,t,s=-1){let i=[];for(let r of this.facet(ZI))for(let o of r(this,t,s))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return o7(t.length?t[0]:"")}wordAt(e){let{text:t,from:s,length:i}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-s,a=e-s;for(;o>0;){let l=$n(t,o,!1);if(r(t.slice(l,o))!=en.Word)break;o=l}for(;an.length?n[0]:4});at.lineSeparator=XI;at.readOnly=eO;at.phrases=be.define({compare(n,e){let t=Object.keys(n),s=Object.keys(e);return t.length==s.length&&t.every(i=>n[i]==e[i])}});at.languageData=ZI;at.changeFilter=YI;at.transactionFilter=JI;at.transactionExtender=QI;im.reconfigure=St.define();function Hu(n,e,t={}){let s={};for(let i of n)for(let r of Object.keys(i)){let o=i[r],a=s[r];if(a===void 0)s[r]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(t,r))s[r]=t[r](a,o);else throw new Error("Config merge conflict for field "+r)}for(let i in e)s[i]===void 0&&(s[i]=e[i]);return s}class bc{eq(e){return this==e}range(e,t=e){return w_.create(e,t,this)}}bc.prototype.startSide=bc.prototype.endSide=0;bc.prototype.point=!1;bc.prototype.mapMode=si.TrackDel;function jx(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let w_=class sO{constructor(e,t,s){this.from=e,this.to=t,this.value=s}static create(e,t,s){return new sO(e,t,s)}};function __(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class Fx{constructor(e,t,s,i){this.from=e,this.to=t,this.value=s,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,t,s,i=0){let r=s?this.to:this.from;for(let o=i,a=r.length;;){if(o==a)return o;let l=o+a>>1,c=r[l]-e||(s?this.value[l].endSide:this.value[l].startSide)-t;if(l==o)return c>=0?o:a;c>=0?a=l:o=l+1}}between(e,t,s,i){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(s,1e9,!1,r);rp||d==p&&c.startSide>0&&c.endSide<=0)continue;(p-d||c.endSide-c.startSide)<0||(o<0&&(o=d),c.point&&(a=Math.max(a,p-d)),s.push(c),i.push(d-o),r.push(p-o))}return{mapped:s.length?new Fx(i,r,s,a):null,pos:o}}}class st{constructor(e,t,s,i){this.chunkPos=e,this.chunk=t,this.nextLayer=s,this.maxPoint=i}static create(e,t,s,i){return new st(e,t,s,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:s=!1,filterFrom:i=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(s&&(t=t.slice().sort(__)),this.isEmpty)return t.length?st.of(t):this;let a=new iO(this,null,-1).goto(0),l=0,c=[],h=new uf;for(;a.value||l=0){let u=t[l++];h.addInner(u.from,u.to,u.value)||c.push(u)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||ra.to||r=r&&e<=r+o.length&&o.between(r,e-r,t-r,s)===!1)return}this.nextLayer.between(e,t,s)}}iter(e=0){return df.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return df.from(e).goto(t)}static compare(e,t,s,i,r=-1){let o=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=r),a=t.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=r),l=TE(o,a,s),c=new ad(o,l,r),h=new ad(a,l,r);s.iterGaps((u,d,p)=>PE(c,u,h,d,p,i)),s.empty&&s.length==0&&PE(c,0,h,0,0,i)}static eq(e,t,s=0,i){i==null&&(i=999999999);let r=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0),o=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let a=TE(r,o),l=new ad(r,a,0).goto(s),c=new ad(o,a,0).goto(s);for(;;){if(l.to!=c.to||!S_(l.active,c.active)||l.point&&(!c.point||!jx(l.point,c.point)))return!1;if(l.to>i)return!0;l.next(),c.next()}}static spans(e,t,s,i,r=-1){let o=new ad(e,null,r).goto(t),a=t,l=o.openStart;for(;;){let c=Math.min(o.to,s);if(o.point){let h=o.activeForPoint(o.to),u=o.pointFroma&&(i.span(a,c,o.active,l),l=o.openEnd(c));if(o.to>s)return l+(o.point&&o.to>s?1:0);a=o.to,o.next()}}static of(e,t=!1){let s=new uf;for(let i of e instanceof w_?[e]:t?a7(e):e)s.add(i.from,i.to,i.value);return s.finish()}static join(e){if(!e.length)return st.empty;let t=e[e.length-1];for(let s=e.length-2;s>=0;s--)for(let i=e[s];i!=st.empty;i=i.nextLayer)t=new st(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}st.empty=new st([],[],null,-1);function a7(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(__);e=s}return n}st.empty.nextLayer=st.empty;class uf{finishChunk(e){this.chunks.push(new Fx(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,s){this.addInner(e,t,s)||(this.nextLayer||(this.nextLayer=new uf)).add(e,t,s)}addInner(e,t,s){let i=e-this.lastTo||s.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||s.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=s,this.lastFrom=e,this.lastTo=t,this.value.push(s),s.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let s=t.value.length-1;return this.last=t.value[s],this.lastFrom=t.from[s]+e,this.lastTo=t.to[s]+e,!0}finish(){return this.finishInner(st.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=st.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function TE(n,e,t){let s=new Map;for(let r of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=s&&i.push(new iO(o,t,s,r));return i.length==1?i[0]:new df(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let s of this.heap)s.goto(e,t);for(let s=this.heap.length>>1;s>=0;s--)Nv(this.heap,s);return this.next(),this}forward(e,t){for(let s of this.heap)s.forward(e,t);for(let s=this.heap.length>>1;s>=0;s--)Nv(this.heap,s);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Nv(this.heap,0)}}}function Nv(n,e){for(let t=n[e];;){let s=(e<<1)+1;if(s>=n.length)break;let i=n[s];if(s+1=0&&(i=n[s+1],s++),t.compare(i)<0)break;n[s]=t,n[e]=i,e=s}}class ad{constructor(e,t,s){this.minPoint=s,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=df.from(e,t,s)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){zm(this.active,e),zm(this.activeTo,e),zm(this.activeRank,e),this.minActive=RE(this.active,this.activeTo)}addActive(e){let t=0,{value:s,to:i,rank:r}=this.cursor;for(;t0;)t++;Hm(this.active,t,s),Hm(this.activeTo,t,i),Hm(this.activeRank,t,r),e&&Hm(e,t,this.cursor.from),this.minActive=RE(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let s=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),s&&zm(s,i)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(s),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&s[i]=0&&!(this.activeRank[s]e||this.activeTo[s]==e&&this.active[s].endSide>=this.point.endSide)&&t.push(this.active[s]);return t.reverse()}openEnd(e){let t=0;for(let s=this.activeTo.length-1;s>=0&&this.activeTo[s]>e;s--)t++;return t}}function PE(n,e,t,s,i,r){n.goto(e),t.goto(s);let o=s+i,a=s,l=s-e,c=!!r.boundChange;for(let h=!1;;){let u=n.to+l-t.to,d=u||n.endSide-t.endSide,p=d<0?n.to+l:t.to,m=Math.min(p,o);if(n.point||t.point?(n.point&&t.point&&jx(n.point,t.point)&&S_(n.activeForPoint(n.to),t.activeForPoint(t.to))||r.comparePoint(a,m,n.point,t.point),h=!1):(h&&r.boundChange(a),m>a&&!S_(n.active,t.active)&&r.compareRange(a,m,n.active,t.active),c&&mo)break;a=p,d<=0&&n.next(),d>=0&&t.next()}}function S_(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;s--)n[s+1]=n[s];n[e]=t}function RE(n,e){let t=-1,s=1e9;for(let i=0;i=e)return i;if(i==n.length)break;r+=n.charCodeAt(i)==9?t-r%t:1,i=$n(n,i)}return n.length}const x_="ͼ",ME=typeof Symbol>"u"?"__"+x_:Symbol.for(x_),A_=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),IE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ku{constructor(e,t){this.rules=[];let{finish:s}=t||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,a,l,c){let h=[],u=/^@(\w+)\b/.exec(o[0]),d=u&&u[1]=="keyframes";if(u&&a==null)return l.push(o[0]+";");for(let p in a){let m=a[p];if(/&/.test(p))r(p.split(/,\s*/).map(y=>o.map(v=>y.replace(/&/,v))).reduce((y,v)=>y.concat(v)),m,l);else if(m&&typeof m=="object"){if(!u)throw new RangeError("The value of a property ("+p+") should be a primitive value.");r(i(p),m,h,d)}else m!=null&&h.push(p.replace(/_.*/,"").replace(/[A-Z]/g,y=>"-"+y.toLowerCase())+": "+m+";")}(h.length||d)&&l.push((s&&!u&&!c?o.map(s):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)r(i(o),e[o],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=IE[ME]||1;return IE[ME]=e+1,x_+e.toString(36)}static mount(e,t,s){let i=e[A_],r=s&&s.nonce;i?r&&i.setNonce(r):i=new c7(e,r),i.mount(Array.isArray(t)?t:[t],e)}}let OE=new Map;class c7{constructor(e,t){let s=e.ownerDocument||e,i=s.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let r=OE.get(s);if(r)return e[A_]=r;this.sheet=new i.CSSStyleSheet,OE.set(s,this)}else this.styleTag=s.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[A_]=this}mount(e,t){let s=this.sheet,i=0,r=0;for(let o=0;o-1&&(this.modules.splice(l,1),r--,l=-1),l==-1){if(this.modules.splice(r++,0,a),s)for(let c=0;c",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},h7=typeof navigator<"u"&&/Mac/.test(navigator.platform),u7=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Un=0;Un<10;Un++)Ma[48+Un]=Ma[96+Un]=String(Un);for(var Un=1;Un<=24;Un++)Ma[Un+111]="F"+Un;for(var Un=65;Un<=90;Un++)Ma[Un]=String.fromCharCode(Un+32),ff[Un]=String.fromCharCode(Un);for(var Lv in Ma)ff.hasOwnProperty(Lv)||(ff[Lv]=Ma[Lv]);function d7(n){var e=h7&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||u7&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?ff:Ma)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Cn(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s)){var i=t[s];typeof i=="string"?n.setAttribute(s,i):i!=null&&(n[s]=i)}e++}for(;e2);var de={mac:DE||/Mac/.test(ms.platform),windows:/Win/.test(ms.platform),linux:/Linux|X11/.test(ms.platform),ie:W0,ie_version:oO?k_.documentMode||6:C_?+C_[1]:E_?+E_[1]:0,gecko:NE,gecko_version:NE?+(/Firefox\/(\d+)/.exec(ms.userAgent)||[0,0])[1]:0,chrome:!!Dv,chrome_version:Dv?+Dv[1]:0,ios:DE,android:/Android\b/.test(ms.userAgent),webkit:LE,webkit_version:LE?+(/\bAppleWebKit\/(\d+)/.exec(ms.userAgent)||[0,0])[1]:0,safari:$_,safari_version:$_?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ms.userAgent)||[0,0])[1]:0,tabSize:k_.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function zx(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const Ey=Object.create(null);function Hx(n,e,t){if(n==e)return!0;n||(n=Ey),e||(e=Ey);let s=Object.keys(n),i=Object.keys(e);if(s.length-0!=i.length-0)return!1;for(let r of s)if(r!=t&&(i.indexOf(r)==-1||n[r]!==e[r]))return!1;return!0}function f7(n,e){for(let t=n.attributes.length-1;t>=0;t--){let s=n.attributes[t].name;e[s]==null&&n.removeAttribute(s)}for(let t in e){let s=e[t];t=="style"?n.style.cssText=s:n.getAttribute(t)!=s&&n.setAttribute(t,s)}}function jE(n,e,t){let s=!1;if(e)for(let i in e)t&&i in t||(s=!0,i=="style"?n.style.cssText="":n.removeAttribute(i));if(t)for(let i in t)e&&e[i]==t[i]||(s=!0,i=="style"?n.style.cssText=t[i]:n.setAttribute(i,t[i]));return s}function p7(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new wc(e,t,t,s,e.widget||null,!1)}static replace(e){let t=!!e.block,s,i;if(e.isBlockGap)s=-5e8,i=4e8;else{let{start:r,end:o}=aO(e,t);s=(r?t?-3e8:-1:5e8)-1,i=(o?t?2e8:1:-6e8)+1}return new wc(e,s,i,t,e.widget||null,!0)}static line(e){return new om(e)}static set(e,t=!1){return st.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Qe.none=st.empty;class rm extends Qe{constructor(e){let{start:t,end:s}=aO(e);super(t?-1:5e8,s?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?zx(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ey}eq(e){return this==e||e instanceof rm&&this.tagName==e.tagName&&Hx(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}rm.prototype.point=!1;class om extends Qe{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof om&&this.spec.class==e.spec.class&&Hx(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}om.prototype.mapMode=si.TrackBefore;om.prototype.point=!0;class wc extends Qe{constructor(e,t,s,i,r,o){super(t,s,r,e),this.block=i,this.isReplace=o,this.mapMode=i?t<=0?si.TrackBefore:si.TrackAfter:si.TrackDel}get type(){return this.startSide!=this.endSide?Vn.WidgetRange:this.startSide<=0?Vn.WidgetBefore:Vn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof wc&&m7(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}wc.prototype.point=!0;function aO(n,e=!1){let{inclusiveStart:t,inclusiveEnd:s}=n;return t==null&&(t=n.inclusive),s==null&&(s=n.inclusive),{start:t??e,end:s??e}}function m7(n,e){return n==e||!!(n&&e&&n.compare(e))}function mh(n,e,t,s=0){let i=t.length-1;i>=0&&t[i]+s>=n?t[i]=Math.max(t[i],e):t.push(n,e)}class pf extends bc{constructor(e,t,s){super(),this.tagName=e,this.attributes=t,this.rank=s}eq(e){return e==this||e instanceof pf&&this.tagName==e.tagName&&Hx(this.attributes,e.attributes)}static create(e){return new pf(e.tagName,e.attributes||Ey,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return st.of(e,t)}}pf.prototype.startSide=pf.prototype.endSide=-1;function mf(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function T_(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Yd(n,e){if(!e.anchorNode)return!1;try{return T_(n,e.anchorNode)}catch{return!1}}function Kg(n){return n.nodeType==3?gf(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function Jd(n,e,t,s){return t?FE(n,e,t,s,-1)||FE(n,e,t,s,1):!1}function Ia(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Cy(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function FE(n,e,t,s,i){for(;;){if(n==t&&e==s)return!0;if(e==(i<0?0:To(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||r.nodeType!=1)return!1;e=Ia(n)+(i<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=i<0?To(n):0}else return!1}}function To(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function $y(n,e){let{left:t,right:s}=n;if(t==s)return n;let i=e?t:s;return{left:i,right:i,top:n.top,bottom:n.bottom}}function g7(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function lO(n,e){let t=e.width/n.offsetWidth,s=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(s>.995&&s<1.005||!isFinite(s)||Math.abs(e.height-n.offsetHeight)<1)&&(s=1),{scaleX:t,scaleY:s}}function y7(n,e,t,s,i,r,o,a){let l=n.ownerDocument,c=l.defaultView||window;for(let h=n,u=!1;h&&!u;)if(h.nodeType==1){let d,p=h==l.body,m=1,y=1;if(p)d=g7(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let _=h.getBoundingClientRect();({scaleX:m,scaleY:y}=lO(h,_)),d={left:_.left,right:_.left+h.clientWidth*m,top:_.top,bottom:_.top+h.clientHeight*y}}let v=0,g=0;if(i=="nearest")e.top0&&e.bottom>d.bottom+g&&(g=e.bottom-d.bottom+o)):e.bottom>d.bottom-o&&(g=e.bottom-d.bottom+o,t<0&&e.top-g0&&e.right>d.right+v&&(v=e.right-d.right+r)):e.right>d.right-r&&(v=e.right-d.right+r,t<0&&e.leftd.bottom||e.leftd.right)&&(e={left:Math.max(e.left,d.left),right:Math.min(e.right,d.right),top:Math.max(e.top,d.top),bottom:Math.min(e.bottom,d.bottom)}),h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function cO(n,e=!0){let t=n.ownerDocument,s=null,i=null;for(let r=n.parentNode;r&&!(r==t.body||(!e||s)&&i);)if(r.nodeType==1)!i&&r.scrollHeight>r.clientHeight&&(i=r),e&&!s&&r.scrollWidth>r.clientWidth&&(s=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:s,y:i}}class v7{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:s}=e;this.set(t,Math.min(e.anchorOffset,t?To(t):0),s,Math.min(e.focusOffset,s?To(s):0))}set(e,t,s,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=s,this.focusOffset=i}}function hO(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function uO(n,e=!0){for(let{node:t,left:s,top:i}of n)e&&t.scrollTop!=i&&(t.scrollTop=i),t.scrollLeft!=s&&(t.scrollLeft=s)}let Qa=null;de.safari&&de.safari_version>=26&&(Qa=!1);function dO(n){if(n.setActive)return n.setActive();if(Qa)return n.focus(Qa);let e=hO(n);n.focus(Qa==null?{get preventScroll(){return Qa={preventScroll:!0},!0}}:void 0),Qa||(Qa=!1,uO(e))}let zE;function gf(n,e,t=e){let s=zE||(zE=document.createRange());return s.setEnd(n,t),s.setStart(n,e),s}function gh(n,e,t,s){let i={key:e,code:e,keyCode:t,which:t,cancelable:!0};s&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=s);let r=new KeyboardEvent("keydown",i);r.synthetic=!0,n.dispatchEvent(r);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,n.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function b7(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function w7(n,e){let t=e.focusNode,s=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=s)return!1;for(s=Math.min(s,To(t));;)if(s){if(t.nodeType!=1)return!1;let i=t.childNodes[s-1];i.contentEditable=="false"?s--:(t=i,s=To(t))}else{if(t==n)return!0;s=Ia(t),t=t.parentNode}}function fO(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function pO(n,e){for(let t=n,s=e;;){if(t.nodeType==3&&s>0)return{node:t,offset:s};if(t.nodeType==1&&s>0){if(t.contentEditable=="false")return null;t=t.childNodes[s-1],s=To(t)}else if(t.parentNode&&!Cy(t))s=Ia(t),t=t.parentNode;else return null}}function mO(n,e){for(let t=n,s=e;;){if(t.nodeType==3&&s=t){if(a.level==s)return o;(r<0||(i!=0?i<0?a.fromt:e[r].level>a.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function vO(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;y-=3)if(sr[y+1]==-p){let v=sr[y+2],g=v&2?i:v&4?v&1?r:i:0;g&&(_t[u]=_t[sr[y]]=g),a=y;break}}else{if(sr.length==189)break;sr[a++]=u,sr[a++]=d,sr[a++]=l}else if((m=_t[u])==2||m==1){let y=m==i;l=y?0:1;for(let v=a-3;v>=0;v-=3){let g=sr[v+2];if(g&2)break;if(y)sr[v+2]|=2;else{if(g&4)break;sr[v+2]|=4}}}}}function E7(n,e,t,s){for(let i=0,r=s;i<=t.length;i++){let o=i?t[i-1].to:n,a=il;)m==v&&(m=t[--y].from,v=y?t[y-1].to:n),_t[--m]=p;l=h}else r=c,l++}}}function R_(n,e,t,s,i,r,o){let a=s%2?2:1;if(s%2==i%2)for(let l=e,c=0;ll&&o.push(new Rr(l,y.from,p));let v=y.direction==_c!=!(p%2);M_(n,v?s+1:s,i,y.inner,y.from,y.to,o),l=y.to}m=y.to}else{if(m==t||(h?_t[m]!=a:_t[m]==a))break;m++}d?R_(n,l,m,s+1,i,d,o):le;){let h=!0,u=!1;if(!c||l>r[c-1].to){let y=_t[l-1];y!=a&&(h=!1,u=y==16)}let d=!h&&a==1?[]:null,p=h?s:s+1,m=l;e:for(;;)if(c&&m==r[c-1].to){if(u)break e;let y=r[--c];if(!h)for(let v=y.from,g=c;;){if(v==e)break e;if(g&&r[g-1].to==v)v=r[--g].from;else{if(_t[v-1]==a)break e;break}}if(d)d.push(y);else{y.to_t.length;)_t[_t.length]=256;let s=[],i=e==_c?0:1;return M_(n,i,i,t,0,n.length,s),s}function bO(n){return[new Rr(0,n,0)]}let wO="";function $7(n,e,t,s,i){var r;let o=s.head-n.from,a=Rr.find(e,o,(r=s.bidiLevel)!==null&&r!==void 0?r:-1,s.assoc),l=e[a],c=l.side(i,t);if(o==c){let d=a+=i?1:-1;if(d<0||d>=e.length)return null;l=e[a=d],o=l.side(!i,t),c=l.side(i,t)}let h=$n(n.text,o,l.forward(i,t));(hl.to)&&(h=c),wO=n.text.slice(Math.min(o,h),Math.max(o,h));let u=a==(i?e.length-1:0)?null:e[a+(i?1:-1)];return u&&h==c&&u.level+(i?0:1)n.some(e=>e)}),$O=be.define({combine:n=>n.some(e=>e)}),TO=be.define();class yh{constructor(e,t,s,i,r,o=!1){this.range=e,this.y=t,this.x=s,this.yMargin=i,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new yh(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new yh(te.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Bm=St.define({map:(n,e)=>n.map(e)}),PO=St.define();function Mr(n,e,t){let s=n.facet(AO);s.length?s[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const bo=be.define({combine:n=>n.length?n[0]:!0});let P7=0;const sh=be.define({combine(n){return n.filter((e,t)=>{for(let s=0;s{let l=[];return o&&l.push(K0.of(c=>{let h=c.plugin(a);return h?o(h):Qe.none})),r&&l.push(r(a)),l})}static fromClass(e,t){return ri.define((s,i)=>new e(s,i),t)}}class jv{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(s){if(Mr(t.state,s,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Mr(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(s){Mr(e.state,s,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const RO=be.define(),Vx=be.define(),K0=be.define(),MO=be.define(),Wx=be.define(),am=be.define(),IO=be.define();function HE(n,e){let t=n.state.facet(IO);if(!t.length)return t;let s=t.map(r=>r instanceof Function?r(n):r),i=[];return st.spans(s,e.from,e.to,{point(){},span(r,o,a,l){let c=r-e.from,h=o-e.from,u=i;for(let d=a.length-1;d>=0;d--,l--){let p=a[d].spec.bidiIsolate,m;if(p==null&&(p=T7(e.text,c,h)),l>0&&u.length&&(m=u[u.length-1]).to==c&&m.direction==p)m.to=h,u=m.inner;else{let y={from:c,to:h,direction:p,inner:[]};u.push(y),u=y.inner}}}}),i}const OO=be.define();function NO(n){let e=0,t=0,s=0,i=0;for(let r of n.state.facet(OO)){let o=r(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(s=Math.max(s,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:e,right:t,top:s,bottom:i}}const Md=be.define();class bi{constructor(e,t,s,i){this.fromA=e,this.toA=t,this.fromB=s,this.toB=i}join(e){return new bi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,s=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>s.toA)){if(i.toAi.push(new bi(r,o,a,l))),this.changedRanges=i}static create(e,t,s){return new Ty(e,t,s)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const R7=[];class Gt{constructor(e,t,s=0){this.dom=e,this.length=t,this.flags=s,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return R7}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&f7(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let s=t;for(let i of this.children){if(i==e)return s;s+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,s){return null}domPosFor(e,t){let s=Ia(this.dom),i=this.length?e>0:t>0;return new Zi(this.parent.dom,s+(i?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof X0)return e;return null}static get(e){return e.cmTile}}class Z0 extends Gt{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,s=null,i,r=(e==null?void 0:e.node)==t?e:null,o=0;for(let a of this.children){if(a.sync(e),o+=a.length+a.breakAfter,i=s?s.nextSibling:t.firstChild,r&&i!=a.dom&&(r.written=!0),a.dom.parentNode==t)for(;i&&i!=a.dom;)i=BE(i);else t.insertBefore(a.dom,i);s=a.dom}for(i=s?s.nextSibling:t.firstChild,r&&i&&(r.written=!0);i;)i=BE(i);this.length=o}}function BE(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class X0 extends Z0{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Gt.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],s=this,i=0,r=0;;)if(i==s.children.length){if(!t.length)return;s=s.parent,s.breakAfter&&r++,i=t.pop()}else{let o=s.children[i++];if(o instanceof Eo)t.push(i),s=o,i=0;else{let a=r+o.length,l=e(o,r);if(l!==void 0)return l;r=a+o.breakAfter}}}resolveBlock(e,t){let s,i=-1,r,o=-1;if(this.blockTiles((a,l)=>{let c=l+a.length;if(e>=l&&e<=c){if(a.isWidget()&&t>=-1&&t<=1){if(a.flags&32)return!0;a.flags&16&&(s=void 0)}(le||e==l&&(t>1?a.length:a.covers(-1)))&&(!r||!a.isWidget()&&r.isWidget())&&(r=a,o=e-l)}}),!s&&!r)throw new Error("No tile at position "+e);return s&&t<0||!r?{tile:s,offset:i}:{tile:r,offset:o}}}class Eo extends Z0{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let s=new Eo(t||document.createElement(e.tagName),e);return t||(s.flags|=4),s}}class Eu extends Z0{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,s){let i=new Eu(t||document.createElement("div"),e);return(!t||!s)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,s){let i=null,r=-1,o=null,a=-1;function l(h,u){for(let d=0,p=0;d=u&&(m.isComposite()?l(m,u-p):(!o||o.isHidden&&(t>0&&!(o.flags&32)||s&&I7(o,m)))&&(y>u||m.flags&32&&t<=1)?(o=m,a=u-p):(p=-1)&&(i=m,r=u-p)),p=y}}l(this,e);let c=(t<0?i:o)||i||o;return c?{tile:c,offset:c==i?r:a}:null}coordsIn(e,t,s){let i=this.resolveInline(e,t,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),t,s):M7(this)}domIn(e,t){let s=this.resolveInline(e,t);if(s){let{tile:i,offset:r}=s;if(this.dom.contains(i.dom))return i.isText()?new Zi(i.dom,Math.min(i.dom.nodeValue.length,r)):i.domPosFor(r,i.flags&16?1:i.flags&32?-1:t);let o=s.tile.parent,a=!1;for(let l of o.children){if(a)return new Zi(l.dom,0);l==s.tile&&(a=!0)}}return new Zi(this.dom,0)}}function M7(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=Kg(e);return t[t.length-1]||null}function I7(n,e){let t=n.coordsIn(0,1),s=e.coordsIn(0,1);return t&&s&&s.topi&&(e=i);let r=e,o=e,a=0;e==0&&t<0||e==i&&t>=0?de.chrome||de.gecko||(e?(r--,a=1):o=0)?0:l.length-1];return de.safari&&!a&&c.width==0&&(c=Array.prototype.find.call(l,h=>h.width)||c),s==null?c:$y(c,(a?a>0:t<0)==s)}static of(e,t){let s=new hl(t||document.createTextNode(e),e);return t||(s.flags|=2),s}}class Sc extends Gt{constructor(e,t,s,i){super(e,t,i),this.widget=s}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,s){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;if(s)return $y(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let a=this.flags&16?!0:this.flags&32?!1:e>0;for(let l=a?r.length-1:0;o=r[l],!(e>0?l==0:l==r.length-1||o.top0==s)}}class O7{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,s){let{tile:i,index:r,beforeBreak:o,parents:a}=this;for(;e||t>0;)if(i.isComposite())if(o){if(!e)break;s&&s.break(),e--,o=!1}else if(r==i.children.length){if(!e&&!a.length)break;s&&s.leave(i),o=!!i.breakAfter,{tile:i,index:r}=a.pop(),r++}else{let l=i.children[r],c=l.breakAfter;(t>0?l.length<=e:l.length=0;a--){let l=t.marks[a],c=i.lastChild;if(c instanceof js&&c.mark.eq(l.mark))c.dom!=l.dom&&c.setDOM(Fv(l.dom)),i=c;else{if(this.cache.reused.get(l)){let u=Gt.get(l.dom);u&&u.setDOM(Fv(l.dom))}let h=js.of(l.mark,l.dom);i.append(h),i=h}this.cache.reused.set(l,2)}let r=Gt.get(e.text);r&&this.cache.reused.set(r,2);let o=new hl(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,i.append(o)}addInlineWidget(e,t,s){let i=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);i||this.flushBuffer();let r=this.ensureMarks(t,s);!i&&!(e.flags&16)&&r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,s){this.flushBuffer(),this.ensureMarks(t,s).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var s;e||(e=LO);let i=Eu.start(e,t||((s=this.cache.find(Eu))===null||s===void 0?void 0:s.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var s;let i=this.curLine;for(let r=e.length-1;r>=0;r--){let o=e[r],a;if(t>0&&(a=i.lastChild)&&a instanceof js&&a.mark.eq(o))i=a,t--;else{let l=js.of(o,(s=this.cache.find(js,c=>c.mark.eq(o)))===null||s===void 0?void 0:s.dom);i.append(l),i=l,t=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!UE(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(de.ios&&UE(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(zv,0,32)||new Sc(zv.toDOM(),0,zv,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=e.rank*102+e.value.rank,s=new N7(e.from,e.to,e.value,t),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-s.rank||this.wrappers[i-1].to-s.to)<0;)i--;this.wrappers.splice(i,0,s)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let s of this.wrappers){let i=t.lastChild;if(s.fromo.wrapper.eq(s.wrapper)))===null||e===void 0?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),s=this.cache.find(Py,void 0,1);return s&&(s.flags=t),s||new Py(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class D7{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:i,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=i;let a=this.textOff=Math.min(e,i.length);return r?null:i.slice(0,a)}let t=Math.min(this.text.length,this.textOff+e),s=this.text.slice(this.textOff,t);return this.textOff=t,s}}const Ry=[Sc,Eu,hl,js,Py,Eo,X0];for(let n=0;n[]),this.index=Ry.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,s=this.buckets[t];s.length<6?s.push(e):s[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,s=2){let i=e.bucket,r=this.buckets[i],o=this.index[i];for(let a=0;a{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let s=t&&this.getCompositionContext(t.text);for(let i=0,r=0,o=0;;){let a=oi){let c=l-i;this.preserve(c,!o,!a),i=l,r+=c}if(!a)break;t&&a.fromA<=t.range.fromA&&a.toA>=t.range.toA?(this.forward(a.fromA,t.range.fromA,t.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(l-a);else{let c=l>0||a{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof js&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=r=0):o instanceof js&&(i.shift(),r=Math.min(r,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let s=null,i=this.builder,r=-1,o=st.spans(this.decorations,e,t,{point:(a,l,c,h,u,d)=>{if(c instanceof wc){if(this.disallowBlockEffectsFor[d]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(l>this.view.state.doc.lineAt(a).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=h.length,u>h.length)i.continueWidget(l-a);else{let p=c.widget||(c.block?Cu.block:Cu.inline),m=z7(c),y=this.cache.findWidget(p,l-a,m)||Sc.of(p,this.view,l-a,m);c.block?(c.startSide>0&&i.addLineStartIfNotCovered(s),i.addBlockWidget(y)):(i.ensureLine(s),i.addInlineWidget(y,h,u))}s=null}else s=H7(s,c);l>a&&this.text.skip(l-a)},span:(a,l,c,h)=>{for(let u=a;u-1&&(this.openWidget=o>r),this.openWidget||i.addLineStartIfNotCovered(s),this.openMarks=o}forward(e,t,s=1){t-e<=10?this.old.advance(t-e,s,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,s,this.reuseWalker))}getCompositionContext(e){let t=[],s=null;for(let i=e.parentNode;;i=i.parentNode){let r=Gt.get(i);if(i==this.view.contentDOM)break;r instanceof js?t.push(r):r!=null&&r.isLine()?s=r:r instanceof Eo||(i.nodeName=="DIV"&&!s&&i!=this.view.contentDOM?s=new Eu(i,LO):s||t.push(js.of(new rm({tagName:i.nodeName.toLowerCase(),attributes:p7(i)}),i)))}return{line:s,marks:t}}}function UE(n,e){let t=s=>{for(let i of s.children)if((e?i.isText():i.length)||t(i))return!0;return!1};return t(n)}function z7(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const LO={class:"cm-line"};function H7(n,e){let t=e.spec.attributes,s=e.spec.class;return!t&&!s||(n||(n={class:"cm-line"}),t&&zx(t,n),s&&(n.class+=" "+s)),n}function B7(n){let e=[];for(let t=n.parents.length;t>1;t--){let s=t==n.parents.length?n.tile:n.parents[t].tile;s instanceof js&&e.push(s.mark)}return e}function Fv(n){let e=Gt.get(n);return e&&e.setDOM(n.cloneNode()),n}class Cu extends G0{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Cu.inline=new Cu("span");Cu.block=new Cu("div");const zv=new class extends G0{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class qE{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Qe.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new X0(e,e.contentDOM),this.updateInner([new bi(0,0,0,e.state.doc.length)],null)}update(e){var t;let s=e.changedRanges;this.minWidth>0&&s.length&&(s.every(({fromA:h,toA:u})=>uthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?i=this.domChanged.newSel.head:!Y7(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let r=i>-1?q7(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:h,to:u}=this.hasComposition;s=new bi(h,u,e.changes.mapPos(h,-1),e.changes.mapPos(u,1)).addToSet(s.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(de.ie||de.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,a=this.blockWrappers;this.updateDeco();let l=G7(o,this.decorations,e.changes);l.length&&(s=bi.extendWithRanges(s,l));let c=Z7(a,this.blockWrappers,e.changes);return c.length&&(s=bi.extendWithRanges(s,c)),r&&!s.some(h=>h.fromA<=r.range.fromA&&h.toA>=r.range.toA)&&(s=r.range.addToSet(s.slice())),this.tile.flags&2&&s.length==0?!1:(this.updateInner(s,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:s}=this.view;s.ignore(()=>{if(t||e.length){let o=this.tile,a=new F7(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Gt.get(t.text)&&a.cache.reused.set(Gt.get(t.text),2),this.tile=a.run(e,t),O_(o,a.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=de.chrome||de.ios?{node:s.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||s.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Yd(s,this.view.observer.selectionRange)&&!(i&&s.contains(i));if(!(r||t||o))return;let a=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,c,h;if(l.empty?h=c=this.inlineDOMNearPos(l.anchor,l.assoc||1):(h=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),c=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),de.gecko&&l.empty&&!this.hasComposition&&U7(c)){let d=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(d,c.node.childNodes[c.offset]||null)),c=h=new Zi(d,0),a=!0}let u=this.view.observer.selectionRange;(a||!u.focusNode||(!Jd(c.node,c.offset,u.anchorNode,u.anchorOffset)||!Jd(h.node,h.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,l))&&(this.view.observer.ignore(()=>{de.android&&de.chrome&&s.contains(u.focusNode)&&X7(u.focusNode,s)&&(s.blur(),s.focus({preventScroll:!0}));let d=mf(this.view.root);if(d)if(l.empty){if(de.gecko){let p=V7(c.node,c.offset);if(p&&p!=3){let m=(p==1?pO:mO)(c.node,c.offset);m&&(c=new Zi(m.node,m.offset))}}d.collapse(c.node,c.offset),l.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=l.bidiLevel)}else if(d.extend){d.collapse(c.node,c.offset);try{d.extend(h.node,h.offset)}catch{}}else{let p=document.createRange();l.anchor>l.head&&([c,h]=[h,c]),p.setEnd(h.node,h.offset),p.setStart(c.node,c.offset),d.removeAllRanges(),d.addRange(p)}o&&this.view.root.activeElement==s&&(s.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(c,h)),this.impreciseAnchor=c.precise?null:new Zi(u.anchorNode,u.anchorOffset),this.impreciseHead=h.precise?null:new Zi(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Jd(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,s=mf(e.root),{anchorNode:i,anchorOffset:r}=e.observer.selectionRange;if(!s||!t.empty||!t.assoc||!s.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let a=o.posAtStart;if(t.head==a||t.head==a+o.length)return;let l=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!l||!c||l.bottom>c.top)return;let h=this.domAtPos(t.head+t.assoc,t.assoc);s.collapse(h.node,h.offset),s.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&s.collapse(i,r)}posFromDOM(e,t){let s=this.tile.nearest(e);if(!s)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let i=s.posAtStart;if(s.isComposite()){let r;if(e==s.dom)r=s.dom.childNodes[t];else{let o=To(e)==0?0:t==0?-1:1;for(;;){let a=e.parentNode;if(a==s.dom)break;o==0&&a.firstChild!=a.lastChild&&(e==a.firstChild?o=-1:o=1),e=a}o<0?r=e:r=e.nextSibling}if(r==s.dom.firstChild)return i;for(;r&&!Gt.get(r);)r=r.nextSibling;if(!r)return i+s.length;for(let o=0,a=i;;o++){let l=s.children[o];if(l.dom==r)return a;a+=l.length+l.breakAfter}}else return s.isText()?e==s.dom?i+t:i+(t?s.length:0):i}domAtPos(e,t){let{tile:s,offset:i}=this.tile.resolveBlock(e,t);return s.isWidget()?s.domPosFor(i,t):s.domIn(i,t)}inlineDOMNearPos(e,t){let s,i=-1,r=!1,o,a=-1,l=!1;return this.tile.blockTiles((c,h)=>{if(c.isWidget()){if(c.flags&32&&h>=e)return!0;c.flags&16&&(r=!0)}else{let u=h+c.length;if(h<=e&&(s=c,i=e-h,r=u=e&&!o&&(o=c,a=e-h,l=h>e),h>e&&o)return!0}}),!s&&!o?this.domAtPos(e,t):(r&&o?s=null:l&&s&&(o=null),s&&t<0||!o?s.domIn(i,t):o.domIn(a,t))}coordsAt(e,t,s){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof Hv?null:i.coordsInWidget(r,t,!0):i.coordsIn(r,t,s)}lineAt(e,t){let{tile:s}=this.tile.resolveBlock(e,t);return s.isLine()?s:null}coordsForChar(e){let{tile:t,offset:s}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function i(r,o){if(r.isComposite())for(let a of r.children){if(a.length>=o){let l=i(a,o);if(l)return l}if(o-=a.length,o<0)break}else if(r.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==It.LTR,c=0,h=(u,d,p)=>{for(let m=0;mi);m++){let y=u.children[m],v=d+y.length,g=y.dom.getBoundingClientRect(),{height:_}=g;if(p&&!m&&(c+=g.top-p.top),y instanceof Eo)v>s&&h(y,d,g);else if(d>=s&&(c>0&&t.push(-c),t.push(_+c),c=0,o)){let b=y.dom.lastChild,x=b?Kg(b):[];if(x.length){let A=x[x.length-1],T=l?A.right-g.left:g.right-A.left;T>a&&(a=T,this.minWidth=r,this.minWidthFrom=d,this.minWidthTo=v)}}p&&m==u.children.length-1&&(c+=p.bottom-g.bottom),d=v+y.breakAfter}};return h(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?It.RTL:It.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let a=0,l;for(let c of o.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let h=Kg(c.dom);if(h.length!=1)return;a+=h[0].width,l=h[0].height}if(a)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:a/o.length,textHeight:l}}});if(e)return e;let t=document.createElement("div"),s,i,r;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=Kg(t.firstChild)[0];s=t.getBoundingClientRect().height,i=o&&o.width?o.width/27:7,r=o&&o.height?o.height:s,t.remove()}),{lineHeight:s,charWidth:i,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let s=0,i=0;;i++){let r=i==t.viewports.length?null:t.viewports[i],o=r?r.from-1:this.view.state.doc.length;if(o>s){let a=(t.lineBlockAt(o).bottom-t.lineBlockAt(s).top)/this.view.scaleY;e.push(Qe.replace({widget:new Hv(a),block:!0,inclusive:!0,isBlockGap:!0}).range(s,o))}if(!r)break;s=r.to+1}return Qe.set(e)}updateDeco(){let e=1,t=this.view.state.facet(K0).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),s=!1,i=this.view.state.facet(Wx).map((r,o)=>{let a=typeof r=="function";return a&&(s=!0),a?r(this.view):r});for(i.length&&(this.dynamicDecorationMap[e++]=s,t.push(st.join(i))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof r=="function"?r(this.view):r)}scrollIntoView(e){if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(TO))try{if(c(this.view,e.range,e))return!0}catch(h){Mr(this.view.state,h,"scroll handler")}let{range:t}=e,s=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),i;if(!s)return;!t.empty&&(i=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(s={left:Math.min(s.left,i.left),top:Math.min(s.top,i.top),right:Math.max(s.right,i.right),bottom:Math.max(s.bottom,i.bottom)});let r=NO(this.view),o={left:s.left-r.left,top:s.top-r.top,right:s.right+r.right,bottom:s.bottom+r.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;if(y7(this.view.scrollDOM,o,t.head1&&(s.top>window.visualViewport.offsetTop+window.visualViewport.height||s.bottoms.isWidget()||s.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){O_(this.tile)}}function O_(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let s of n.children)O_(s,e)}}function U7(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function DO(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let s=pO(t.focusNode,t.focusOffset),i=mO(t.focusNode,t.focusOffset),r=s||i;if(i&&s&&i.node!=s.node){let a=Gt.get(i.node);if(!a||a.isText()&&a.text!=i.node.nodeValue)r=i;else if(n.docView.lastCompositionAfterCursor){let l=Gt.get(s.node);!l||l.isText()&&l.text!=s.node.nodeValue||(r=i)}}if(n.docView.lastCompositionAfterCursor=r!=s,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function q7(n,e,t){let s=DO(n,t);if(!s)return null;let{node:i,from:r,to:o}=s,a=i.nodeValue;if(/[\n\r]/.test(a)||n.state.doc.sliceString(s.from,s.to)!=a)return null;let l=e.invertedDesc;return{range:new bi(l.mapPos(r),l.mapPos(o),r,o),text:i}}function V7(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{se.from&&(t=!0)}),t}class Hv extends G0{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function J7(n,e,t=1){let s=n.charCategorizer(e),i=n.doc.lineAt(e),r=e-i.from;if(i.length==0)return te.cursor(e);r==0?t=1:r==i.length&&(t=-1);let o=r,a=r;t<0?o=$n(i.text,r,!1):a=$n(i.text,r);let l=s(i.text.slice(o,a));for(;o>0;){let c=$n(i.text,o,!1);if(s(i.text.slice(c,o))!=l)break;o=c}for(;an.defaultLineHeight*1.5){let a=n.viewState.heightOracle.textHeight,l=Math.floor((i-t.top-(n.defaultLineHeight-a)*.5)/a);r+=l*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+l7(o,r,n.state.tabSize)}function N_(n,e,t){let s=n.lineBlockAt(e);if(Array.isArray(s.type)){let i;for(let r of s.type){if(r.from>e)break;if(!(r.toe)return r;(!i||r.type==Vn.Text&&(i.type!=r.type||(t<0?r.frome)))&&(i=r)}}return i||s}return s}function eJ(n,e,t,s){let i=N_(n,e.head,e.assoc||-1),r=!s||i.type!=Vn.Text||!(n.lineWrapping||i.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(r){let o=n.dom.getBoundingClientRect(),a=n.textDirectionAt(i.from),l=n.posAtCoords({x:t==(a==It.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(l!=null)return te.cursor(l,t?-1:1)}return te.cursor(t?i.to:i.from,t?-1:1)}function VE(n,e,t,s){let i=n.state.doc.lineAt(e.head),r=n.bidiSpans(i),o=n.textDirectionAt(i.from);for(let a=e,l=null;;){let c=$7(i,r,o,a,t),h=wO;if(!c){if(i.number==(t?n.state.doc.lines:1))return a;h=` -`,i=n.state.doc.line(i.number+(t?1:-1)),r=n.bidiSpans(i),c=n.visualLineSide(i,!t)}if(l){if(!l(h))return a}else{if(!s)return c;l=s(h)}a=c}}function tJ(n,e,t){let s=n.state.charCategorizer(e),i=s(t);return r=>{let o=s(r);return i==en.Space&&(i=o),i==o}}function nJ(n,e,t,s){let i=e.head,r=t?1:-1;if(i==(t?n.state.doc.length:0))return te.cursor(i,e.assoc);let o=e.goalColumn,a,l=n.contentDOM.getBoundingClientRect(),c=n.coordsAtPos(i,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),h=n.documentTop;if(c)o==null&&(o=c.left-l.left),a=r<0?c.top:c.bottom;else{let m=n.viewState.lineBlockAt(i);o==null&&(o=Math.min(l.right-l.left,n.defaultCharacterWidth*(i-m.from))),a=(r<0?m.top:m.bottom)+h}let u=l.left+o,d=n.viewState.heightOracle.textHeight>>1,p=s??d;for(let m=0;;m+=d){let y=a+(p+m)*r,v=L_(n,{x:u,y},!1,r);if(t?y>l.bottom:ya:_{if(e>r&&ei(n)),t.from,e.head>t.from?-1:1);return s==t.from?t:te.cursor(s,sn.viewState.docHeight)return new $r(n.state.doc.length,-1);if(c=n.elementAtHeight(l),s==null)break;if(c.type==Vn.Text){if(s<0?c.ton.viewport.to)break;let d=n.docView.coordsAt(s<0?c.from:c.to,s>0?-1:1);if(d&&(s<0?d.top<=l+r:d.bottom>=l+r))break}let u=n.viewState.heightOracle.textHeight/2;l=s>0?c.bottom+u:c.top-u}if(n.viewport.from>=c.to||n.viewport.to<=c.from){if(t)return null;if(c.type==Vn.Text){let u=Q7(n,i,c,o,a);return new $r(u,u==c.from?1:-1)}}if(c.type!=Vn.Text)return l<(c.top+c.bottom)/2?new $r(c.from,1):new $r(c.to,-1);let h=n.docView.lineAt(c.from,2);return(!h||h.length!=c.length)&&(h=n.docView.lineAt(c.from,-2)),new sJ(n,o,a,n.textDirectionAt(c.from)).scanTile(h,c.from)}class sJ{constructor(e,t,s,i){this.view=e,this.x=t,this.y=s,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||s.length&&(s[0].level!=this.baseDir||s[0].to+i.from>1;t:if(o.has(y)){for(let _=1;_=r&&(b-=m),!o.has(b)){y=b;break t}}break e}o.add(y);let v=t(y),g=0;if(v)for(let _=0;_1))if(b.bottomthis.y)(!c||c.top>b.top)&&(c=b),g=-1;else{let x=b.left>this.x?this.x-b.left:b.right(m+m+y)/3)return this.y=l.bottom-1,this.scan(e,t,!0);if(c&&c.top<(m+y+y)/3)return this.y=c.top+1,this.scan(e,t,!0)}let p=(a?this.dirAt(e[h],1):this.baseDir)==It.LTR;return{i:h,after:this.x>(d.left+d.right)/2==p}}scanText(e,t){let s=[];for(let r=0;r{let o=s[r]-t,a=s[r+1]-t;return gf(e.dom,o,a).getClientRects()});return i.after?new $r(s[i.i+1],-1):new $r(s[i.i],1)}scanTile(e,t){if(!e.length)return new $r(t,1);if(e.children.length==1){let a=e.children[0];if(a.isText())return this.scanText(a,t);if(a.isComposite())return this.scanTile(a,t)}let s=[t];for(let a=0,l=t;a{let l=e.children[a];return l.flags&48?null:(l.dom.nodeType==1?l.dom:gf(l.dom,0,l.length)).getClientRects()}),r=e.children[i.i],o=s[i.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):i.after?new $r(s[i.i+1],-1):new $r(o,1)}}const Yc="￿";class iJ{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(at.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Yc}readRange(e,t){if(!e)return this;let s=e.parentNode;for(let i=e;;){this.findPointBefore(s,i);let r=this.text.length;this.readNode(i);let o=Gt.get(i),a=i.nextSibling;if(a==t){o!=null&&o.breakAfter&&!a&&s!=this.view.contentDOM&&this.lineBreak();break}let l=Gt.get(a);(o&&l?o.breakAfter:(o?o.breakAfter:Cy(i))||Cy(a)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>r)&&!oJ(a,t)&&this.lineBreak(),i=a}return this.findPointBefore(s,t),this}readTextNode(e){let t=e.nodeValue;for(let s of this.points)s.node==e&&(s.pos=this.text.length+Math.min(s.offset,t.length));for(let s=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,a;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,s),o=this.lineSeparator.length):(a=i.exec(t))&&(r=a.index,o=a[0].length),this.append(t.slice(s,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=o-1);s=r+o}}readNode(e){let t=Gt.get(e),s=t&&t.overrideDOMText;if(s!=null){this.findPointInside(e,s.length);for(let i=s.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let s of this.points)s.node==e&&e.childNodes[s.offset]==t&&(s.pos=this.text.length)}findPointInside(e,t){for(let s of this.points)(e.nodeType==3?s.node==e:e.contains(s.node))&&(s.pos=this.text.length+(rJ(e,s.node,s.offset)?t:0))}}function rJ(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView,a=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=FO(e.docView.tile,t,s,0))){let l=r||o?[]:cJ(e),c=new iJ(l,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=hJ(l,this.bounds.from)}else{let l=e.observer.selectionRange,c=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!T_(e.contentDOM,l.focusNode)?a.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!T_(e.contentDOM,l.anchorNode)?a.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),u=e.viewport;if((de.ios||de.chrome)&&c!=h&&Math.min(c,h)<=a.main.from&&Math.max(c,h)>=a.main.to&&(u.from>0||u.to-1&&a.ranges.length>1)this.newSel=a.replaceRange(te.range(h,c));else if(e.lineWrapping&&h==c&&!(a.main.empty&&a.main.head==c)&&e.inputState.lastTouchTime>Date.now()-100){let d=e.coordsAtPos(c,-1),p=0;d&&(p=e.inputState.lastTouchY<=d.bottom?-1:1),this.newSel=te.create([te.cursor(c,p)])}else this.newSel=te.single(h,c)}}}function FO(n,e,t,s){if(n.isComposite()){let i=-1,r=-1,o=-1,a=-1;for(let l=0,c=s,h=s;lt)return FO(u,e,t,c);if(d>=e&&i==-1&&(i=l,r=c),c>t&&u.dom.parentNode==n.dom){o=l,a=h;break}h=d,c=d+u.breakAfter}return{from:r,to:a<0?s+n.length:a,startDOM:(i?n.children[i-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o=0?n.children[o].dom:null}}else return n.isText()?{from:s,to:s+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function zO(n,e){let t,{newSel:s}=e,{state:i}=n,r=i.selection.main,o=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:l}=e.bounds,c=r.from,h=null;(o===8||de.android&&e.text.length=a&&r.to<=l&&(e.typeOver||u!=e.text)&&u.slice(0,r.from-a)==e.text.slice(0,r.from-a)&&u.slice(r.to-a)==e.text.slice(d=e.text.length-(u.length-(r.to-a)))?t={from:r.from,to:r.to,insert:lt.of(e.text.slice(r.from-a,d).split(Yc))}:(p=HO(u,e.text,c-a,h))&&(de.chrome&&o==13&&p.toB==p.from+2&&e.text.slice(p.from,p.toB)==Yc+Yc&&p.toB--,t={from:a+p.from,to:a+p.toA,insert:lt.of(e.text.slice(p.from,p.toB).split(Yc))})}else s&&(!n.hasFocus&&i.facet(bo)||My(s,r))&&(s=null);if(!t&&!s)return!1;if((de.mac||de.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(s&&t.insert.length==2&&(s=te.single(s.main.anchor-1,s.main.head-1)),t={from:t.from,to:t.to,insert:lt.of([t.insert.toString().replace("."," ")])}):i.doc.lineAt(r.from).toDate.now()-50?t={from:r.from,to:r.to,insert:i.toText(n.inputState.insertingText)}:de.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==` - `&&n.lineWrapping&&(s&&(s=te.single(s.main.anchor-1,s.main.head-1)),t={from:r.from,to:r.to,insert:lt.of([" "])}),t)return Gx(n,t,s,o);if(s&&!My(s,r)){let a=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(a=!0),l=n.inputState.lastSelectionOrigin,l=="select.pointer"&&(s=jO(i.facet(am).map(c=>c(n)),s))),n.dispatch({selection:s,scrollIntoView:a,userEvent:l}),!0}else return!1}function Gx(n,e,t,s=-1){if(de.ios&&n.inputState.flushIOSKey(e))return!0;let i=n.state.selection.main;if(de.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&n.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&gh(n.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||s==8&&e.insert.lengthi.head)&&gh(n.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&gh(n.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,a=()=>o||(o=lJ(n,e,t));return n.state.facet(kO).some(l=>l(n,e.from,e.to,r,a))||n.dispatch(a()),!0}function lJ(n,e,t){let s,i=n.state,r=i.selection.main,o=-1;if(e.from==e.to&&e.fromr.to){let l=e.fromu(n)),c,l);e.from==h&&(o=h)}if(o>-1)s={changes:e,selection:te.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=r.frome.to?i.sliceDoc(e.to,r.to):"";s=i.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+c))}else{let l=i.changes(e),c=t&&t.main.to<=l.newLength?t.main:void 0;if(i.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=r.to+10&&e.to>=r.to-10){let h=n.state.sliceDoc(e.from,e.to),u,d=t&&DO(n,t.main.head);if(d){let m=e.insert.length-(e.to-e.from);u={from:d.from,to:d.to-m}}else u=n.state.doc.lineAt(r.head);let p=r.to-e.to;s=i.changeByRange(m=>{if(m.from==r.from&&m.to==r.to)return{changes:l,range:c||m.map(l)};let y=m.to-p,v=y-h.length;if(n.state.sliceDoc(v,y)!=h||y>=u.from&&v<=u.to)return{range:m};let g=i.changes({from:v,to:y,insert:e.insert}),_=m.to-r.to;return{changes:g,range:c?te.range(Math.max(0,c.anchor+_),Math.max(0,c.head+_)):m.map(g)}})}else s={changes:l,selection:c&&i.selection.replaceRange(c)}}let a="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,a+=".compose",n.inputState.compositionFirstChange&&(a+=".start",n.inputState.compositionFirstChange=!1)),i.update(s,{userEvent:a,scrollIntoView:!0})}function HO(n,e,t,s){let i=Math.min(n.length,e.length),r=0;for(;r0&&a>0&&n.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(s=="end"){let l=Math.max(0,r-Math.min(o,a));t-=o+l-r}if(o=o?r-t:0;r-=l,a=r+(a-o),o=r}else if(a=a?r-t:0;r-=l,o=r+(o-a),a=r}return{from:r,toA:o,toB:a}}function cJ(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:s,focusNode:i,focusOffset:r}=n.observer.selectionRange;return t&&(e.push(new WE(t,s)),(i!=t||r!=s)&&e.push(new WE(i,r))),e}function hJ(n,e){if(n.length==0)return null;let t=n[0].pos,s=n.length==2?n[1].pos:t;return t>-1&&s>-1?te.single(t+e,s+e):null}function My(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}class uJ{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,de.safari&&e.contentDOM.addEventListener("input",()=>null),de.gecko&&CJ(e.contentDOM.ownerDocument)}handleEvent(e){!wJ(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let s=this.handlers[e];if(s){for(let i of s.observers)i(this.view,t);for(let i of s.handlers){if(t.defaultPrevented)break;if(i(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=fJ(e),s=this.handlers,i=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,a=s[r];a&&o!=!a.handlers.length&&(i.removeEventListener(r,this.handleEvent),a=null),a||i.addEventListener(r,this.handleEvent,{passive:o})}for(let r in s)r!="scroll"&&!t[r]&&i.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&UO.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),de.android&&de.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(de.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(BO.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||pJ.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&de.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&dJ(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:de.safari&&!de.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function dJ(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function GE(n,e){return(t,s)=>{try{return e.call(n,s,t)}catch(i){Mr(t.state,i)}}}function fJ(n){let e=Object.create(null);function t(s){return e[s]||(e[s]={observers:[],handlers:[]})}for(let s of n){let i=s.spec,r=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(r)for(let a in r){let l=r[a];l&&t(a).handlers.push(GE(s.value,l))}if(o)for(let a in o){let l=o[a];l&&t(a).observers.push(GE(s.value,l))}}for(let s in Qi)t(s).handlers.push(Qi[s]);for(let s in _s)t(s).observers.push(_s[s]);return e}const BO=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],pJ="dthko",UO=[16,17,18,20,91,92,224,225],Um=6;function qm(n){return Math.max(0,n)*.7+8}function mJ(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class gJ{constructor(e,t,s,i){this.view=e,this.startEvent=t,this.style=s,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=cO(e.contentDOM),this.atoms=e.state.facet(am).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(at.allowMultipleSelections)&&yJ(e,t),this.dragging=bJ(e,t)&&WO(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&mJ(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,s=0,i=0,r=0,o=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=NO(this.view);e.clientX-l.left<=i+Um?t=-qm(i-e.clientX):e.clientX+l.right>=o-Um&&(t=qm(e.clientX-o)),e.clientY-l.top<=r+Um?s=-qm(r-e.clientY):e.clientY+l.bottom>=a-Um&&(s=qm(e.clientY-a)),this.setScrollSpeed(t,s)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,s=jO(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!s.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:s,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function yJ(n,e){let t=n.state.facet(_O);return t.length?t[0](e):de.mac?e.metaKey:e.ctrlKey}function vJ(n,e){let t=n.state.facet(SO);return t.length?t[0](e):de.mac?!e.altKey:!e.ctrlKey}function bJ(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let s=mf(n.root);if(!s||s.rangeCount==0)return!0;let i=s.getRangeAt(0).getClientRects();for(let r=0;r=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function wJ(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,s;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(s=Gt.get(t))&&s.isWidget()&&!s.isHidden&&s.widget.ignoreEvent(e))return!1;return!0}const Qi=Object.create(null),_s=Object.create(null),qO=de.ie&&de.ie_version<15||de.ios&&de.webkit_version<604;function _J(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),VO(n,t.value)},50)}function Y0(n,e,t){for(let s of n.facet(e))t=s(t,n);return t}function VO(n,e){e=Y0(n.state,Ux,e);let{state:t}=n,s,i=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(D_!=null&&t.selection.ranges.every(l=>l.empty)&&D_==r.toString()){let l=-1;s=t.changeByRange(c=>{let h=t.doc.lineAt(c.from);if(h.from==l)return{range:c};l=h.from;let u=t.toText((o?r.line(i++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:u},range:te.cursor(c.from+u.length)}})}else o?s=t.changeByRange(l=>{let c=r.line(i++);return{changes:{from:l.from,to:l.to,insert:c.text},range:te.cursor(l.from+c.length)}}):s=t.replaceSelection(r);n.dispatch(s,{userEvent:"input.paste",scrollIntoView:!0})}_s.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,de.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};_s.wheel=_s.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};Qi.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);_s.touchstart=(n,e)=>{let t=n.inputState,s=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),s&&(t.lastTouchX=s.clientX,t.lastTouchY=s.clientY),t.setSelectionOrigin("select.pointer")};_s.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};_s.touchend=(n,e)=>{n.inputState.touchActive=!1};Qi.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let s of n.state.facet(xO))if(t=s(n,e),t)break;if(!t&&e.button==0&&(t=xJ(n,e)),t){let s=!n.hasFocus;n.inputState.startMouseSelection(new gJ(n,e,t,s)),s&&n.observer.ignore(()=>{dO(n.contentDOM);let r=n.root.activeElement;r&&!r.contains(n.contentDOM)&&r.blur()});let i=n.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function KE(n,e,t,s){if(s==1)return te.cursor(e,t);if(s==2)return J7(n.state,e,t);{let i=n.docView.lineAt(e,t),r=n.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:r.from,a=i?i.posAtEnd:r.to;return aDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(XE+1)%3:1}function xJ(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),s=WO(e),i=n.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),i=i.map(r.changes))},get(r,o,a){let l=n.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),c,h=KE(n,l.pos,l.assoc,s);if(t.pos!=l.pos&&!o){let u=KE(n,t.pos,t.assoc,s),d=Math.min(u.from,h.from),p=Math.max(u.to,h.to);h=d1&&(c=AJ(i,l.pos))?c:a?i.addRange(h):te.create([h])}}}function AJ(n,e){for(let t=0;t=e)return te.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}Qi.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let i=n.docView.tile.nearest(e.target);if(i&&i.isWidget()){let r=i.posAtStart,o=r+i.length;(r>=t.to||o<=t.from)&&(t=te.undirectionalRange(r,o))}}let{inputState:s}=n;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",Y0(n.state,qx,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Qi.dragend=n=>(n.inputState.draggedContent=null,!1);function JE(n,e,t,s){if(t=Y0(n.state,Ux,t),!t)return;let i=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=n.inputState,o=s&&r&&vJ(n,e)?{from:r.from,to:r.to}:null,a={from:i,insert:t},l=n.state.changes(o?[o,a]:a);n.focus(),n.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Qi.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let s=Array(t.length),i=0,r=()=>{++i==t.length&&JE(n,e,s.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(s[o]=a.result),r()},a.readAsText(t[o])}return!0}else{let s=e.dataTransfer.getData("Text");if(s)return JE(n,e,s,!0),!0}return!1};Qi.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=qO?null:e.clipboardData;return t?(VO(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(_J(n),!1)};function kJ(n,e){let t=n.dom.parentNode;if(!t)return;let s=t.appendChild(document.createElement("textarea"));s.style.cssText="position: fixed; left: -10000px; top: 10px",s.value=e,s.focus(),s.selectionEnd=e.length,s.selectionStart=0,setTimeout(()=>{s.remove(),n.focus()},50)}function EJ(n){let e=[],t=[],s=!1;for(let i of n.selection.ranges)i.empty||(e.push(n.sliceDoc(i.from,i.to)),t.push(i));if(!e.length){let i=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>i&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),i=o.number}s=!0}return{text:Y0(n,qx,e.join(n.lineBreak)),ranges:t,linewise:s}}let D_=null;Qi.copy=Qi.cut=(n,e)=>{if(!Yd(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:s,linewise:i}=EJ(n.state);if(!t&&!i)return!1;D_=i?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:s,scrollIntoView:!0,userEvent:"delete.cut"});let r=qO?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(kJ(n,t),!1)};const GO=Fa.define();function KO(n,e){let t=[];for(let s of n.facet(EO)){let i=s(n,e);i&&t.push(i)}return t.length?n.update({effects:t,annotations:GO.of(!0)}):null}function ZO(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=KO(n.state,e);t?n.dispatch(t):n.update([])}},10)}_s.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),ZO(n)};_s.blur=n=>{n.observer.clearSelectionRange(),ZO(n)};_s.compositionstart=_s.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};_s.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,de.chrome&&de.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};_s.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Qi.beforeinput=(n,e)=>{var t,s;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let a=o[0],l=n.posAtDOM(a.startContainer,a.startOffset),c=n.posAtDOM(a.endContainer,a.endOffset);return Gx(n,{from:l,to:c,insert:n.state.toText(r)},null),!0}}let i;if(de.chrome&&de.android&&(i=BO.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let r=((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return de.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),de.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>_s.compositionend(n,e),20),!1};const QE=new Set;function CJ(n){QE.has(n)||(QE.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const eC=["pre-wrap","normal","pre-line","break-spaces"];let $u=!1;function tC(){$u=!1}class $J{constructor(e){this.lineWrapping=e,this.doc=lt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let s=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(s+=Math.max(0,Math.ceil((t-e-s*this.lineLength*.5)/this.lineLength))),this.lineHeight*s}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return eC.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let s=0;s-1,l=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=s,this.textHeight=i,this.lineLength=r,l){this.heightSamples={};for(let c=0;c0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Zg&&($u=!0),this.height=e)}replace(e,t,s){return vs.of(s)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,s,i){let r=this,o=s.doc;for(let a=i.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:h,toB:u}=i[a],d=r.lineAt(l,Et.ByPosNoHeight,s.setDoc(t),0,0),p=d.to>=c?d:r.lineAt(c,Et.ByPosNoHeight,s,0,0);for(u+=p.to-c,c=p.to;a>0&&d.from<=i[a-1].toA;)l=i[a-1].fromA,h=i[a-1].fromB,a--,lr*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),s+=1+a.break,i-=a.size}else if(r>i*2){let a=e[s];a.break?e.splice(s,1,a.left,null,a.right):e.splice(s,1,a.left,a.right),s+=2+a.break,r-=a.size}else break;else if(i=r&&o(this.lineAt(0,Et.ByPos,s,i,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,s=!1,i){return i&&i.from<=t&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ti extends XO{constructor(e,t,s){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=s}mainBlock(e,t){return new Ki(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,s){let i=s[0];return s.length==1&&(i instanceof ti||i instanceof Fn&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Fn?i=new ti(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):vs.of(s)}updateHeight(e,t=0,s=!1,i){return i&&i.from<=t&&i.more?this.setMeasuredHeight(i):(s||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Fn extends vs{constructor(e){super(e,0)}heightMetrics(e,t){let s=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,r=i-s+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*r);o=l/r,this.length>r+1&&(a=(this.height-l)/(this.length-r-1))}else o=this.height/r;return{firstLine:s,lastLine:i,perLine:o,perChar:a}}blockAt(e,t,s,i){let{firstLine:r,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(t,i);if(t.lineWrapping){let c=i+(e0){let r=s[s.length-1];r instanceof Fn?s[s.length-1]=new Fn(r.length+i):s.push(null,new Fn(i-1))}if(e>0){let r=s[0];r instanceof Fn?s[0]=new Fn(e+r.length):s.unshift(new Fn(e-1),null)}return vs.of(s)}decomposeLeft(e,t){t.push(new Fn(e-1),null)}decomposeRight(e,t){t.push(null,new Fn(this.length-e-1))}updateHeight(e,t=0,s=!1,i){let r=t+this.length;if(i&&i.from<=t+this.length&&i.more){let o=[],a=Math.max(t,i.from),l=-1;for(i.from>t&&o.push(new Fn(i.from-t-1).updateHeight(e,t));a<=r&&i.more;){let h=e.doc.lineAt(a).length;o.length&&o.push(null);let u=i.heights[i.index++],d=0;u<0&&(d=-u,u=i.heights[i.index++]),l==-1?l=u:Math.abs(u-l)>=Zg&&(l=-2);let p=new ti(h,u,d);p.outdated=!1,o.push(p),a+=h+1}a<=r&&o.push(null,new Fn(r-a).updateHeight(e,a));let c=vs.of(o);return(l<0||Math.abs(c.height-this.height)>=Zg||Math.abs(l-this.heightMetrics(e,t).perLine)>=Zg)&&($u=!0),Iy(this,c)}else(s||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class RJ extends vs{constructor(e,t,s){super(e.length+t+s.length,e.height+s.height,t|(e.outdated||s.outdated?2:0)),this.left=e,this.right=s,this.size=e.size+s.size}get break(){return this.flags&1}blockAt(e,t,s,i){let r=s+this.left.height;return ea))return c;let h=t==Et.ByPosNoHeight?Et.ByPosNoHeight:Et.ByPos;return l?c.join(this.right.lineAt(a,h,s,o,a)):this.left.lineAt(a,h,s,i,r).join(c)}forEachLine(e,t,s,i,r,o){let a=i+this.left.height,l=r+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,t,s,a,l,o);else{let c=this.lineAt(l,Et.ByPos,s,i,r);e=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,s,a,l,o)}}replace(e,t,s){let i=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,s));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let a of s)r.push(a);if(e>0&&nC(r,o-1),t=s&&t.push(null)),e>s&&this.right.decomposeLeft(e-s,t)}decomposeRight(e,t){let s=this.left.length,i=s+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e2*t.size||t.size>2*e.size?vs.of(this.break?[e,null,t]:[e,t]):(this.left=Iy(this.left,e),this.right=Iy(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,s=!1,i){let{left:r,right:o}=this,a=t+r.length+this.break,l=null;return i&&i.from<=t+r.length&&i.more?l=r=r.updateHeight(e,t,s,i):r.updateHeight(e,t,s),i&&i.from<=a+o.length&&i.more?l=o=o.updateHeight(e,a,s,i):o.updateHeight(e,a,s),l?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function nC(n,e){let t,s;n[e]==null&&(t=n[e-1])instanceof Fn&&(s=n[e+1])instanceof Fn&&n.splice(e-1,3,new Fn(t.length+1+s.length))}const MJ=5;class Kx{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let s=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof ti?i.length+=s-this.pos:(s>this.pos||!this.isCovered)&&this.nodes.push(new ti(s-this.pos,-1,0)),this.writtenTo=s,t>s&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,s){if(e=MJ)&&this.addLineDeco(i,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new ti(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let s=new Fn(t-e);return this.oracle.doc.lineAt(e).to==t&&(s.flags|=4),s}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ti)return e;let t=new ti(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,s){let i=this.ensureLine();i.length+=s,i.collapsed+=s,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+s}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ti)&&!this.isCovered?this.nodes.push(new ti(0,-1,0)):(this.writtenToh.clientHeight||h.scrollWidth>h.clientWidth)&&u.overflow!="visible"){let d=h.getBoundingClientRect();r=Math.max(r,d.left),o=Math.min(o,d.right),a=Math.max(a,d.top),l=Math.min(c==n.parentNode?i.innerHeight:l,d.bottom)}c=u.position=="absolute"||u.position=="fixed"?h.offsetParent:h.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function LJ(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function DJ(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Uv{constructor(e,t,s,i){this.from=e,this.to=t,this.size=s,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let s=0;stypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new $J(s),this.stateDeco=rC(t),this.heightMap=vs.empty().applyChanges(this.stateDeco,lt.empty,this.heightOracle.setDoc(t.doc),[new bi(0,0,0,t.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Qe.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let s=0;s<=1;s++){let i=s?t.head:t.anchor;if(!e.some(({from:r,to:o})=>i>=r&&i<=o)){let{from:r,to:o}=this.lineBlockAt(i);e.push(new Vm(r,o))}}return this.viewports=e.sort((s,i)=>s.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?iC:new Zx(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Id(e,this.scaler))})}update(e,t=null){this.state=e.state;let s=this.stateDeco;this.stateDeco=rC(this.state);let i=e.changedRanges,r=bi.extendWithRanges(i,IJ(s,this.stateDeco,e?e.changes:pn.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);tC(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||$u)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let l=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet($O)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,s=window.getComputedStyle(t),i=this.heightOracle,r=s.whiteSpace;this.defaultTextDirection=s.direction=="rtl"?It.RTL:It.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",a=t.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,h=0;if(a.width&&a.height){let{scaleX:A,scaleY:T}=lO(t,a);(A>.005&&Math.abs(this.scaleX-A)>.005||T>.005&&Math.abs(this.scaleY-T)>.005)&&(this.scaleX=A,this.scaleY=T,c|=16,o=l=!0)}let u=(parseInt(s.paddingTop)||0)*this.scaleY,d=(parseInt(s.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let p=cO(this.view.contentDOM,!1).y;p!=this.scrollParent&&(this.scrollParent=p,this.scrollAnchorHeight=-1,this.scrollOffset=0);let m=this.getScrollOffset();this.scrollOffset!=m&&(this.scrollAnchorHeight=-1,this.scrollOffset=m),this.scrolledToBottom=fO(this.scrollParent||e.win);let y=(this.printing?DJ:NJ)(t,this.paddingTop),v=y.top-this.pixelViewport.top,g=y.bottom-this.pixelViewport.bottom;this.pixelViewport=y;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(l=!0)),!this.inView&&!this.scrollTarget&&!LJ(e.dom))return 0;let b=a.width;if((this.contentDOMWidth!=b||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let A=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(A)&&(o=!0),o||i.lineWrapping&&Math.abs(b-this.contentDOMWidth)>i.charWidth){let{lineHeight:T,charWidth:C,textHeight:I}=e.docView.measureTextSize();o=T>0&&i.refresh(r,T,C,I,Math.max(5,b/C),A),o&&(e.docView.minWidth=0,c|=16)}v>0&&g>0?h=Math.max(v,g):v<0&&g<0&&(h=Math.min(v,g)),tC();for(let T of this.viewports){let C=T.from==this.viewport.from?A:e.docView.measureVisibleLineHeights(T);this.heightMap=(o?vs.empty().applyChanges(this.stateDeco,lt.empty,this.heightOracle,[new bi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new TJ(T.from,C))}$u&&(c|=2)}let x=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return x&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),c|=this.updateForViewport()),(c&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let s=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new Vm(i.lineAt(o-s*1e3,Et.ByHeight,r,0,0).from,i.lineAt(a+(1-s)*1e3,Et.ByHeight,r,0,0).to);if(t){let{head:c}=t.range;if(cl.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=i.lineAt(c,Et.ByPos,r,0,0),d;t.y=="center"?d=(u.top+u.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&c=a+Math.max(10,Math.min(s,250)))&&i>o-2*1e3&&r>1,o=i<<1;if(this.defaultTextDirection!=It.LTR&&!s)return[];let a=[],l=(h,u,d,p)=>{if(u-hh&&gg.from>=d.from&&g.to<=d.to&&Math.abs(g.from-h)g.from<_&&g.to>_));if(!v){if(ub.from<=u&&b.to>=u)){let b=t.moveToLineBoundary(te.cursor(u),!1,!0).head;b>h&&(u=b)}let g=this.gapSize(d,h,u,p),_=s||g<2e6?g:2e6;v=new Uv(h,u,g,_)}a.push(v)},c=h=>{if(h.length2e6)for(let T of e)T.from>=h.from&&T.fromh.from&&l(h.from,p,h,u),mt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let s=[];st.spans(t,this.viewport.from,this.viewport.to,{span(r,o){s.push({from:r,to:o})},point(){}},20);let i=0;if(s.length!=this.visibleRanges.length)i=12;else for(let r=0;r=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Id(this.heightMap.lineAt(e,Et.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Id(this.heightMap.lineAt(this.scaler.fromDOM(e),Et.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Id(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Vm{constructor(e,t){this.from=e,this.to=t}}function FJ(n,e,t){let s=[],i=n,r=0;return st.spans(t,n,e,{span(){},point(o,a){o>i&&(s.push({from:i,to:o}),r+=o-i),i=a}},20),i=1)return e[e.length-1].to;let s=Math.floor(n*t);for(let i=0;;i++){let{from:r,to:o}=e[i],a=o-r;if(s<=a)return r+s;s-=a}}function Gm(n,e){let t=0;for(let{from:s,to:i}of n.ranges){if(e<=i){t+=e-s;break}t+=i-s}return t/n.total}function zJ(n,e){for(let t of n)if(e(t))return t}const iC={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function rC(n){let e=n.facet(K0).filter(s=>typeof s!="function"),t=n.facet(Wx).filter(s=>typeof s!="function");return t.length&&e.push(st.join(t)),e}class Zx{constructor(e,t,s){let i=0,r=0,o=0;this.viewports=s.map(({from:a,to:l})=>{let c=t.lineAt(a,Et.ByPos,e,0,0).top,h=t.lineAt(l,Et.ByPos,e,0,0).bottom;return i+=h-c,{from:a,to:l,top:c,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(t.height-i);for(let a of this.viewports)a.domTop=o+(a.top-r)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),r=a.bottom}toDOM(e){for(let t=0,s=0,i=0;;t++){let r=tt.from==e.viewports[s].from&&t.to==e.viewports[s].to):!1}}function Id(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),s=e.toDOM(n.bottom);return new Ki(n.from,n.length,t,s-t,Array.isArray(n._content)?n._content.map(i=>Id(i,e)):n._content)}const Km=be.define({combine:n=>n.join(" ")}),j_=be.define({combine:n=>n.indexOf(!0)>-1}),F_=ku.newName(),YO=ku.newName(),JO=ku.newName(),QO={"&light":"."+YO,"&dark":"."+JO};function z_(n,e,t){return new ku(e,{finish(s){return/&/.test(s)?s.replace(/&\w*/,i=>{if(i=="&")return n;if(!t||!t[i])throw new RangeError(`Unsupported selector: ${i}`);return t[i]}):n+" "+s}})}const HJ=z_("."+F_,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},QO),BJ={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},qv=de.ie&&de.ie_version<=11;class UJ{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new v7,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let s of t)this.queue.push(s);(de.ie&&de.ie_version<=11||de.ios&&e.composing)&&t.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&de.android&&e.constructor.EDIT_CONTEXT!==!1&&!(de.chrome&&de.chrome_version<126)&&(this.editContext=new VJ(e),e.state.facet(bo)&&(e.contentDOM.editContext=this.editContext.editContext)),qv&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,s)=>t!=e[s]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:s}=this,i=this.selectionRange;if(s.state.facet(bo)?s.root.activeElement!=this.dom:!Yd(this.dom,i))return;let r=i.anchorNode&&s.docView.tile.nearest(i.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(de.ie&&de.ie_version<=11||de.android&&de.chrome)&&!s.state.selection.main.empty&&i.focusNode&&Jd(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=mf(e.root);if(!t)return!1;let s=de.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&qJ(this.view,t)||t;if(!s||this.selectionRange.eq(s))return!1;let i=Yd(this.dom,s);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&gh(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,s=-1,i=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(i=!0),t==-1?{from:t,to:s}=o:(t=Math.min(o.from,t),s=Math.max(o.to,s)))}return{from:t,to:s,typeOver:i}}readChange(){let{from:e,to:t,typeOver:s}=this.processRecords(),i=this.selectionChanged&&Yd(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new aJ(this.view,e,t,s);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let s=this.view.state,i=zO(this.view,t);return this.view.state==s&&(t.domChanged||t.newSel&&!My(this.view.state.selection,t.newSel.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let s=oC(t,e.previousSibling||e.target.previousSibling,-1),i=oC(t,e.nextSibling||e.target.nextSibling,1);return{from:s?t.posAfter(s):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(bo)!=e.state.facet(bo)&&(e.view.contentDOM.editContext=e.state.facet(bo)?this.editContext.editContext:null))}destroy(){var e,t,s;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(s=this.resizeScroll)===null||s===void 0||s.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function oC(n,e,t){for(;e;){let s=Gt.get(e);if(s&&s.parent==n)return s;let i=e.parentNode;e=i!=n.dom?i:t>0?e.nextSibling:e.previousSibling}return null}function aC(n,e){let t=e.startContainer,s=e.startOffset,i=e.endContainer,r=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return Jd(o.node,o.offset,i,r)&&([t,s,i,r]=[i,r,t,s]),{anchorNode:t,anchorOffset:s,focusNode:i,focusOffset:r}}function qJ(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return aC(n,i)}let t=null;function s(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",s,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",s,!0),t?aC(n,t):null}class VJ{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=s=>{let i=e.state.selection.main,{anchor:r,head:o}=i,a=this.toEditorPos(s.updateRangeStart),l=this.toEditorPos(s.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:s.updateRangeStart,editorBase:a,drifted:!1});let c=l-a>s.text.length;a==this.from&&rthis.to&&(l=r);let h=HO(e.state.sliceDoc(a,l),s.text,(c?i.from:i.to)-a,c?"end":null);if(!h){let d=te.single(this.toEditorPos(s.selectionStart),this.toEditorPos(s.selectionEnd));My(d,i)||e.dispatch({selection:d,userEvent:"select"});return}let u={from:h.from+a,to:h.toA+a,insert:lt.of(s.text.slice(h.from,h.toB).split(` -`))};if((de.mac||de.android)&&u.from==o-1&&/^\. ?$/.test(s.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:a,to:l,insert:lt.of([s.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let d=this.to-this.from+(u.to-u.from+u.insert.length);Gx(e,u,te.single(this.toEditorPos(s.selectionStart,d),this.toEditorPos(s.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,s.updateRangeStart-1),Math.min(t.text.length,s.updateRangeStart+1)))&&this.handlers.compositionend(s)},this.handlers.characterboundsupdate=s=>{let i=[],r=null;for(let o=this.toEditorPos(s.rangeStart),a=this.toEditorPos(s.rangeEnd);o{let i=[];for(let r of s.getTextFormats()){let o=r.underlineStyle,a=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(a)){let l=this.toEditorPos(r.rangeStart),c=this.toEditorPos(r.rangeEnd);if(l{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:s}=this.composing;this.composing=null,s&&this.reset(e.state)}};for(let s in this.handlers)t.addEventListener(s,this.handlers[s]);this.measureReq={read:s=>{let i=mf(s.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,s=!1,i=this.pendingContextChange;return e.changes.iterChanges((r,o,a,l,c)=>{if(s)return;let h=c.length-(o-r);if(i&&o>=i.to)if(i.from==r&&i.to==o&&i.insert.eq(c)){i=this.pendingContextChange=null,t+=h,this.to+=h;return}else i=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=h,this.to+=h;else if(rthis.to||this.to-this.from+c.length>3e4){s=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),c.toString()),this.to+=h}t+=h}),i&&!s&&this.revertPending(e.state),!s}update(e){let t=this.pendingContextChange,s=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(s.from,s.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,s=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);(this.editContext.selectionStart!=s||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(s,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let s=this.composing;return s&&s.drifted?s.editorBase+(e-s.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class xe{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:s}=e;this.dispatchTransactions=e.dispatchTransactions||s&&(i=>i.forEach(r=>s(r,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||b7(e.parent)||document,this.viewState=new sC(this,e.state||at.create(e)),e.scrollTo&&e.scrollTo.is(Bm)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(sh).map(i=>new jv(i));for(let i of this.plugins)i.update(this);this.observer=new UJ(this),this.inputState=new uJ(this),this.inputState.ensureHandlers(this.plugins),this.docView=new qE(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof yn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,s=!1,i,r=this.state;for(let d of e){if(d.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=d.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,a=0,l=null;e.some(d=>d.annotation(GO))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=KO(r,o),l||(a=1));let c=this.observer.delayedAndroidKey,h=null;if(c?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet(at.phrases)!=this.state.facet(at.phrases))return this.setState(r);i=Ty.create(this,r,e),i.flags|=a;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(u&&(u=u.map(d.changes)),d.scrollIntoView){let{main:p}=d.state.selection,{x:m,y}=this.state.facet(xe.cursorScrollMargin);u=new yh(p.empty?p:te.cursor(p.head,p.head>p.anchor?-1:1),"nearest","nearest",y,m)}for(let p of d.effects)p.is(Bm)&&(u=p.value.clip(this.state))}this.viewState.update(i,u),this.bidiCache=Oy.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),t=this.docView.update(i),this.state.facet(Md)!=this.styleModules&&this.mountStyles(),s=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Km)!=i.state.facet(Km)&&(this.viewState.mustMeasureContent=!0),(t||s||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(I_))try{d(i)}catch(p){Mr(this.state,p,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!zO(this,h)&&c.force&&gh(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let s of this.plugins)s.destroy(this);this.viewState=new sC(this,e),this.plugins=e.facet(sh).map(s=>new jv(s)),this.pluginMap.clear();for(let s of this.plugins)s.update(this);this.docView.destroy(),this.docView=new qE(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(sh),s=e.state.facet(sh);if(t!=s){let i=[];for(let r of s){let o=t.indexOf(r);if(o<0)i.push(new jv(r));else{let a=this.plugins[o];a.mustUpdate=e,i.push(a)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,s=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(fO(s||this.win))r=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(i);r=p.from,o=p.top}this.updateState=1;let l=this.viewState.measure();if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let h=c.map(p=>{try{return p.read(this)}catch(m){return Mr(this.state,m),lC}}),u=Ty.create(this,this.state,[]),d=!1;u.flags|=l,t?t.flags|=l:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let p=0;p1||m<-1)&&!(de.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(s==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+m,s?r<0?s.scrollTop=s.scrollHeight:s.scrollTop+=m:this.win.scrollBy(0,m),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(I_))a(t)}get themeClasses(){return F_+" "+(this.state.facet(j_)?JO:YO)+" "+this.state.facet(Km)}updateAttrs(){let e=cC(this,RO,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(bo)?"true":"false",class:"cm-content",style:`${de.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),cC(this,Vx,t);let s=this.observer.ignore(()=>{let i=jE(this.contentDOM,this.contentAttrs,t),r=jE(this.dom,this.editorAttrs,e);return i||r});return this.editorAttrs=e,this.contentAttrs=t,s}showAnnouncements(e){let t=!0;for(let s of e)for(let i of s.effects)if(i.is(xe.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Md);let e=this.state.facet(xe.cspNonce);ku.mount(this.root,this.styleModules.concat(HJ).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ts.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,s){return Bv(this,e,VE(this,e,t,s))}moveByGroup(e,t){return Bv(this,e,VE(this,e,t,s=>tJ(this,e.head,s)))}visualLineSide(e,t){let s=this.bidiSpans(e),i=this.textDirectionAt(e.from),r=s[t?s.length-1:0];return te.cursor(r.side(t,i)+e.from,r.forward(!t,i)?1:-1)}moveToLineBoundary(e,t,s=!0){return eJ(this,e,t,s)}moveVertically(e,t,s){return Bv(this,e,nJ(this,e,t,s))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let s=L_(this,e,t);return s&&s.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),L_(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let s=this.state.doc.lineAt(e),i=this.bidiSpans(s),r=i[Rr.find(i,e-s.from,-1,t)];return this.docView.coordsAt(e,t,r.dir==It.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(CO)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>WJ)return bO(e.length);let t=this.textDirectionAt(e.from),s;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||vO(r.isolates,s=HE(this,e))))return r.order;s||(s=HE(this,e));let i=C7(e.text,t,s);return this.bidiCache.push(new Oy(e.from,e.to,t,s,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||de.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{dO(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var s,i,r,o;return Bm.of(new yh(typeof e=="number"?te.cursor(e):e,(s=t.y)!==null&&s!==void 0?s:"nearest",(i=t.x)!==null&&i!==void 0?i:"nearest",(r=t.yMargin)!==null&&r!==void 0?r:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,s=this.viewState.scrollAnchorAt(e);return Bm.of(new yh(te.cursor(s.from),"start","start",s.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return ri.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ri.define(()=>({}),{eventObservers:e})}static theme(e,t){let s=ku.newName(),i=[Km.of(s),Md.of(z_(`.${s}`,e))];return t&&t.dark&&i.push(j_.of(!0)),i}static baseTheme(e){return q0.lowest(Md.of(z_("."+F_,e,QO)))}static findFromDOM(e){var t;let s=e.querySelector(".cm-content"),i=s&&Gt.get(s)||Gt.get(e);return((t=i==null?void 0:i.root)===null||t===void 0?void 0:t.view)||null}}xe.styleModule=Md;xe.inputHandler=kO;xe.clipboardInputFilter=Ux;xe.clipboardOutputFilter=qx;xe.scrollHandler=TO;xe.focusChangeEffect=EO;xe.perLineTextDirection=CO;xe.exceptionSink=AO;xe.updateListener=I_;xe.editable=bo;xe.mouseSelectionStyle=xO;xe.dragMovesSelection=SO;xe.clickAddsSelectionRange=_O;xe.decorations=K0;xe.blockWrappers=MO;xe.outerDecorations=Wx;xe.atomicRanges=am;xe.bidiIsolatedRanges=IO;xe.cursorScrollMargin=be.define({combine:n=>{let e=5,t=5;for(let s of n)typeof s=="number"?e=t=s:{x:e,y:t}=s;return{x:e,y:t}}});xe.scrollMargins=OO;xe.darkTheme=j_;xe.cspNonce=be.define({combine:n=>n.length?n[0]:""});xe.contentAttributes=Vx;xe.editorAttributes=RO;xe.lineWrapping=xe.contentAttributes.of({class:"cm-lineWrapping"});xe.announce=St.define();const WJ=4096,lC={};class Oy{constructor(e,t,s,i,r,o){this.from=e,this.to=t,this.dir=s,this.isolates=i,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let s=[],i=e.length?e[e.length-1].dir:It.LTR;for(let r=Math.max(0,e.length-10);r=0;i--){let r=s[i],o=typeof r=="function"?r(n):r;o&&zx(o,t)}return t}const GJ=de.mac?"mac":de.windows?"win":de.linux?"linux":"key";function KJ(n,e){const t=n.split(/-(?!$)/);let s=t[t.length-1];s=="Space"&&(s=" ");let i,r,o,a;for(let l=0;ls.concat(i),[]))),t}function XJ(n,e,t){return nN(tN(n.state),e,n,t)}let Vo=null;const YJ=4e3;function JJ(n,e=GJ){let t=Object.create(null),s=Object.create(null),i=(o,a)=>{let l=s[o];if(l==null)s[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,a,l,c,h)=>{var u,d;let p=t[o]||(t[o]=Object.create(null)),m=a.split(/ (?!$)/).map(g=>KJ(g,e));for(let g=1;g{let x=Vo={view:b,prefix:_,scope:o};return setTimeout(()=>{Vo==x&&(Vo=null)},YJ),!0}]})}let y=m.join(" ");i(y,!1);let v=p[y]||(p[y]={preventDefault:!1,stopPropagation:!1,run:((d=(u=p._any)===null||u===void 0?void 0:u.run)===null||d===void 0?void 0:d.slice())||[]});l&&v.run.push(l),c&&(v.preventDefault=!0),h&&(v.stopPropagation=!0)};for(let o of n){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of a){let h=t[c]||(t[c]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=o;for(let d in h)h[d].run.push(p=>u(p,H_))}let l=o[e]||o.key;if(l)for(let c of a)r(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return t}let H_=null;function nN(n,e,t,s){H_=e;let i=d7(e),r=qI(i,0),o=VI(r)==i.length&&i!=" ",a="",l=!1,c=!1,h=!1;Vo&&Vo.view==t&&Vo.scope==s&&(a=Vo.prefix+" ",UO.indexOf(e.keyCode)<0&&(c=!0,Vo=null));let u=new Set,d=v=>{if(v){for(let g of v.run)if(!u.has(g)&&(u.add(g),g(t)))return v.stopPropagation&&(h=!0),!0;v.preventDefault&&(v.stopPropagation&&(h=!0),c=!0)}return!1},p=n[s],m,y;return p&&(d(p[a+Zm(i,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(de.windows&&e.ctrlKey&&e.altKey)&&!(de.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(m=Ma[e.keyCode])&&m!=i?(d(p[a+Zm(m,e,!0)])||e.shiftKey&&(y=ff[e.keyCode])!=i&&y!=m&&d(p[a+Zm(y,e,!1)]))&&(l=!0):o&&e.shiftKey&&d(p[a+Zm(i,e,!0)])&&(l=!0),!l&&d(p._any)&&(l=!0)),c&&(l=!0),l&&h&&e.stopPropagation(),H_=null,l}class ac{constructor(e,t,s,i,r){this.className=e,this.left=t,this.top=s,this.width=i,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,s){if(s.empty){let i=e.coordsAtPos(s.head,s.assoc||1);if(!i)return[];let r=sN(e);return[new ac(t,i.left-r.left,i.top-r.top,null,i.bottom-i.top)]}else return QJ(e,t,s)}}function sN(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==It.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function uC(n,e,t,s){let i=n.coordsAtPos(e,t*2);if(!i)return s;let r=n.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,a=n.posAtCoords({x:r.left+1,y:o}),l=n.posAtCoords({x:r.right-1,y:o});return a==null||l==null?s:{from:Math.max(s.from,Math.min(a,l)),to:Math.min(s.to,Math.max(a,l))}}function QJ(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let s=Math.max(t.from,n.viewport.from),i=Math.min(t.to,n.viewport.to),r=n.textDirection==It.LTR,o=n.contentDOM,a=o.getBoundingClientRect(),l=sN(n),c=o.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),d=a.right-(h?parseInt(h.paddingRight):0),p=N_(n,s,1),m=N_(n,i,-1),y=p.type==Vn.Text?p:null,v=m.type==Vn.Text?m:null;if(y&&(n.lineWrapping||p.widgetLineBreaks)&&(y=uC(n,s,1,y)),v&&(n.lineWrapping||m.widgetLineBreaks)&&(v=uC(n,i,-1,v)),y&&v&&y.from==v.from&&y.to==v.to)return _(b(t.from,t.to,y));{let A=y?b(t.from,null,y):x(p,!1),T=v?b(null,t.to,v):x(m,!0),C=[];return(y||p).to<(v||m).from-(y&&v?1:0)||p.widgetLineBreaks>1&&A.bottom+n.defaultLineHeight/2U&&L.from=se)break;z>X&&j(Math.max(ge,X),A==null&&ge<=U,Math.min(z,se),T==null&&z>=B,Y.dir)}if(X=J.to+1,X>=se)break}return H.length==0&&j(U,A==null,B,T==null,n.textDirection),{top:I,bottom:D,horizontal:H}}function x(A,T){let C=a.top+(T?A.top:A.bottom);return{top:C,bottom:C,horizontal:[]}}}function eQ(n,e){return n.constructor==e.constructor&&n.eq(e)}class tQ{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(Xg)!=e.state.facet(Xg)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,s=e.facet(Xg);for(;t!eQ(t,this.drawn[s]))){let t=this.dom.firstChild,s=0;for(let i of e)i.update&&t&&i.constructor&&this.drawn[s].constructor&&i.update(t,this.drawn[s])?(t=t.nextSibling,s++):this.dom.insertBefore(i.draw(),t);for(;t;){let i=t.nextSibling;t.remove(),t=i}this.drawn=e,de.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Xg=be.define();function iN(n){return[ri.define(e=>new tQ(e,n)),Xg.of(n)]}const Tu=be.define({combine(n){return Hu(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function nQ(n={}){return[Tu.of(n),sQ,iQ,oQ,$O.of(!0)]}function rN(n){return n.startState.facet(Tu)!=n.state.facet(Tu)}const sQ=iN({above:!0,markers(n){let{state:e}=n,t=e.facet(Tu),s=[];for(let i of e.selection.ranges){let r=i==e.selection.main;if(i.empty||t.drawRangeCursor&&!(r&&de.ios&&t.iosSelectionHandles)){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=i.empty?i:te.cursor(i.head,i.assoc);for(let l of ac.forRange(n,o,a))s.push(l)}}return s},update(n,e){n.transactions.some(s=>s.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=rN(n);return t&&dC(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){dC(e.state,n)},class:"cm-cursorLayer"});function dC(n,e){e.style.animationDuration=n.facet(Tu).cursorBlinkRate+"ms"}const iQ=iN({above:!1,markers(n){let e=[],{main:t,ranges:s}=n.state.selection;for(let i of s)if(!i.empty)for(let r of ac.forRange(n,"cm-selectionBackground",i))e.push(r);if(de.ios&&!t.empty&&n.state.facet(Tu).iosSelectionHandles){for(let i of ac.forRange(n,"cm-selectionHandle cm-selectionHandle-start",te.cursor(t.from,1)))e.push(i);for(let i of ac.forRange(n,"cm-selectionHandle cm-selectionHandle-end",te.cursor(t.to,1)))e.push(i)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||rN(n)},class:"cm-selectionLayer"}),rQ=de.gecko&&de.gecko_version==153?"#ffffff01":"transparent",oQ=q0.highest(xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${rQ} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function aQ(){return cQ}const lQ=Qe.line({class:"cm-activeLine"}),cQ=ri.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let s of n.state.selection.ranges){let i=n.lineBlockAt(s.head);i.from>e&&(t.push(lQ.range(i.from)),e=i.from)}return Qe.set(t)}},{decorations:n=>n.decorations}),fC=be.define({combine(n){let e,t;for(let s of n)e=e||s.topContainer,t=t||s.bottomContainer;return{topContainer:e,bottomContainer:t}}});function oN(n,e){let t=n.plugin(aN),s=t?t.specs.indexOf(e):-1;return s>-1?t.panels[s]:null}const aN=ri.fromClass(class{constructor(n){this.input=n.state.facet(Ny),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(fC);this.top=new Xm(n,!0,e.topContainer),this.bottom=new Xm(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(fC);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Xm(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Xm(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Ny);if(t!=this.input){let s=t.filter(l=>l),i=[],r=[],o=[],a=[];for(let l of s){let c=this.specs.indexOf(l),h;c<0?(h=l(n.view),a.push(h)):(h=this.panels[c],h.update&&h.update(n)),i.push(h),(h.top?r:o).push(h)}this.specs=s,this.panels=i,this.top.sync(r),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let s of this.panels)s.update&&s.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>xe.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Xm{constructor(e,t,s){this.view=e,this.top=t,this.container=s,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=pC(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=pC(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function pC(n){let e=n.nextSibling;return n.remove(),e}const Ny=be.define({enables:aN});function hQ(n,e){let t,s=new Promise(o=>t=o),i=o=>uQ(o,e,t);n.state.field(Vv,!1)?n.dispatch({effects:lN.of(i)}):n.dispatch({effects:St.appendConfig.of(Vv.init(()=>[i]))});let r=cN.of(i);return{close:r,result:s.then(o=>((n.win.queueMicrotask||(l=>n.win.setTimeout(l,10)))(()=>{n.state.field(Vv).indexOf(i)>-1&&n.dispatch({effects:r})}),o))}}const Vv=Fr.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(lN)?n=[t.value].concat(n):t.is(cN)&&(n=n.filter(s=>s!=t.value));return n},provide:n=>Ny.computeN([n],e=>e.field(n))}),lN=St.define(),cN=St.define();function uQ(n,e,t){let s=e.content?e.content(n,()=>o(null)):null;if(!s){if(s=Cn("form"),e.input){let a=Cn("input",e.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),s.appendChild(Cn("label",(e.label||"")+": ",a))}else s.appendChild(document.createTextNode(e.label||""));s.appendChild(document.createTextNode(" ")),s.appendChild(Cn("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let i=s.nodeName=="FORM"?[s]:s.querySelectorAll("form");for(let a=0;a{c.keyCode==27?(c.preventDefault(),o(null)):c.keyCode==13&&(c.preventDefault(),o(l))}),l.addEventListener("submit",c=>{c.preventDefault(),o(l)})}let r=Cn("div",s,Cn("button",{onclick:()=>o(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");function o(a){r.contains(r.ownerDocument.activeElement)&&n.focus(),t(a)}return{dom:r,top:e.top,mount:()=>{if(e.focus){let a;typeof e.focus=="string"?a=s.querySelector(e.focus):a=s.querySelector("input")||s.querySelector("button"),a&&"select"in a?a.select():a&&"focus"in a&&a.focus()}}}}class xc extends bc{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}xc.prototype.elementClass="";xc.prototype.toDOM=void 0;xc.prototype.mapMode=si.TrackBefore;xc.prototype.startSide=xc.prototype.endSide=-1;xc.prototype.point=!0;const Wv=be.define(),dQ=be.define(),Yg=be.define(),mC=be.define({combine:n=>n.some(e=>e)});function fQ(n){return[pQ]}const pQ=ri.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(Yg).map(e=>new yC(n,e)),this.fixed=!n.state.facet(mC);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,s=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(s<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(mC)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=st.iter(this.view.state.facet(Wv),this.view.viewport.from),s=[],i=this.gutters.map(r=>new mQ(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(r.type)){let o=!0;for(let a of r.type)if(a.type==Vn.Text&&o){B_(t,s,a.from);for(let l of i)l.line(this.view,a,s);o=!1}else if(a.widget)for(let l of i)l.widget(this.view,a)}else if(r.type==Vn.Text){B_(t,s,r.from);for(let o of i)o.line(this.view,r,s)}else if(r.widget)for(let o of i)o.widget(this.view,r);for(let r of i)r.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(Yg),t=n.state.facet(Yg),s=n.docChanged||n.heightChanged||n.viewportChanged||!st.eq(n.startState.facet(Wv),n.state.facet(Wv),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let i of this.gutters)i.update(n)&&(s=!0);else{s=!0;let i=[];for(let r of t){let o=e.indexOf(r);o<0?i.push(new yC(this.view,r)):(this.gutters[o].update(n),i.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),i.indexOf(r)<0&&r.destroy();for(let r of i)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=i}return s}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>xe.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let s=t.dom.offsetWidth*e.scaleX,i=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==It.LTR?{left:s,right:i}:{right:s,left:i}})});function gC(n){return Array.isArray(n)?n:[n]}function B_(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class mQ{constructor(e,t,s){this.gutter=e,this.height=s,this.i=0,this.cursor=st.iter(e.markers,t.from)}addElement(e,t,s){let{gutter:i}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==i.elements.length){let a=new hN(e,o,r,s);i.elements.push(a),i.dom.appendChild(a.dom)}else i.elements[this.i].update(e,o,r,s);this.height=t.bottom,this.i++}line(e,t,s){let i=[];B_(this.cursor,i,t.from),s.length&&(i=i.concat(s));let r=this.gutter.config.lineMarker(e,t,i);r&&i.unshift(r);let o=this.gutter;i.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,i)}widget(e,t){let s=this.gutter.config.widgetMarker(e,t.widget,t),i=s?[s]:null;for(let r of e.state.facet(dQ)){let o=r(e,t.widget,t);o&&(i||(i=[])).push(o)}i&&this.addElement(e,t,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class yC{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let s in t.domEventHandlers)this.dom.addEventListener(s,i=>{let r=i.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let l=r.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=i.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[s](e,a,i)&&i.preventDefault()});this.markers=gC(t.markers(e)),t.initialSpacer&&(this.spacer=new hN(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=gC(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],e);i!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[i])}let s=e.view.viewport;return!st.eq(this.markers,t,s.from,s.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class hN{constructor(e,t,s,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,s,i)}update(e,t,s,i){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=s&&(this.dom.style.marginTop=(this.above=s)?s+"px":""),gQ(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,t){let s="cm-gutterElement",i=this.dom.firstChild;for(let r=0,o=0;;){let a=o,l=rr(a,l,c)||o(a,l,c):o}return s}})}});class Gv extends xc{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Kv(n,e){return n.state.facet(ih).formatNumber(e,n.state)}const bQ=Yg.compute([ih],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(yQ)},lineMarker(e,t,s){return s.some(i=>i.toDOM)?null:new Gv(Kv(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,s)=>{for(let i of e.state.facet(vQ)){let r=i(e,t,s);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(ih)!=e.state.facet(ih),initialSpacer(e){return new Gv(Kv(e,vC(e.state.doc.lines)))},updateSpacer(e,t){let s=Kv(t.view,vC(t.view.state.doc.lines));return s==e.number?e:new Gv(s)},domEventHandlers:n.facet(ih).domEventHandlers,side:"before"}));function wQ(n={}){return[ih.of(n),fQ(),bQ]}function vC(n){let e=9;for(;e{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Hs.match(e)),t=>{let s=e(t);return s===void 0?null:[this,s]}}}nt.closedBy=new nt({deserialize:n=>n.split(" ")});nt.openedBy=new nt({deserialize:n=>n.split(" ")});nt.group=new nt({deserialize:n=>n.split(" ")});nt.isolate=new nt({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});nt.contextHash=new nt({perNode:!0});nt.lookAhead=new nt({perNode:!0});nt.mounted=new nt({perNode:!0});class ef{constructor(e,t,s,i=!1){this.tree=e,this.overlay=t,this.parser=s,this.bracketed=i}static get(e){return e&&e.props&&e.props[nt.mounted.id]}}const xQ=Object.create(null);class Hs{constructor(e,t,s,i=0){this.name=e,this.props=t,this.id=s,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):xQ,s=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Hs(e.name||"",t,e.id,s);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(i)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(nt.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let s in e)for(let i of s.split(" "))t[i]=e[s];return s=>{for(let i=s.prop(nt.group),r=-1;r<(i?i.length:0);r++){let o=t[r<0?s.name:i[r]];if(o)return o}}}}Hs.none=new Hs("",Object.create(null),0,8);class Xx{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(o|Qt.IncludeAnonymous);;){let c=!1;if(l.from<=r&&l.to>=i&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&s&&(a||!l.type.isAnonymous)&&s(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Qx(Hs.none,this.children,this.positions,0,this.children.length,0,this.length,(t,s,i)=>new Ot(this.type,t,s,i,this.propValues),e.makeTree||((t,s,i)=>new Ot(Hs.none,t,s,i)))}static build(e){return CQ(e)}}Ot.empty=new Ot(Hs.none,[],[],0);class Yx{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Yx(this.buffer,this.index)}}class Oa{constructor(e,t,s){this.buffer=e,this.length=t,this.set=s}get type(){return Hs.none}toString(){let e=[];for(let t=0;t0));l=o[l+3]);return a}slice(e,t,s){let i=this.buffer,r=new Uint16Array(t-e),o=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&s>e;case 2:return s>e;case 4:return!0}}function yf(n,e,t,s){for(var i;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?a.length:-1;e!=c;e+=t){let h=a[e],u=l[e]+o.from,d;if(!(!(r&Qt.EnterBracketed&&h instanceof Ot&&(d=ef.get(h))&&!d.overlay&&d.bracketed&&s>=u&&s<=u+h.length)&&!uN(i,s,u,u+h.length))){if(h instanceof Oa){if(r&Qt.ExcludeBuffers)continue;let p=h.findChild(0,h.buffer.length,t,s-u,i);if(p>-1)return new Aa(new AQ(o,h,e,u),null,p)}else if(r&Qt.IncludeAnonymous||!h.type.isAnonymous||Jx(h)){let p;if(!(r&Qt.IgnoreMounts)&&(p=ef.get(h))&&!p.overlay)return new _i(p.tree,u,e,o);let m=new _i(h,u,e,o);return r&Qt.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(t<0?h.children.length-1:0,t,s,i,r)}}}if(r&Qt.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,s=0){let i;if(!(s&Qt.IgnoreOverlays)&&(i=ef.get(this._tree))&&i.overlay){let r=e-this.from,o=s&Qt.EnterBracketed&&i.bracketed;for(let{from:a,to:l}of i.overlay)if((t>0||o?a<=r:a=r:l>r))return new _i(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,s)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function wC(n,e,t,s){let i=n.cursor(),r=[];if(!i.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=i.type.is(t),!i.nextSibling())return r}for(;;){if(s!=null&&i.type.is(s))return r;if(i.type.is(e)&&r.push(i.node),!i.nextSibling())return s==null?r:[]}}function U_(n,e,t=e.length-1){for(let s=n;t>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(e[t]&&e[t]!=s.name)return!1;t--}}return!0}class AQ{constructor(e,t,s,i){this.parent=e,this.buffer=t,this.index=s,this.start=i}}class Aa extends dN{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,s){super(),this.context=e,this._parent=t,this.index=s,this.type=e.buffer.set.types[e.buffer.buffer[s]]}child(e,t,s){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,s);return r<0?null:new Aa(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,s=0){if(s&Qt.ExcludeBuffers)return null;let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new Aa(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Aa(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Aa(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:s}=this.context,i=this.index+4,r=s.buffer[this.index+3];if(r>i){let o=s.buffer[this.index+1];e.push(s.slice(i,r,o)),t.push(0)}return new Ot(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function fN(n){if(!n.length)return null;let e=0,t=n[0];for(let r=1;rt.from||o.to=e){let a=new _i(o.tree,o.overlay[0].from+r.from,-1,r);(i||(i=[s])).push(yf(a,e,t,!1))}}return i?fN(i):s}class q_{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Qt.EnterBracketed,e instanceof _i)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let s=e._parent;s;s=s._parent)this.stack.unshift(s.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:s,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=s+i.buffer[e+1],this.to=s+i.buffer[e+2],!0}yield(e){return e?e instanceof _i?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,s){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,s,this.mode));let{buffer:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,s);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,s=this.mode){return this.buffer?s&Qt.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,s))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Qt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Qt.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,s=this.stack.length-1;if(e<0){let i=s<0?0:this.stack[s]+4;if(this.index!=i)return this.yieldBuf(t.findChild(i,this.index,-1,0,4))}else{let i=t.buffer[this.index+3];if(i<(s<0?t.buffer.length:t.buffer[this.stack[s]+3]))return this.yieldBuf(i)}return s<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,s,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let r=t+e,o=e<0?-1:s._tree.children.length;r!=o;r+=e){let a=s._tree.children[r];if(this.mode&Qt.IncludeAnonymous||a instanceof Oa||!a.type.isAnonymous||Jx(a))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;t=o,s=r+1;break e}i=this.stack[--r]}for(let i=s;i=0;r--){if(r<0)return U_(this._tree,e,i);let o=s[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function Jx(n){return n.children.some(e=>e instanceof Oa||!e.type.isAnonymous||Jx(e))}function CQ(n){var e;let{buffer:t,nodeSet:s,maxBufferLength:i=_Q,reused:r=[],minRepeatType:o=s.types.length}=n,a=Array.isArray(t)?new Yx(t,t.length):t,l=s.types,c=0,h=0;function u(A,T,C,I,D,H){let{id:j,start:U,end:B,size:L}=a,X=h,se=c;if(L<0)if(a.next(),L==-1){let E=r[j];C.push(E),I.push(U-A);return}else if(L==-3){c=j;return}else if(L==-4){h=j;return}else throw new RangeError(`Unrecognized record size: ${L}`);let J=l[j],Y,ge,z=U-A;if(B-U<=i&&(ge=v(a.pos-T,D))){let E=new Uint16Array(ge.size-ge.skip),O=a.pos-ge.size,R=E.length;for(;a.pos>O;)R=g(ge.start,E,R);Y=new Oa(E,B-ge.start,s),z=ge.start-A}else{let E=a.pos-L;a.next();let O=[],R=[],w=j>=o?j:-1,k=0,N=B;for(;a.pos>E;)w>=0&&a.id==w&&a.size>=0?(a.end<=N-i&&(m(O,R,U,k,a.end,N,w,X,se),k=O.length,N=a.end),a.next()):H>2500?d(U,E,O,R):u(U,E,O,R,w,H+1);if(w>=0&&k>0&&k-1&&k>0){let G=p(J,se);Y=Qx(J,O,R,0,O.length,0,B-U,G,G)}else Y=y(J,O,R,B-U,X-B,se)}C.push(Y),I.push(z)}function d(A,T,C,I){let D=[],H=0,j=-1;for(;a.pos>T;){let{id:U,start:B,end:L,size:X}=a;if(X>4)a.next();else{if(j>-1&&B=0;L-=3)U[X++]=D[L],U[X++]=D[L+1]-B,U[X++]=D[L+2]-B,U[X++]=X;C.push(new Oa(U,D[2]-B,s)),I.push(B-A)}}function p(A,T){return(C,I,D)=>{let H=0,j=C.length-1,U,B;if(j>=0&&(U=C[j])instanceof Ot){if(!j&&U.type==A&&U.length==D)return U;(B=U.prop(nt.lookAhead))&&(H=I[j]+U.length+B)}return y(A,C,I,D,H,T)}}function m(A,T,C,I,D,H,j,U,B){let L=[],X=[];for(;A.length>I;)L.push(A.pop()),X.push(T.pop()+C-D);A.push(y(s.types[j],L,X,H-D,U-H,B)),T.push(D-C)}function y(A,T,C,I,D,H,j){if(H){let U=[nt.contextHash,H];j=j?[U].concat(j):[U]}if(D>25){let U=[nt.lookAhead,D];j=j?[U].concat(j):[U]}return new Ot(A,T,C,I,j)}function v(A,T){let C=a.fork(),I=0,D=0,H=0,j=C.end-i,U={size:0,start:0,skip:0};e:for(let B=C.pos-A;C.pos>B;){let L=C.size;if(C.id==T&&L>=0){U.size=I,U.start=D,U.skip=H,H+=4,I+=4,C.next();continue}let X=C.pos-L;if(L<0||X=o?4:0,J=C.start;for(C.next();C.pos>X;){if(C.size<0)if(C.size==-3||C.size==-4)se+=4;else break e;else C.id>=o&&(se+=4);C.next()}D=J,I+=L,H+=se}return(T<0||I==A)&&(U.size=I,U.start=D,U.skip=H),U.size>4?U:void 0}function g(A,T,C){let{id:I,start:D,end:H,size:j}=a;if(a.next(),j>=0&&I4){let B=a.pos-(j-4);for(;a.pos>B;)C=g(A,T,C)}T[--C]=U,T[--C]=H-A,T[--C]=D-A,T[--C]=I}else j==-3?c=I:j==-4&&(h=I);return C}let _=[],b=[];for(;a.pos>0;)u(n.start||0,n.bufferStart||0,_,b,-1,0);let x=(e=n.length)!==null&&e!==void 0?e:_.length?b[0]+_[0].length:0;return new Ot(l[n.topID],_.reverse(),b.reverse(),x)}const _C=new WeakMap;function Jg(n,e){if(!n.isAnonymous||e instanceof Oa||e.type!=n)return 1;let t=_C.get(e);if(t==null){t=1;for(let s of e.children){if(s.type!=n||!(s instanceof Ot)){t=1;break}t+=Jg(n,s)}_C.set(e,t)}return t}function Qx(n,e,t,s,i,r,o,a,l){let c=0;for(let m=s;m=h)break;T+=C}if(b==x+1){if(T>h){let C=m[x];p(C.children,C.positions,0,C.children.length,y[x]+_);continue}u.push(m[x])}else{let C=y[b-1]+m[b-1].length-A;u.push(Qx(n,m,y,x,b,A,C,null,l))}d.push(A+_-r)}}return p(e,t,s,i,0),(a||l)(u,d,o)}class lc{constructor(e,t,s,i,r=!1,o=!1){this.from=e,this.to=t,this.tree=s,this.offset=i,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],s=!1){let i=[new lc(0,e.length,e,0,!1,s)];for(let r of t)r.to>e.length&&i.push(r);return i}static applyChanges(e,t,s=128){if(!t.length)return e;let i=[],r=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let h=a=s)for(;o&&o.from=d.from||u<=d.to||c){let p=Math.max(d.from,l)-c,m=Math.min(d.to,u)-c;d=p>=m?null:new lc(p,m,d.tree,d.offset+c,a>0,!!h)}if(d&&i.push(d),o.to>u)break;o=rnew Zv(i.from,i.to)):[new Zv(0,0)]:[new Zv(0,e.length)],this.createParse(e,t||[],s)}parse(e,t,s){let i=this.startParse(e,t,s);for(;;){let r=i.advance();if(r)return r}}}class $Q{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new nt({perNode:!0});let TQ=0;class gi{constructor(e,t,s,i){this.name=e,this.set=t,this.base=s,this.modified=i,this.id=TQ++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let s=typeof e=="string"?e:"?";if(e instanceof gi&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let i=new gi(s,[],null,[]);if(i.set.push(i),t)for(let r of t.set)i.set.push(r);return i}static defineModifier(e){let t=new Ly(e);return s=>s.modified.indexOf(t)>-1?s:Ly.get(s.base||s,s.modified.concat(t).sort((i,r)=>i.id-r.id))}}let PQ=0;class Ly{constructor(e){this.name=e,this.instances=[],this.id=PQ++}static get(e,t){if(!t.length)return e;let s=t[0].instances.find(a=>a.base==e&&RQ(t,a.modified));if(s)return s;let i=[],r=new gi(e.name,i,e,t);for(let a of t)a.instances.push(r);let o=MQ(t);for(let a of e.set)if(!a.modified.length)for(let l of o)i.push(Ly.get(a,l));return r}}function RQ(n,e){return n.length==e.length&&n.every((t,s)=>t==e[s])}function MQ(n){let e=[[]];for(let t=0;ts.length-t.length)}function IQ(n){let e=Object.create(null);for(let t in n){let s=n[t];Array.isArray(s)||(s=[s]);for(let i of t.split(" "))if(i){let r=[],o=2,a=i;for(let u=0;;){if(a=="..."&&u>0&&u+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!d)throw new RangeError("Invalid path: "+i);if(r.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),u+=d[0].length,u==i.length)break;let p=i[u++];if(u==i.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+i);a=i.slice(u)}let l=r.length-1,c=r[l];if(!c)throw new RangeError("Invalid path: "+i);let h=new Dy(s,o,l>0?r.slice(0,l):null);e[c]=h.sort(e[c])}}return OQ.add(e)}const OQ=new nt({combine(n,e){let t,s,i;for(;n||e;){if(!n||e&&n.depth>=e.depth?(i=e,e=e.next):(i=n,n=n.next),t&&t.mode==i.mode&&!i.context&&!t.context)continue;let r=new Dy(i.tags,i.mode,i.context);t?t.next=r:s=r,t=r}return s}});class Dy{constructor(e,t,s,i){this.tags=e,this.mode=t,this.context=s,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=i;for(let a of r)for(let l of a.set){let c=t[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:s}}const he=gi.define,Jm=he(),Ho=he(),SC=he(Ho),xC=he(Ho),Bo=he(),Qm=he(Bo),Xv=he(Bo),or=he(),Wa=he(or),ir=he(),rr=he(),V_=he(),ld=he(V_),eg=he(),ze={comment:Jm,lineComment:he(Jm),blockComment:he(Jm),docComment:he(Jm),name:Ho,variableName:he(Ho),typeName:SC,tagName:he(SC),propertyName:xC,attributeName:he(xC),className:he(Ho),labelName:he(Ho),namespace:he(Ho),macroName:he(Ho),literal:Bo,string:Qm,docString:he(Qm),character:he(Qm),attributeValue:he(Qm),number:Xv,integer:he(Xv),float:he(Xv),bool:he(Bo),regexp:he(Bo),escape:he(Bo),color:he(Bo),url:he(Bo),keyword:ir,self:he(ir),null:he(ir),atom:he(ir),unit:he(ir),modifier:he(ir),operatorKeyword:he(ir),controlKeyword:he(ir),definitionKeyword:he(ir),moduleKeyword:he(ir),operator:rr,derefOperator:he(rr),arithmeticOperator:he(rr),logicOperator:he(rr),bitwiseOperator:he(rr),compareOperator:he(rr),updateOperator:he(rr),definitionOperator:he(rr),typeOperator:he(rr),controlOperator:he(rr),punctuation:V_,separator:he(V_),bracket:ld,angleBracket:he(ld),squareBracket:he(ld),paren:he(ld),brace:he(ld),content:or,heading:Wa,heading1:he(Wa),heading2:he(Wa),heading3:he(Wa),heading4:he(Wa),heading5:he(Wa),heading6:he(Wa),contentSeparator:he(or),list:he(or),quote:he(or),emphasis:he(or),strong:he(or),link:he(or),monospace:he(or),strikethrough:he(or),inserted:he(),deleted:he(),changed:he(),invalid:he(),meta:eg,documentMeta:he(eg),annotation:he(eg),processingInstruction:he(eg),definition:gi.defineModifier("definition"),constant:gi.defineModifier("constant"),function:gi.defineModifier("function"),standard:gi.defineModifier("standard"),local:gi.defineModifier("local"),special:gi.defineModifier("special")};for(let n in ze){let e=ze[n];e instanceof gi&&(e.name=n)}NQ([{tag:ze.link,class:"tok-link"},{tag:ze.heading,class:"tok-heading"},{tag:ze.emphasis,class:"tok-emphasis"},{tag:ze.strong,class:"tok-strong"},{tag:ze.keyword,class:"tok-keyword"},{tag:ze.atom,class:"tok-atom"},{tag:ze.bool,class:"tok-bool"},{tag:ze.url,class:"tok-url"},{tag:ze.labelName,class:"tok-labelName"},{tag:ze.inserted,class:"tok-inserted"},{tag:ze.deleted,class:"tok-deleted"},{tag:ze.literal,class:"tok-literal"},{tag:ze.string,class:"tok-string"},{tag:ze.number,class:"tok-number"},{tag:[ze.regexp,ze.escape,ze.special(ze.string)],class:"tok-string2"},{tag:ze.variableName,class:"tok-variableName"},{tag:ze.local(ze.variableName),class:"tok-variableName tok-local"},{tag:ze.definition(ze.variableName),class:"tok-variableName tok-definition"},{tag:ze.special(ze.variableName),class:"tok-variableName2"},{tag:ze.definition(ze.propertyName),class:"tok-propertyName tok-definition"},{tag:ze.typeName,class:"tok-typeName"},{tag:ze.namespace,class:"tok-namespace"},{tag:ze.className,class:"tok-className"},{tag:ze.macroName,class:"tok-macroName"},{tag:ze.propertyName,class:"tok-propertyName"},{tag:ze.operator,class:"tok-operator"},{tag:ze.comment,class:"tok-comment"},{tag:ze.meta,class:"tok-meta"},{tag:ze.invalid,class:"tok-invalid"},{tag:ze.punctuation,class:"tok-punctuation"}]);var Yv;const Od=new nt;function LQ(n){return be.define({combine:n?e=>e.concat(n):void 0})}const DQ=new nt;class Ir{constructor(e,t,s=[],i=""){this.data=e,this.name=i,at.prototype.hasOwnProperty("tree")||Object.defineProperty(at.prototype,"tree",{get(){return Na(this)}}),this.parser=t,this.extension=[Mu.of(this),at.languageData.of((r,o,a)=>{let l=AC(r,o,a),c=l.type.prop(Od);if(!c)return[];let h=r.facet(c),u=l.type.prop(DQ);if(u){let d=l.resolve(o-l.from,a);for(let p of u)if(p.test(d,r)){let m=r.facet(p.facet);return p.type=="replace"?m:m.concat(h)}}return h})].concat(s)}isActiveAt(e,t,s=-1){return AC(e,t,s).type.prop(Od)==this.data}findRegions(e){let t=e.facet(Mu);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let s=[],i=(r,o)=>{if(r.prop(Od)==this.data){s.push({from:o,to:o+r.length});return}let a=r.prop(nt.mounted);if(a){if(a.tree.prop(Od)==this.data){if(a.overlay)for(let l of a.overlay)s.push({from:l.from+o,to:l.to+o});else s.push({from:o,to:o+r.length});return}else if(a.overlay){let l=s.length;if(i(a.tree,a.overlay[0].from+o),s.length>l)return}}for(let l=0;l=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-s,t-s)}}let cd=null;class Pu{constructor(e,t,s=[],i,r,o,a,l){this.parser=e,this.state=t,this.fragments=s,this.tree=i,this.treeLen=r,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,s){return new Pu(e,t,[],Ot.empty,0,s,[],null)}startParse(){return this.parser.startParse(new jQ(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Ot.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var s;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(lc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=cd;cd=this;try{return e()}finally{cd=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=kC(e,t.from,t.to);return e}changes(e,t){let{fragments:s,tree:i,treeLen:r,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,h,u,d)=>l.push({fromA:c,toA:h,fromB:u,toB:d})),s=lc.applyChanges(s,l),i=Ot.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let h=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);he.from&&(this.fragments=kC(this.fragments,i,r),this.skipped.splice(s--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends pN{createParse(t,s,i){let r=i[0].from,o=i[i.length-1].to;return{parsedPos:r,advance(){let l=cd;if(l){for(let c of i)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new Ot(Hs.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return cd}}function kC(n,e,t){return lc.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class Ru{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),s=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,s)||t.takeTree(),new Ru(t)}static init(e){let t=Math.min(3e3,e.doc.length),s=Pu.create(e.facet(Mu).parser,e,{from:0,to:t});return s.work(20,t)||s.takeTree(),new Ru(s)}}Ir.state=Fr.define({create:Ru.init,update(n,e){for(let t of e.effects)if(t.is(Ir.setState))return t.value;return e.startState.facet(Mu)!=e.state.facet(Mu)?Ru.init(e.state):n.apply(e)}});let mN=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(mN=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Jv=typeof navigator<"u"&&(!((Yv=navigator.scheduling)===null||Yv===void 0)&&Yv.isInputPending)?()=>navigator.scheduling.isInputPending():null,FQ=ri.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Ir.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Ir.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=mN(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndi+1e3,l=r.context.work(()=>Jv&&Jv()||Date.now()>o,i+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Ir.setState.of(new Ru(r.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Mr(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Mu=be.define({combine(n){return n.length?n[0]:null},enables:n=>[Ir.state,FQ,xe.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),zQ=be.define(),eA=be.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Ac(n){let e=n.facet(eA);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function jy(n,e){let t="",s=n.tabSize,i=n.facet(eA)[0];if(i==" "){for(;e>=s;)t+=" ",e-=s;i=" "}for(let r=0;r=e?HQ(n,t,e):null}class J0{constructor(e,t={}){this.state=e,this.options=t,this.unit=Ac(e)}lineAt(e,t=1){let s=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:r}=this.options;return i!=null&&i>=s.from&&i<=s.to?r&&i==e?{text:"",from:e}:(t<0?i-1&&(r+=o-this.countColumn(s,s.search(/\S|$/))),r}countColumn(e,t=e.length){return V0(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:s,from:i}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(i);if(o>-1)return o}return this.countColumn(s,s.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const yN=new nt;function HQ(n,e,t){let s=e.resolveStack(t),i=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(i!=s.node){let r=[];for(let o=i;o&&!(o.froms.node.to||o.from==s.node.from&&o.type==s.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)s={node:r[o],next:s}}return vN(s,n,t)}function vN(n,e,t){for(let s=n;s;s=s.next){let i=UQ(s.node);if(i)return i(tA.create(e,t,s))}return 0}function BQ(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function UQ(n){let e=n.type.prop(yN);if(e)return e;let t=n.firstChild,s;if(t&&(s=t.type.prop(nt.closedBy))){let i=n.lastChild,r=i&&s.indexOf(i.name)>-1;return o=>GQ(o,!0,1,void 0,r&&!BQ(o)?i.from:void 0)}return n.parent==null?qQ:null}function qQ(){return 0}class tA extends J0{constructor(e,t,s){super(e.state,e.options),this.base=e,this.pos=t,this.context=s}get node(){return this.context.node}static create(e,t,s){return new tA(e,t,s)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let s=e.resolve(t.from);for(;s.parent&&s.parent.from==s.from;)s=s.parent;if(VQ(s,e))break;t=this.state.doc.lineAt(s.from)}return this.lineIndent(t.from)}continue(){return vN(this.context.next,this.base,this.pos)}}function VQ(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function WQ(n){let e=n.node,t=e.childAfter(e.from),s=e.lastChild;if(!t)return null;let i=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=i==null||i<=r.from?r.to:Math.min(r.to,i);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==s)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+c}}a=l.to}}function GQ(n,e,t,s,i){let r=n.textAfter,o=r.match(/^\s*/)[0].length,a=s&&r.slice(o,o+s.length)==s||i==n.pos+o,l=WQ(n);return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*t)}const KQ=xe.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),bN=1e4,wN="()[]{}",_N=be.define({combine(n){return Hu(n,{afterCursor:!0,brackets:wN,maxScanDistance:bN,renderMatch:YQ})}}),ZQ=Qe.mark({class:"cm-matchingBracket"}),XQ=Qe.mark({class:"cm-nonmatchingBracket"});function YQ(n){let e=[],t=n.matched?ZQ:XQ;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function EC(n){let e=[],t=n.facet(_N);for(let s of n.selection.ranges){if(!s.empty)continue;let i=Or(n,s.head,-1,t)||s.head>0&&Or(n,s.head-1,1,t)||t.afterCursor&&(Or(n,s.head,1,t)||s.headn.decorations}),QQ=[JQ,KQ];function eee(n={}){return[_N.of(n),QQ]}const tee=new nt;function W_(n,e,t){let s=n.prop(e<0?nt.openedBy:nt.closedBy);if(s)return s;if(n.name.length==1){let i=t.indexOf(n.name);if(i>-1&&i%2==(e<0?1:0))return[t[i+e]]}return null}function G_(n){let e=n.type.prop(tee);return e?e(n.node):n}function Or(n,e,t,s={}){let i=s.maxScanDistance||bN,r=s.brackets||wN,o=Na(n),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=W_(l.type,t,r);if(c&&l.from0?e>=h.from&&eh.from&&e<=h.to))return nee(n,e,t,l,h,c,r)}}return see(n,e,t,o,a.type,i,r)}function nee(n,e,t,s,i,r,o){let a=s.parent,l={from:i.from,to:i.to},c=0,h=a==null?void 0:a.cursor();if(h&&(t<0?h.childBefore(s.from):h.childAfter(s.to)))do if(t<0?h.to<=s.from:h.from>=s.to){if(c==0&&r.indexOf(h.type.name)>-1&&h.from0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},h=n.doc.iterRange(e,t>0?n.doc.length:0),u=0;for(let d=0;!h.next().done&&d<=r;){let p=h.value;t<0&&(d+=p.length);let m=e+d*t;for(let y=t>0?0:p.length-1,v=t>0?p.length:-1;y!=v;y+=t){let g=o.indexOf(p[y]);if(!(g<0||s.resolveInner(m+y,1).type!=i))if(g%2==0==t>0)u++;else{if(u==1)return{start:c,end:{from:m+y,to:m+y+1},matched:g>>1==l>>1};u--}}t>0&&(d+=p.length)}return h.done?{start:c,matched:!1}:null}function CC(n,e,t,s=0,i=0){e==null&&(e=n.search(/[^\s\u00a0]/),e==-1&&(e=n.length));let r=i;for(let o=s;o=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.post}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPoss?o.toLowerCase():o,r=this.string.substr(this.pos,e.length);return i(r)==i(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let i=this.string.slice(this.pos).match(e);return i&&i.index>0?null:(i&&t!==!1&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function iee(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||ree,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||iA,mergeTokens:n.mergeTokens!==!1}}function ree(n){if(typeof n!="object")return n;let e={};for(let t in n){let s=n[t];e[t]=s instanceof Array?s.slice():s}return e}const $C=new WeakMap;class nA extends Ir{constructor(e){let t=LQ(e.languageData),s=iee(e),i,r=new class extends pN{createParse(o,a,l){return new aee(i,o,a,l)}};super(t,r,[],e.name),this.topNode=hee(t,this),i=this,this.streamParser=s,this.stateAfter=new nt({perNode:!0}),this.tokenTable=e.tokenTable?new EN(s.tokenTable):cee}static define(e){return new nA(e)}getIndent(e){let t,{overrideIndentation:s}=e.options;s&&(t=$C.get(e.state),t!=null&&t1e4)return null;for(;r=s&&t+e.length<=i&&e.prop(n.stateAfter);if(r)return{state:n.streamParser.copyState(r),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let a=e.children[o],l=t+e.positions[o],c=a instanceof Ot&&l=e.length)return e;!i&&t==0&&e.type==n.topNode&&(i=!0);for(let r=e.children.length-1;r>=0;r--){let o=e.positions[r],a=e.children[r],l;if(ot&&sA(n,r.tree,0-r.offset,t,a),c;if(l&&l.pos<=s&&(c=xN(n,r.tree,t+r.offset,l.pos+r.offset,!1)))return{state:l.state,tree:c}}return{state:n.streamParser.startState(i?Ac(i):4),tree:Ot.empty}}class aee{constructor(e,t,s,i){this.lang=e,this.input=t,this.fragments=s,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let r=Pu.get(),o=i[0].from,{state:a,tree:l}=oee(e,s,o,this.to,r==null?void 0:r.state);this.state=a,this.parsedPos=this.chunkStart=o+l.length;for(let c=0;cc.from<=r.viewport.from&&c.to>=r.viewport.from)&&(this.state=this.lang.streamParser.startState(Ac(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let e=Pu.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),s=Math.min(t,this.chunkStart+512);for(e&&(s=Math.min(s,e.viewport.to));this.parsedPos=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==` -`&&(t="");else{let s=t.indexOf(` -`);s>-1&&(t=t.slice(0,s))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),s=e+t.length;for(let i=this.rangeIndex;;){let r=this.ranges[i].to;if(r>=s||(t=t.slice(0,r-(s-t.length)),i++,i==this.ranges.length))break;let o=this.ranges[i].from,a=this.lineAfter(o);t+=a,s=o+a.length}return{line:t,end:s}}skipGapsTo(e,t,s){for(;;){let i=this.ranges[this.rangeIndex].to,r=e+t;if(s>0?i>r:i>=r)break;let o=this.ranges[++this.rangeIndex].from;t+=o-i}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to1){i=this.skipGapsTo(t,i,1),t+=i;let a=this.chunk.length;i=this.skipGapsTo(s,i,-1),s+=i,r+=this.chunk.length-a}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&r==4&&o>=0&&this.chunk[o]==e&&this.chunk[o+2]==t?this.chunk[o+2]=s:this.chunk.push(e,t,s,r),i}parseLine(e){let{line:t,end:s}=this.nextLine(),i=0,{streamParser:r}=this.lang,o=new SN(t,e?e.state.tabSize:4,e?Ac(e.state):2);if(o.eol())r.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let a=AN(r.token,o,this.state);if(a&&(i=this.emitToken(this.lang.tokenTable.resolve(a),this.parsedPos+o.start,this.parsedPos+o.pos,i)),o.start>1e4)break}this.parsedPos=s,this.moveRangeIndex(),this.parsedPose.start)return i}throw new Error("Stream parser failed to advance stream.")}const iA=Object.create(null),vf=[Hs.none],lee=new Xx(vf),TC=[],PC=Object.create(null),kN=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])kN[n]=CN(iA,e);class EN{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),kN)}resolve(e){return e?this.table[e]||(this.table[e]=CN(this.extra,e)):0}}const cee=new EN(iA);function Qv(n,e){TC.indexOf(n)>-1||(TC.push(n),console.warn(e))}function CN(n,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let h=n[c]||ze[c];h?typeof h=="function"?l.length?l=l.map(h):Qv(c,`Modifier ${c} used at start of tag`):l.length?Qv(c,`Tag ${c} used as modifier`):l=Array.isArray(h)?h:[h]:Qv(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let s=e.replace(/ /g,"_"),i=s+" "+t.map(a=>a.id),r=PC[i];if(r)return r.id;let o=PC[i]=Hs.define({id:vf.length,name:s,props:[IQ({[s]:t})]});return vf.push(o),o.id}function hee(n,e){let t=Hs.define({id:vf.length,name:"Document",props:[Od.add(()=>n),yN.add(()=>s=>e.getIndent(s))],top:!0});return vf.push(t),t}It.RTL,It.LTR;const uee=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),s=oA(n.state,t.from);return s.line?dee(n):s.block?pee(n):!1};function rA(n,e){return({state:t,dispatch:s})=>{if(t.readOnly)return!1;let i=n(e,t);return i?(s(t.update(i)),!0):!1}}const dee=rA(yee,0),fee=rA($N,0),pee=rA((n,e)=>$N(n,e,gee(e)),0);function oA(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const hd=50;function mee(n,{open:e,close:t},s,i){let r=n.sliceDoc(s-hd,s),o=n.sliceDoc(i,i+hd),a=/\s*$/.exec(r)[0].length,l=/^\s*/.exec(o)[0].length,c=r.length-a;if(r.slice(c-e.length,c)==e&&o.slice(l,l+t.length)==t)return{open:{pos:s-a,margin:a&&1},close:{pos:i+l,margin:l&&1}};let h,u;i-s<=2*hd?h=u=n.sliceDoc(s,i):(h=n.sliceDoc(s,s+hd),u=n.sliceDoc(i-hd,i));let d=/^\s*/.exec(h)[0].length,p=/\s*$/.exec(u)[0].length,m=u.length-p-t.length;return h.slice(d,d+e.length)==e&&u.slice(m,m+t.length)==t?{open:{pos:s+d+e.length,margin:/\s/.test(h.charAt(d+e.length))?1:0},close:{pos:i-p-t.length,margin:/\s/.test(u.charAt(m-1))?1:0}}:null}function gee(n){let e=[];for(let t of n.selection.ranges){let s=n.doc.lineAt(t.from),i=t.to<=s.to?s:n.doc.lineAt(t.to);i.from>s.from&&i.from==t.to&&(i=t.to==s.to+1?s:n.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>s.from?e[r].to=i.to:e.push({from:s.from+/^\s*/.exec(s.text)[0].length,to:i.to})}return e}function $N(n,e,t=e.selection.ranges){let s=t.map(r=>oA(e,r.from).block);if(!s.every(r=>r))return null;let i=t.map((r,o)=>mee(e,s[o],r.from,r.to));if(n!=2&&!i.every(r=>r))return{changes:e.changes(t.map((r,o)=>i[o]?[]:[{from:r.from,insert:s[o].open+" "},{from:r.to,insert:" "+s[o].close}]))};if(n!=1&&i.some(r=>r)){let r=[];for(let o=0,a;oi&&(r==o||o>u.from)){i=u.from;let d=/^\s*/.exec(u.text)[0].length,p=d==u.length,m=u.text.slice(d,d+c.length)==c?d:-1;dr.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:a,token:l,indent:c,empty:h,single:u}of s)(u||!h)&&r.push({from:a.from+c,insert:l+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&s.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:a,token:l}of s)if(a>=0){let c=o.from+a,h=c+l.length;o.text[h-o.from]==" "&&h++,r.push({from:c,to:h})}return{changes:r}}return null}const K_=Fa.define(),vee=Fa.define(),bee=be.define(),TN=be.define({combine(n){return Hu(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(s,i)=>e(s,i)||t(s,i)})}}),PN=Fr.define({create(){return Nr.empty},update(n,e){let t=e.state.facet(TN),s=e.annotation(K_);if(s){let l=Fs.fromTransaction(e,s.selection),c=s.side,h=c==0?n.undone:n.done;return l?h=Fy(h,h.length,t.minDepth,l):h=IN(h,e.startState.selection),new Nr(c==0?s.rest:h,c==0?h:s.rest)}let i=e.annotation(vee);if((i=="full"||i=="before")&&(n=n.isolate()),e.annotation(yn.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=Fs.fromTransaction(e),o=e.annotation(yn.time),a=e.annotation(yn.userEvent);return r?n=n.addChanges(r,o,a,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,a,t.newGroupDelay)),(i=="full"||i=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new Nr(n.done.map(Fs.fromJSON),n.undone.map(Fs.fromJSON))}});function wee(n={}){return[PN,TN.of(n),xe.domEventHandlers({beforeinput(e,t){let s=e.inputType=="historyUndo"?RN:e.inputType=="historyRedo"?Z_:null;return s?(e.preventDefault(),s(t)):!1}})]}function Q0(n,e){return function({state:t,dispatch:s}){if(!e&&t.readOnly)return!1;let i=t.field(PN,!1);if(!i)return!1;let r=i.pop(n,t,e);return r?(s(r),!0):!1}}const RN=Q0(0,!1),Z_=Q0(1,!1),_ee=Q0(0,!0),See=Q0(1,!0);class Fs{constructor(e,t,s,i,r){this.changes=e,this.effects=t,this.mapped=s,this.startSelection=i,this.selectionsAfter=r}setSelAfter(e){return new Fs(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,s;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(s=this.startSelection)===null||s===void 0?void 0:s.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new Fs(e.changes&&pn.fromJSON(e.changes),[],e.mapped&&Lr.fromJSON(e.mapped),e.startSelection&&te.fromJSON(e.startSelection),e.selectionsAfter.map(te.fromJSON))}static fromTransaction(e,t){let s=wi;for(let i of e.startState.facet(bee)){let r=i(e);r.length&&(s=s.concat(r))}return!s.length&&e.changes.empty?null:new Fs(e.changes.invert(e.startState.doc),s,void 0,t||e.startState.selection,wi)}static selection(e){return new Fs(void 0,wi,void 0,void 0,e)}}function Fy(n,e,t,s){let i=e+1>t+20?e-t-1:0,r=n.slice(i,e);return r.push(s),r}function xee(n,e){let t=[],s=!1;return n.iterChangedRanges((i,r)=>t.push(i,r)),e.iterChangedRanges((i,r,o,a)=>{for(let l=0;l=c&&o<=h&&(s=!0)}}),s}function Aee(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,s)=>t.empty!=e.ranges[s].empty).length===0}function MN(n,e){return n.length?e.length?n.concat(e):n:e}const wi=[],kee=200;function IN(n,e){if(n.length){let t=n[n.length-1],s=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-kee));return s.length&&s[s.length-1].eq(e)?n:(s.push(e),Fy(n,n.length-1,1e9,t.setSelAfter(s)))}else return[Fs.selection([e])]}function Eee(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function eb(n,e){if(!n.length)return n;let t=n.length,s=wi;for(;t;){let i=Cee(n[t-1],e,s);if(i.changes&&!i.changes.empty||i.effects.length){let r=n.slice(0,t);return r[t-1]=i,r}else e=i.mapped,t--,s=i.selectionsAfter}return s.length?[Fs.selection(s)]:wi}function Cee(n,e,t){let s=MN(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):wi,t);if(!n.changes)return Fs.selection(s);let i=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new Fs(i,St.mapEffects(n.effects,e),o,n.startSelection.map(r),s)}const $ee=/^(input\.type|delete)($|\.)/;class Nr{constructor(e,t,s=0,i=void 0){this.done=e,this.undone=t,this.prevTime=s,this.prevUserEvent=i}isolate(){return this.prevTime?new Nr(this.done,this.undone):this}addChanges(e,t,s,i,r){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!s||$ee.test(s))&&(!a.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):ev(t,e))}function as(n){return n.textDirectionAt(n.state.selection.main.head)==It.LTR}const NN=n=>ON(n,!as(n)),LN=n=>ON(n,as(n));function DN(n,e){return tr(n,t=>t.empty?n.moveByGroup(t,e):ev(t,e))}const Pee=n=>DN(n,!as(n)),Ree=n=>DN(n,as(n));function Mee(n,e,t){if(e.type.prop(t))return!0;let s=e.to-e.from;return s&&(s>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function tv(n,e,t){let s=Na(n).resolveInner(e.head),i=t?nt.closedBy:nt.openedBy;for(let l=e.head;;){let c=t?s.childAfter(l):s.childBefore(l);if(!c)break;Mee(n,c,i)?s=c:l=t?c.to:c.from}let r=s.type.prop(i),o,a;return r&&(o=t?Or(n,s.from,1):Or(n,s.to,-1))&&o.matched?a=t?o.end.to:o.end.from:a=t?s.to:s.from,te.cursor(a,t?-1:1)}const Iee=n=>tr(n,e=>tv(n.state,e,!as(n))),Oee=n=>tr(n,e=>tv(n.state,e,as(n)));function jN(n,e){return tr(n,t=>{if(!t.empty)return ev(t,e);let s=n.moveVertically(t,e);return s.head!=t.head?s:n.moveToLineBoundary(t,e)})}const FN=n=>jN(n,!1),zN=n=>jN(n,!0);function HN(n){let e=n.scrollDOM.clientHeighto.empty?n.moveVertically(o,e,t.height):ev(o,e));if(i.eq(s.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(s.selection.main.head),a=n.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;o&&o.top>l&&o.bottomBN(n,!1),X_=n=>BN(n,!0);function za(n,e,t){let s=n.lineBlockAt(e.head),i=n.moveToLineBoundary(e,t);if(i.head==e.head&&i.head!=(t?s.to:s.from)&&(i=n.moveToLineBoundary(e,t,!1)),!t&&i.head==s.from&&s.length){let r=/^\s*/.exec(n.state.sliceDoc(s.from,Math.min(s.from+100,s.to)))[0].length;r&&e.head!=s.from+r&&(i=te.cursor(s.from+r))}return i}const Nee=n=>tr(n,e=>za(n,e,!0)),Lee=n=>tr(n,e=>za(n,e,!1)),Dee=n=>tr(n,e=>za(n,e,!as(n))),jee=n=>tr(n,e=>za(n,e,as(n))),Fee=n=>tr(n,e=>te.cursor(n.lineBlockAt(e.head).from,1)),zee=n=>tr(n,e=>te.cursor(n.lineBlockAt(e.head).to,-1));function Hee(n,e,t){let s=!1,i=Bu(n.selection,r=>{let o=Or(n,r.head,-1)||Or(n,r.head,1)||r.head>0&&Or(n,r.head-1,1)||r.headHee(n,e);function Ei(n,e,t){let s=Bu(n.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=te.range(i.head,i.anchor));let r=t(i);return te.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return s.eq(n.state.selection)?!1:(n.dispatch(er(n.state,s)),!0)}function UN(n,e){return Ei(n,e,t=>n.moveByChar(t,e))}const qN=n=>UN(n,!as(n)),VN=n=>UN(n,as(n));function WN(n,e){return Ei(n,e,t=>n.moveByGroup(t,e))}const Uee=n=>WN(n,!as(n)),qee=n=>WN(n,as(n)),Vee=n=>{let e=!as(n);return Ei(n,e,t=>tv(n.state,t,e))},Wee=n=>{let e=as(n);return Ei(n,e,t=>tv(n.state,t,e))};function GN(n,e){return Ei(n,e,t=>n.moveVertically(t,e))}const KN=n=>GN(n,!1),ZN=n=>GN(n,!0);function XN(n,e){return Ei(n,e,t=>n.moveVertically(t,e,HN(n).height))}const MC=n=>XN(n,!1),IC=n=>XN(n,!0),Gee=n=>Ei(n,!0,e=>za(n,e,!0)),Kee=n=>Ei(n,!1,e=>za(n,e,!1)),Zee=n=>{let e=!as(n);return Ei(n,e,t=>za(n,t,e))},Xee=n=>{let e=as(n);return Ei(n,e,t=>za(n,t,e))},Yee=n=>Ei(n,!1,e=>te.cursor(n.lineBlockAt(e.head).from)),Jee=n=>Ei(n,!0,e=>te.cursor(n.lineBlockAt(e.head).to)),OC=({state:n,dispatch:e})=>(e(er(n,{anchor:0})),!0),NC=({state:n,dispatch:e})=>(e(er(n,{anchor:n.doc.length})),!0),LC=({state:n,dispatch:e})=>(e(er(n,{anchor:n.selection.main.anchor,head:0})),!0),DC=({state:n,dispatch:e})=>(e(er(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Qee=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),ete=({state:n,dispatch:e})=>{let t=nv(n).map(({from:s,to:i})=>te.undirectionalRange(s,Math.min(i+1,n.doc.length)));return e(n.update({selection:te.create(t),userEvent:"select"})),!0},tte=({state:n,dispatch:e})=>{let t=Bu(n.selection,s=>{let i=Na(n),r=i.resolveStack(s.from,1);if(s.empty){let o=i.resolveStack(s.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:a}=o;if((a.from=s.to||a.to>s.to&&a.from<=s.from)&&o.next)return te.undirectionalRange(a.from,a.to)}return s});return t.eq(n.selection)?!1:(e(er(n,t)),!0)};function YN(n,e){let{state:t}=n,s=t.selection,i=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to0)for(let a=r;;){let l=n.moveVertically(a,e);if(l.heado.to){i.some(c=>c.head==l.head)||i.push(l);break}else{if(l.head==a.head)break;a=l}}}return i.length==s.ranges.length?!1:(n.dispatch(er(t,te.create(i,i.length-1))),!0)}const nte=n=>YN(n,!1),ste=n=>YN(n,!0),ite=({state:n,dispatch:e})=>{let t=n.selection,s=null;return t.ranges.length>1?s=te.create([t.main]):t.main.empty||(s=te.create([te.cursor(t.main.head)])),s?(e(er(n,s)),!0):!1};function lm(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:s}=n,i=s.changeByRange(r=>{let{from:o,to:a}=r;if(o==a){let l=e(r);lo&&(t="delete.forward",l=tg(n,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=tg(n,o,!1),a=tg(n,a,!0);return o==a?{range:r}:{changes:{from:o,to:a},range:te.cursor(o,oi(n)))s.between(e,e,(i,r)=>{ie&&(e=t?r:i)});return e}const JN=(n,e,t)=>lm(n,s=>{let i=s.from,{state:r}=n,o=r.doc.lineAt(i),a,l;if(t&&!e&&i>o.from&&iJN(n,!1,!0),QN=n=>JN(n,!0,!1),eL=(n,e)=>lm(n,t=>{let s=t.head,{state:i}=n,r=i.doc.lineAt(s),o=i.charCategorizer(s);for(let a=null;;){if(s==(e?r.to:r.from)){s==t.head&&r.number!=(e?i.doc.lines:1)&&(s+=e?1:-1);break}let l=$n(r.text,s-r.from,e)+r.from,c=r.text.slice(Math.min(s,l)-r.from,Math.max(s,l)-r.from),h=o(c);if(a!=null&&h!=a)break;(c!=" "||s!=t.head)&&(a=h),s=l}return s}),tL=n=>eL(n,!1),rte=n=>eL(n,!0),ote=n=>lm(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headlm(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),lte=n=>lm(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(s=>({changes:{from:s.from,to:s.to,insert:lt.of(["",""])},range:te.cursor(s.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},hte=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(s=>{if(!s.empty||s.from==0||s.from==n.doc.length)return{range:s};let i=s.from,r=n.doc.lineAt(i),o=i==r.from?i-1:$n(r.text,i-r.from,!1)+r.from,a=i==r.to?i+1:$n(r.text,i-r.from,!0)+r.from;return{changes:{from:o,to:a,insert:n.doc.slice(i,a).append(n.doc.slice(o,i))},range:te.cursor(a)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function nv(n){let e=[],t=-1;for(let s of n.selection.ranges){let i=n.doc.lineAt(s.from),r=n.doc.lineAt(s.to);if(!s.empty&&s.to==r.from&&(r=n.doc.lineAt(s.to-1)),t>=i.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(s)}else e.push({from:i.from,to:r.to,ranges:[s]});t=r.number+1}return e}function nL(n,e,t){if(n.readOnly)return!1;let s=[],i=[];for(let r of nv(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),a=o.length+1;if(t){s.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let l of r.ranges)i.push(te.range(Math.min(n.doc.length,l.anchor+a),Math.min(n.doc.length,l.head+a)))}else{s.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let l of r.ranges)i.push(te.range(l.anchor-a,l.head-a))}}return s.length?(e(n.update({changes:s,scrollIntoView:!0,selection:te.create(i,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const ute=({state:n,dispatch:e})=>nL(n,e,!1),dte=({state:n,dispatch:e})=>nL(n,e,!0);function sL(n,e,t){if(n.readOnly)return!1;let s=[];for(let r of nv(n))t?s.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):s.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});let i=n.changes(s);return e(n.update({changes:i,selection:n.selection.map(i,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const fte=({state:n,dispatch:e})=>sL(n,e,!1),pte=({state:n,dispatch:e})=>sL(n,e,!0),mte=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(nv(e).map(({from:i,to:r})=>(i>0?i--:r{let r;if(n.lineWrapping){let o=n.lineBlockAt(i.head),a=n.coordsAtPos(i.head,i.assoc||1);a&&(r=o.bottom+n.documentTop-a.bottom+n.defaultLineHeight/2)}return n.moveVertically(i,!0,r)}).map(t);return n.dispatch({changes:t,selection:s,scrollIntoView:!0,userEvent:"delete.line"}),!0};function gte(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Na(n).resolveInner(e),s=t.childBefore(e),i=t.childAfter(e),r;return s&&i&&s.to<=e&&i.from>=e&&(r=s.type.prop(nt.closedBy))&&r.indexOf(i.name)>-1&&n.doc.lineAt(s.to).from==n.doc.lineAt(i.from).from&&!/\S/.test(n.sliceDoc(s.to,i.from))?{from:s.to,to:i.from}:null}const jC=iL(!1),yte=iL(!0);function iL(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let s=e.changeByRange(i=>{let{from:r,to:o}=i,a=e.doc.lineAt(r),l=!n&&r==o&>e(e,r);n&&(r=o=(o<=a.to?a:e.doc.lineAt(o)).to);let c=new J0(e,{simulateBreak:r,simulateDoubleBreak:!!l}),h=gN(c,r);for(h==null&&(h=V0(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));oa.from&&r{let i=[];for(let o=s.from;o<=s.to;){let a=n.doc.lineAt(o);a.number>t&&(s.empty||s.to>a.from)&&(e(a,i,s),t=a.number),o=a.to+1}let r=n.changes(i);return{changes:i,range:te.range(r.mapPos(s.anchor,1),r.mapPos(s.head,1))}})}const vte=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),s=new J0(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),i=aA(n,(r,o,a)=>{let l=gN(s,r.from);if(l==null)return;/\S/.test(r.text)||(l=0);let c=/^\s*/.exec(r.text)[0],h=jy(n,l);(c!=h||a.fromn.readOnly?!1:(e(n.update(aA(n,(t,s)=>{s.push({from:t.from,insert:n.facet(eA)})}),{userEvent:"input.indent"})),!0),oL=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(aA(n,(t,s)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let r=V0(i,n.tabSize),o=0,a=jy(n,Math.max(0,r-Ac(n)));for(;o(n.setTabFocusMode(),!0),wte=[{key:"Ctrl-b",run:NN,shift:qN,preventDefault:!0},{key:"Ctrl-f",run:LN,shift:VN},{key:"Ctrl-p",run:FN,shift:KN},{key:"Ctrl-n",run:zN,shift:ZN},{key:"Ctrl-a",run:Fee,shift:Yee},{key:"Ctrl-e",run:zee,shift:Jee},{key:"Ctrl-d",run:QN},{key:"Ctrl-h",run:Y_},{key:"Ctrl-k",run:ote},{key:"Ctrl-Alt-h",run:tL},{key:"Ctrl-o",run:cte},{key:"Ctrl-t",run:hte},{key:"Ctrl-v",run:X_}],_te=[{key:"ArrowLeft",run:NN,shift:qN,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Pee,shift:Uee,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Dee,shift:Zee,preventDefault:!0},{key:"ArrowRight",run:LN,shift:VN,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Ree,shift:qee,preventDefault:!0},{mac:"Cmd-ArrowRight",run:jee,shift:Xee,preventDefault:!0},{key:"ArrowUp",run:FN,shift:KN,preventDefault:!0},{mac:"Cmd-ArrowUp",run:OC,shift:LC},{mac:"Ctrl-ArrowUp",run:RC,shift:MC},{key:"ArrowDown",run:zN,shift:ZN,preventDefault:!0},{mac:"Cmd-ArrowDown",run:NC,shift:DC},{mac:"Ctrl-ArrowDown",run:X_,shift:IC},{key:"PageUp",run:RC,shift:MC},{key:"PageDown",run:X_,shift:IC},{key:"Home",run:Lee,shift:Kee,preventDefault:!0},{key:"Mod-Home",run:OC,shift:LC},{key:"End",run:Nee,shift:Gee,preventDefault:!0},{key:"Mod-End",run:NC,shift:DC},{key:"Enter",run:jC,shift:jC},{key:"Mod-a",run:Qee},{key:"Backspace",run:Y_,shift:Y_,preventDefault:!0},{key:"Delete",run:QN,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:tL,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:rte,preventDefault:!0},{mac:"Mod-Backspace",run:ate,preventDefault:!0},{mac:"Mod-Delete",run:lte,preventDefault:!0}].concat(wte.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Ste=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Iee,shift:Vee},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Oee,shift:Wee},{key:"Alt-ArrowUp",run:ute},{key:"Shift-Alt-ArrowUp",run:fte},{key:"Alt-ArrowDown",run:dte},{key:"Shift-Alt-ArrowDown",run:pte},{key:"Mod-Alt-ArrowUp",run:nte},{key:"Mod-Alt-ArrowDown",run:ste},{key:"Escape",run:ite},{key:"Mod-Enter",run:yte},{key:"Alt-l",mac:"Ctrl-l",run:ete},{key:"Mod-i",run:tte,preventDefault:!0},{key:"Mod-[",run:oL},{key:"Mod-]",run:rL},{key:"Mod-Alt-\\",run:vte},{key:"Shift-Mod-k",run:mte},{key:"Shift-Mod-\\",run:Bee},{key:"Mod-/",run:uee},{key:"Alt-A",mac:"Ctrl-A",run:fee},{key:"Ctrl-m",mac:"Shift-Alt-m",run:bte}].concat(_te),xte={key:"Tab",run:rL,shift:oL};function aL(n){function e(u,d){u.cmdState.push(d)}function t(u){return u.cmdState.length>0?u.cmdState[u.cmdState.length-1]:null}function s(u){var d=u.cmdState.pop();d&&d.closeBracket()}function i(u){for(var d=u.cmdState,p=d.length-1;p>=0;p--){var m=d[p];if(m.name!="DEFAULT")return m}return{styleIdentifier:function(){return null}}}function r(u,d,p){return function(){this.name=u,this.bracketNo=0,this.style=d,this.styles=p,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var o={};o.importmodule=r("importmodule","tag",["string","builtin"]),o.documentclass=r("documentclass","tag",["","atom"]),o.usepackage=r("usepackage","tag",["atom"]),o.begin=r("begin","tag",["atom"]),o.end=r("end","tag",["atom"]),o.label=r("label","tag",["atom"]),o.ref=r("ref","tag",["atom"]),o.eqref=r("eqref","tag",["atom"]),o.cite=r("cite","tag",["atom"]),o.bibitem=r("bibitem","tag",["atom"]),o.Bibitem=r("Bibitem","tag",["atom"]),o.RBibitem=r("RBibitem","tag",["atom"]),o.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function a(u,d){u.f=d}function l(u,d){var p;if(u.match(/^\\[a-zA-Z@\xc0-\u1fff\u2060-\uffff]+/)){var m=u.current().slice(1);return p=o.hasOwnProperty(m)?o[m]:o.DEFAULT,p=new p,e(d,p),a(d,h),p.style}if(u.match(/^\\[$&%#{}_]/)||u.match(/^\\[,;!\/\\]/))return"tag";if(u.match("\\["))return a(d,function(v,g){return c(v,g,"\\]")}),"keyword";if(u.match("\\("))return a(d,function(v,g){return c(v,g,"\\)")}),"keyword";if(u.match("$$"))return a(d,function(v,g){return c(v,g,"$$")}),"keyword";if(u.match("$"))return a(d,function(v,g){return c(v,g,"$")}),"keyword";var y=u.next();if(y=="%")return u.skipToEnd(),"comment";if(y=="}"||y=="]"){if(p=t(d),p)p.closeBracket(y),a(d,h);else return"error";return"bracket"}else return y=="{"||y=="["?(p=o.DEFAULT,p=new p,e(d,p),"bracket"):/\d/.test(y)?(u.eatWhile(/[\w.%]/),"atom"):(u.eatWhile(/[\w\-_]/),p=i(d),p.name=="begin"&&(p.argument=u.current()),p.styleIdentifier())}function c(u,d,p){if(u.eatSpace())return null;if(p&&u.match(p))return a(d,l),"keyword";if(u.match(/^\\[a-zA-Z@]+/))return"tag";if(u.match(/^[a-zA-Z]+/))return"variableName.special";if(u.match(/^\\[$&%#{}_]/)||u.match(/^\\[,;!\/]/)||u.match(/^[\^_&]/))return"tag";if(u.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(u.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var m=u.next();return m=="{"||m=="}"||m=="["||m=="]"||m=="("||m==")"?"bracket":m=="%"?(u.skipToEnd(),"comment"):"error"}function h(u,d){var p=u.peek(),m;return p=="{"||p=="["?(m=t(d),m.openBracket(p),u.eat(p),a(d,l),"bracket"):/[ \t\r]/.test(p)?(u.eat(p),null):(a(d,l),s(d),l(u,d))}return{name:"stex",startState:function(){var u=n?function(d,p){return c(d,p)}:l;return{cmdState:[],f:u}},copyState:function(u){return{cmdState:u.cmdState.slice(),f:u.f}},token:function(u,d){return d.f(u,d)},blankLine:function(u){u.f=l,u.cmdState.length=0},languageData:{commentTokens:{line:"%"}}}}const Ate=aL(!1);aL(!0);const FC=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class Iu{constructor(e,t,s=0,i=e.length,r,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(s,i),this.bufferStart=s,this.normalize=r?a=>r(FC(a)):FC,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return qI(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=ZY(e),s=this.bufferStart+this.bufferPos;this.bufferPos+=VI(e);let i=this.normalize(t);if(i.length)for(let r=0,o=s,a=!0;;r++){let l=i.charCodeAt(r),c=this.match(l,o,a,this.bufferPos+this.bufferStart,r==i.length-1);if(c)return this.value=c,this;if(r==i.length-1)break;a&&rthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let s=this.curLineStart+t.index,i=s+t[0].length;if(this.matchPos=zy(this.text,i+(s==i?1:0)),s==this.curLineStart+this.curLine.length&&this.nextLine(),(sthis.value.to)&&(!this.test||this.test(s,i,t)))return this.value={from:s,to:i,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=s||i.to<=t){let a=new vh(t,e.sliceString(t,s));return tb.set(e,a),a}if(i.from==t&&i.to==s)return i;let{text:r,from:o}=i;return o>t&&(r=e.sliceString(t,o)+r,o=t),i.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let s=this.flat.from+t.index,i=s+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(s,i,t)))return this.value={from:s,to:i,precise:!0,match:t},this.matchPos=zy(this.text,i+(s==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=vh.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(cL.prototype[Symbol.iterator]=hL.prototype[Symbol.iterator]=function(){return this});function kte(n){try{return new RegExp(n,lA),!0}catch{return!1}}function zy(n,e){if(e>=n.length)return e;let t=n.lineAt(e),s;for(;e=56320&&s<57344;)e++;return e}const Ete=n=>{let{state:e}=n,t=String(e.doc.lineAt(n.state.selection.main.head).number),{close:s,result:i}=hQ(n,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return i.then(r=>{let o=r&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(r.elements.line.value);if(!o){n.dispatch({effects:s});return}let a=e.doc.lineAt(e.selection.main.head),[,l,c,h,u]=o,d=h?+h.slice(1):0,p=c?+c:a.number;if(c&&u){let v=p/100;l&&(v=v*(l=="-"?-1:1)+a.number/e.doc.lines),p=Math.round(e.doc.lines*v)}else c&&l&&(p=p*(l=="-"?-1:1)+a.number);let m=e.doc.line(Math.max(1,Math.min(e.doc.lines,p))),y=te.cursor(m.from+Math.max(0,Math.min(d,m.length)));n.dispatch({effects:[s,xe.scrollIntoView(y.from,{y:"center"})],selection:y})}),!0},Cte={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},$te=be.define({combine(n){return Hu(n,Cte,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Tte(n){return[Ote,Ite]}const Pte=Qe.mark({class:"cm-selectionMatch"}),Rte=Qe.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function zC(n,e,t,s){return(t==0||n(e.sliceDoc(t-1,t))!=en.Word)&&(s==e.doc.length||n(e.sliceDoc(s,s+1))!=en.Word)}function Mte(n,e,t,s){return n(e.sliceDoc(t,t+1))==en.Word&&n(e.sliceDoc(s-1,s))==en.Word}const Ite=ri.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet($te),{state:t}=n,s=t.selection;if(s.ranges.length>1)return Qe.none;let i=s.main,r,o=null;if(i.empty){if(!e.highlightWordAroundCursor)return Qe.none;let l=t.wordAt(i.head);if(!l)return Qe.none;o=t.charCategorizer(i.head),r=t.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l200)return Qe.none;if(e.wholeWords){if(r=t.sliceDoc(i.from,i.to),o=t.charCategorizer(i.head),!(zC(o,t,i.from,i.to)&&Mte(o,t,i.from,i.to)))return Qe.none}else if(r=t.sliceDoc(i.from,i.to),!r)return Qe.none}let a=[];for(let l of n.visibleRanges){let c=new Iu(t.doc,r,l.from,l.to);for(;!c.next().done;){let{from:h,to:u}=c.value;if((!o||zC(o,t,h,u))&&(i.empty&&h<=i.from&&u>=i.to?a.push(Rte.range(h,u)):(h>=i.to||u<=i.from)&&a.push(Pte.range(h,u)),a.length>e.maxMatches))return Qe.none}}return Qe.set(a)}},{decorations:n=>n.decorations}),Ote=xe.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Nte=({state:n,dispatch:e})=>{let{selection:t}=n,s=te.create(t.ranges.map(i=>n.wordAt(i.head)||te.cursor(i.head)),t.mainIndex);return s.eq(t)?!1:(e(n.update({selection:s})),!0)};function Lte(n,e){let{main:t,ranges:s}=n.selection,i=n.wordAt(t.head),r=i&&i.from==t.from&&i.to==t.to;for(let o=!1,a=new Iu(n.doc,e,s[s.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new Iu(n.doc,e,0,Math.max(0,s[s.length-1].from-1)),o=!0}else{if(o&&s.some(l=>l.from==a.value.from))continue;if(r){let l=n.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}const Dte=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return Nte({state:n,dispatch:e});let s=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=s))return!1;let i=Lte(n,s);return i?(e(n.update({selection:n.selection.addRange(te.range(i.from,i.to),!1),effects:xe.scrollIntoView(i.to)})),!0):!1},Uu=be.define({combine(n){return Hu(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Yte(e),scrollToMatch:e=>xe.scrollIntoView(e)})}});class uL{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||kte(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,s)=>s=="n"?` -`:s=="r"?"\r":s=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Ute(this):new zte(this)}getCursor(e,t=0,s){let i=e.doc?e:at.create({doc:e});return s==null&&(s=i.doc.length),this.regexp?Qc(this,i,t,s):Jc(this,i,t,s)}}class dL{constructor(e){this.spec=e}}function jte(n,e,t){return(s,i,r,o)=>{if(t&&!t(s,i,r,o))return!1;let a=s>=o&&i<=o+r.length?r.slice(s-o,i-o):e.doc.sliceString(s,i);return n(a,e,s,i)}}function Jc(n,e,t,s){let i;return n.wholeWord&&(i=Fte(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(i=jte(n.test,e,i)),new Iu(e.doc,n.unquoted,t,s,n.caseSensitive?void 0:r=>r.toLowerCase(),i)}function Fte(n,e){return(t,s,i,r)=>((r>t||r+i.length=t)return null;i.push(s.value)}return i}highlight(e,t,s,i){let r=Jc(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(s+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}function Hte(n,e,t){return(s,i,r)=>(!t||t(s,i,r))&&n(r[0],e,s,i)}function Qc(n,e,t,s){let i;return n.wholeWord&&(i=Bte(e.charCategorizer(e.selection.main.head))),n.test&&(i=Hte(n.test,e,i)),new cL(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:i},t,s)}function Hy(n,e){return n.slice($n(n,e,!1),e)}function By(n,e){return n.slice(e,$n(n,e))}function Bte(n){return(e,t,s)=>!s[0].length||(n(Hy(s.input,s.index))!=en.Word||n(By(s.input,s.index))!=en.Word)&&(n(By(s.input,s.index+s[0].length))!=en.Word||n(Hy(s.input,s.index+s[0].length))!=en.Word)}class Ute extends dL{nextMatch(e,t,s){let i=Qc(this.spec,e,s,e.doc.length).next();return i.done&&(i=Qc(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,s){for(let i=1;;i++){let r=Math.max(t,s-i*1e4),o=Qc(this.spec,e,r,s),a=null;for(;!o.next().done;)a=o.value;if(a&&(r==t||a.from>r+10))return a;if(r==t)return null}}prevMatch(e,t,s){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,s,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,s)=>{if(s=="&")return e.match[0];if(s=="$")return"$";for(let i=s.length;i>0;i--){let r=+s.slice(0,i);if(r>0&&r=t)return null;i.push(s.value)}return i}highlight(e,t,s,i){let r=Qc(this.spec,e,Math.max(0,t-250),Math.min(s+250,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}const bf=St.define(),cA=St.define(),Ca=Fr.define({create(n){return new nb(J_(n).create(),null)},update(n,e){for(let t of e.effects)t.is(bf)?n=new nb(t.value.create(),n.panel):t.is(cA)&&(n=new nb(n.query,t.value?hA:null));return n},provide:n=>Ny.from(n,e=>e.panel)});class nb{constructor(e,t){this.query=e,this.panel=t}}const qte=Qe.mark({class:"cm-searchMatch"}),Vte=Qe.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Wte=ri.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Ca))}update(n){let e=n.state.field(Ca);(e!=n.startState.field(Ca)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return Qe.none;let{view:t}=this,s=new uf;for(let i=0,r=t.visibleRanges,o=r.length;ir[i+1].from-2*250;)l=r[++i].to;n.highlight(t.state,a,l,(c,h)=>{let u=t.state.selection.ranges.some(d=>d.from==c&&d.to==h);s.add(c,h,u?Vte:qte)})}return s.finish()}},{decorations:n=>n.decorations});function cm(n){return e=>{let t=e.state.field(Ca,!1);return t&&t.query.spec.valid?n(e,t):mL(e)}}const Uy=cm((n,{query:e})=>{let{to:t}=n.state.selection.main,s=e.nextMatch(n.state,t,t);if(!s)return!1;let i=te.single(s.from,s.to),r=n.state.facet(Uu);return n.dispatch({selection:i,effects:[uA(n,s),r.scrollToMatch(i.main,n)],userEvent:"select.search"}),pL(n),!0}),qy=cm((n,{query:e})=>{let{state:t}=n,{from:s}=t.selection.main,i=e.prevMatch(t,s,s);if(!i)return!1;let r=te.single(i.from,i.to),o=n.state.facet(Uu);return n.dispatch({selection:r,effects:[uA(n,i),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),pL(n),!0}),Gte=cm((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:te.create(t.map(s=>te.range(s.from,s.to))),userEvent:"select.search.matches"}),!0)}),Kte=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:s,to:i}=t.main,r=[],o=0;for(let a=new Iu(n.doc,n.sliceDoc(s,i));!a.next().done;){if(r.length>1e3)return!1;a.value.from==s&&(o=r.length),r.push(te.range(a.value.from,a.value.to))}return e(n.update({selection:te.create(r,o),userEvent:"select.search.matches"})),!0},HC=cm((n,{query:e})=>{let{state:t}=n,{from:s,to:i}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,s,s);if(!r)return!1;let o=r,a=[],l,c,h=[];o.precise?o.from==s&&o.to==i&&(c=t.toText(e.getReplacement(o)),a.push({from:o.from,to:o.to,insert:c}),o=e.nextMatch(t,o.from,o.to),h.push(xe.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(s).number)+"."))):o=e.nextMatch(t,o.from,o.to);let u=n.state.changes(a);return o&&(l=te.single(o.from,o.to).map(u),h.push(uA(n,o)),h.push(t.facet(Uu).scrollToMatch(l.main,n))),n.dispatch({changes:u,selection:l,effects:h,userEvent:"input.replace"}),!0}),Zte=cm((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let i of e.matchAll(n.state,1e9)){let{from:r,to:o,precise:a}=i;a&&t.push({from:r,to:o,insert:e.getReplacement(i)})}if(!t.length)return!1;let s=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:xe.announce.of(s),userEvent:"input.replace.all"}),!0});function hA(n){return n.state.facet(Uu).createPanel(n)}function J_(n,e){var t,s,i,r,o;let a=n.selection.main,l=a.empty||a.to>a.from+100?"":n.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=n.facet(Uu);return new uL({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(s=e==null?void 0:e.caseSensitive)!==null&&s!==void 0?s:c.caseSensitive,literal:(i=e==null?void 0:e.literal)!==null&&i!==void 0?i:c.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function fL(n){let e=oN(n,hA);return e&&e.dom.querySelector("[main-field]")}function pL(n){let e=fL(n);e&&e==n.root.activeElement&&e.select()}const mL=n=>{let e=n.state.field(Ca,!1);if(e&&e.panel){let t=fL(n);if(t&&t!=n.root.activeElement){let s=J_(n.state,e.query.spec);s.valid&&n.dispatch({effects:bf.of(s)}),t.focus(),t.select()}}else n.dispatch({effects:[cA.of(!0),e?bf.of(J_(n.state,e.query.spec)):St.appendConfig.of(Qte)]});return!0},gL=n=>{let e=n.state.field(Ca,!1);if(!e||!e.panel)return!1;let t=oN(n,hA);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:cA.of(!1)}),!0},Xte=[{key:"Mod-f",run:mL,scope:"editor search-panel"},{key:"F3",run:Uy,shift:qy,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Uy,shift:qy,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:gL,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Kte},{key:"Mod-Alt-g",run:Ete},{key:"Mod-d",run:Dte,preventDefault:!0}];class Yte{constructor(e){this.view=e;let t=this.query=e.state.field(Ca).query.spec;this.commit=this.commit.bind(this),this.searchField=Cn("input",{value:t.search,placeholder:Vs(e,"Find"),"aria-label":Vs(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Cn("input",{value:t.replace,placeholder:Vs(e,"Replace"),"aria-label":Vs(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Cn("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Cn("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Cn("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function s(i,r,o){return Cn("button",{class:"cm-button",name:i,onclick:r,type:"button"},o)}this.dom=Cn("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,s("next",()=>Uy(e),[Vs(e,"next")]),s("prev",()=>qy(e),[Vs(e,"previous")]),s("select",()=>Gte(e),[Vs(e,"all")]),Cn("label",null,[this.caseField,Vs(e,"match case")]),Cn("label",null,[this.reField,Vs(e,"regexp")]),Cn("label",null,[this.wordField,Vs(e,"by word")]),...e.state.readOnly?[]:[Cn("br"),this.replaceField,s("replace",()=>HC(e),[Vs(e,"replace")]),s("replaceAll",()=>Zte(e),[Vs(e,"replace all")])],Cn("button",{name:"close",onclick:()=>gL(e),"aria-label":Vs(e,"close"),type:"button"},["×"])])}commit(){let e=new uL({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:bf.of(e)}))}keydown(e){XJ(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?qy:Uy)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),HC(this.view))}update(e){for(let t of e.transactions)for(let s of t.effects)s.is(bf)&&!s.value.eq(this.query)&&this.setQuery(s.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Uu).top}}function Vs(n,e){return n.state.phrase(e)}const ng=30,sg=/[\s\.,:;?!]/;function uA(n,{from:e,to:t}){let s=n.state.doc.lineAt(e),i=n.state.doc.lineAt(t).to,r=Math.max(s.from,e-ng),o=Math.min(i,t+ng),a=n.state.sliceDoc(r,o);if(r!=s.from){for(let l=0;la.length-ng;l--)if(!sg.test(a[l-1])&&sg.test(a[l])){a=a.slice(0,l);break}}return xe.announce.of(`${n.state.phrase("current match")}. ${a} ${n.state.phrase("on line")} ${s.number}.`)}const Jte=xe.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Qte=[Ca,q0.low(Wte),Jte],ene=({path:n,value:e,readOnly:t,onChange:s})=>{const i=ee.useRef(null),r=ee.useRef(null),o=ee.useRef(new im),a=ee.useRef(s);return a.current=s,ee.useEffect(()=>{if(!i.current)return;const l=at.create({doc:e,extensions:[wQ(),nQ(),aQ(),wee(),Tte(),eee(),nA.define(Ate),eN.of([...Ste,...Tee,...Xte,xte]),xe.contentAttributes.of({"aria-label":`Editing ${n}`,class:"ph-no-capture","data-ph-no-autocapture":"true","data-ph-no-capture":"true"}),o.current.of(xe.editable.of(!t)),xe.updateListener.of(c=>{c.docChanged&&a.current(c.state.doc.toString())})]});return r.current=new xe({state:l,parent:i.current}),()=>{var c;return(c=r.current)==null?void 0:c.destroy()}},[n]),ee.useEffect(()=>{const l=r.current;!l||l.state.doc.toString()===e||l.dispatch({changes:{from:0,to:l.state.doc.length,insert:e}})},[e]),ee.useEffect(()=>{var l;(l=r.current)==null||l.dispatch({effects:o.current.reconfigure(xe.editable.of(!t))})},[t]),S.jsx("div",{className:"latex-source-editor ph-no-capture","data-ph-no-autocapture":"true","data-ph-no-capture":"true","data-testid":"latex-source-editor",ref:i})},tne="pwc:artifact-navigation";function use(){return typeof window>"u"?!0:window.dispatchEvent(new Event(tne,{cancelable:!0}))}const yL=()=>({open:!1,selectedKey:null,selected:null,selectedVersionId:null,tab:"preview",sourceFile:null,panelPercent:55,requestNonce:0,registry:{},autoOpened:{},manuallyClosed:{}});function nne(n,e){if(e.type==="reset")return{...yL(),panelPercent:n.panelPercent};if(e.type==="register"){const t=n.registry[e.key];if(t&&JSON.stringify(t)===JSON.stringify(e.block))return n;const s={...n.registry,[e.key]:e.block},i=n.selectedKey===e.key?e.block:n.selected,r=(t==null?void 0:t.status)==="generating"&&e.block.status==="ready",o=e.autoOpenOnMount&&!t&&e.block.status==="ready"&&!Object.values(n.autoOpened).some(Boolean);return(r||o)&&!n.autoOpened[e.key]&&!n.manuallyClosed[e.key]?{...n,registry:s,open:!0,selectedKey:e.key,selected:e.block,selectedVersionId:e.block.version_id??null,tab:"preview",sourceFile:null,requestNonce:n.requestNonce+1,autoOpened:{...n.autoOpened,[e.key]:!0}}:{...n,registry:s,selected:i}}return e.type==="unregister"?n:e.type==="open"?{...n,open:!0,selectedKey:e.key,selected:e.block,selectedVersionId:e.block.version_id??null,tab:"preview",sourceFile:null,requestNonce:n.requestNonce+1,manuallyClosed:{...n.manuallyClosed,[e.key]:!1}}:e.type==="close"?{...n,open:!1,manuallyClosed:n.selectedKey?{...n.manuallyClosed,[n.selectedKey]:!0}:n.manuallyClosed}:e.type==="tab"?{...n,tab:e.tab}:e.type==="source"?{...n,sourceFile:e.path}:e.type==="version"?{...n,selectedVersionId:e.versionId,tab:"preview",sourceFile:null}:{...n,panelPercent:e.percent}}function Q_(n){return n.publication_id||n.public_capability||n.version_id||`${n.scope}:${n.identifier}:${n.version??"pending"}`}const vL=ee.createContext(null),dse=({children:n,workspaceKey:e,autoOpenOnMount:t=!1,onAskAiFix:s})=>{const[i,r]=ee.useReducer(nne,void 0,yL),o=ee.useRef(null),a=ee.useRef(e);ee.useEffect(()=>{a.current!==e&&(a.current=e,o.current=null,r({type:"reset"}))},[e]);const l=ee.useCallback(()=>{r({type:"close"}),window.setTimeout(()=>{var b;(b=o.current)!=null&&b.isConnected&&o.current.focus()},0)},[]),c=ee.useCallback(b=>r({type:"register",key:Q_(b),block:b,autoOpenOnMount:t}),[t]),h=ee.useCallback(b=>r({type:"unregister",key:b}),[]),u=ee.useCallback((b,x)=>{const A=document.activeElement;o.current=x??(A instanceof HTMLElement&&A!==document.body?A:null),r({type:"open",key:Q_(b),block:b})},[]),d=ee.useCallback(b=>r({type:"tab",tab:b}),[]),p=ee.useCallback(b=>r({type:"source",path:b}),[]),m=ee.useCallback(b=>r({type:"version",versionId:b}),[]),y=ee.useCallback(b=>r({type:"width",percent:b}),[]),v=ee.useCallback(b=>s==null?void 0:s(b),[s]),g=ee.useCallback(()=>r({type:"reset"}),[]),_=ee.useMemo(()=>({state:i,autoOpenOnMount:t,register:c,unregister:h,open:u,close:l,setTab:d,setSourceFile:p,setVersion:m,setPanelPercent:y,askAiToFix:v,reset:g}),[v,t,l,u,c,g,y,p,d,m,i,h]);return S.jsx(vL.Provider,{value:_,children:n})};function hm(){const n=ee.useContext(vL);if(!n)throw new Error("Poster artifacts require an ArtifactPanelProvider");return n}function sne(n,e,t){return rn(`/api/v1/chat/artifacts/${encodeURIComponent(n)}/versions/${encodeURIComponent(e)}/source/${t.split("/").map(encodeURIComponent).join("/")}`)}function ine(n,e,t){return rn(`/api/v1/chat/artifacts/${encodeURIComponent(n)}/versions/${encodeURIComponent(e)}/figures/${t.split("/").map(encodeURIComponent).join("/")}`)}function rne(n){return rn(`/api/v1/chat/artifacts/${encodeURIComponent(n)}/export/pdf`)}function BC(n,e){return rn(`/api/v1/chat/artifacts/${encodeURIComponent(n)}/versions/${encodeURIComponent(e)}/export/source.zip`)}function ig(n){return`pwc:latex-paper-draft:${n}`}function one(n,e){const t=Object.keys(n).sort(),s=Object.keys(e).sort();return t.length===s.length&&t.every((i,r)=>i===s[r]&&n[i]===e[i])}function UC(n){return!n.includes("\\")&&/^(?!\/)(?!.*(?:^|\/)\.\.?\/)[^\0]{1,300}\.(?:tex|bib)$/iu.test(n)}function ane(n){var s,i;const e=((s=n.provenance)==null?void 0:s.action)??(n.actor_type==="restore"?"restore":n.actor_type==="ai"?"ai_draft":"human_save"),t={human_save:"Human save",ai_draft:"AI draft",ai_repair:"AI repair",restore:"Restore"}[e];return(i=n.provenance)!=null&&i.model_identity?`${t} · ${n.provenance.model_identity}`:t}const lne=({block:n,forceDialog:e=!1})=>{var ks,cs,wn,Kt,Zn,an,Es,qu,Io;const t=hm(),s=ZC(),i=t.close,[r,o]=ee.useState(()=>{var V;return typeof window<"u"&&((V=window.matchMedia)==null?void 0:V.call(window,"(max-width: 760px)").matches)}),[a,l]=ee.useState({}),[c,h]=ee.useState({}),[u,d]=ee.useState(null),[p,m]=ee.useState(!1),[y,v]=ee.useState(!1),[g,_]=ee.useState(null),[b,x]=ee.useState(!1),[A,T]=ee.useState(null),C=ee.useRef(null),I=ee.useRef(null),D=ee.useRef(!1),H=e||r,j=u!==null&&!one(a,c);ee.useEffect(()=>{var Ce,rt;const V=(Ce=window.matchMedia)==null?void 0:Ce.call(window,"(max-width: 760px)");if(!V)return;const ye=()=>o(V.matches);return ye(),(rt=V.addEventListener)==null||rt.call(V,"change",ye),()=>{var qt;return(qt=V.removeEventListener)==null?void 0:qt.call(V,"change",ye)}},[]),ee.useEffect(()=>{var Ce,rt;if(!H)return;(rt=(Ce=I.current)==null?void 0:Ce.querySelector("[data-artifact-close]"))==null||rt.focus(),window.history.pushState({...window.history.state,pwcArtifactPanel:!0},""),D.current=!0;const V=()=>{if(j&&!window.confirm("Leave this view? Unsaved paper edits remain in this browser.")){window.history.pushState({...window.history.state,pwcArtifactPanel:!0},""),D.current=!0;return}D.current=!1,i()},ye=qt=>{qt.key==="Escape"&&(qt.preventDefault(),!(j&&!window.confirm("Leave this view? Unsaved paper edits remain in this browser."))&&(i(),D.current&&(D.current=!1,window.history.back())))};return window.addEventListener("popstate",V),document.addEventListener("keydown",ye),()=>{window.removeEventListener("popstate",V),document.removeEventListener("keydown",ye)}},[i,H,j]),ee.useEffect(()=>{if(!H)return;const V=ye=>{if(ye.key!=="Tab"||!I.current)return;const Ce=[...I.current.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), [contenteditable="true"], [tabindex]:not([tabindex="-1"])')];if(!Ce.length)return;const rt=Ce[0],qt=Ce.at(-1);ye.shiftKey&&document.activeElement===rt?(ye.preventDefault(),qt.focus()):!ye.shiftKey&&document.activeElement===qt&&(ye.preventDefault(),rt.focus())};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[H]),ee.useEffect(()=>{const V=ye=>{j&&(ye.preventDefault(),ye.returnValue="")};return window.addEventListener("beforeunload",V),()=>window.removeEventListener("beforeunload",V)},[j]),ee.useEffect(()=>{const V=ye=>{j&&!window.confirm("Leave this view? Unsaved paper edits remain in this browser.")&&ye.preventDefault()};return window.addEventListener("pwc:artifact-navigation",V),()=>window.removeEventListener("pwc:artifact-navigation",V)},[j]);const U=wo({queryKey:["chat-latex-paper",n.artifact_id],queryFn:async()=>{const V=await fetch(rn(`/api/v1/chat/artifacts/${encodeURIComponent(n.artifact_id)}`),{credentials:"include",cache:"no-store"});if(!V.ok)throw new Error("Could not load paper details");return V.json()},enabled:!!n.artifact_id,staleTime:5e3}),B=U.data,L=B==null?void 0:B.source_head,X=B==null?void 0:B.preview_head,se=wo({queryKey:["chat-latex-paper-history",n.artifact_id,A],queryFn:async()=>{const V=new URLSearchParams({limit:"20"});A&&V.set("cursor",A);const ye=await fetch(rn(`/api/v1/chat/artifacts/${encodeURIComponent(n.artifact_id)}/versions?${V}`),{credentials:"include",cache:"no-store"});if(!ye.ok)throw new Error("Could not load paper history");return ye.json()},enabled:b&&!!n.artifact_id,staleTime:Number.POSITIVE_INFINITY}),J=wo({queryKey:["chat-latex-paper-manifest",n.artifact_id,L==null?void 0:L.version_id],queryFn:async()=>{const V=await fetch(rn(`/api/v1/chat/artifacts/${encodeURIComponent(n.artifact_id)}/versions/${encodeURIComponent(L.version_id)}/manifest`),{credentials:"include",cache:"no-store"});if(!V.ok)throw new Error("Could not load paper files");return V.json()},enabled:t.state.tab==="files"&&!!(L!=null&&L.version_id),staleTime:Number.POSITIVE_INFINITY}),Y=((ks=J.data)==null?void 0:ks.files.filter(V=>V.media_type==="text/x-tex"||V.media_type==="application/x-bibtex"))??[],ge=((cs=J.data)==null?void 0:cs.files.filter(V=>V.media_type==="image/png"||V.media_type==="image/jpeg"||V.media_type==="application/pdf"))??[],z=wo({queryKey:["chat-latex-paper-source-files",n.artifact_id,L==null?void 0:L.version_id],queryFn:async()=>Object.fromEntries(await Promise.all(Y.map(async V=>{const ye=await fetch(sne(n.artifact_id,L.version_id,V.path),{credentials:"include",cache:"no-store"});if(!ye.ok)throw new Error("Could not load paper source");return[V.path,await ye.text()]}))),enabled:t.state.tab==="files"&&!!(L!=null&&L.version_id&&Y.length),staleTime:Number.POSITIVE_INFINITY});ee.useEffect(()=>{m(!1)},[L==null?void 0:L.version_id]),ee.useEffect(()=>{var qt;if(!(L!=null&&L.version_id)||!z.data||C.current===L.version_id)return;const V=z.data;let ye=V,Ce=!1,rt=L.version_id;try{const zr=window.localStorage.getItem(ig(n.artifact_id)),Cs=zr?JSON.parse(zr):null;Cs!=null&&Cs.files&&typeof Cs.files=="object"&&(ye=Cs.files,Ce=Cs.parentVersionId!==L.version_id,rt=Cs.parentVersionId)}catch{}C.current=L.version_id,l(ye),h(V),d(rt),v(Ce),m(!0),Ce&&_("This local draft is based on an older paper version. Copy or discard it before saving the latest version."),(!t.state.sourceFile||!ye[t.state.sourceFile])&&t.setSourceFile(((qt=J.data)==null?void 0:qt.root_document)??null)},[n.artifact_id,(wn=J.data)==null?void 0:wn.root_document,t,L==null?void 0:L.version_id,z.data]),ee.useEffect(()=>{if(!u||!n.artifact_id)return;const V=ig(n.artifact_id);if(!j){window.localStorage.removeItem(V);return}window.localStorage.setItem(V,JSON.stringify({parentVersionId:u,files:a}))},[n.artifact_id,j,u,a]);const E=ym({mutationFn:async()=>{var Ce;if(!(L!=null&&L.version_id))throw new Error("Paper source is not ready to save");const V=await fetch(rn(`/api/v1/chat/artifacts/${encodeURIComponent(n.artifact_id)}/save-compile`),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({expected_parent_version_id:L.version_id,files:Object.entries(a).map(([rt,qt])=>({path:rt,content:qt}))})}),ye=await V.json().catch(()=>null);if(!V.ok)throw new Error(((Ce=ye==null?void 0:ye.detail)==null?void 0:Ce.message)??"Could not save paper");return ye},onSuccess:V=>{var ye,Ce;s.setQueryData(["chat-latex-paper",n.artifact_id],V),s.invalidateQueries({queryKey:["chat-latex-paper-manifest",n.artifact_id]}),s.invalidateQueries({queryKey:["chat-latex-paper-source-files",n.artifact_id]}),C.current=((ye=V.source_head)==null?void 0:ye.version_id)??null,h(a),d(((Ce=V.source_head)==null?void 0:Ce.version_id)??null),window.localStorage.removeItem(ig(n.artifact_id)),_(null),v(!1),t.setTab("preview")},onError:V=>_(V instanceof Error?V.message:"Could not save paper")}),O=ym({mutationFn:async V=>{var rt;if(!(L!=null&&L.version_id))throw new Error("Paper source is not ready to restore");const ye=await fetch(rn(`/api/v1/chat/artifacts/${encodeURIComponent(n.artifact_id)}/versions/restore`),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_version_id:V,expected_parent_version_id:L.version_id})}),Ce=await ye.json().catch(()=>null);if(!ye.ok)throw new Error(((rt=Ce==null?void 0:Ce.detail)==null?void 0:rt.message)??"Could not restore paper version");return Ce},onSuccess:V=>{s.setQueryData(["chat-latex-paper",n.artifact_id],V),s.invalidateQueries({queryKey:["chat-latex-paper-history",n.artifact_id]}),s.invalidateQueries({queryKey:["chat-latex-paper-manifest",n.artifact_id]}),s.invalidateQueries({queryKey:["chat-latex-paper-source-files",n.artifact_id]}),C.current=null,m(!1),T(null),_(null),t.setTab("preview")},onError:V=>_(V instanceof Error?V.message:"Could not restore paper version")}),R=ym({mutationFn:async V=>{var qt;if(!(L!=null&&L.version_id))throw new Error("Paper source is not ready to upload a figure");if(j)throw new Error("Save or discard text edits before uploading a figure");const ye=new FormData;ye.set("expected_parent_version_id",L.version_id),ye.set("path",`figures/${V.name}`),ye.set("figure",V);const Ce=await fetch(rn(`/api/v1/chat/artifacts/${encodeURIComponent(n.artifact_id)}/figures`),{method:"POST",credentials:"include",body:ye}),rt=await Ce.json().catch(()=>null);if(!Ce.ok)throw new Error(((qt=rt==null?void 0:rt.detail)==null?void 0:qt.message)??"Could not upload figure");return rt},onSuccess:V=>{s.setQueryData(["chat-latex-paper",n.artifact_id],V),s.invalidateQueries({queryKey:["chat-latex-paper-manifest",n.artifact_id]}),s.invalidateQueries({queryKey:["chat-latex-paper-source-files",n.artifact_id]}),_(null)},onError:V=>_(V instanceof Error?V.message:"Could not upload figure")}),k=ym({mutationFn:async()=>{const V=await fetch(rn(`/api/v1/chat/artifacts/${encodeURIComponent(n.artifact_id)}/refresh-compile`),{method:"POST",credentials:"include"});if(!V.ok)throw new Error("Could not refresh paper compilation");return V.json()},onSuccess:V=>s.setQueryData(["chat-latex-paper",n.artifact_id],V)}).mutate,N=L==null?void 0:L.version_id,G=L==null?void 0:L.compile_status;ee.useEffect(()=>{if(!N||!n.artifact_id||!["queued","compiling"].includes(G??""))return;const V=window.setTimeout(()=>k(),2e3);return()=>window.clearTimeout(V)},[n.artifact_id,k,G,N]);const Z=t.state.sourceFile??((Kt=J.data)==null?void 0:Kt.root_document)??null,ae=(B==null?void 0:B.editing_enabled)===!0&&!!(L!=null&&L.version_id)&&p&&!y&&!E.isPending,ie=new Map(((Zn=se.data)==null?void 0:Zn.items.map(V=>[V.version_id,V.version]))??[]),Ae=X?rn(`/api/v1/chat/artifacts/${encodeURIComponent(n.artifact_id)}/versions/${encodeURIComponent(X.version_id)}/preview`):null,ct=!!(L&&X&&L.version_id!==X.version_id),Ie=()=>!j||window.confirm("Leave this view? Unsaved paper edits remain in this browser."),Fe=V=>V!==t.state.tab&&!Ie()?!1:(t.setTab(V),!0),Je=V=>{var Ce,rt;if(!["ArrowLeft","ArrowRight","Home","End"].includes(V.key))return;V.preventDefault();const ye=V.key==="ArrowLeft"||V.key==="Home"?"preview":"files";Fe(ye)&&((rt=(Ce=V.currentTarget.parentElement)==null?void 0:Ce.querySelector(`#paper-${ye}-tab`))==null||rt.focus())},it=V=>{V!==Z&&j&&!window.confirm("Switch files? Unsaved edits stay in this browser.")||t.setSourceFile(V)},bn=()=>{const V=window.prompt("New TeX or BibTeX file name","section.tex");if(V){if(!UC(V)||a[V]){_("Choose a new safe .tex or .bib filename.");return}if(Object.keys(a).length>=100){_("A paper can contain at most 100 files.");return}l({...a,[V]:""}),_(null),t.setSourceFile(V)}},ut=()=>{var Ce;if(!Z||Z===((Ce=J.data)==null?void 0:Ce.root_document))return;const V=window.prompt("Rename file",Z);if(!V||V===Z)return;if(!UC(V)||a[V]){_("Choose a new safe .tex or .bib filename.");return}const ye={...a,[V]:a[Z]};delete ye[Z],l(ye),t.setSourceFile(V)},Ss=()=>{var ye,Ce;if(!Z||Z===((ye=J.data)==null?void 0:ye.root_document)||!window.confirm(`Delete ${Z}?`))return;const V={...a};delete V[Z],l(V),t.setSourceFile(((Ce=J.data)==null?void 0:Ce.root_document)??null)},xs=()=>{!y||!window.confirm("Discard this stale local draft?")||(window.localStorage.removeItem(ig(n.artifact_id)),l(c),d((L==null?void 0:L.version_id)??null),v(!1),_(null))},Pn=()=>{Ie()&&(i(),H&&D.current&&(D.current=!1,window.history.back()))},ls=()=>{if(!L||L.compile_status!=="failed"||L.repair_exhausted)return;const V=(L.compile_diagnostics??[]).slice(0,20).map(ye=>`${ye.file??"project"}${ye.line?`:${ye.line}`:""}: ${ye.message}`).join(` -`);t.askAiToFix(`Repair the failed paper source version ${L.version_id}. Use pwc-paper to inspect and repair it; make no more than three attempts. Compiler diagnostics: -${V||"No compiler diagnostic was available."}`)},As=V=>{!V||!Fe("files")||t.setSourceFile(V)};return S.jsxs("section",{ref:I,className:`chat-artifact-panel${H?" is-dialog":" is-docked"}`,role:H?"dialog":"complementary","aria-modal":H?!0:void 0,"aria-labelledby":"latex-paper-title","data-testid":"latex-paper-panel",children:[S.jsxs("header",{children:[S.jsxs("div",{children:[S.jsx("span",{children:"Private paper"}),S.jsx("h2",{id:"latex-paper-title",children:n.title}),S.jsxs("p",{className:"chat-paper-status",role:"status","aria-live":"polite",children:[L?`Source v${L.version} · ${L.compile_status}`:"Preparing paper source",ct?" · Preview out of date":""]}),S.jsx("p",{className:"chat-paper-privacy-note",children:"This paper is private to this chat. Source, figures, and PDFs are stored privately; AI-authored text needs your review."})]}),S.jsxs("div",{className:"chat-artifact-header-actions",children:[S.jsx("button",{type:"button","aria-expanded":b,"aria-controls":"paper-version-history",onClick:()=>{T(null),x(!b)},children:"Version history"}),S.jsx("button",{type:"button","data-artifact-close":!0,"aria-label":H?"Back to conversation":"Close paper",onClick:Pn,children:S.jsx(c0,{})})]})]}),S.jsxs("nav",{"aria-label":"Paper views",role:"tablist",children:[S.jsx("button",{type:"button",id:"paper-preview-tab",role:"tab","aria-selected":t.state.tab==="preview","aria-controls":"paper-preview-panel",tabIndex:t.state.tab==="preview"?0:-1,className:t.state.tab==="preview"?"active":"",onClick:()=>Fe("preview"),onKeyDown:Je,children:"Preview"}),S.jsx("button",{type:"button",id:"paper-files-tab",role:"tab","aria-selected":t.state.tab==="files","aria-controls":"paper-files-panel",tabIndex:t.state.tab==="files"?0:-1,className:t.state.tab==="files"?"active":"",onClick:()=>Fe("files"),onKeyDown:Je,children:"Files"})]}),S.jsxs("div",{id:t.state.tab==="preview"?"paper-preview-panel":"paper-files-panel",role:"tabpanel","aria-labelledby":t.state.tab==="preview"?"paper-preview-tab":"paper-files-tab",className:"chat-artifact-panel-body",children:[t.state.tab==="preview"?U.isError?S.jsxs("div",{role:"alert",children:["Could not load paper details. ",S.jsx("button",{type:"button",onClick:()=>void U.refetch(),children:"Retry paper details"})]}):Ae?S.jsx(HY,{url:Ae,downloadUrl:rne(n.artifact_id),paperKey:`${n.artifact_id}:${X==null?void 0:X.version_id}`,paperTitle:n.title,paperHref:"/chat",chrome:"canvas"},X==null?void 0:X.version_id):L?L.compile_status==="failed"?S.jsx("p",{role:"alert",children:"No compiled preview is available for this failed source version. Review the diagnostics or fix the paper in Files."}):["queued","compiling"].includes(L.compile_status)?S.jsx("p",{role:"status",children:"Preview is compiling. The stored source is available in Files."}):S.jsx("p",{role:"alert",children:"No compiled preview is available for this source version."}):S.jsx("p",{role:"status",children:"Paper source and compiled preview are not available yet."}):S.jsxs("div",{className:"chat-artifact-source-workspace",children:[S.jsxs("nav",{"aria-label":"Paper source files",children:[Y.map(V=>S.jsx("button",{type:"button","aria-pressed":Z===V.path,onClick:()=>it(V.path),children:V.path},V.path)),ae&&S.jsxs("button",{type:"button",className:"latex-file-action","aria-label":"Add TeX file",onClick:bn,children:[S.jsx(lD,{})," Add file"]}),ae&&S.jsxs("label",{className:"latex-file-action",children:["Upload figure",S.jsx("input",{"aria-label":"Upload figure",type:"file",accept:"image/png,image/jpeg,application/pdf,.png,.jpg,.jpeg,.pdf",disabled:R.isPending,onChange:V=>{var Ce;const ye=(Ce=V.currentTarget.files)==null?void 0:Ce[0];V.currentTarget.value="",ye&&R.mutate(ye)}})]}),ge.map(V=>L&&S.jsx("a",{href:ine(n.artifact_id,L.version_id,V.path),download:!0,children:V.path},V.path))]}),S.jsxs("div",{className:"latex-editor-column",children:[Z&&a[Z]!==void 0?S.jsx(ene,{path:Z,value:a[Z],readOnly:!ae,onChange:V=>l({...a,[Z]:V})}):S.jsx("p",{children:z.isError?"Source could not be loaded.":"Loading source…"}),ae&&Z&&Z!==((an=J.data)==null?void 0:an.root_document)&&S.jsxs("div",{className:"latex-file-buttons",children:[S.jsxs("button",{type:"button",onClick:ut,children:[S.jsx(r$,{})," Rename"]}),S.jsxs("button",{type:"button",onClick:Ss,children:[S.jsx(GL,{})," Delete"]})]})]})]}),b&&S.jsxs("section",{id:"paper-version-history",className:"chat-artifact-history","aria-label":"Paper version history",children:[S.jsx("h3",{children:"Version history"}),se.isLoading&&S.jsx("p",{children:"Loading history…"}),se.isError&&S.jsx("p",{role:"alert",children:"Paper history could not be loaded."}),(Es=se.data)==null?void 0:Es.items.map(V=>{var ye,Ce,rt,qt;return S.jsxs("article",{children:[S.jsxs("strong",{children:["v",V.version," · ",V.compile_status]}),S.jsx("span",{children:ane(V)}),V.created_at&&S.jsx("time",{dateTime:V.created_at,children:V.created_at}),V.parent_version_id&&S.jsxs("span",{children:["Parent ",ie.has(V.parent_version_id)?`v${ie.get(V.parent_version_id)}`:V.parent_version_id]}),(ye=V.provenance)!=null&&ye.changed_files.length?S.jsxs("span",{children:["Changed: ",V.provenance.changed_files.join(", ")]}):null,((Ce=V.provenance)==null?void 0:Ce.restored_from_version_id)&&S.jsxs("span",{children:["Restored from ",V.provenance.restored_from_version_id]}),((rt=V.provenance)==null?void 0:rt.change_summary)&&S.jsx("p",{children:V.provenance.change_summary}),(qt=V.provenance)==null?void 0:qt.reference_changes.map(zr=>S.jsx("p",{children:zr},zr)),S.jsx("a",{href:BC(n.artifact_id,V.version_id),download:!0,children:"Source ZIP"}),(B==null?void 0:B.editing_enabled)&&(L==null?void 0:L.version_id)&&V.version_id!==L.version_id&&S.jsxs("button",{type:"button",disabled:O.isPending||j,onClick:()=>O.mutate(V.version_id),children:["Restore version ",V.version]})]},V.version_id)}),((qu=se.data)==null?void 0:qu.next_cursor)&&S.jsx("button",{type:"button",onClick:()=>T(se.data.next_cursor??null),children:"Load older versions"})]})]}),S.jsxs("footer",{children:[S.jsxs("div",{className:"chat-artifact-metadata","aria-live":"polite",children:[ct&&S.jsx("strong",{children:"Out of date"}),(Io=L==null?void 0:L.compile_diagnostics)==null?void 0:Io.map((V,ye)=>S.jsxs("button",{type:"button",onClick:()=>As(V.file),className:"latex-compile-diagnostic",children:[V.file?`${V.file}${V.line?`:${V.line}`:""}: `:"",V.message]},`${V.file??"global"}:${V.line??""}:${ye}`)),g&&S.jsx("span",{role:"alert",children:g}),y&&S.jsx("button",{type:"button",onClick:xs,children:"Discard stale local draft"})]}),S.jsxs("div",{className:"chat-artifact-actions",children:[(L==null?void 0:L.compile_status)==="failed"&&!L.repair_exhausted&&S.jsx("button",{type:"button",onClick:ls,children:"Ask AI to fix"}),(L==null?void 0:L.compile_status)==="failed"&&L.repair_exhausted&&S.jsx("span",{role:"status",children:"AI repair attempts exhausted"}),t.state.tab==="files"&&ae&&S.jsxs("button",{type:"button",disabled:!j,onClick:()=>E.mutate(),children:[S.jsx(uD,{}),E.isPending?"Saving…":"Save & Compile"]}),L&&S.jsxs("a",{href:BC(n.artifact_id,L.version_id),download:!0,children:[S.jsx(nS,{})," Source ZIP"]})]})]})]})},cne="https://github.com/Chenruishuo/posterly/tree/b9f42e5578a49a27525a68f85376bb3bb25af86f";function hne(){if(typeof window>"u")return null;const n=window.location.pathname.match(/^\/share\/([^/]+)/u);return n?decodeURIComponent(n[1]):null}function bL(n){if(n.scope==="public"){const s=hne();if(!s||!n.public_capability)return null;const i=`/api/v1/chat/shares/${encodeURIComponent(s)}/artifacts/${encodeURIComponent(n.public_capability)}`;return{preview:rn(`${i}/preview`),png:rn(`${i}/download/png`),pdf:rn(`${i}/download/pdf`),manifest:null,source:null,gate:null,download:null}}if(!n.artifact_id||!n.version_id)return null;const e=`/api/v1/chat/artifacts/${encodeURIComponent(n.artifact_id)}/versions/${encodeURIComponent(n.version_id)}`,t=(s,i)=>rn(`${e}/${s}/${i.split("/").map(encodeURIComponent).join("/")}`);return{preview:rn(`${e}/preview`),png:t("download","poster.png"),pdf:null,manifest:rn(`${e}/manifest`),source:s=>t("source",s),gate:s=>t("source",s),download:s=>t("download",s)}}const wL=n=>({passed:"Passed",warnings:"Passed with warnings",failed:"Draft—checks failed"})[n??"passed"];function une(){const[n,e]=ee.useState(()=>{var t;return typeof window<"u"&&((t=window.matchMedia)==null?void 0:t.call(window,"(max-width: 760px)").matches)});return ee.useEffect(()=>{var i,r;const t=(i=window.matchMedia)==null?void 0:i.call(window,"(max-width: 760px)");if(!t)return;const s=()=>e(t.matches);return s(),(r=t.addEventListener)==null||r.call(t,"change",s),()=>{var o;return(o=t.removeEventListener)==null?void 0:o.call(t,"change",s)}},[]),n}const dne=({forceDialog:n=!1,readerFallback:e=!1})=>{var A,T,C,I;const t=hm(),s=t.close,{state:i}=t,r=i.selected,o=une(),a=n||o,l=ee.useRef(null),c=ee.useRef(!1),h=wo({queryKey:["chat-artifact-versions",r==null?void 0:r.artifact_id],queryFn:async()=>{const D=await fetch(rn(`/api/v1/chat/artifacts/${encodeURIComponent(r.artifact_id)}`),{credentials:"include",cache:"no-store"});if(!D.ok)throw new Error("Could not load poster versions");return(await D.json()).versions},enabled:i.open&&(r==null?void 0:r.scope)==="owner"&&!!r.artifact_id,staleTime:Number.POSITIVE_INFINITY}),u=(A=h.data)==null?void 0:A.find(D=>D.version_id===i.selectedVersionId),d=r&&u?{...r,version_id:u.version_id,version:u.version,gate_status:u.gate_status,total_bytes:u.total_bytes}:r,p=d?bL(d):null,y=wo({queryKey:["chat-artifact-manifest",d==null?void 0:d.version_id],queryFn:async()=>{const D=await fetch(p.manifest,{credentials:"include",cache:"no-store"});if(!D.ok)throw new Error("Could not load poster details");return D.json()},enabled:i.open&&(d==null?void 0:d.scope)==="owner"&&!!(p!=null&&p.manifest),staleTime:Number.POSITIVE_INFINITY}).data,v=i.sourceFile??(y==null?void 0:y.entrypoint)??null,g=wo({queryKey:["chat-artifact-source",d==null?void 0:d.version_id,v],queryFn:async()=>{const D=await fetch(p.source(v),{credentials:"include",cache:"no-store"});if(!D.ok)throw new Error("Source could not be loaded");return D.text()},enabled:i.open&&i.tab==="source"&&(d==null?void 0:d.scope)==="owner"&&!!(v&&(p!=null&&p.source)),staleTime:Number.POSITIVE_INFINITY});if(ee.useEffect(()=>{var H,j;if(!i.open||!a)return;(j=(H=l.current)==null?void 0:H.querySelector("[data-artifact-close]"))==null||j.focus(),window.history.pushState({...window.history.state,pwcArtifactPanel:!0},""),c.current=!0;const D=()=>{c.current=!1,s()};return window.addEventListener("popstate",D),()=>window.removeEventListener("popstate",D)},[s,a,i.open]),ee.useEffect(()=>{if(!i.open||!a)return;const D=H=>{if(H.key==="Escape"){H.preventDefault(),s(),c.current&&(c.current=!1,window.history.back());return}if(H.key!=="Tab"||!l.current)return;const j=[...l.current.querySelectorAll('button:not([disabled]), a[href], select:not([disabled]), [tabindex]:not([tabindex="-1"])')];if(!j.length)return;const U=j[0],B=j.at(-1);H.shiftKey&&document.activeElement===U?(H.preventDefault(),B.focus()):!H.shiftKey&&document.activeElement===B&&(H.preventDefault(),U.focus())};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[s,a,i.open]),!i.open||!d||!p)return null;const _=()=>{s(),a&&c.current&&(c.current=!1,window.history.back())},b=(T=y==null?void 0:y.downloads[0])==null?void 0:T.path,x=d.scope==="public"?p.pdf:b&&p.download?p.download(b):null;return S.jsxs("section",{ref:l,className:`chat-artifact-panel${a?" is-dialog":" is-docked"}${e?" is-reader-fallback":""}`,role:a?"dialog":"complementary","aria-modal":a?!0:void 0,"aria-label":d.title,"data-testid":"artifact-panel",children:[S.jsxs("header",{children:[S.jsxs("div",{children:[S.jsx("span",{children:"Posterly artifact"}),S.jsx("h2",{children:d.title})]}),(((C=h.data)==null?void 0:C.length)??0)>1&&S.jsxs("label",{className:"chat-artifact-version",children:["Version",S.jsx("select",{"aria-label":"Poster version",value:d.version_id,onChange:D=>t.setVersion(D.target.value),children:[...h.data??[]].reverse().map(D=>S.jsxs("option",{value:D.version_id,children:["v",D.version]},D.version_id))})]}),S.jsx("button",{type:"button","data-artifact-close":!0,"aria-label":a?"Back to conversation":"Close poster",onClick:_,children:S.jsx(c0,{})})]}),S.jsxs("nav",{"aria-label":"Poster views",children:[S.jsx("button",{type:"button","aria-pressed":i.tab==="preview",className:i.tab==="preview"?"active":"",onClick:()=>t.setTab("preview"),children:"Preview"}),d.scope==="owner"&&S.jsx("button",{type:"button","aria-pressed":i.tab==="source",className:i.tab==="source"?"active":"",onClick:()=>t.setTab("source"),children:"Source"})]}),S.jsx("div",{className:"chat-artifact-panel-body",children:i.tab==="preview"?S.jsx("img",{src:p.preview,alt:`Full preview of ${d.title}`}):S.jsxs("div",{className:"chat-artifact-source-workspace",children:[(((I=y==null?void 0:y.source_files)==null?void 0:I.length)??0)>1&&S.jsx("nav",{"aria-label":"Poster source files",children:y.source_files.map(D=>S.jsx("button",{type:"button","aria-pressed":v===D,onClick:()=>t.setSourceFile(D),children:D},D))}),S.jsx("pre",{children:S.jsx("code",{children:g.isError?"Source could not be loaded.":g.data??"Loading source…"})})]})}),S.jsxs("footer",{children:[S.jsxs("div",{className:"chat-artifact-metadata",children:[S.jsx("strong",{children:wL(d.gate_status)}),y&&S.jsxs("span",{children:[y.canvas.width," × ",y.canvas.height," ",y.canvas.unit," · ",y.canvas.orientation," · ",y.direction]}),y==null?void 0:y.gate_summary.map(D=>S.jsx("span",{children:D},D))]}),S.jsxs("div",{className:"chat-artifact-actions",children:[S.jsxs("a",{href:p.png,download:!0,children:[S.jsx(bA,{})," PNG"]}),d.gate_status!=="failed"&&x&&S.jsxs("a",{href:x,download:!0,children:[S.jsx(bA,{})," PDF"]}),d.scope==="owner"&&y&&p.source&&S.jsxs("a",{href:p.source(y.entrypoint),download:!0,children:[S.jsx(nS,{})," HTML"]}),d.scope==="owner"&&y&&p.gate&&S.jsx("a",{href:p.gate(y.gate_report),download:!0,children:"Gate report"}),S.jsxs("a",{href:cne,target:"_blank",rel:"noreferrer",children:[S.jsx(n$,{})," Posterly source · AGPL-3.0"]})]})]})]})},qC=n=>{var t;const{state:e}=hm();return((t=e.selected)==null?void 0:t.artifact_kind)==="latex_paper"?S.jsx(lne,{block:e.selected,...n}):S.jsx(dne,{...n})},fne=({block:n})=>{const e=hm(),t=e.register,s=e.unregister,i=Q_(n);if(ee.useEffect(()=>{t(n)},[n,t]),ee.useEffect(()=>()=>s(i),[i,s]),n.status==="generating")return S.jsxs("div",{className:"chat-artifact-card chat-artifact-generating",role:"status",children:[S.jsx("span",{className:"chat-artifact-pulse","aria-hidden":"true"}),S.jsxs("span",{children:[S.jsx("strong",{children:n.title}),S.jsx("small",{children:"Publishing Posterly preview…"})]})]});if(n.status==="error")return S.jsxs("div",{className:"chat-artifact-card chat-artifact-error",role:"alert",children:[S.jsx(nS,{"aria-hidden":"true"}),S.jsxs("span",{children:[S.jsx("strong",{children:n.title}),S.jsx("small",{children:n.error_message??"Poster publication failed."})]})]});const r=bL(n);if(!r)return null;const o=e.state.open&&e.state.selectedKey===i;return S.jsxs("button",{type:"button",className:`chat-artifact-card${o?" is-selected":""}`,"aria-pressed":o,onClick:a=>e.open(n,a.currentTarget),children:[S.jsx("img",{src:r.preview,alt:`Preview of ${n.title}`}),S.jsxs("span",{className:"chat-artifact-card-copy",children:[S.jsxs("span",{className:"chat-artifact-kicker",children:[S.jsx(cD,{"aria-hidden":"true"})," Posterly · v",n.version]}),S.jsx("strong",{children:n.title}),S.jsx("small",{className:`chat-artifact-gate chat-artifact-gate-${n.gate_status}`,children:wL(n.gate_status)})]})]})};function pne(n){if(!n.authors.length)return"";const e=n.authors.slice(0,3).map(t=>t.name).join(", ");return n.authors.length>3?`${e}, et al.`:e}function mne(n){var t;if(n.conference)return n.conference;const e=(t=n.published)==null?void 0:t.slice(0,4);if(n.arxiv_id)return e?`arXiv ${e}`:"arXiv";if(n.source_url)try{return new URL(n.source_url).hostname.replace(/^www\./,"")}catch{}return e??"external"}function gne(n,e=240){const t=n.content.trim();return t.length<=e?t:`${t.slice(0,e).trimEnd()}…`}const yne="https://huggingface.co/pro",vne="https://huggingface.co/docs/inference-providers/pricing",bne="https://paperswithcode.co/chat",_L=()=>S.jsx("span",{className:"chat-caret"}),wne=n=>{var t;if(!n.streaming)return!1;const e=(t=n.blocks)==null?void 0:t.at(-1);return e?e.kind==="reasoning"?!e.active:e.kind==="tool"?e.status!=="running":!1:!0},_ne=n=>{var p,m;const e=n.currentTarget,t=e.ownerDocument,s=(p=t.caretPositionFromPoint)==null?void 0:p.call(t,n.clientX,n.clientY),i=s?null:(m=t.caretRangeFromPoint)==null?void 0:m.call(t,n.clientX,n.clientY),r=(s==null?void 0:s.offsetNode)??(i==null?void 0:i.startContainer),o=(s==null?void 0:s.offset)??(i==null?void 0:i.startOffset);if(!(r instanceof Text)||o===void 0||!e.contains(r))return;const a=r.data,l=/[\p{L}\p{M}\p{N}_'-]/u;let c=Math.min(o,a.length),h=c;for(;c>0&&l.test(a[c-1]);)c-=1;for(;h"]+/gi,VC=/[.,;:!?'"\]}>*_]+$/,xne=n=>{let e=n.replace(VC,"");for(;e.endsWith(")")&&e.split("(").length{const t=[];let s=0;for(const i of n.matchAll(Sne)){const r=xne(i[0]);r.endsWith("://")||(t.push(n.slice(s,i.index)),t.push(S.jsx("a",{className:"chat-user-link",href:r,target:"_blank",rel:"noopener noreferrer",children:r},`${e}-${i.index}`)),s=i.index+r.length)}return t.push(n.slice(s)),t},Ane=({text:n,mentions:e})=>{const t=[];let s=0;for(const i of[...e].sort((r,o)=>r.start-o.start)){const r=n.slice(i.start,i.end);i.startn.length||r!==i.title&&r!==`@${i.title}`||(t.push(...WC(n.slice(s,i.start),`text-${s}`)),t.push(S.jsxs("span",{className:"chat-inline-paper-mention",children:[S.jsx(t$,{size:13,"aria-hidden":"true"}),S.jsx(u0,{routeId:i.route_id,className:"chat-inline-paper-link",children:r.startsWith("@")?r.slice(1):r})]},i.key)),s=i.end)}return t.push(...WC(n.slice(s),`text-${s}`)),S.jsx(S.Fragment,{children:t})},kne=({block:n,papers:e,citations:t,webCitations:s,onToggle:i})=>n.active?S.jsxs("div",{className:"chat-reason-live",children:[S.jsxs("div",{className:"chat-reason-live-head",children:[S.jsx(tS,{})," ",S.jsx("span",{children:"Thinking…"})]}),S.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[S.jsx(sb,{text:n.text,streaming:!0,papers:e,citations:t,webCitations:s}),S.jsx(_L,{})]})]}):S.jsxs("div",{className:"chat-reason-done",children:[S.jsxs("button",{type:"button",className:"chat-reason-done-head",onClick:i,"aria-expanded":n.open,children:[S.jsx(HL,{}),S.jsx("span",{children:"Thought for a few seconds"}),S.jsx(QC,{open:n.open})]}),n.open&&S.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:S.jsx(sb,{text:n.text,papers:e,citations:t,webCitations:s})})]}),Ene=({block:n,papers:e,onToggle:t})=>{var d,p,m,y;const s=n.status==="running",i=s&&n.argumentState==="streaming",r=n.schema_version===2||!!n.content,o=n.status==="error"||n.status==="denied",a=typeof n.args.query=="string"?n.args.query:"",l=typeof n.args.command=="string"?n.args.command:typeof n.args.file_path=="string"?n.args.file_path:a,c=n.name.startsWith("pwc_")?Object.entries(n.args).filter(([,v])=>v!=null&&v!=="").map(([v,g])=>`${v}=${typeof g=="string"?g:JSON.stringify(g)}`).join(" · "):r?l:`("${a}")`,h=((d=n.content)==null?void 0:d.map(v=>v.text).join(""))??"",u=i?"streaming arguments…":s?"running…":r?`${n.status} · ${n.took_ms??0} ms`:`${n.hits} results · ${n.took_ms} ms`;return S.jsxs("div",{className:`chat-tool${s?" chat-tool-running":""}${o?" chat-tool-failed":""}`,children:[S.jsxs("button",{type:"button",className:"chat-tool-head",onClick:t,"aria-expanded":n.open,children:[S.jsxs("span",{className:"chat-tool-head-left",children:[s?S.jsx(tS,{}):S.jsx(BL,{}),S.jsx("code",{className:"chat-tool-name",children:n.name}),S.jsx("span",{className:"chat-tool-query",title:c,children:c})]}),S.jsxs("span",{className:"chat-tool-head-right",children:[S.jsx("span",{className:"chat-tool-status",children:u}),S.jsx(QC,{open:n.open})]})]}),n.open&&S.jsxs("div",{className:"chat-tool-body",children:[S.jsxs("div",{className:"chat-tool-args",children:[S.jsxs("span",{className:"chat-tool-label",children:["arguments",n.arguments_redacted?" · redacted":""]}),S.jsx("pre",{children:n.argumentState==="streaming"&&!n.arguments_redacted&&n.argumentText||JSON.stringify(n.args,null,2)})]}),!s&&r?S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"chat-tool-output-head",children:[S.jsx("span",{className:"chat-tool-label",children:"result"}),S.jsx("button",{type:"button",className:"chat-tool-copy",onClick:()=>void navigator.clipboard.writeText(h),children:"Copy"})]}),S.jsx("pre",{className:"chat-tool-output",children:S.jsx("code",{children:h})}),((p=n.metadata)==null?void 0:p.output_truncated)&&S.jsx("div",{className:"chat-tool-truncated",children:"Output was truncated."})]}):s?null:S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"chat-tool-label chat-tool-results-label",children:["returned ",((m=n.results)==null?void 0:m.length)??0," papers"]}),S.jsx("ol",{className:"chat-tool-results",children:(y=n.results)==null?void 0:y.map(v=>S.jsxs("li",{className:"chat-hit",children:[S.jsx("div",{className:"chat-hit-top",children:S.jsx(c$,{routeId:v.route_id,paper:e[v.route_id],className:"chat-hit-title",children:v.title})}),S.jsx("div",{className:"chat-hit-meta",children:[pne(v.metadata),mne(v.metadata)].filter(Boolean).join(" · ")}),S.jsxs("div",{className:"chat-hit-snippet",children:[gne(v),v.content_truncated&&S.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},v.route_id))})]})]})]})},Cne=({block:n,papers:e,citations:t,webCitations:s,streaming:i})=>S.jsxs("div",{className:"chat-answer",children:[S.jsx(sb,{text:n.text,streaming:i,papers:e,citations:t,webCitations:s}),i&&!!n.text.trim()&&S.jsx(_L,{})]}),$ne=({block:n})=>S.jsx(H6,{block:n}),SL=n=>{const e=ee.useRef(null),t=ee.useCallback(()=>{const s=e.current;if(!s)return;s.style.height="auto";const i=Math.max(120,window.innerHeight*.4);s.style.height=`${Math.min(s.scrollHeight,i)}px`,s.style.overflowY=s.scrollHeight>i?"auto":"hidden"},[]);return ee.useLayoutEffect(()=>{var s,i;(s=e.current)==null||s.focus(),(i=e.current)==null||i.setSelectionRange(n.length,n.length),t()},[t,n.length]),{textareaRef:e,resize:t}},Tne=({id:n,text:e,paperSelection:t,editNotice:s,onCancel:i,onResend:r,onResendDraft:o})=>{const[a,l]=ee.useState(e),[c,h]=ee.useState(t),[u,d]=ee.useState(!1),{textareaRef:p,resize:m}=SL(e);ee.useLayoutEffect(m,[m,a]);const y=!!a.trim()&&a.length<=8e3,v=()=>{if(!y||u)return;d(!0),((o==null?void 0:o({text:a,paperMentions:[],...c?{paperSelection:c}:{}}))??(r==null?void 0:r(a))??!1)||d(!1)};return S.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":n,children:S.jsxs("div",{className:"chat-inline-editor",children:[c&&S.jsx(d0,{selection:c,editable:!0,onRemove:()=>h(void 0)}),S.jsx("textarea",{ref:p,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:a,maxLength:8e3,onChange:g=>l(g.target.value),onKeyDown:g=>{g.key==="Escape"?(g.preventDefault(),i==null||i()):g.key==="Enter"&&!g.shiftKey&&!g.nativeEvent.isComposing&&(g.preventDefault(),v())}}),s&&S.jsx("div",{className:"chat-inline-editor-notice",children:s}),S.jsxs("div",{className:"chat-inline-editor-actions",children:[S.jsx("button",{type:"button",onClick:i,children:"Cancel"}),S.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!y||u,onClick:v,children:"Send"})]})]})})},Pne=({id:n,text:e,paperMentions:t,paperSelection:s,enabled:i,editNotice:r,onCancel:o,onResend:a,onResendDraft:l})=>{const[c,h]=ee.useState({text:e,paperMentions:t,...s?{paperSelection:s}:{}}),[u,d]=ee.useState(!1),[p,m]=ee.useState(0),{textareaRef:y,resize:v}=SL(e),g=XC({draft:c,onChange:h,enabled:i,textareaRef:y});ee.useLayoutEffect(v,[v,c.text]);const _=!!c.text.trim()&&c.text.length<=8e3&&(i||c.paperMentions.length===0),b=()=>{if(!_||u)return;d(!0),((l==null?void 0:l(c))??(a==null?void 0:a(c.text))??!1)||d(!1)};return S.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":n,children:S.jsxs("div",{className:"chat-inline-editor",children:[c.paperSelection&&S.jsx(d0,{selection:c.paperSelection,editable:!0,onRemove:()=>h({text:c.text,paperMentions:c.paperMentions})}),S.jsxs("div",{className:"chat-inline-editor-textarea-wrap",children:[S.jsx(YC,{text:c.text,mentions:c.paperMentions,scrollTop:p,variant:"editor"}),S.jsx("textarea",{ref:y,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:c.text,maxLength:8e3,role:"combobox","aria-autocomplete":"list","aria-expanded":g.open,"aria-controls":g.open?g.pickerId:void 0,"aria-activedescendant":g.open&&g.results.length?`${g.optionIdPrefix}-${g.activeIndex}`:void 0,onChange:x=>g.updateText(x.target.value,x.target.selectionStart),onSelect:x=>g.refresh(x.currentTarget.selectionStart),onScroll:x=>m(x.currentTarget.scrollTop),onKeyDown:x=>{g.keyDown(x)||(x.key==="Escape"?(x.preventDefault(),o==null||o()):x.key==="Enter"&&!x.shiftKey&&!x.nativeEvent.isComposing&&(x.preventDefault(),b()))}}),S.jsx(JC,{open:g.open,query:g.query,results:g.results,activeIndex:g.activeIndex,loading:g.loading,error:g.error,onSelect:g.select,id:g.pickerId,optionIdPrefix:g.optionIdPrefix})]}),!i&&c.paperMentions.length>0&&S.jsx("div",{className:"chat-inline-editor-notice",role:"status",children:"Paper mentions are currently disabled. Remove them before sending."}),r&&S.jsx("div",{className:"chat-inline-editor-notice",children:r}),S.jsxs("div",{className:"chat-inline-editor-actions",children:[S.jsx("button",{type:"button",onClick:o,children:"Cancel"}),S.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!_||u,onClick:b,children:"Send"})]})]})})},fse=({id:n,text:e,paperMentions:t=[],paperSelection:s,paperMentionsEnabled:i=!1,editingAllowed:r=!1,editing:o=!1,editNotice:a,onEdit:l,onCancel:c,onResend:h,onResendDraft:u})=>{const[d,p]=ee.useState(!1),m=ee.useRef(null);ee.useEffect(()=>()=>{m.current!==null&&window.clearTimeout(m.current)},[]);const y=async()=>{var v;if((v=navigator.clipboard)!=null&&v.writeText)try{await navigator.clipboard.writeText(e),p(!0),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>p(!1),1500)}catch{}};return o?!i&&t.length===0?S.jsx(Tne,{id:n,text:e,paperSelection:s,editNotice:a,onCancel:c,onResend:h,onResendDraft:u}):S.jsx(Pne,{id:n,text:e,paperMentions:t,paperSelection:s,enabled:i,editNotice:a,onCancel:c,onResend:h,onResendDraft:u}):S.jsx("div",{className:"chat-msg chat-msg-user","data-message-id":n,children:S.jsxs("div",{className:"chat-user-message-wrap",children:[s&&S.jsx(d0,{selection:s}),S.jsx("div",{className:"chat-bubble",onDoubleClick:_ne,children:S.jsx(Ane,{text:e,mentions:t})}),S.jsxs("div",{className:"chat-user-actions",children:[S.jsx("button",{type:"button",className:"chat-user-action","aria-label":d?"Message copied":"Copy message",title:d?"Copied":"Copy",onClick:()=>void y(),children:d?S.jsx(IL,{"aria-hidden":"true"}):S.jsx(eD,{"aria-hidden":"true"})}),r&&S.jsx("button",{type:"button",className:"chat-user-action","aria-label":"Edit message",title:"Edit",onClick:l,children:S.jsx(r$,{"aria-hidden":"true"})})]})]})})},pse=({msg:n,papers:e,onToggleBlock:t,onRetryCompaction:s,onRetryWithLuna:i,onArchiveOldChats:r,onArchiveOldestChats:o,archivePending:a=null,hfBilling:l=null,openRouterFallbackEnabled:c=!1,feedbackEnabled:h=!1})=>{var D,H,j,U;const[u,d]=ee.useState(null),[p,m]=ee.useState(!1),[y,v]=ee.useState(!1),[g,_]=ee.useState(!1),[b,x]=ee.useState(""),A=ee.useRef(null),T=`chat-feedback-panel-${n.id}`,C=h&&!n.streaming&&!n.error&&!!((D=n.blocks)!=null&&D.some(B=>B.kind==="answer"&&B.text.trim()));ee.useEffect(()=>{var B;g&&((B=A.current)==null||B.focus())},[g]);const I=async(B,L)=>{if(!p){m(!0),v(!1);try{L===void 0?await vA.reportFeedback(n.id,B):await vA.reportFeedback(n.id,B,L),d(B),_(!1),x("")}catch{v(!0)}finally{m(!1)}}};return S.jsx("div",{className:"chat-msg chat-msg-assistant",children:S.jsxs("div",{className:"chat-msg-blocks",children:[(H=n.blocks)==null?void 0:H.map((B,L)=>{var ge;const X=`${n.id}-${L}`,se="citations"in B&&B.citations!==void 0?B.citations:n.citations??[],J=Object.fromEntries(se.filter(z=>(z.kind==="catalog_paper"||z.kind==="paper"||!z.kind&&z.route_id)&&z.route_id).map(z=>[z.route_id,z])),Y=Object.fromEntries(se.filter(z=>(z.kind==="external_source"||z.kind==="web")&&z.url).map(z=>[z.url,z]));return B.kind==="reasoning"?S.jsx(kne,{block:B,papers:e,citations:J,webCitations:Y,onToggle:()=>t(n.id,L)},X):B.kind==="tool"?S.jsx(Ene,{block:B,papers:e,onToggle:()=>t(n.id,L)},X):B.kind==="app"?S.jsx($ne,{block:B},B.instance_id||X):B.kind==="artifact"?S.jsx(fne,{block:B},B.publication_id||B.version_id||X):S.jsx(Cne,{block:B,papers:e,citations:J,webCitations:Y,streaming:!!(n.streaming&&L===(((ge=n.blocks)==null?void 0:ge.length)??0)-1)},X)}),n.streaming&&n.compacting&&S.jsx(pD,{}),!n.compacting&&wne(n)&&S.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:S.jsx("span",{className:"chat-thinking",children:(((j=n.blocks)==null?void 0:j.length)??0)===0?n.status??"Thinking…":"Thinking…"})}),n.error&&S.jsxs("div",{className:"chat-error",children:[((U=n.blocks)==null?void 0:U.some(B=>B.kind==="answer"&&B.text.trim()))&&S.jsx("strong",{children:"Incomplete—response interrupted. "}),["context_too_large","provider_error","persistence_error"].includes(n.errorCode??"")&&s&&S.jsx("button",{type:"button",onClick:s,children:"Retry"}),S.jsx("span",{children:n.errorCode==="chat_disabled_interrupted"?"Chat was disabled while this response was running. The partial response is saved. Please try again later.":n.errorCode==="chat_session_quota_exceeded"?n.error:`The assistant hit an error: ${n.error}`}),["hf_inference_billing_required","hf_inference_credential_expired"].includes(n.errorCode??"")&&S.jsx("a",{href:"/settings",children:"Re-sign in with Hugging Face"}),n.errorCode==="hf_inference_billing_exhausted"&&S.jsxs(S.Fragment,{children:[i&&S.jsx("button",{type:"button",onClick:i,children:"Retry with GPT-6 Luna"}),(l==null?void 0:l.account_type)==="Free"&&!l.bill_to?S.jsx("a",{href:yne,target:"_blank",rel:"noreferrer",children:"Upgrade to Hugging Face PRO — $9/month for 20× more included credits"}):S.jsx("a",{href:(l==null?void 0:l.usage_url)??"/settings",target:l?"_blank":void 0,rel:l?"noreferrer":void 0,children:"Review Hugging Face usage and billing"}),S.jsx("a",{href:vne,target:"_blank",rel:"noreferrer",children:"Inference Providers pricing and billing details"})]}),n.errorCode==="hf_sponsored_unavailable"&&i&&S.jsx("button",{type:"button",onClick:i,children:"Retry with GPT-6 Luna"}),n.errorCode==="openrouter_monthly_budget_exhausted"&&S.jsxs(S.Fragment,{children:[c?S.jsx("span",{children:"This response started on the shared allowance. Your connected OpenRouter key will be used when you explicitly retry."}):S.jsx("a",{href:"/settings#openrouter-byok",children:"Connect your own OpenRouter key"}),S.jsx("span",{children:"Or select a Hugging Face-backed model and explicitly retry."})]}),n.errorCode==="openrouter_staging_funding_disabled"&&S.jsx("a",{href:bne,children:"Continue on paperswithcode.co"}),n.errorCode==="openrouter_unavailable"&&S.jsxs(S.Fragment,{children:[S.jsx("a",{href:"/settings#openrouter-byok",children:"Bring your own key in Settings"}),S.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback",target:"_blank",rel:"noreferrer",children:"File an issue"})]}),n.errorCode==="openrouter_byok_billing_error"&&S.jsx("a",{href:"https://openrouter.ai/settings/credits",target:"_blank",rel:"noreferrer",children:"Review OpenRouter billing"}),["openrouter_byok_credential_invalid","openrouter_byok_rate_limit"].includes(n.errorCode??"")&&S.jsx("a",{href:"/settings#openrouter-byok",children:"Review OpenRouter settings"}),n.errorCode==="chat_session_quota_exceeded"&&(r||o)&&S.jsxs("span",{className:"chat-error-actions",children:[r&&S.jsx("button",{type:"button",disabled:a!==null,onClick:r,children:a==="old"?"Archiving…":"Archive chats older than 30 days"}),o&&S.jsx("button",{type:"button",disabled:a!==null,onClick:o,children:a==="oldest"?"Archiving…":"Archive oldest 50 chats"})]})]}),!n.streaming&&n.finishReason&&!["success","scope_blocked"].includes(n.finishReason)&&S.jsx("div",{className:"chat-finish-note",children:["tool_limit","max_turns"].includes(n.finishReason)?"The assistant stopped at the execution limit.":`The assistant stopped early (${n.finishReason.replace(/_/g," ")}).`}),C&&S.jsxs("div",{className:"chat-feedback","aria-label":"Rate this response",children:[S.jsx("span",{className:"chat-feedback-label",children:u===null?"Was this helpful?":"Thanks for your feedback"}),S.jsx("button",{type:"button",className:`chat-feedback-action${u===!0?" chat-feedback-action-selected":""}`,"aria-label":"Helpful response","aria-pressed":u===!0,disabled:p,onClick:()=>{_(!1),I(!0)},children:S.jsx(tD,{"aria-hidden":"true"})}),S.jsx("button",{type:"button",className:`chat-feedback-action${u===!1?" chat-feedback-action-selected":""}`,"aria-label":"Unhelpful response","aria-pressed":u===!1,"aria-expanded":g,"aria-controls":T,disabled:p,onClick:()=>{v(!1),_(!0)},children:S.jsx(dD,{"aria-hidden":"true"})}),y&&S.jsx("span",{className:"chat-feedback-error",role:"status",children:"Couldn’t send feedback."})]}),C&&g&&S.jsxs("div",{className:"chat-feedback-panel",id:T,role:"group","aria-labelledby":`${T}-title`,children:[S.jsx("div",{className:"chat-feedback-panel-title",id:`${T}-title`,children:"Additional feedback"}),S.jsx("label",{className:"chat-feedback-panel-label",htmlFor:`${T}-comment`,children:"Tell us what went wrong (optional)"}),S.jsx("textarea",{ref:A,id:`${T}-comment`,className:"chat-feedback-comment",value:b,maxLength:500,rows:4,disabled:p,onChange:B=>x(B.target.value),onKeyDown:B=>{B.key==="Escape"&&(B.preventDefault(),_(!1))}}),S.jsxs("div",{className:"chat-feedback-panel-actions",children:[S.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:p,onClick:()=>void I(!1),children:"Skip"}),S.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:p,onClick:()=>void I(!1,b.trim()||void 0),children:p?"Submitting…":"Submit"})]})]})]})})},Rne={chat:{breakpoint:760,left:360,right:360},shared:{breakpoint:760,left:360,right:360},reader:{breakpoint:1260,left:840,right:420}};function Ga(n,e,t,s){if(!n)return Math.max(25,Math.min(75,e));const i=Math.max(25,s/n*100),r=Math.min(75,(n-t)/n*100);return Math.max(i,Math.min(r,e))}const mse=({children:n,variant:e})=>{var _;const t=hm(),s=Rne[e],i=ee.useRef(null),r=ee.useRef(null),o=ee.useRef(null),a=ee.useRef(null),[l,c]=ee.useState(0),h=ee.useRef(!1),u=ee.useRef(t.state.panelPercent);ee.useLayoutEffect(()=>{const b=i.current;if(!b)return;const x=()=>c(b.clientWidth||window.innerWidth);if(x(),typeof ResizeObserver>"u")return;const A=new ResizeObserver(x);return A.observe(b),()=>A.disconnect()},[]);const d=t.state.open&&l>=s.breakpoint,p=Ga(l,t.state.panelPercent,s.left,s.right),m=((_=t.state.selected)==null?void 0:_.artifact_kind)==="latex_paper"?"paper":"poster",y=b=>{var A;const x=Ga(l,b,s.left,s.right);u.current=x,r.current&&(r.current.style.width=`${100-x}%`),o.current&&(o.current.style.width=`${x}%`),(A=a.current)==null||A.setAttribute("aria-valuenow",String(Math.round(x)))},v=b=>{var A;const x=(A=i.current)==null?void 0:A.getBoundingClientRect();x!=null&&x.width&&y((x.right-b)/x.width*100)},g=()=>{h.current&&(h.current=!1,t.setPanelPercent(u.current))};return S.jsxs("div",{ref:i,className:`chat-artifact-workspace chat-artifact-workspace-${e}${d?" has-docked-artifact":""}`,"data-artifact-layout":d?"split":t.state.open?"dialog":"closed",children:[S.jsx("div",{ref:r,className:"chat-artifact-workspace-content",style:d?{width:`${100-p}%`}:void 0,children:n}),d&&S.jsxs(S.Fragment,{children:[S.jsx("div",{ref:a,className:"chat-artifact-resize-handle",role:"separator","aria-label":`Resize conversation and ${m} panels`,"aria-orientation":"vertical","aria-valuemin":Math.ceil(Ga(l,0,s.left,s.right)),"aria-valuemax":Math.floor(Ga(l,100,s.left,s.right)),"aria-valuenow":Math.round(p),tabIndex:0,onPointerDown:b=>{h.current=!0,b.currentTarget.setPointerCapture(b.pointerId),v(b.clientX)},onPointerMove:b=>{h.current&&v(b.clientX)},onPointerUp:g,onPointerCancel:g,onLostPointerCapture:g,onDoubleClick:()=>t.setPanelPercent(55),onKeyDown:b=>{(b.key==="ArrowLeft"||b.key==="ArrowRight")&&(b.preventDefault(),t.setPanelPercent(Ga(l,p+(b.key==="ArrowLeft"?2:-2),s.left,s.right))),b.key==="Home"&&t.setPanelPercent(Ga(l,25,s.left,s.right)),b.key==="End"&&t.setPanelPercent(Ga(l,75,s.left,s.right))}}),S.jsx("div",{ref:o,className:"chat-artifact-workspace-pane",style:{width:`${p}%`},children:S.jsx(qC,{})})]}),t.state.open&&!d&&S.jsx(qC,{forceDialog:!0,readerFallback:e==="reader"})]})};export{dse as A,ese as C,HY as P,VX as R,fse as U,mse as a,pse as b,hm as c,tse as d,PD as e,use as f,Q_ as g,BX as u}; diff --git a/assets/AstraForRoboticsView-BZJ-P8S9.js b/assets/AstraForRoboticsView-BMiTVC2T.js similarity index 89% rename from assets/AstraForRoboticsView-BZJ-P8S9.js rename to assets/AstraForRoboticsView-BMiTVC2T.js index 42dce87f0ee9777d1cd233fd142284582bbcb347..33203cf45249e4cfe02fe532b546853bacede5d9 100644 --- a/assets/AstraForRoboticsView-BZJ-P8S9.js +++ b/assets/AstraForRoboticsView-BMiTVC2T.js @@ -1 +1 @@ -import{p,d as u,j as a,L as o}from"./index-DyXq7-Tg.js";import{u as g,b as x,a as b}from"./PaperFeed-EBt97iOL.js";import{A as f,a as j}from"./alert-gbJBhAVE.js";import{u as y}from"./usePapers-B0s20UcU.js";import{p as v}from"./papers-Dh3ljlL0.js";import{u as k,f as w}from"./useDocumentTitle-DcxM2Zv_.js";import{t as A}from"./transform-D46m70Qr.js";import"./PaperCard-57p1OSGy.js";import"./AuthorAvatar-B-9xS2Wo.js";import"./SotaBadges-vbLLOUtT.js";import"./colors-BkWRhvFI.js";import"./Icon-T4LYkEQj.js";import"./LatexTitle-Bkyz3jCs.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-CTBEUp7Y.js";import"./skeleton-C3IIzpSL.js";import"./useIntersectionObserver-D6_Iig9a.js";import"./useInfiniteQuery-BYh2zN-T.js";import"./curation-YeS7FBYf.js";const n="robotics",i="gpt-6-astra",_="https://x.com/YuXiang_IRVL/status/2100395131924840570",P=[{handle:"Frame_Robotics",author:"Frame Robotics",summary:"Real-arm control that fixes grip angle and carry height on the next try after a miss.",url:"https://x.com/Frame_Robotics/status/2099900836273090614"},{handle:"qineng_wang",author:"Qineng Wang",summary:"Dual-ALOHA spatial-constraint puzzles: unlocking interlocked parts and threading a rope through three rings.",url:"https://x.com/qineng_wang/status/2099893504658866561"},{handle:"__Rhodium__",author:"Lucas",summary:"In-context learning of the controls and the workspace, reaching the task goal in three tries.",url:"https://x.com/__Rhodium__/status/2099521054678925534"},{handle:"SuveenE",author:"Suveen Ellawela",summary:"Picking up a pipette and fitting a 5 mm tip on a MolmoAct2 real-world eval, using the free hand for a better view.",url:"https://x.com/SuveenE/status/2099448450341605672"},{handle:"cdngdev",author:"thijs",summary:"A robot arm with a paintbrush painting the Golden Gate Bridge, improving across attempts from camera feedback.",url:"https://x.com/cdngdev/status/2097339677128982873"},{handle:"IsaacSin12",author:"Isaac Sin",summary:"Zero-shot sorting of irregularly shaped blocks into cups by color.",url:"https://x.com/IsaacSin12/status/2096715382166098302"},{handle:"chooi_jeq",author:"Jay Chooi",summary:"Robocurve's robot-control comparison: 95% task completion versus 40% for Fable 5.1 at lower cost.",url:"https://x.com/chooi_jeq/status/2096064315115839904"}],R=[{handle:"Lingjun_Mao",author:"Lingjun Mao",summary:"Adapting to a new embodiment to put a cake into an air fryer through CuRobo motion-planning tool APIs.",url:"https://x.com/Lingjun_Mao/status/2100294902672462176"},{handle:"walterzhu8",author:"Wentao Zhu",summary:"A day-and-a-half autonomous run that builds and trains pen spinning on a Sharpa hand in Isaac Lab.",url:"https://x.com/walterzhu8/status/2100212420840989112"},{handle:"mishig25",author:"Mishig",summary:"Painting the Eiffel Tower in MuJoCo with an SO-101 and a brush, with the full experiment shared on Hugging Face.",url:"https://x.com/mishig25/status/2099611674793668676"},{handle:"RunpeiDong",author:"Runpei Dong",summary:"Getting a humanoid into a Tesla in MuJoCo: learning from feedback, then reusing that experience with egocentric perception.",url:"https://x.com/RunpeiDong/status/2099604536327614717"},{handle:"frankzydou",author:"Zhiyang (Frank) Dou",summary:"A LeRobot SO-101 real-world pickup from a third-person RGB camera, where the arm has to bend back to reach the pen.",url:"https://x.com/frankzydou/status/2099338127915512297"},{handle:"Parvkpr",author:"Parv Kapoor",summary:"Real-to-sim: building an interactive simulation environment from a single image or video.",url:"https://x.com/Parvkpr/status/2098847963867238597"},{handle:"z_code68632",author:"code_z",summary:"One demo per task: unscrewing a bottle cap, inserting a plug, clearing obstacles, and imitating a dance on a real robot.",url:"https://x.com/z_code68632/status/2098397364725895387"}],h=({posts:s,label:e})=>a.jsxs("div",{className:"astra-posts",children:[a.jsx("div",{className:"astra-posts-label",children:e}),a.jsx("ul",{children:s.map(t=>a.jsxs("li",{children:[a.jsxs("a",{href:t.url,target:"_blank",rel:"noreferrer",children:["@",t.handle]}),a.jsxs("span",{className:"astra-post-author",children:[" ",t.author]}),a.jsxs("span",{className:"astra-post-summary",children:[" — ",t.summary]})]},t.url))})]}),B=()=>{var l,c;const s=g(),e=y([...p.feeds.infinite,{task:n,method:i,...s.filters}],r=>v.list({...s.filters,task:n,method:i,page:r,page_size:12}));k(w("GPT-6 Astra for Robotics"));const t=u.useMemo(()=>{var r;return(((r=e.data)==null?void 0:r.pages)??[]).flatMap(d=>d.results.map(A))},[e.data]),m=((c=(l=e.data)==null?void 0:l.pages[0])==null?void 0:c.count)??0;return a.jsxs("div",{className:"page",children:[a.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[a.jsx(o,{to:"/",children:"Home"}),a.jsx("span",{children:" / "}),a.jsx("span",{children:"GPT-6 Astra for Robotics"})]}),a.jsx("header",{className:"feed-header",children:a.jsxs("div",{children:[a.jsx("div",{className:"astra-eyebrow",children:"Collection"}),a.jsxs("h1",{className:"feed-title",children:["GPT-6 Astra ",a.jsx("em",{children:"for Robotics"})]}),a.jsx("div",{className:"feed-subtitle",children:"Papers, technical reports, and evaluations that put OpenAI’s frontier model in control of real and simulated robots."}),a.jsxs("p",{className:"astra-lede",children:["The GPT-6 Astra launch never mentioned robots, yet within days the model was driving arms, hands, and humanoids. As"," ",a.jsx("a",{href:_,target:"_blank",rel:"noreferrer",children:"Yu Xiang"})," ","framed it, the work splits into two families: Astra acting as the robot policy itself, and Astra acting as an agent that orchestrates everything else."]})]})}),a.jsxs("section",{className:"astra-approaches","aria-label":"How GPT-6 Astra is used for robots",children:[a.jsxs("article",{className:"astra-approach",children:[a.jsx("div",{className:"astra-approach-num",children:"01 / Robot policy"}),a.jsx("h2",{children:"Astra as the policy, like a VLA"}),a.jsx("p",{children:"The model looks at camera frames and robot state and directly emits actions: end-effector poses, joint targets, or gripper commands, closing the control loop step by step with no task-specific training."}),a.jsx(h,{posts:P,label:"Seen on X"})]}),a.jsxs("article",{className:"astra-approach",children:[a.jsx("div",{className:"astra-approach-num",children:"02 / Agent"}),a.jsx("h2",{children:"Astra as the agent"}),a.jsx("p",{children:"The model reasons about the scene, writes and runs code, calls planners and tools, or delegates low-level motion to pretrained policies such as VLAs, and keeps the robot on task over long horizons."}),a.jsx(h,{posts:R,label:"Seen on X"})]})]}),a.jsxs("p",{className:"astra-note",children:["Listing is automatic: any paper tagged with both the"," ",a.jsx(o,{to:`/tasks/${n}`,children:"Robotics"})," task and the"," ",a.jsx(o,{to:`/methods/${i}`,children:"GPT-6 Astra"})," method appears here. Missing a report or preprint?"," ",a.jsx(o,{to:"/submit",children:"Submit it"}),"."]}),a.jsxs("div",{className:"task-section-head",style:{marginTop:36},children:[a.jsx("div",{className:"task-section-eyebrow",children:"Top trending · sort below"}),a.jsxs("div",{className:"task-section-title",children:["Papers ",a.jsxs("span",{className:"meta",children:["[",m.toLocaleString(),"]"]})]})]}),a.jsx(x,{feed:s,showDateFilter:!1}),e.error?a.jsx(f,{variant:"destructive",children:a.jsx(j,{children:"Failed to load the collection. Please try again."})}):a.jsx(b,{query:e,cards:t,empty:"No papers match this selection yet."})]})};export{B as default}; +import{p,d as u,j as a,L as o}from"./index-CjdUkE4w.js";import{u as g,b as x,a as b}from"./PaperFeed-D3FZw29k.js";import{A as f,a as j}from"./alert-BM9Xfuyy.js";import{u as y}from"./usePapers-BZThqZCx.js";import{p as v}from"./papers-DgZwjF3K.js";import{u as k,f as w}from"./useDocumentTitle-2Ho8_KfW.js";import{t as A}from"./transform-CRNzYLch.js";import"./PaperCard-dvXhr75r.js";import"./AuthorAvatar-D9249Frl.js";import"./SotaBadges-CyScuNCv.js";import"./colors-BkWRhvFI.js";import"./Icon-CGRs4BYD.js";import"./LatexTitle-DESKtS30.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-Df5_dywQ.js";import"./skeleton-DTWi7Ctg.js";import"./useIntersectionObserver-Ch6RpsSk.js";import"./useInfiniteQuery-DeZTTVbI.js";import"./curation-CyyuHfv5.js";const n="robotics",i="gpt-6-astra",_="https://x.com/YuXiang_IRVL/status/2100395131924840570",P=[{handle:"Frame_Robotics",author:"Frame Robotics",summary:"Real-arm control that fixes grip angle and carry height on the next try after a miss.",url:"https://x.com/Frame_Robotics/status/2099900836273090614"},{handle:"qineng_wang",author:"Qineng Wang",summary:"Dual-ALOHA spatial-constraint puzzles: unlocking interlocked parts and threading a rope through three rings.",url:"https://x.com/qineng_wang/status/2099893504658866561"},{handle:"__Rhodium__",author:"Lucas",summary:"In-context learning of the controls and the workspace, reaching the task goal in three tries.",url:"https://x.com/__Rhodium__/status/2099521054678925534"},{handle:"SuveenE",author:"Suveen Ellawela",summary:"Picking up a pipette and fitting a 5 mm tip on a MolmoAct2 real-world eval, using the free hand for a better view.",url:"https://x.com/SuveenE/status/2099448450341605672"},{handle:"cdngdev",author:"thijs",summary:"A robot arm with a paintbrush painting the Golden Gate Bridge, improving across attempts from camera feedback.",url:"https://x.com/cdngdev/status/2097339677128982873"},{handle:"IsaacSin12",author:"Isaac Sin",summary:"Zero-shot sorting of irregularly shaped blocks into cups by color.",url:"https://x.com/IsaacSin12/status/2096715382166098302"},{handle:"chooi_jeq",author:"Jay Chooi",summary:"Robocurve's robot-control comparison: 95% task completion versus 40% for Fable 5.1 at lower cost.",url:"https://x.com/chooi_jeq/status/2096064315115839904"}],R=[{handle:"Lingjun_Mao",author:"Lingjun Mao",summary:"Adapting to a new embodiment to put a cake into an air fryer through CuRobo motion-planning tool APIs.",url:"https://x.com/Lingjun_Mao/status/2100294902672462176"},{handle:"walterzhu8",author:"Wentao Zhu",summary:"A day-and-a-half autonomous run that builds and trains pen spinning on a Sharpa hand in Isaac Lab.",url:"https://x.com/walterzhu8/status/2100212420840989112"},{handle:"mishig25",author:"Mishig",summary:"Painting the Eiffel Tower in MuJoCo with an SO-101 and a brush, with the full experiment shared on Hugging Face.",url:"https://x.com/mishig25/status/2099611674793668676"},{handle:"RunpeiDong",author:"Runpei Dong",summary:"Getting a humanoid into a Tesla in MuJoCo: learning from feedback, then reusing that experience with egocentric perception.",url:"https://x.com/RunpeiDong/status/2099604536327614717"},{handle:"frankzydou",author:"Zhiyang (Frank) Dou",summary:"A LeRobot SO-101 real-world pickup from a third-person RGB camera, where the arm has to bend back to reach the pen.",url:"https://x.com/frankzydou/status/2099338127915512297"},{handle:"Parvkpr",author:"Parv Kapoor",summary:"Real-to-sim: building an interactive simulation environment from a single image or video.",url:"https://x.com/Parvkpr/status/2098847963867238597"},{handle:"z_code68632",author:"code_z",summary:"One demo per task: unscrewing a bottle cap, inserting a plug, clearing obstacles, and imitating a dance on a real robot.",url:"https://x.com/z_code68632/status/2098397364725895387"}],h=({posts:s,label:e})=>a.jsxs("div",{className:"astra-posts",children:[a.jsx("div",{className:"astra-posts-label",children:e}),a.jsx("ul",{children:s.map(t=>a.jsxs("li",{children:[a.jsxs("a",{href:t.url,target:"_blank",rel:"noreferrer",children:["@",t.handle]}),a.jsxs("span",{className:"astra-post-author",children:[" ",t.author]}),a.jsxs("span",{className:"astra-post-summary",children:[" — ",t.summary]})]},t.url))})]}),B=()=>{var l,c;const s=g(),e=y([...p.feeds.infinite,{task:n,method:i,...s.filters}],r=>v.list({...s.filters,task:n,method:i,page:r,page_size:12}));k(w("GPT-6 Astra for Robotics"));const t=u.useMemo(()=>{var r;return(((r=e.data)==null?void 0:r.pages)??[]).flatMap(d=>d.results.map(A))},[e.data]),m=((c=(l=e.data)==null?void 0:l.pages[0])==null?void 0:c.count)??0;return a.jsxs("div",{className:"page",children:[a.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[a.jsx(o,{to:"/",children:"Home"}),a.jsx("span",{children:" / "}),a.jsx("span",{children:"GPT-6 Astra for Robotics"})]}),a.jsx("header",{className:"feed-header",children:a.jsxs("div",{children:[a.jsx("div",{className:"astra-eyebrow",children:"Collection"}),a.jsxs("h1",{className:"feed-title",children:["GPT-6 Astra ",a.jsx("em",{children:"for Robotics"})]}),a.jsx("div",{className:"feed-subtitle",children:"Papers, technical reports, and evaluations that put OpenAI’s frontier model in control of real and simulated robots."}),a.jsxs("p",{className:"astra-lede",children:["The GPT-6 Astra launch never mentioned robots, yet within days the model was driving arms, hands, and humanoids. As"," ",a.jsx("a",{href:_,target:"_blank",rel:"noreferrer",children:"Yu Xiang"})," ","framed it, the work splits into two families: Astra acting as the robot policy itself, and Astra acting as an agent that orchestrates everything else."]})]})}),a.jsxs("section",{className:"astra-approaches","aria-label":"How GPT-6 Astra is used for robots",children:[a.jsxs("article",{className:"astra-approach",children:[a.jsx("div",{className:"astra-approach-num",children:"01 / Robot policy"}),a.jsx("h2",{children:"Astra as the policy, like a VLA"}),a.jsx("p",{children:"The model looks at camera frames and robot state and directly emits actions: end-effector poses, joint targets, or gripper commands, closing the control loop step by step with no task-specific training."}),a.jsx(h,{posts:P,label:"Seen on X"})]}),a.jsxs("article",{className:"astra-approach",children:[a.jsx("div",{className:"astra-approach-num",children:"02 / Agent"}),a.jsx("h2",{children:"Astra as the agent"}),a.jsx("p",{children:"The model reasons about the scene, writes and runs code, calls planners and tools, or delegates low-level motion to pretrained policies such as VLAs, and keeps the robot on task over long horizons."}),a.jsx(h,{posts:R,label:"Seen on X"})]})]}),a.jsxs("p",{className:"astra-note",children:["Listing is automatic: any paper tagged with both the"," ",a.jsx(o,{to:`/tasks/${n}`,children:"Robotics"})," task and the"," ",a.jsx(o,{to:`/methods/${i}`,children:"GPT-6 Astra"})," method appears here. Missing a report or preprint?"," ",a.jsx(o,{to:"/submit",children:"Submit it"}),"."]}),a.jsxs("div",{className:"task-section-head",style:{marginTop:36},children:[a.jsx("div",{className:"task-section-eyebrow",children:"Top trending · sort below"}),a.jsxs("div",{className:"task-section-title",children:["Papers ",a.jsxs("span",{className:"meta",children:["[",m.toLocaleString(),"]"]})]})]}),a.jsx(x,{feed:s,showDateFilter:!1}),e.error?a.jsx(f,{variant:"destructive",children:a.jsx(j,{children:"Failed to load the collection. Please try again."})}):a.jsx(b,{query:e,cards:t,empty:"No papers match this selection yet."})]})};export{B as default}; diff --git a/assets/AuthorAvatar-B-9xS2Wo.js b/assets/AuthorAvatar-D9249Frl.js similarity index 86% rename from assets/AuthorAvatar-B-9xS2Wo.js rename to assets/AuthorAvatar-D9249Frl.js index 61351f27f8ead52f6845eb5f6fc15b35eb423f00..e3963ce4b99038e335d00b086f51ebc08c075e71 100644 --- a/assets/AuthorAvatar-B-9xS2Wo.js +++ b/assets/AuthorAvatar-D9249Frl.js @@ -1 +1 @@ -import{d as c,j as r}from"./index-DyXq7-Tg.js";const p=a=>a!=null&&a.startsWith("https://")&&!a.startsWith("https://huggingface.co/avatars/")?a:null,g=({url:a,className:o,href:t,label:n})=>{const[i,l]=c.useState(!1),s=i?null:p(a);if(!s)return null;const e=r.jsx("img",{className:`author-avatar-base ${o}`,src:s,alt:"",loading:"lazy",onError:()=>l(!0)});return t?r.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer","aria-label":n,children:e}):e};export{g as A}; +import{d as c,j as r}from"./index-CjdUkE4w.js";const p=a=>a!=null&&a.startsWith("https://")&&!a.startsWith("https://huggingface.co/avatars/")?a:null,g=({url:a,className:o,href:t,label:n})=>{const[i,l]=c.useState(!1),s=i?null:p(a);if(!s)return null;const e=r.jsx("img",{className:`author-avatar-base ${o}`,src:s,alt:"",loading:"lazy",onError:()=>l(!0)});return t?r.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer","aria-label":n,children:e}):e};export{g as A}; diff --git a/assets/AuthorDetailView-BykOxZh0.js b/assets/AuthorDetailView-BwEN_vpq.js similarity index 76% rename from assets/AuthorDetailView-BykOxZh0.js rename to assets/AuthorDetailView-BwEN_vpq.js index 75d91e698108e6c9ae4dfc01797b6acd6974941c..833c0df9fac6b2a1a3fce1d77ead9fa4175beced 100644 --- a/assets/AuthorDetailView-BykOxZh0.js +++ b/assets/AuthorDetailView-BwEN_vpq.js @@ -1 +1 @@ -import{u as b,j as a,b as N,p as v,d as F,ao as y,L as A}from"./index-DyXq7-Tg.js";import{A as k}from"./AuthorAvatar-B-9xS2Wo.js";import{u as P,b as $,a as S}from"./PaperFeed-EBt97iOL.js";import{R as L}from"./ResearchFollowButton-Dv316ClR.js";import{A as R,a as w}from"./alert-gbJBhAVE.js";import{S as z}from"./skeleton-C3IIzpSL.js";import{u as C}from"./usePapers-B0s20UcU.js";import{p as m}from"./papers-Dh3ljlL0.js";import{i as H}from"./apiErrors-BSvbQBb0.js";import{t as q}from"./transform-D46m70Qr.js";import f from"./NotFound-DV_nwcxG.js";import"./PaperCard-57p1OSGy.js";import"./SotaBadges-vbLLOUtT.js";import"./colors-BkWRhvFI.js";import"./Icon-T4LYkEQj.js";import"./LatexTitle-Bkyz3jCs.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-CTBEUp7Y.js";import"./useIntersectionObserver-D6_Iig9a.js";import"./researchTopic-DbX0eko-.js";import"./useMutation-UWxBeqtn.js";import"./plus-Yh42pKZz.js";import"./useInfiniteQuery-BYh2zN-T.js";import"./curation-YeS7FBYf.js";const Q=({authorId:r})=>{var n,i,l,p,c,d,h,u;const o=P(),{searchParams:g}=o,e=N({queryKey:["author",r],queryFn:()=>m.getAuthor(r)}),s=C([...v.feeds.infinite,{author:r,...o.filters}],t=>m.list({...o.filters,author:r,page:t,page_size:12})),x=F.useMemo(()=>{var t;return(((t=s.data)==null?void 0:t.pages)??[]).flatMap(_=>_.results.map(q))},[s.data]),j=((i=(n=s.data)==null?void 0:n.pages[0])==null?void 0:i.count)??0;if(H(e.error))return a.jsx(f,{});if((l=e.data)!=null&&l.organization_slug){const t=g.toString();return a.jsx(y,{to:`/orgs/${e.data.organization_slug}${t?`?${t}`:""}`,replace:!0})}return a.jsxs("div",{className:"page",children:[a.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[a.jsx(A,{to:"/",children:"Home"}),a.jsx("span",{children:" / "}),a.jsx("span",{children:"Authors"}),a.jsx("span",{children:" / "}),a.jsx("span",{children:((p=e.data)==null?void 0:p.full_name)??r})]}),a.jsxs("header",{className:"author-hero",children:[a.jsx("div",{className:"organizations-eyebrow",children:"AUTHOR"}),a.jsxs("div",{className:"author-hero-title",children:[(c=e.data)!=null&&c.photo?a.jsxs("figure",{className:"author-photo",children:[a.jsx("img",{className:"author-avatar-base author-avatar",src:e.data.photo.url,alt:""}),a.jsxs("figcaption",{children:["Photo:"," ",a.jsx("a",{href:e.data.photo.source_url,target:"_blank",rel:"noopener noreferrer",children:e.data.photo.credit}),", ",e.data.photo.license_url?a.jsx("a",{href:e.data.photo.license_url,target:"_blank",rel:"noopener noreferrer",children:e.data.photo.license}):e.data.photo.license]})]}):((d=e.data)==null?void 0:d.hf_username)&&a.jsx(k,{className:"author-avatar",url:e.data.hf_avatar_url,href:`https://huggingface.co/${e.data.hf_username}`,label:`@${e.data.hf_username} on Hugging Face`}),a.jsx("h1",{className:"feed-title",children:((h=e.data)==null?void 0:h.full_name)??a.jsx(z,{className:"h-12 w-64 inline-block"})})]}),e.data&&a.jsxs("div",{className:"feed-subtitle",children:[e.data.paper_count.toLocaleString()," ",e.data.paper_count===1?"paper":"papers",e.data.hf_username&&a.jsxs(a.Fragment,{children:[" · ",a.jsxs("a",{href:`https://huggingface.co/${e.data.hf_username}`,target:"_blank",rel:"noopener noreferrer",children:["@",e.data.hf_username," on Hugging Face ↗"]})]}),e.data.google_scholar_id&&a.jsxs(a.Fragment,{children:[" · ",a.jsx("a",{href:`https://scholar.google.com/citations?user=${encodeURIComponent(e.data.google_scholar_id)}`,target:"_blank",rel:"noopener noreferrer",children:"Google Scholar ↗"})]})]}),e.data&&a.jsx(L,{kind:"author",entityId:e.data.id})]}),a.jsx($,{feed:o,style:{alignItems:"center",gap:16},children:a.jsxs("div",{className:"results-count",children:[j.toLocaleString()," papers"]})}),s.error?a.jsx(R,{variant:"destructive",children:a.jsxs(w,{children:["Failed to load papers."," ",a.jsx("button",{type:"button",onClick:()=>void s.refetch(),children:"Try again"})]})}):a.jsx(S,{query:s,cards:x,empty:((u=e.data)==null?void 0:u.paper_count)===0?"No public papers are available.":"No papers found for this selection."})]})},la=()=>{const{authorId:r}=b();return r?a.jsx(Q,{authorId:r},r):a.jsx(f,{})};export{la as default}; +import{u as b,j as a,b as N,p as v,d as F,ao as y,L as A}from"./index-CjdUkE4w.js";import{A as k}from"./AuthorAvatar-D9249Frl.js";import{u as P,b as $,a as S}from"./PaperFeed-D3FZw29k.js";import{R as L}from"./ResearchFollowButton-DcTptDpW.js";import{A as R,a as w}from"./alert-BM9Xfuyy.js";import{S as z}from"./skeleton-DTWi7Ctg.js";import{u as C}from"./usePapers-BZThqZCx.js";import{p as m}from"./papers-DgZwjF3K.js";import{i as H}from"./apiErrors-D0w5By9R.js";import{t as q}from"./transform-CRNzYLch.js";import f from"./NotFound-BeWhm9El.js";import"./PaperCard-dvXhr75r.js";import"./SotaBadges-CyScuNCv.js";import"./colors-BkWRhvFI.js";import"./Icon-CGRs4BYD.js";import"./LatexTitle-DESKtS30.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-Df5_dywQ.js";import"./useIntersectionObserver-Ch6RpsSk.js";import"./researchTopic-NmABF6tT.js";import"./useMutation-BYtVrkc7.js";import"./plus-AztI1566.js";import"./useInfiniteQuery-DeZTTVbI.js";import"./curation-CyyuHfv5.js";const Q=({authorId:r})=>{var n,i,l,p,c,d,h,u;const o=P(),{searchParams:g}=o,e=N({queryKey:["author",r],queryFn:()=>m.getAuthor(r)}),s=C([...v.feeds.infinite,{author:r,...o.filters}],t=>m.list({...o.filters,author:r,page:t,page_size:12})),x=F.useMemo(()=>{var t;return(((t=s.data)==null?void 0:t.pages)??[]).flatMap(_=>_.results.map(q))},[s.data]),j=((i=(n=s.data)==null?void 0:n.pages[0])==null?void 0:i.count)??0;if(H(e.error))return a.jsx(f,{});if((l=e.data)!=null&&l.organization_slug){const t=g.toString();return a.jsx(y,{to:`/orgs/${e.data.organization_slug}${t?`?${t}`:""}`,replace:!0})}return a.jsxs("div",{className:"page",children:[a.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[a.jsx(A,{to:"/",children:"Home"}),a.jsx("span",{children:" / "}),a.jsx("span",{children:"Authors"}),a.jsx("span",{children:" / "}),a.jsx("span",{children:((p=e.data)==null?void 0:p.full_name)??r})]}),a.jsxs("header",{className:"author-hero",children:[a.jsx("div",{className:"organizations-eyebrow",children:"AUTHOR"}),a.jsxs("div",{className:"author-hero-title",children:[(c=e.data)!=null&&c.photo?a.jsxs("figure",{className:"author-photo",children:[a.jsx("img",{className:"author-avatar-base author-avatar",src:e.data.photo.url,alt:""}),a.jsxs("figcaption",{children:["Photo:"," ",a.jsx("a",{href:e.data.photo.source_url,target:"_blank",rel:"noopener noreferrer",children:e.data.photo.credit}),", ",e.data.photo.license_url?a.jsx("a",{href:e.data.photo.license_url,target:"_blank",rel:"noopener noreferrer",children:e.data.photo.license}):e.data.photo.license]})]}):((d=e.data)==null?void 0:d.hf_username)&&a.jsx(k,{className:"author-avatar",url:e.data.hf_avatar_url,href:`https://huggingface.co/${e.data.hf_username}`,label:`@${e.data.hf_username} on Hugging Face`}),a.jsx("h1",{className:"feed-title",children:((h=e.data)==null?void 0:h.full_name)??a.jsx(z,{className:"h-12 w-64 inline-block"})})]}),e.data&&a.jsxs("div",{className:"feed-subtitle",children:[e.data.paper_count.toLocaleString()," ",e.data.paper_count===1?"paper":"papers",e.data.hf_username&&a.jsxs(a.Fragment,{children:[" · ",a.jsxs("a",{href:`https://huggingface.co/${e.data.hf_username}`,target:"_blank",rel:"noopener noreferrer",children:["@",e.data.hf_username," on Hugging Face ↗"]})]}),e.data.google_scholar_id&&a.jsxs(a.Fragment,{children:[" · ",a.jsx("a",{href:`https://scholar.google.com/citations?user=${encodeURIComponent(e.data.google_scholar_id)}`,target:"_blank",rel:"noopener noreferrer",children:"Google Scholar ↗"})]})]}),e.data&&a.jsx(L,{kind:"author",entityId:e.data.id})]}),a.jsx($,{feed:o,style:{alignItems:"center",gap:16},children:a.jsxs("div",{className:"results-count",children:[j.toLocaleString()," papers"]})}),s.error?a.jsx(R,{variant:"destructive",children:a.jsxs(w,{children:["Failed to load papers."," ",a.jsx("button",{type:"button",onClick:()=>void s.refetch(),children:"Try again"})]})}):a.jsx(S,{query:s,cards:x,empty:((u=e.data)==null?void 0:u.paper_count)===0?"No public papers are available.":"No papers found for this selection."})]})},la=()=>{const{authorId:r}=b();return r?a.jsx(Q,{authorId:r},r):a.jsx(f,{})};export{la as default}; diff --git a/assets/AuthorizePaperEditView-DNfre5z5.js b/assets/AuthorizePaperEditView-C-sg5DHX.js similarity index 87% rename from assets/AuthorizePaperEditView-DNfre5z5.js rename to assets/AuthorizePaperEditView-C-sg5DHX.js index 3feca8cc22aea7b75df60208f5014c702f985f3c..8e5734df803e77335a6c2dbb1468044767f1766b 100644 --- a/assets/AuthorizePaperEditView-DNfre5z5.js +++ b/assets/AuthorizePaperEditView-C-sg5DHX.js @@ -1 +1 @@ -import{u,a as d,b as l,j as e,L as p,H as c}from"./index-DyXq7-Tg.js";import{u as h}from"./useMutation-UWxBeqtn.js";import{B as g}from"./button-DZeAbOf2.js";import{p as n}from"./paperEdits-CIjFYfYE.js";function f(){const{authorizationId:t=""}=u(),{user:s,isLoading:o}=d(),i=l({queryKey:["paper-edit-authorization",t],queryFn:()=>n.authorization(t),retry:!1}),r=h({mutationFn:()=>n.approve(t)}),a=i.data;return e.jsxs("main",{className:"mx-auto max-w-xl space-y-5 px-6 py-12",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Authorize your agent to edit a paper"}),(i.isLoading||o)&&e.jsx("p",{children:"Loading authorization…"}),i.error&&e.jsx("p",{role:"alert",children:i.error.message}),a&&e.jsxs(e.Fragment,{children:[e.jsx(p,{className:"underline",to:`/paper/${a.paper_id}`,children:a.title}),e.jsxs("p",{children:["Check that your CLI shows this code: ",e.jsx("strong",{className:"font-mono",children:a.user_code})]}),e.jsx("p",{children:"Only approve a request you started. Your agent will be able to publish changes to this paper’s links, tags, and evaluation results for one hour, without further approval."}),e.jsx("p",{children:"Edits appear publicly under your Hugging Face username. You can edit up to 20 distinct papers per UTC day. Evaluation deletion and changes to shared benchmark definitions require an administrator."}),r.isSuccess||a.approved?e.jsx("p",{role:"status",children:"Access approved. Return to your CLI to continue."}):s?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Signed in as ",e.jsxs("strong",{children:["@",s.username]})]}),e.jsx(g,{disabled:r.isPending||!s.can_directly_edit_catalog,onClick:()=>r.mutate(),children:r.isPending?"Authorizing…":"Authorize for one hour"}),!s.can_directly_edit_catalog&&e.jsx("p",{children:"Direct editing is unavailable for this session."})]}):e.jsx(c,{returnTo:`/authorize-paper-edit/${t}`,label:"Sign in with Hugging Face"}),r.error&&e.jsx("p",{role:"alert",children:r.error.message})]})]})}export{f as default}; +import{u,a as d,b as l,j as e,L as p,H as c}from"./index-CjdUkE4w.js";import{u as h}from"./useMutation-BYtVrkc7.js";import{B as g}from"./button-DetZl_ch.js";import{p as n}from"./paperEdits-C_3nZTKz.js";function f(){const{authorizationId:t=""}=u(),{user:s,isLoading:o}=d(),i=l({queryKey:["paper-edit-authorization",t],queryFn:()=>n.authorization(t),retry:!1}),r=h({mutationFn:()=>n.approve(t)}),a=i.data;return e.jsxs("main",{className:"mx-auto max-w-xl space-y-5 px-6 py-12",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Authorize your agent to edit a paper"}),(i.isLoading||o)&&e.jsx("p",{children:"Loading authorization…"}),i.error&&e.jsx("p",{role:"alert",children:i.error.message}),a&&e.jsxs(e.Fragment,{children:[e.jsx(p,{className:"underline",to:`/paper/${a.paper_id}`,children:a.title}),e.jsxs("p",{children:["Check that your CLI shows this code: ",e.jsx("strong",{className:"font-mono",children:a.user_code})]}),e.jsx("p",{children:"Only approve a request you started. Your agent will be able to publish changes to this paper’s links, tags, and evaluation results for one hour, without further approval."}),e.jsx("p",{children:"Edits appear publicly under your Hugging Face username. You can edit up to 20 distinct papers per UTC day. Evaluation deletion and changes to shared benchmark definitions require an administrator."}),r.isSuccess||a.approved?e.jsx("p",{role:"status",children:"Access approved. Return to your CLI to continue."}):s?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Signed in as ",e.jsxs("strong",{children:["@",s.username]})]}),e.jsx(g,{disabled:r.isPending||!s.can_directly_edit_catalog,onClick:()=>r.mutate(),children:r.isPending?"Authorizing…":"Authorize for one hour"}),!s.can_directly_edit_catalog&&e.jsx("p",{children:"Direct editing is unavailable for this session."})]}):e.jsx(c,{returnTo:`/authorize-paper-edit/${t}`,label:"Sign in with Hugging Face"}),r.error&&e.jsx("p",{role:"alert",children:r.error.message})]})]})}export{f as default}; diff --git a/assets/AutonomousOperations-B4vSAvB8.js b/assets/AutonomousOperations-BMzZOLm6.js similarity index 91% rename from assets/AutonomousOperations-B4vSAvB8.js rename to assets/AutonomousOperations-BMzZOLm6.js index 90dc8430b7cdf5ea8094fec5af11c3365664f634..3f842b9f2d887d6a879539a58eb22445b83f682b 100644 --- a/assets/AutonomousOperations-B4vSAvB8.js +++ b/assets/AutonomousOperations-BMzZOLm6.js @@ -1 +1 @@ -import{i as R,d,b as B,I as C,j as e,L as q}from"./index-DyXq7-Tg.js";import{u as I}from"./useMutation-UWxBeqtn.js";import{C as n,e as i,S as Q,b as l,c as t,t as E,f as m,o as x}from"./CronDashboard-qYV75PLc.js";import{B as H}from"./badge-e6t3GCyf.js";import{B as h}from"./button-DZeAbOf2.js";import{I as u}from"./input-DJqCAbs7.js";import{A as P}from"./activity-S-FQ6Anu.js";import{A as D}from"./arrow-left-PA_b6law.js";const j={submissions:"Submission review",curation:"Scheduled curation",cron_health:"CRON health",chat_reliability:"Chat reliability"},S={healthy:"healthy",degraded:"degraded",repairing:"running","rolled-back":"broken",manual:"degraded"},V=()=>{var A;const M=R(),[p,T]=d.useState(""),[f,_]=d.useState(""),[b,v]=d.useState({}),[g,N]=d.useState(""),c=B({queryKey:C.autonomousOperations,queryFn:()=>x.getAutonomousOperations(),refetchInterval:3e4,retry:!1}),r=I({mutationFn:s=>s(),onSuccess:s=>{M.setQueryData(C.autonomousOperations,s),_(""),v({}),N("")}}),a=c.data,y=r.error instanceof Error?r.error.message:null;if(c.isLoading)return e.jsx("div",{className:"page","aria-busy":"true",children:"Loading autonomous operations…"});if(c.error||!a)return e.jsxs("div",{className:"page",children:[e.jsx("h1",{children:"Autonomous operations unavailable"}),e.jsx("p",{children:c.error instanceof Error?c.error.message:"No status was returned."})]});const O=()=>r.mutate(()=>x.setAutonomousManualMode(!a.manual_mode,a.revision,f)),k=(s,o)=>r.mutate(()=>x.setAutonomousOperator(s,o,a.revision,b[s]??"")),w=()=>{var o;const s=((o=a.baseline)==null?void 0:o.revision)??0;r.mutate(()=>x.qualifyAutonomousChatBaseline(p,s,g))};return e.jsx("div",{className:"cron-dashboard","data-shadcn":!0,children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center gap-3",children:[e.jsx(P,{className:"h-8 w-8"}),"Autonomous operations"]}),e.jsx("p",{className:"mt-2 cron-muted",children:"Content-free supervision, remote controls, and bounded audit history."})]}),e.jsx(h,{asChild:!0,variant:"outline",children:e.jsxs(q,{to:"/admin-dashboard",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Admin dashboard"]})})]}),a.manual_mode&&e.jsx(n,{className:"cron-status--degraded",role:"status",children:e.jsxs(i,{className:"pt-6 flex gap-3",children:[e.jsx(Q,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Manual mode is enabled."}),e.jsxs("p",{children:[a.monitoring_active?"Monitoring remains active":"Monitoring is not currently verified","; autonomous callbacks, retries, deployments, and data mutations fail closed."]})]})]})}),e.jsxs("div",{className:"grid md:grid-cols-4 gap-4",children:[e.jsxs(n,{className:E(S[a.display_state]),children:[e.jsx(l,{children:e.jsx(t,{className:"text-sm",children:"Overall state"})}),e.jsxs(i,{children:[e.jsx("div",{className:"text-2xl font-bold capitalize",children:a.display_state}),e.jsxs("p",{className:"text-sm",children:["Monitoring ",a.monitoring_active?"active":"inactive"]})]})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{className:"text-sm",children:"Codex cost"})}),e.jsxs(i,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:["$",a.costs.total_usd]}),e.jsxs("p",{className:"text-sm",children:[a.costs.input_tokens+a.costs.output_tokens," tokens"]})]})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{className:"text-sm",children:"Repair lease"})}),e.jsxs(i,{children:[e.jsx("div",{className:"text-lg font-bold",children:a.active_lease?a.active_lease.owner_operator:"Available"}),e.jsx("p",{className:"text-sm",children:a.active_lease?`Expires ${m(a.active_lease.expires_at)}`:"No active source repair"})]})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{className:"text-sm",children:"Global control"})}),e.jsxs(i,{className:"space-y-2",children:[e.jsx(u,{"aria-label":"Manual mode confirmation",value:f,onChange:s=>_(s.target.value),placeholder:"Type SET_MANUAL_MODE"}),e.jsx(h,{disabled:r.isPending||f!=="SET_MANUAL_MODE",onClick:O,children:a.manual_mode?"Leave manual mode":"Enable manual mode"})]})]})]}),e.jsx("div",{className:"grid md:grid-cols-4 gap-4",children:a.operators.map(s=>e.jsxs(n,{className:E(S[s.status]),children:[e.jsx(l,{children:e.jsxs(t,{className:"flex justify-between gap-2",children:[e.jsx("span",{children:j[s.operator]}),e.jsx(H,{children:s.status})]})}),e.jsxs(i,{className:"space-y-3",children:[e.jsxs("p",{children:[s.enabled?"Mutation enabled":"Mutation disabled"," · monitoring ",s.monitoring_active?"active":"unverified"]}),e.jsxs("p",{className:"text-sm",children:["Next scheduled run: ",s.next_scheduled_run?m(s.next_scheduled_run):"not scheduled"]}),e.jsx(u,{"aria-label":`${j[s.operator]} confirmation`,value:b[s.operator]??"",onChange:o=>v(L=>({...L,[s.operator]:o.target.value})),placeholder:"Type SET_OPERATOR_STATE"}),e.jsx(h,{disabled:r.isPending||a.manual_mode&&!s.enabled||b[s.operator]!=="SET_OPERATOR_STATE",onClick:()=>k(s.operator,!s.enabled),children:s.enabled?"Disable":"Enable"})]})]},s.operator))}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{children:"Qualified scalable-chat baseline"})}),e.jsxs(i,{className:"space-y-3",children:[e.jsx("p",{className:"font-mono break-all",children:((A=a.baseline)==null?void 0:A.sha)??"No baseline qualified"}),a.baseline&&e.jsxs("p",{className:"text-sm",children:["Revision ",a.baseline.revision," · ",a.baseline.qualified_by," · ",m(a.baseline.qualified_at)]}),e.jsxs("div",{className:"grid md:grid-cols-[1fr_1fr_auto] gap-2",children:[e.jsx(u,{"aria-label":"Exact baseline SHA",value:p,onChange:s=>T(s.target.value),placeholder:"40-character lowercase commit SHA"}),e.jsx(u,{"aria-label":"Baseline confirmation",value:g,onChange:s=>N(s.target.value),placeholder:"Type QUALIFY_CHAT_BASELINE"}),e.jsx(h,{disabled:r.isPending||!/^[0-9a-f]{40}$/.test(p)||g!=="QUALIFY_CHAT_BASELINE",onClick:w,children:"Qualify exact SHA"})]})]})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{children:"Provider and fallback state"})}),e.jsx(i,{children:a.provider_states.length?e.jsx("ul",{className:"space-y-2",children:a.provider_states.map(s=>e.jsxs("li",{children:[e.jsx("strong",{children:s.environment}),": ",s.active_provider," · ",s.reason_code," · manifest ",s.manifest_revision]},s.environment))}):e.jsx("p",{children:"No provider state recorded."})})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{children:"Recent runs"})}),e.jsx(i,{children:a.recent_runs.length?e.jsx("ul",{className:"space-y-2",children:a.recent_runs.map(s=>e.jsxs("li",{children:[e.jsx("strong",{children:j[s.operator]})," · ",s.status," · ",s.exit_classification," · $",s.cost_usd," · ",m(s.created_at)]},s.run_id))}):e.jsx("p",{children:"No runs recorded."})})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{children:"Recent actions"})}),e.jsx(i,{children:a.recent_actions.length?e.jsx("ul",{className:"space-y-2",children:a.recent_actions.map(s=>e.jsxs("li",{children:[e.jsx("strong",{children:j[s.operator]})," · ",s.capability," · ",s.reason_code," · ",s.resource_kind,"/",s.resource_identifier]},s.action_id))}):e.jsx("p",{children:"No actions recorded."})})]})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{children:"Hard exclusions"})}),e.jsx(i,{children:e.jsx("ul",{className:"list-disc pl-5",children:a.exclusions.map(s=>e.jsx("li",{children:s},s))})})]}),y&&e.jsxs("p",{role:"alert",children:["Control update failed: ",y,". Refresh before retrying."]})]})})};export{V as default}; +import{i as R,d,b as B,J as C,j as e,L as q}from"./index-CjdUkE4w.js";import{u as Q}from"./useMutation-BYtVrkc7.js";import{C as n,e as i,S as H,b as l,c as t,t as E,f as m,o as x}from"./CronDashboard-Di5xM1py.js";import{B as I}from"./badge-C8r6F6JD.js";import{B as h}from"./button-DetZl_ch.js";import{I as u}from"./input-7i-rZ7fA.js";import{A as P}from"./activity--6WvmXv2.js";import{A as D}from"./arrow-left-CkQb0MI4.js";const j={submissions:"Submission review",curation:"Scheduled curation",cron_health:"CRON health",chat_reliability:"Chat reliability"},S={healthy:"healthy",degraded:"degraded",repairing:"running","rolled-back":"broken",manual:"degraded"},V=()=>{var A;const M=R(),[p,T]=d.useState(""),[f,_]=d.useState(""),[b,v]=d.useState({}),[g,N]=d.useState(""),c=B({queryKey:C.autonomousOperations,queryFn:()=>x.getAutonomousOperations(),refetchInterval:3e4,retry:!1}),r=Q({mutationFn:s=>s(),onSuccess:s=>{M.setQueryData(C.autonomousOperations,s),_(""),v({}),N("")}}),a=c.data,y=r.error instanceof Error?r.error.message:null;if(c.isLoading)return e.jsx("div",{className:"page","aria-busy":"true",children:"Loading autonomous operations…"});if(c.error||!a)return e.jsxs("div",{className:"page",children:[e.jsx("h1",{children:"Autonomous operations unavailable"}),e.jsx("p",{children:c.error instanceof Error?c.error.message:"No status was returned."})]});const O=()=>r.mutate(()=>x.setAutonomousManualMode(!a.manual_mode,a.revision,f)),k=(s,o)=>r.mutate(()=>x.setAutonomousOperator(s,o,a.revision,b[s]??"")),w=()=>{var o;const s=((o=a.baseline)==null?void 0:o.revision)??0;r.mutate(()=>x.qualifyAutonomousChatBaseline(p,s,g))};return e.jsx("div",{className:"cron-dashboard","data-shadcn":!0,children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center gap-3",children:[e.jsx(P,{className:"h-8 w-8"}),"Autonomous operations"]}),e.jsx("p",{className:"mt-2 cron-muted",children:"Content-free supervision, remote controls, and bounded audit history."})]}),e.jsx(h,{asChild:!0,variant:"outline",children:e.jsxs(q,{to:"/admin-dashboard",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Admin dashboard"]})})]}),a.manual_mode&&e.jsx(n,{className:"cron-status--degraded",role:"status",children:e.jsxs(i,{className:"pt-6 flex gap-3",children:[e.jsx(H,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Manual mode is enabled."}),e.jsxs("p",{children:[a.monitoring_active?"Monitoring remains active":"Monitoring is not currently verified","; autonomous callbacks, retries, deployments, and data mutations fail closed."]})]})]})}),e.jsxs("div",{className:"grid md:grid-cols-4 gap-4",children:[e.jsxs(n,{className:E(S[a.display_state]),children:[e.jsx(l,{children:e.jsx(t,{className:"text-sm",children:"Overall state"})}),e.jsxs(i,{children:[e.jsx("div",{className:"text-2xl font-bold capitalize",children:a.display_state}),e.jsxs("p",{className:"text-sm",children:["Monitoring ",a.monitoring_active?"active":"inactive"]})]})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{className:"text-sm",children:"Codex cost"})}),e.jsxs(i,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:["$",a.costs.total_usd]}),e.jsxs("p",{className:"text-sm",children:[a.costs.input_tokens+a.costs.output_tokens," tokens"]})]})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{className:"text-sm",children:"Repair lease"})}),e.jsxs(i,{children:[e.jsx("div",{className:"text-lg font-bold",children:a.active_lease?a.active_lease.owner_operator:"Available"}),e.jsx("p",{className:"text-sm",children:a.active_lease?`Expires ${m(a.active_lease.expires_at)}`:"No active source repair"})]})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{className:"text-sm",children:"Global control"})}),e.jsxs(i,{className:"space-y-2",children:[e.jsx(u,{"aria-label":"Manual mode confirmation",value:f,onChange:s=>_(s.target.value),placeholder:"Type SET_MANUAL_MODE"}),e.jsx(h,{disabled:r.isPending||f!=="SET_MANUAL_MODE",onClick:O,children:a.manual_mode?"Leave manual mode":"Enable manual mode"})]})]})]}),e.jsx("div",{className:"grid md:grid-cols-4 gap-4",children:a.operators.map(s=>e.jsxs(n,{className:E(S[s.status]),children:[e.jsx(l,{children:e.jsxs(t,{className:"flex justify-between gap-2",children:[e.jsx("span",{children:j[s.operator]}),e.jsx(I,{children:s.status})]})}),e.jsxs(i,{className:"space-y-3",children:[e.jsxs("p",{children:[s.enabled?"Mutation enabled":"Mutation disabled"," · monitoring ",s.monitoring_active?"active":"unverified"]}),e.jsxs("p",{className:"text-sm",children:["Next scheduled run: ",s.next_scheduled_run?m(s.next_scheduled_run):"not scheduled"]}),e.jsx(u,{"aria-label":`${j[s.operator]} confirmation`,value:b[s.operator]??"",onChange:o=>v(L=>({...L,[s.operator]:o.target.value})),placeholder:"Type SET_OPERATOR_STATE"}),e.jsx(h,{disabled:r.isPending||a.manual_mode&&!s.enabled||b[s.operator]!=="SET_OPERATOR_STATE",onClick:()=>k(s.operator,!s.enabled),children:s.enabled?"Disable":"Enable"})]})]},s.operator))}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{children:"Qualified scalable-chat baseline"})}),e.jsxs(i,{className:"space-y-3",children:[e.jsx("p",{className:"font-mono break-all",children:((A=a.baseline)==null?void 0:A.sha)??"No baseline qualified"}),a.baseline&&e.jsxs("p",{className:"text-sm",children:["Revision ",a.baseline.revision," · ",a.baseline.qualified_by," · ",m(a.baseline.qualified_at)]}),e.jsxs("div",{className:"grid md:grid-cols-[1fr_1fr_auto] gap-2",children:[e.jsx(u,{"aria-label":"Exact baseline SHA",value:p,onChange:s=>T(s.target.value),placeholder:"40-character lowercase commit SHA"}),e.jsx(u,{"aria-label":"Baseline confirmation",value:g,onChange:s=>N(s.target.value),placeholder:"Type QUALIFY_CHAT_BASELINE"}),e.jsx(h,{disabled:r.isPending||!/^[0-9a-f]{40}$/.test(p)||g!=="QUALIFY_CHAT_BASELINE",onClick:w,children:"Qualify exact SHA"})]})]})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{children:"Provider and fallback state"})}),e.jsx(i,{children:a.provider_states.length?e.jsx("ul",{className:"space-y-2",children:a.provider_states.map(s=>e.jsxs("li",{children:[e.jsx("strong",{children:s.environment}),": ",s.active_provider," · ",s.reason_code," · manifest ",s.manifest_revision]},s.environment))}):e.jsx("p",{children:"No provider state recorded."})})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{children:"Recent runs"})}),e.jsx(i,{children:a.recent_runs.length?e.jsx("ul",{className:"space-y-2",children:a.recent_runs.map(s=>e.jsxs("li",{children:[e.jsx("strong",{children:j[s.operator]})," · ",s.status," · ",s.exit_classification," · $",s.cost_usd," · ",m(s.created_at)]},s.run_id))}):e.jsx("p",{children:"No runs recorded."})})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{children:"Recent actions"})}),e.jsx(i,{children:a.recent_actions.length?e.jsx("ul",{className:"space-y-2",children:a.recent_actions.map(s=>e.jsxs("li",{children:[e.jsx("strong",{children:j[s.operator]})," · ",s.capability," · ",s.reason_code," · ",s.resource_kind,"/",s.resource_identifier]},s.action_id))}):e.jsx("p",{children:"No actions recorded."})})]})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(t,{children:"Hard exclusions"})}),e.jsx(i,{children:e.jsx("ul",{className:"list-disc pl-5",children:a.exclusions.map(s=>e.jsx("li",{children:s},s))})})]}),y&&e.jsxs("p",{role:"alert",children:["Control update failed: ",y,". Refresh before retrying."]})]})})};export{V as default}; diff --git a/assets/BenchmarkDetailView-BObHaEFx.js b/assets/BenchmarkDetailView-B6qFGTVj.js similarity index 93% rename from assets/BenchmarkDetailView-BObHaEFx.js rename to assets/BenchmarkDetailView-B6qFGTVj.js index 2ae51375bd351cd1518d6bbcc6b797b2745fccb1..7f14b3a68ca462c3fb5a8c51490625a553a45d5a 100644 --- a/assets/BenchmarkDetailView-BObHaEFx.js +++ b/assets/BenchmarkDetailView-B6qFGTVj.js @@ -1,2 +1,2 @@ -import{d as L,j as a,K as le,L as ne,e as dt,x as ut,u as mt,g as ht,b as te,o as de,t as ft,T as oe}from"./index-DyXq7-Tg.js";import{R as pt}from"./ResearchFollowButton-Dv316ClR.js";import{c as re}from"./catalog-CRar2olQ.js";import{C as gt,E as xt,e as bt}from"./ExternalSourceEvalBadge-K3r45EmO.js";import{u as yt}from"./preferences-COzeOLyS.js";import{L as ce}from"./LatexTitle-Bkyz3jCs.js";import{S as Ge}from"./switch-nfvTohnt.js";import{I as wt}from"./Icon-T4LYkEQj.js";import{S as ue}from"./skeleton-C3IIzpSL.js";import{A as vt,a as jt}from"./alert-gbJBhAVE.js";import{B as _t}from"./BenchmarkTrendSparkline-DhXxdQ2D.js";import{s as St}from"./safeExternalHref-CkBrsh84.js";import{s as kt}from"./slug-BpH-Nkvz.js";import{i as Ct}from"./apiErrors-BSvbQBb0.js";import Et from"./NotFound-DV_nwcxG.js";import"./researchTopic-DbX0eko-.js";import"./useMutation-UWxBeqtn.js";import"./plus-Yh42pKZz.js";import"./curation-YeS7FBYf.js";import"./hover-card-B45EJIn_.js";import"./account-cbblajck.js";import"./index-C041TDos.js";function ie(e){if(e==null)return null;if(typeof e=="number")return Number.isFinite(e)?e:null;const t=e.includes("±")?e.split("±")[0].trim():e.trim(),r=parseFloat(t);return Number.isFinite(r)?r:null}const Xe=[{label:"All",maxParametersExclusive:void 0},{label:"<10M",maxParametersExclusive:1e7},{label:"<100M",maxParametersExclusive:1e8},{label:"<1B",maxParametersExclusive:1e9},{label:"<3B",maxParametersExclusive:3e9},{label:"<6B",maxParametersExclusive:6e9},{label:"<12B",maxParametersExclusive:12e9},{label:"<32B",maxParametersExclusive:32e9},{label:"<128B",maxParametersExclusive:128e9},{label:"<500B",maxParametersExclusive:5e11}];function Nt(e){const t=e===null?void 0:Number(e);return Xe.some(r=>r.maxParametersExclusive===t)?t:void 0}function Rt(e){return new Intl.NumberFormat("en",{notation:"compact",maximumSignificantDigits:3}).format(e)}function Pt(e){return[e.paper_id,e.task_id,e.dataset_id,e.model_name,e.harness??""].join("|")}function Tt(e){const t=new Map;for(const r of e){const s=Pt(r),n=t.get(s);if(!n){t.set(s,{...r,metrics:{...r.metrics||{}},sourceEvaluationIds:[r.id],ranksByMetric:r.best_metric&&r.best_rank!=null?{[r.best_metric]:r.best_rank}:{},parameterCount:r.num_parameters??null,hasParameterConflict:!1});continue}n.metrics={...n.metrics,...r.metrics||{}},n.sourceEvaluationIds.push(r.id),r.best_metric&&r.best_rank!=null&&(n.ranksByMetric[r.best_metric]=r.best_rank),r.num_parameters!=null&&!n.hasParameterConflict&&(n.parameterCount===null?n.parameterCount=r.num_parameters:n.parameterCount!==r.num_parameters&&(n.parameterCount=null,n.hasParameterConflict=!0))}return Array.from(t.values())}function Ae(e,t){return t===void 0?e:e.filter(r=>r.parameterCount!==null&&r.parameterCounts+n,0);for(const[s,n]of t)if(n>=2&&n*2>r)return s;return null}function Lt(e,t){const r=e.evaluated_on;return r&&r!==t&&r!==Mt(e.updated_at)?r:e.paper_published_date||""}function It(e,t,r){if(e.length===0)return{points:[],sota:0,sotaModel:""};const s=Ft(e),n=e.map(u=>{var R;const h=ie((R=u.metrics)==null?void 0:R[t]);return{eval:u,value:h,date:Lt(u,s)}}).filter(u=>u.value!==null&&!!u.date).sort((u,h)=>u.date.localeCompare(h.date)),i=[];let l=null;for(const u of n){const h=l==null?!0:r==="↓"?u.valuel;h&&(l=u.value),i.push({value:u.value,date:u.date,dateLabel:u.date.slice(0,7),modelName:u.eval.model_name||"",paperTitle:u.eval.paper_title||"",paperRouteId:u.eval.paper_arxiv_id||u.eval.paper_id||null,isSota:h})}const d=e.map(u=>{var h;return{eval:u,value:ie((h=u.metrics)==null?void 0:h[t])}}).filter(u=>u.value!==null).sort((u,h)=>r==="↓"?u.value-h.value:h.value-u.value)[0],f=(d==null?void 0:d.value)??0,x=(d==null?void 0:d.eval.model_name)||(d==null?void 0:d.eval.paper_title)||"";return{points:i,sota:f,sotaModel:x}}function At(e,t,r){const s=t?(e??[]).filter(l=>l.task_id===t):e??[],n=s.filter(l=>l.is_open===!1),i=n.reduce((l,c)=>l?(c.best_rank??Number.POSITIVE_INFINITY)<(l.best_rank??Number.POSITIVE_INFINITY)?c:l:c,null);return{visible:r?s.filter(l=>l.is_open!==!1):s,hiddenClosed:n,topHiddenClosed:i}}function Ye(e,t,r,s){const n=t.find(i=>i.id===s);if(e.length===0)return null;if(n!=null&&n.task_id&&e.some(i=>i.id===n.task_id))return n.task_id;if(r){const i=e.find(l=>l.slug===r);if(i)return i.id}if(e.length===1)return e[0].id;if(t.length>0){const i=new Map;for(const d of t)i.set(d.task_id,(i.get(d.task_id)||0)+1);let l=null,c=-1;for(const d of e){const f=i.get(d.id)||0;f>c&&(c=f,l=d.id)}if(l)return l}return e[0].id}function Bt(e){var _,X,Y;const{evaluations:t,tasks:r,taskSlug:s,highlightEvalId:n,parameterBound:i,showMoreMetrics:l,fittingMetricCount:c=1}=e,d=Ye(r,t,s,n),f=r.find(o=>o.id===d)||r[0]||null,x=t.find(o=>o.id===n),u=At(t,d,e.hideClosed),h=Tt(u.visible),R=Ae(h,i),C=e.configuredMetrics.map(o=>o.metric_name),P=Array.from(new Set(h.flatMap(o=>[...o.best_metric?[o.best_metric]:[],...Object.keys(o.metrics||{})]))),S=C.length?C:P,g=new Map;for(const o of h){const m=o.best_metric;!m||ie(o.metrics[m])===null||C.length&&!S.includes(m)||g.set(m,(g.get(m)||0)+1)}const k=((_=[...g].sort((o,m)=>m[1]-o[1])[0])==null?void 0:_[0])||S[0]||"",j=S.find(o=>{var m;return o.toLocaleLowerCase()===((m=e.metric)==null?void 0:m.trim().toLocaleLowerCase())})||(x==null?void 0:x.best_metric)||k,D=((X=e.directions)==null?void 0:X.directions[j])==="lower_is_better"?"↓":"↑",W=j&&S.includes(j)?[j,...S.filter(o=>o!==j)]:S,w=W.length?l?W:W.slice(0,Math.max(1,c)):j?[j]:[],q=R.slice().sort((o,m)=>{const p=ie(o.metrics[j]),y=ie(m.metrics[j]);return p!==null&&y!==null?D==="↓"?p-y:y-p:p!==null?-1:y!==null?1:Be(o,j)-Be(m,j)});let I=null,N=0;const G=q.map((o,m)=>{const p=ie(o.metrics[j]);return p!==null&&p!==I&&(I=p,N=m+1),{evaluation:o,rank:p===null?null:N,isHighlighted:$t(o,n)}}),{points:z,sota:ee,sotaModel:O}=It(R,j,D),$=i===void 0?e.initialSummary:void 0,U=e.ready.evaluations&&e.ready.tasks&&e.ready.directions&&(!d||e.ready.metrics),K={parameter_coverage_known:h.filter(o=>o.parameterCount!==null).length,parameter_coverage_total:h.length};return{currentTaskId:d,primaryTask:f,activeMetric:j,arrow:D,allowedMetrics:S,orderedMetrics:W,visibleMetrics:w,rows:G,chartPoints:z,highlightedEval:((Y=G.find(o=>o.isHighlighted))==null?void 0:Y.evaluation)||null,hiddenClosedEvals:u.hiddenClosed,hiddenClosedTopEval:u.topHiddenClosed,parameterBound:i,parameterCoverage:K,hasParameterMetadata:K.parameter_coverage_known>0,parameterFilters:Xe.map(o=>({...o,selected:i===o.maxParametersExclusive,disabled:i!==o.maxParametersExclusive&&Ae(h,o.maxParametersExclusive).length===0})),displayedMetric:U?j:$==null?void 0:$.metric,displayedSota:U?ee:$==null?void 0:$.value,displayedSotaModel:U?O:$==null?void 0:$.model_name,isSummaryLoading:!U&&!$,isInitialFilteredViewLoading:i!==void 0&&!U}}function Dt(e,t,r,s=1,n=0){const i=e-t.fixed-(r?t.harness:0);if(t.metric<=0)return 1;const l=Math.floor(i/t.metric);if(lr+pe(t,s),0),harness:pe(t,"--bm-harness-width"),metric:pe(t,"--bm-metric-width")}}const Vt=20;function De(e,t){return e?a.jsx(ce,{title:e}):t||"—"}function Wt({model:e,showHarness:t,setMetric:r,highlightRowRef:s,onFittingMetricCountChange:n}){const{rows:i,visibleMetrics:l,activeMetric:c,arrow:d}=e,[f,x]=L.useState(null);return L.useEffect(()=>{if(!f)return;const u=()=>{f.classList.toggle("has-horizontal-overflow",f.scrollWidth>f.clientWidth);const R=f.firstElementChild;if(!R)return;const C=f.clientWidth,P=Ht(R);f.classList.toggle("unpins-trailing-columns",CS.clientHeight?0:Vt;n(k=>Dt(C,P,t,k,g))},h=new ResizeObserver(u);return h.observe(f),f.firstElementChild&&h.observe(f.firstElementChild),u(),()=>h.disconnect()},[f,t,n]),a.jsx("div",{ref:x,className:"bm-table-scroll",role:"region","aria-label":"Leaderboard metrics",tabIndex:0,children:a.jsxs("table",{id:"benchmark-leaderboard",className:"bm-table",style:{"--bm-metric-count":l.length,"--bm-harness-count":t?1:0},children:[a.jsxs("colgroup",{children:[a.jsx("col",{className:"bm-width-rank"}),a.jsx("col",{className:"bm-width-model"}),a.jsx("col",{className:"bm-width-parameters"}),t&&a.jsx("col",{className:"bm-width-harness"}),l.map(u=>a.jsx("col",{className:"bm-width-metric"},u)),a.jsx("col",{}),a.jsx("col",{className:"bm-width-year"})]}),a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{className:"col-rank",children:"Rank"}),a.jsx("th",{className:"col-model",children:"Model"}),a.jsxs("th",{className:"col-parameters",children:[a.jsx("span",{className:"bm-label-full",children:"Parameters"}),a.jsx("span",{className:"bm-label-short",children:"Params"})]}),t&&a.jsx("th",{className:"col-harness",children:"Harness"}),l.map(u=>{const h=u===c;return a.jsx("th",{className:`col-value ${h?"is-active":""}`,"aria-sort":h?d==="↓"?"ascending":"descending":"none",children:a.jsxs("button",{type:"button",className:"bm-metric-header",onClick:()=>r(u),"aria-pressed":h,title:`Sort by ${u}`,children:[u,h?` ${d}`:""]})},u)}),a.jsx("th",{className:"col-paper",children:"Paper"}),a.jsx("th",{className:"col-year",children:"Year"})]})}),a.jsx("tbody",{children:i.map(({evaluation:u,rank:h,isHighlighted:R})=>{var S;const C=u.paper_arxiv_id||u.paper_id,P=u.paper_title||(u.paper_arxiv_id?`arXiv:${u.paper_arxiv_id}`:null);return a.jsxs("tr",{ref:R?s:void 0,className:R?"is-highlighted":void 0,children:[a.jsx("td",{className:"col-rank",children:h??"—"}),a.jsxs("td",{className:"col-model",children:[R&&a.jsx("span",{className:"bm-row-marker","aria-hidden":"true"}),u.hf_model_url?a.jsx("a",{href:u.hf_model_url,target:"_blank",rel:"noopener noreferrer",className:"bm-model-link",title:`Open ${u.model_name||"model"} on Hugging Face`,children:u.model_name||"—"}):u.model_name||"—",u.is_open===!1&&a.jsx(gt,{}),(u.external??u.is_external)&&a.jsx(xt,{sourceUrl:u.source_url||u.external_source_url||u.result_url})]}),a.jsx("td",{className:"col-parameters",title:u.parameterCount===null?void 0:u.parameterCount.toLocaleString("en-US"),"aria-label":u.parameterCount===null?"Parameters unknown":`${u.parameterCount.toLocaleString("en-US")} parameters`,children:u.parameterCount===null?"—":Rt(u.parameterCount)}),t&&a.jsx("td",{className:"col-harness",children:u.harness||"—"}),l.map(g=>{var j;const k=g===c,B=(j=u.metrics)==null?void 0:j[g];return a.jsx("td",{className:`col-value${k?" is-active":""}${k&&h===1?" is-best":""}`,children:B!=null&&B!==""?le(B):"—"},g)}),a.jsx("td",{className:"col-paper",children:C?a.jsx(ne,{to:`/paper/${C}`,title:u.paper_title||P||void 0,children:De(u.paper_title,P)}):De(u.paper_title,P)}),a.jsx("td",{className:"col-year",children:((S=u.evaluated_on||u.paper_published_date)==null?void 0:S.slice(0,4))||"—"})]},u.id)})})]})})}function He(e){const t=e.length===7?`${e}-01`:e,r=new Date(t).getTime();return Number.isFinite(r)?r:0}const ge=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function xe(e){const t=new Date(e);return{year:t.getFullYear(),month:t.getMonth()}}function Ot(e,t){if(e===t){const{year:d,month:f}=xe(e);return[{timestamp:new Date(d,f,1).getTime(),key:`${d}-${f}`,label:`${ge[f]} ${d}`}]}const r=xe(e),s=xe(t);if(r.year===s.year){const d=s.month-r.month+1;let f=1;const x=12;d>x&&(f=Math.ceil(d/x));const u=[];for(let h=r.month;h<=s.month;h+=f)u.push({timestamp:new Date(r.year,h,1).getTime(),key:`${r.year}-${h}`,label:d<=3?`${ge[h]} ${r.year}`:ge[h]});return u}const n=s.year-r.year+1;let i=1;const l=12;n>l&&(i=Math.ceil(n/l));const c=[];for(let d=r.year;d<=s.year;d+=i)c.push({timestamp:new Date(d,0,1).getTime(),key:String(d),label:String(d)});return c}const Ut=({points:e,metric:t})=>{const r=dt(),[s,n]=L.useState(null),i=880,l=320,c=60,d=30,f=40,x=50,u=e.map(o=>o.value),h=Math.min(...u),C=Math.max(...u)-h||1,P=i-c-d,S=l-f-x,g=e.map(o=>He(o.date)),k=Math.min(...g),B=Math.max(...g),j=B-k||1,D=o=>k===B?c+P/2:c+(o-k)/j*P,W=e.map((o,m)=>{const p=D(He(o.date)),y=(o.value-h)/C,T=f+S*(1-y);return{x:p,y:T,data:o,idx:m}}),w=W.filter(o=>o.data.isSota);let q="";if(w.length>=2){q=`M${w[0].x},${w[0].y}`;for(let o=1;o{const m=o.data.modelName||o.data.paperTitle||"";if(!m)return null;const p=m.length>22?m.slice(0,21)+"…":m,y=p.length*I;let T=o.x-y/2,E=o.x+y/2,v="middle";return Ti-d&&(E=i-d,T=E-y,v="end"),{x:v==="start"?c:v==="end"?i-d:o.x,y:o.y-G,text:p,anchor:v,left:T,right:E}},ee=[],O=w.length>0?z(w[w.length-1]):null;let $=-1/0;for(let o=0;oO.left-N||($=m.right,ee.push({x:m.x,y:m.y,text:m.text,anchor:m.anchor})))}O&&ee.push({x:O.x,y:O.y,text:O.text,anchor:O.anchor});const U=Ot(k,B),K=5,_=o=>n(m=>m===o?null:m),X=o=>{o&&r(`/paper/${o}`)},Y=(o,m)=>{const y=`${o.data.modelName||o.data.paperTitle||"Unknown model"}: ${le(o.data.value)} on ${o.data.dateLabel}`,T=!!o.data.paperRouteId;return a.jsxs("g",{children:[m,a.jsx("circle",{cx:o.x,cy:o.y,r:"10",fill:"transparent",style:{cursor:T?"pointer":"default",outline:"none"},tabIndex:0,role:T?"link":"img","aria-label":y,onMouseEnter:()=>n(o.idx),onMouseLeave:()=>_(o.idx),onFocus:()=>n(o.idx),onBlur:()=>_(o.idx),onClick:()=>X(o.data.paperRouteId),onKeyDown:E=>{T&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),X(o.data.paperRouteId))},children:a.jsx("title",{children:y})})]},o.idx)};return a.jsxs("svg",{width:"100%",viewBox:`0 0 ${i} ${l}`,style:{display:"block"},children:[a.jsx("text",{x:c-38,y:f+S/2,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-faint)",textAnchor:"middle",transform:`rotate(-90 ${c-38} ${f+S/2})`,children:t}),Array.from({length:K}).map((o,m)=>{const p=m/(K-1),y=f+S*(1-p),T=h+C*p;return a.jsxs("g",{children:[a.jsx("line",{x1:c,y1:y,x2:i-d,y2:y,stroke:"var(--hairline)",strokeWidth:"1"}),a.jsx("text",{x:c-10,y:y+4,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-faint)",textAnchor:"end",children:le(T)})]},m)}),U.map(o=>{const m=D(o.timestamp);return a.jsx("text",{x:m,y:l-x+18,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-soft)",textAnchor:"middle",children:o.label},o.key)}),W.filter(o=>!o.data.isSota).map(o=>{const m=s===o.idx;return Y(o,a.jsx("circle",{cx:o.x,cy:o.y,r:m?3:2,fill:"var(--ink-faint)",opacity:m?1:.45,style:{transition:"r 0.12s ease, opacity 0.12s ease"}}))}),q&&a.jsx("path",{d:q,stroke:"var(--accent)",strokeWidth:"2",fill:"none",strokeLinejoin:"round",strokeLinecap:"round"}),w.map(o=>{const m=s===o.idx;return Y(o,a.jsx("circle",{cx:o.x,cy:o.y,r:m?4.5:3,fill:m?"var(--accent)":"var(--bg-elevated)",stroke:"var(--accent)",strokeWidth:"1.5",style:{transition:"r 0.12s ease, fill 0.12s ease"}}))}),ee.map((o,m)=>a.jsx("text",{x:o.x,y:o.y,fontSize:"9.5",fontFamily:"var(--mono)",fill:"var(--ink-soft)",textAnchor:o.anchor,pointerEvents:"none",style:{paintOrder:"stroke",stroke:"var(--bg-elevated)",strokeWidth:3,strokeLinejoin:"round"},children:o.text},`label-${m}`)),s!==null&&W[s]&&(()=>{const o=W[s],m=o.data.modelName||o.data.paperTitle||"Unknown model",y=`${m.length>40?m.slice(0,39)+"…":m}: ${le(o.data.value)}`,E=Math.max(120,Math.min(340,y.length*6.6+24)),v=30;let H=o.x-E/2;Hi-d&&(H=i-d-E);const Q=o.y-v-14>=f?o.y-v-12:o.y+12;return a.jsxs("g",{pointerEvents:"none",children:[a.jsx("rect",{x:H,y:Q,width:E,height:v,rx:"6",ry:"6",fill:"var(--bg-elevated)",stroke:"var(--hairline-strong)",strokeWidth:"1",style:{filter:"drop-shadow(0 2px 6px rgba(0,0,0,0.08))"}}),a.jsx("text",{x:H+12,y:Q+19,fontSize:"12",fontFamily:"var(--sans)",fill:"var(--ink)",fontWeight:500,children:y})]})})()]})};function qt(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const r=document.implementation.createHTMLDocument(),s=r.createElement("base"),n=r.createElement("a");return r.head.appendChild(s),r.body.appendChild(n),t&&(s.href=t),n.href=e,n.href}const zt=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Z(e){const t=[];for(let r=0,s=e.length;rV||e.height>V)&&(e.width>V&&e.height>V?e.width>e.height?(e.height*=V/e.width,e.width=V):(e.width*=V/e.height,e.height=V):e.width>V?(e.height*=V/e.width,e.width=V):(e.width*=V/e.height,e.height=V))}function Yt(e,t={}){return e.toBlob?new Promise(r=>{e.toBlob(r,t.type?t.type:"image/png",t.quality?t.quality:1)}):new Promise(r=>{const s=window.atob(e.toDataURL(t.type?t.type:void 0,t.quality?t.quality:void 0).split(",")[1]),n=s.length,i=new Uint8Array(n);for(let l=0;l{const s=new Image;s.onload=()=>{s.decode().then(()=>{requestAnimationFrame(()=>t(s))})},s.onerror=r,s.crossOrigin="anonymous",s.decoding="async",s.src=e})}async function Jt(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Zt(e,t,r){const s="http://www.w3.org/2000/svg",n=document.createElementNS(s,"svg"),i=document.createElementNS(s,"foreignObject");return n.setAttribute("width",`${t}`),n.setAttribute("height",`${r}`),n.setAttribute("viewBox",`0 0 ${t} ${r}`),i.setAttribute("width","100%"),i.setAttribute("height","100%"),i.setAttribute("x","0"),i.setAttribute("y","0"),i.setAttribute("externalResourcesRequired","true"),n.appendChild(i),i.appendChild(e),Jt(n)}const A=(e,t)=>{if(e instanceof t)return!0;const r=Object.getPrototypeOf(e);return r===null?!1:r.constructor.name===t.name||A(r,t)};function er(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function tr(e,t){return Je(t).map(r=>{const s=e.getPropertyValue(r),n=e.getPropertyPriority(r);return`${r}: ${s}${n?" !important":""};`}).join(" ")}function rr(e,t,r,s){const n=`.${e}:${t}`,i=r.cssText?er(r):tr(r,s);return document.createTextNode(`${n}{${i}}`)}function Ve(e,t,r,s){const n=window.getComputedStyle(e,r),i=n.getPropertyValue("content");if(i===""||i==="none")return;const l=zt();try{t.className=`${t.className} ${l}`}catch{return}const c=document.createElement("style");c.appendChild(rr(l,r,n,s)),t.appendChild(c)}function ar(e,t,r){Ve(e,t,":before",r),Ve(e,t,":after",r)}const We="application/font-woff",Oe="image/jpeg",sr={woff:We,woff2:We,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Oe,jpeg:Oe,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function nr(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function ve(e){const t=nr(e).toLowerCase();return sr[t]||""}function ir(e){return e.split(/,/)[1]}function ye(e){return e.search(/^(data:)/)!==-1}function lr(e,t){return`data:${t};base64,${e}`}async function et(e,t,r){const s=await fetch(e,t);if(s.status===404)throw new Error(`Resource "${s.url}" not found`);const n=await s.blob();return new Promise((i,l)=>{const c=new FileReader;c.onerror=l,c.onloadend=()=>{try{i(r({res:s,result:c.result}))}catch(d){l(d)}},c.readAsDataURL(n)})}const be={};function or(e,t,r){let s=e.replace(/\?.*/,"");return r&&(s=e),/ttf|otf|eot|woff2?/i.test(s)&&(s=s.replace(/.*\//,"")),t?`[${t}]${s}`:s}async function je(e,t,r){const s=or(e,t,r.includeQueryParams);if(be[s]!=null)return be[s];r.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let n;try{const i=await et(e,r.fetchRequestInit,({res:l,result:c})=>(t||(t=l.headers.get("Content-Type")||""),ir(c)));n=lr(i,t)}catch(i){n=r.imagePlaceholder||"";let l=`Failed to fetch resource: ${e}`;i&&(l=typeof i=="string"?i:i.message),l&&console.warn(l)}return be[s]=n,n}async function cr(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):he(t)}async function dr(e,t){if(e.currentSrc){const i=document.createElement("canvas"),l=i.getContext("2d");i.width=e.clientWidth,i.height=e.clientHeight,l==null||l.drawImage(e,0,0,i.width,i.height);const c=i.toDataURL();return he(c)}const r=e.poster,s=ve(r),n=await je(r,s,t);return he(n)}async function ur(e,t){var r;try{if(!((r=e==null?void 0:e.contentDocument)===null||r===void 0)&&r.body)return await fe(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function mr(e,t){return A(e,HTMLCanvasElement)?cr(e):A(e,HTMLVideoElement)?dr(e,t):A(e,HTMLIFrameElement)?ur(e,t):e.cloneNode(tt(e))}const hr=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",tt=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function fr(e,t,r){var s,n;if(tt(t))return t;let i=[];return hr(e)&&e.assignedNodes?i=Z(e.assignedNodes()):A(e,HTMLIFrameElement)&&(!((s=e.contentDocument)===null||s===void 0)&&s.body)?i=Z(e.contentDocument.body.childNodes):i=Z(((n=e.shadowRoot)!==null&&n!==void 0?n:e).childNodes),i.length===0||A(e,HTMLVideoElement)||await i.reduce((l,c)=>l.then(()=>fe(c,r)).then(d=>{d&&t.appendChild(d)}),Promise.resolve()),t}function pr(e,t,r){const s=t.style;if(!s)return;const n=window.getComputedStyle(e);n.cssText?(s.cssText=n.cssText,s.transformOrigin=n.transformOrigin):Je(r).forEach(i=>{let l=n.getPropertyValue(i);i==="font-size"&&l.endsWith("px")&&(l=`${Math.floor(parseFloat(l.substring(0,l.length-2)))-.1}px`),A(e,HTMLIFrameElement)&&i==="display"&&l==="inline"&&(l="block"),i==="d"&&t.getAttribute("d")&&(l=`path(${t.getAttribute("d")})`),s.setProperty(i,l,n.getPropertyPriority(i))})}function gr(e,t){A(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),A(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function xr(e,t){if(A(e,HTMLSelectElement)){const r=t,s=Array.from(r.children).find(n=>e.value===n.getAttribute("value"));s&&s.setAttribute("selected","")}}function br(e,t,r){return A(t,Element)&&(pr(e,t,r),ar(e,t,r),gr(e,t),xr(e,t)),t}async function yr(e,t){const r=e.querySelectorAll?e.querySelectorAll("use"):[];if(r.length===0)return e;const s={};for(let i=0;imr(s,t)).then(s=>fr(e,s,t)).then(s=>br(e,s,t)).then(s=>yr(s,t))}const rt=/url\((['"]?)([^'"]+?)\1\)/g,wr=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,vr=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function jr(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function _r(e){const t=[];return e.replace(rt,(r,s,n)=>(t.push(n),r)),t.filter(r=>!ye(r))}async function Sr(e,t,r,s,n){try{const i=r?qt(t,r):t,l=ve(t);let c;return n||(c=await je(i,l,s)),e.replace(jr(t),`$1${c}$3`)}catch{}return e}function kr(e,{preferredFontFormat:t}){return t?e.replace(vr,r=>{for(;;){const[s,,n]=wr.exec(r)||[];if(!n)return"";if(n===t)return`src: ${s};`}}):e}function at(e){return e.search(rt)!==-1}async function st(e,t,r){if(!at(e))return e;const s=kr(e,r);return _r(s).reduce((i,l)=>i.then(c=>Sr(c,l,t,r)),Promise.resolve(s))}async function se(e,t,r){var s;const n=(s=t.style)===null||s===void 0?void 0:s.getPropertyValue(e);if(n){const i=await st(n,null,r);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function Cr(e,t){await se("background",e,t)||await se("background-image",e,t),await se("mask",e,t)||await se("-webkit-mask",e,t)||await se("mask-image",e,t)||await se("-webkit-mask-image",e,t)}async function Er(e,t){const r=A(e,HTMLImageElement);if(!(r&&!ye(e.src))&&!(A(e,SVGImageElement)&&!ye(e.href.baseVal)))return;const s=r?e.src:e.href.baseVal,n=await je(s,ve(s),t);await new Promise((i,l)=>{e.onload=i,e.onerror=t.onImageErrorHandler?(...d)=>{try{i(t.onImageErrorHandler(...d))}catch(f){l(f)}}:l;const c=e;c.decode&&(c.decode=i),c.loading==="lazy"&&(c.loading="eager"),r?(e.srcset="",e.src=n):e.href.baseVal=n})}async function Nr(e,t){const s=Z(e.childNodes).map(n=>nt(n,t));await Promise.all(s).then(()=>e)}async function nt(e,t){A(e,Element)&&(await Cr(e,t),await Er(e,t),await Nr(e,t))}function Rr(e,t){const{style:r}=e;t.backgroundColor&&(r.backgroundColor=t.backgroundColor),t.width&&(r.width=`${t.width}px`),t.height&&(r.height=`${t.height}px`);const s=t.style;return s!=null&&Object.keys(s).forEach(n=>{r[n]=s[n]}),e}const Ue={};async function qe(e){let t=Ue[e];if(t!=null)return t;const s=await(await fetch(e)).text();return t={url:e,cssText:s},Ue[e]=t,t}async function ze(e,t){let r=e.cssText;const s=/url\(["']?([^"')]+)["']?\)/g,i=(r.match(/url\([^)]+\)/g)||[]).map(async l=>{let c=l.replace(s,"$1");return c.startsWith("https://")||(c=new URL(c,e.url).href),et(c,t.fetchRequestInit,({result:d})=>(r=r.replace(l,`url(${d})`),[l,d]))});return Promise.all(i).then(()=>r)}function Ke(e){if(e==null)return[];const t=[],r=/(\/\*[\s\S]*?\*\/)/gi;let s=e.replace(r,"");const n=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const d=n.exec(s);if(d===null)break;t.push(d[0])}s=s.replace(n,"");const i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,l="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(l,"gi");for(;;){let d=i.exec(s);if(d===null){if(d=c.exec(s),d===null)break;i.lastIndex=c.lastIndex}else c.lastIndex=i.lastIndex;t.push(d[0])}return t}async function Pr(e,t){const r=[],s=[];return e.forEach(n=>{if("cssRules"in n)try{Z(n.cssRules||[]).forEach((i,l)=>{if(i.type===CSSRule.IMPORT_RULE){let c=l+1;const d=i.href,f=qe(d).then(x=>ze(x,t)).then(x=>Ke(x).forEach(u=>{try{n.insertRule(u,u.startsWith("@import")?c+=1:n.cssRules.length)}catch(h){console.error("Error inserting rule from remote css",{rule:u,error:h})}})).catch(x=>{console.error("Error loading remote css",x.toString())});s.push(f)}})}catch(i){const l=e.find(c=>c.href==null)||document.styleSheets[0];n.href!=null&&s.push(qe(n.href).then(c=>ze(c,t)).then(c=>Ke(c).forEach(d=>{l.insertRule(d,l.cssRules.length)})).catch(c=>{console.error("Error loading remote stylesheet",c)})),console.error("Error inlining remote css file",i)}}),Promise.all(s).then(()=>(e.forEach(n=>{if("cssRules"in n)try{Z(n.cssRules||[]).forEach(i=>{r.push(i)})}catch(i){console.error(`Error while reading CSS rules from ${n.href}`,i)}}),r))}function Tr(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>at(t.style.getPropertyValue("src")))}async function $r(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=Z(e.ownerDocument.styleSheets),s=await Pr(r,t);return Tr(s)}function it(e){return e.trim().replace(/["']/g,"")}function Mr(e){const t=new Set;function r(s){(s.style.fontFamily||getComputedStyle(s).fontFamily).split(",").forEach(i=>{t.add(it(i))}),Array.from(s.children).forEach(i=>{i instanceof HTMLElement&&r(i)})}return r(e),t}async function Fr(e,t){const r=await $r(e,t),s=Mr(e);return(await Promise.all(r.filter(i=>s.has(it(i.style.fontFamily))).map(i=>{const l=i.parentStyleSheet?i.parentStyleSheet.href:null;return st(i.cssText,l,t)}))).join(` -`)}async function Lr(e,t){const r=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Fr(e,t);if(r){const s=document.createElement("style"),n=document.createTextNode(r);s.appendChild(n),e.firstChild?e.insertBefore(s,e.firstChild):e.appendChild(s)}}async function Ir(e,t={}){const{width:r,height:s}=Ze(e,t),n=await fe(e,t,!0);return await Lr(n,t),await nt(n,t),Rr(n,t),await Zt(n,r,s)}async function Ar(e,t={}){const{width:r,height:s}=Ze(e,t),n=await Ir(e,t),i=await he(n),l=document.createElement("canvas"),c=l.getContext("2d"),d=t.pixelRatio||Gt(),f=t.canvasWidth||r,x=t.canvasHeight||s;return l.width=f*d,l.height=x*d,t.skipAutoScale||Xt(l),l.style.width=`${f}`,l.style.height=`${x}`,t.backgroundColor&&(c.fillStyle=t.backgroundColor,c.fillRect(0,0,l.width,l.height)),c.drawImage(i,0,0,l.width,l.height),l}async function Br(e,t={}){const r=await Ar(e,t);return await Yt(r)}const we="#ffffff";function Dr(){return typeof window>"u"?we:window.getComputedStyle(document.documentElement).getPropertyValue("--bg-elevated").trim()||we}function Hr(e){if(typeof window>"u")return we;const t=window.getComputedStyle(e).backgroundColor;return!t||t==="rgba(0, 0, 0, 0)"||t==="transparent"?Dr():t}async function Vr(e){var r,s;if(typeof window>"u"||!((s=(r=window.navigator)==null?void 0:r.clipboard)!=null&&s.write))throw new Error("Clipboard image copy is not supported in this browser.");if(typeof window.ClipboardItem>"u")throw new Error("Clipboard image copy is not supported in this browser.");const t=await Br(e,{pixelRatio:2,cacheBust:!0,backgroundColor:Hr(e)});if(!t)throw new Error("Failed to render screenshot.");await window.navigator.clipboard.write([new window.ClipboardItem({"image/png":t})])}const lt=({targetRef:e,label:t})=>{const{toast:r}=ut(),[s,n]=L.useState("idle"),i=L.useRef(null);L.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]);const l=L.useCallback(async()=>{const d=e.current;if(d){n("copying"),d.classList.add("is-capturing"),d.offsetHeight,await new Promise(f=>window.requestAnimationFrame(()=>f()));try{await Vr(d),n("copied"),r({title:"Screenshot copied",description:`Image of the ${t} copied to your clipboard.`}),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>n("idle"),1500)}catch(f){n("idle"),r({title:"Copy failed",description:f instanceof Error&&f.message?f.message:"Could not copy the screenshot to your clipboard.",variant:"destructive"})}finally{d.classList.remove("is-capturing")}}},[e,t,r]),c=s==="copied"?"Copied":s==="copying"?"Copying…":"Copy image";return a.jsxs("button",{type:"button",className:"bm-copy-btn",onClick:l,disabled:s==="copying","aria-label":`Copy ${t} screenshot to clipboard`,title:`Copy ${t} screenshot to clipboard`,children:[a.jsx(wt,{name:"copy",size:11}),c]})};function Wr({model:e,datasetName:t,hideClosed:r,setHideClosed:s,setMetric:n}){const i=L.useRef(null),{isInitialFilteredViewLoading:l,chartPoints:c,activeMetric:d,allowedMetrics:f,orderedMetrics:x,parameterBound:u}=e;return l||c.length===0?null:a.jsxs("div",{className:"bm-card",ref:i,children:[a.jsxs("div",{className:"bm-card-screenshot-header","aria-hidden":"true",children:[a.jsxs("div",{className:"bm-card-screenshot-title",children:[a.jsx("span",{className:"bm-card-screenshot-eyebrow",children:"Benchmark"}),a.jsx("span",{className:"bm-card-screenshot-name",children:t})]}),a.jsxs("div",{className:"bm-card-screenshot-brand",children:[a.jsxs("span",{className:"brand",children:[a.jsx("span",{className:"brand-mark"}),a.jsxs("span",{className:"brand-name",children:["Papers ",a.jsx("em",{children:"With Code"})]})]}),a.jsx("span",{className:"bm-card-screenshot-url",children:"paperswithcode.co"})]})]}),a.jsxs("div",{className:"bm-card-head",children:[a.jsx("div",{className:"bm-card-title",children:"SOTA progression"}),a.jsxs("div",{className:"bm-card-actions",children:[f.length>1&&a.jsxs("label",{className:"bm-view-select",children:[a.jsx("span",{className:"bm-view-select-label",children:"View"}),a.jsx("select",{value:d,onChange:h=>n(h.target.value),children:x.map(h=>a.jsx("option",{value:h,children:h},h))})]}),a.jsxs("label",{className:"bm-closed-toggle",title:"Show or hide evaluations of closed-source models",children:[a.jsx(Ge,{className:"bm-closed-toggle-switch",checked:!r,onCheckedChange:h=>{s(!h)},"aria-label":"Show closed-source models"}),a.jsx("span",{className:"bm-closed-toggle-label",children:"Closed-source"})]}),a.jsx(lt,{targetRef:i,label:"SOTA chart"})]})]}),a.jsx("div",{className:"bm-chart-wrap",children:a.jsx(Ut,{points:c,metric:d})}),a.jsxs("div",{className:"bm-chart-foot",children:[a.jsx("span",{className:"legend-dot"}),u===void 0?"All models":"Filtered models"," over time · highlighted dots track the running best · hover for the model · click to open the paper"]})]})}function Or(e){if(!e)return null;const t=e.trim(),r=t.match(/^https?:\/\/(?:www\.)?arxiv\.org\/(?:abs|pdf)\/([^/?#]+)/i);if(r!=null&&r[1])return r[1].replace(/\.pdf$/i,"");const s=t.match(/^(?:https?:\/\/(?:www\.)?paperswithcode\.co)?\/paper\/([^/?#]+)/i);return(s==null?void 0:s[1])??null}function Qe(e,t){return e?a.jsx(ce,{title:e}):t||"—"}const ma=()=>{var _e,Se,ke,Ce,Ee,Ne,Re,Pe,Te,$e,Me;const{datasetSlug:e}=mt(),[t,r]=ht(),s=t.get("task")||void 0,n=t.get("eval")||void 0,i=Nt(t.get("max_parameters_exclusive")),{preferences:l,setHideClosedSourceEvals:c}=yt(),d=L.useRef(null),f=L.useRef(!1),x=L.useRef(null),[u,h]=L.useState(null),R=`${e}:${s||""}`,C=u===R,[P,S]=L.useState(1),g=te({queryKey:[...de.dataset(e),"with-paper",s,l.hide_closed_source_evals?"open":"all"],queryFn:()=>re.getDatasetBySlug(e,{include_paper:!0,task:s,is_open:l.hide_closed_source_evals?!0:void 0}),enabled:!!e,staleTime:oe}),k=te({queryKey:ft.byDataset((_e=g.data)==null?void 0:_e.id),queryFn:()=>bt.byDataset(g.data.id),enabled:!!((Se=g.data)!=null&&Se.id),staleTime:5*60*1e3}),B=te({queryKey:[...de.datasetTasks,(ke=g.data)==null?void 0:ke.id],queryFn:()=>re.datasetTasks(g.data.id),enabled:!!((Ce=g.data)!=null&&Ce.id),staleTime:oe}),j=te({queryKey:["metric-directions"],queryFn:()=>re.metricDirections(),staleTime:60*60*1e3}),D=Ye(B.data||[],k.data||[],s,n),W=te({queryKey:[...de.taskBenchmarkTrends,D,l.hide_closed_source_evals?!0:void 0],queryFn:()=>re.trendingBenchmarks(D,{limit:100,min_recent_papers:0,is_open:l.hide_closed_source_evals?!0:void 0}),enabled:!!D&&!!((Ee=g.data)!=null&&Ee.id),staleTime:oe}),w=L.useMemo(()=>{var b;return(((b=W.data)==null?void 0:b.results)||[]).find(M=>{var F;return M.id===((F=g.data)==null?void 0:F.id)})||null},[W.data,(Ne=g.data)==null?void 0:Ne.id]),q=te({queryKey:["leaderboard-metrics",(Re=g.data)==null?void 0:Re.id,D],queryFn:()=>re.leaderboardMetrics(g.data.id,D),enabled:!!((Pe=g.data)!=null&&Pe.id)&&!!D,staleTime:oe}),I=Bt({evaluations:k.data||[],tasks:B.data||[],configuredMetrics:q.data||[],directions:j.data,initialSummary:(Te=g.data)==null?void 0:Te.leaderboard_summary,taskSlug:s,highlightEvalId:n,metric:t.get("metric")||void 0,hideClosed:l.hide_closed_source_evals,parameterBound:i,showMoreMetrics:C,fittingMetricCount:P,ready:{evaluations:k.isSuccess,tasks:B.isSuccess,directions:j.isSuccess,metrics:q.isSuccess}}),{primaryTask:N,hiddenClosedEvals:G,hiddenClosedTopEval:z,isSummaryLoading:ee,displayedMetric:O,displayedSota:$,displayedSotaModel:U,isInitialFilteredViewLoading:K,highlightedEval:_,hasParameterMetadata:X,parameterCoverage:Y,orderedMetrics:o}=I;L.useEffect(()=>{if(f.current||!n||!k.data||k.data.length===0)return;const b=d.current;b&&(f.current=!0,b.scrollIntoView({behavior:"smooth",block:"start"}))},[n,k.data]);const m=te({queryKey:de.area(N==null?void 0:N.area_id),queryFn:()=>re.getArea(N.area_id),enabled:!!(N!=null&&N.area_id),staleTime:oe});if(g.isLoading)return a.jsxs("div",{className:"page",children:[a.jsx(ue,{className:"h-12 w-1/2 mb-6"}),a.jsx(ue,{className:"h-64 w-full"})]});if(Ct(g.error))return a.jsx(Et,{});if(g.error||!g.data)return a.jsx("div",{className:"page",children:a.jsx(vt,{variant:"destructive",children:a.jsx(jt,{children:"Benchmark not found."})})});const p=g.data,y=!!p.supports_harness,T=b=>{r(M=>{const F=new URLSearchParams(M);return b===void 0?F.delete("max_parameters_exclusive"):F.set("max_parameters_exclusive",String(b)),F})},E=b=>{r(M=>{const F=new URLSearchParams(M);return F.set("metric",b),F})},v=p.introducing_paper??void 0,H=(v==null?void 0:v.arxiv_id)||(v==null?void 0:v.id)||Or(p.paper_url),J=(v==null?void 0:v.title)||p.introducing_paper_title||null,Q=(($e=v==null?void 0:v.published)==null?void 0:$e.slice(0,4))||p.introduced_year||null,ot=!!H||!!p.paper_url||!!J,ct=v!=null&&v.arxiv_id||(Me=p.paper_url)!=null&&Me.match(/^https?:\/\/(?:www\.)?arxiv\.org\//i)?`arXiv:${H}`:`Paper ${H}`;return a.jsx("div",{className:"page",children:a.jsxs("div",{className:"bm-page",children:[a.jsxs("div",{className:"breadcrumb",children:[a.jsx(ne,{to:"/tasks",children:"Tasks"}),m.data&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"sep",children:"/"}),a.jsx(ne,{to:`/tasks#area-${kt(m.data.name)}`,children:m.data.name})]}),N&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"sep",children:"/"}),a.jsx(ne,{to:`/tasks/${N.slug||N.id}`,children:N.name})]}),a.jsx("span",{className:"sep",children:"/"}),a.jsx("span",{style:{color:"var(--accent-text)"},children:p.name})]}),a.jsxs("div",{className:"bm-title-row",children:[a.jsx("h1",{className:"bm-title",children:p.name}),w&&a.jsxs("div",{className:"bm-title-trend","aria-label":`${p.name} reporting trend`,children:[a.jsx(_t,{history:w.history,benchmarkName:w.name}),a.jsxs("span",{className:"bm-title-trend-summary",children:[a.jsx("strong",{children:w.recent_paper_count})," ",w.recent_paper_count===1?"paper":"papers",w.rate_change==null?w.recent_paper_count>0&&a.jsx("span",{className:"benchmark-trend-change is-new",children:"new"}):a.jsxs("span",{className:`benchmark-trend-change ${w.rate_change>=1?"is-up":"is-down"}`,children:[w.rate_change>=1?"↑":"↓"," ",w.rate_change.toFixed(1),"×"]})]})]})]}),a.jsx(pt,{kind:"benchmark",entityId:p.id}),a.jsxs("div",{className:"bm-subtitle",children:[ee?a.jsx(ue,{className:"h-5 w-64 bm-summary-skeleton","aria-label":"Loading benchmark summary"}):a.jsxs("span",{children:[O&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"metric-tag",children:O}),a.jsx("span",{style:{color:"var(--hairline-strong)",margin:"0 8px"},children:"·"})]}),U?a.jsxs("span",{children:["Best: ",a.jsx("span",{className:"best-name",children:le($)})," by ",a.jsx("span",{className:"best-name",style:{fontStyle:"normal"},children:U})]}):a.jsxs("span",{children:[I.rows.length," evaluations"]})]}),p.hf_url&&a.jsxs("a",{className:"bm-action-btn",href:p.hf_url,target:"_blank",rel:"noopener noreferrer",children:[a.jsx("span",{"aria-hidden":"true",children:"🤗"})," View on Hugging Face"]})]}),p.description&&a.jsx("p",{className:"bm-description",children:p.description}),l.hide_closed_source_evals&&G.length>0&&a.jsxs("div",{className:"bm-hidden-closed-notice",children:[a.jsxs("span",{children:[G.length," closed-source ",G.length===1?"row is":"rows are"," hidden",z!=null&&z.model_name?a.jsxs(a.Fragment,{children:[", including ",a.jsx("strong",{children:z.model_name})]}):null,"."]}),a.jsx("button",{type:"button",className:"bm-hidden-closed-action",onClick:()=>{c(!1)},children:"Show closed-source"})]}),ot&&a.jsxs("div",{className:"method-source",style:{marginTop:0,marginBottom:18},children:[a.jsx("span",{className:"method-source-label",children:"Source"}),H?a.jsxs(ne,{to:`/paper/${H}`,target:"_blank",rel:"noopener noreferrer",className:"method-source-link",children:[a.jsx("span",{className:"method-source-title",children:J?a.jsx(ce,{title:J}):ct}),Q&&a.jsx("span",{className:"method-source-meta",children:Q})]}):p.paper_url?a.jsxs("a",{href:St(p.paper_url)??void 0,target:"_blank",rel:"noopener noreferrer",className:"method-source-link",children:[a.jsx("span",{className:"method-source-title",children:J?a.jsx(ce,{title:J}):p.paper_url}),Q&&a.jsx("span",{className:"method-source-meta",children:Q})]}):a.jsxs("div",{className:"method-source-link is-static",children:[a.jsx("span",{className:"method-source-title",children:J?a.jsx(ce,{title:J}):null}),Q&&a.jsx("span",{className:"method-source-meta",children:Q})]})]}),a.jsx(Wr,{model:I,datasetName:p.name,hideClosed:l.hide_closed_source_evals,setHideClosed:c,setMetric:E}),_&&(()=>{var Le,Ie;const b=_.paper_arxiv_id||_.paper_id,M=_.paper_title||(_.paper_arxiv_id?`arXiv:${_.paper_arxiv_id}`:null),F=_.best_metric&&((Le=_.metrics)==null?void 0:Le[_.best_metric])!==void 0?_.best_metric:I.activeMetric,Fe=(Ie=_.metrics)==null?void 0:Ie[F];return a.jsxs("div",{className:"bm-highlight-banner",role:"status",children:[a.jsx("span",{className:"bm-highlight-dot","aria-hidden":"true"}),a.jsxs("div",{className:"bm-highlight-text",children:[a.jsx("span",{className:"bm-highlight-label",children:"Comparing result"}),a.jsxs("span",{className:"bm-highlight-paper",children:[_.model_name||M||"—",_.harness?` · ${_.harness}`:""]}),a.jsxs("span",{className:"bm-highlight-meta",children:[Fe!==void 0&&F?a.jsxs(a.Fragment,{children:[F,": ",le(Fe),M?" · ":""]}):null,b?a.jsx(ne,{to:`/paper/${b}`,children:Qe(_.paper_title,M)}):Qe(_.paper_title,M)]})]})]})})(),a.jsxs("div",{className:"bm-card",ref:x,children:[a.jsxs("div",{className:"bm-card-screenshot-header","aria-hidden":"true",children:[a.jsxs("div",{className:"bm-card-screenshot-title",children:[a.jsx("span",{className:"bm-card-screenshot-eyebrow",children:"Benchmark"}),a.jsx("span",{className:"bm-card-screenshot-name",children:p.name})]}),a.jsxs("div",{className:"bm-card-screenshot-brand",children:[a.jsxs("span",{className:"brand",children:[a.jsx("span",{className:"brand-mark"}),a.jsxs("span",{className:"brand-name",children:["Papers ",a.jsx("em",{children:"With Code"})]})]}),a.jsx("span",{className:"bm-card-screenshot-url",children:"paperswithcode.co"})]})]}),a.jsxs("div",{className:"bm-card-head",children:[a.jsx("div",{className:"bm-card-title",children:"Leaderboard"}),a.jsxs("div",{className:"bm-card-actions",children:[I.allowedMetrics.length>1&&a.jsxs("label",{className:"bm-view-select",children:[a.jsx("span",{className:"bm-view-select-label",children:"View"}),a.jsx("select",{value:I.activeMetric,onChange:b=>E(b.target.value),children:o.map(b=>a.jsx("option",{value:b,children:b},b))})]}),a.jsxs("label",{className:"bm-closed-toggle",title:"Show or hide evaluations of closed-source models",children:[a.jsx(Ge,{className:"bm-closed-toggle-switch",checked:!l.hide_closed_source_evals,onCheckedChange:b=>{c(!b)},"aria-label":"Show closed-source models"}),a.jsx("span",{className:"bm-closed-toggle-label",children:"Closed-source"})]}),!K&&!X&&k.isSuccess?a.jsx("span",{className:"bm-parameter-unavailable",children:"Parameter metadata unavailable"}):null,a.jsx(lt,{targetRef:x,label:"leaderboard"})]})]}),!K&&X&&a.jsxs("div",{className:"bm-parameter-filter-bar",children:[a.jsx("span",{className:"bm-parameter-filter-label",children:"Parameters Size"}),a.jsx("div",{className:"bm-parameter-filter-options",role:"group","aria-label":"Filter leaderboard by parameter size",children:I.parameterFilters.map(b=>{const{selected:M,disabled:F}=b;return a.jsx("button",{type:"button",className:`bm-parameter-filter-option${M?" is-active":""}`,"aria-pressed":M,disabled:F,onClick:()=>T(b.maxParametersExclusive),children:b.label},b.label)})}),a.jsxs("span",{className:"bm-parameter-coverage",children:["Parameters known for ",Y.parameter_coverage_known," of ",Y.parameter_coverage_total," entries"]})]}),k.isLoading||K?a.jsx("div",{style:{padding:16},children:Array.from({length:5}).map((b,M)=>a.jsx(ue,{className:"h-10 w-full mb-2"},M))}):I.rows.length===0?i?a.jsxs("div",{className:"no-results",children:["No known parameter counts match this filter. "," ",a.jsx("button",{type:"button",className:"bm-empty-filter-action",onClick:()=>T(void 0),children:"Show all"})]}):a.jsx("div",{className:"no-results",children:"No evaluations submitted yet."}):a.jsxs(a.Fragment,{children:[o.length>P&&a.jsxs("div",{className:"bm-metric-columns-control",children:[a.jsx("button",{type:"button",className:"bm-metric-columns-toggle","aria-expanded":C,"aria-controls":"benchmark-leaderboard",onClick:()=>h(C?null:R),children:C?"Show fewer metrics":`Show more metrics (${o.length-P})`}),C&&a.jsx("span",{children:"Scroll metrics horizontally; model and paper details stay visible."})]}),a.jsx(Wt,{model:I,showHarness:y,setMetric:E,highlightRowRef:d,onFittingMetricCountChange:S})]})]})]})})};export{ma as default}; +import{d as L,j as a,M as le,L as ne,e as dt,x as ut,u as mt,g as ht,b as te,o as de,t as ft,T as oe}from"./index-CjdUkE4w.js";import{R as pt}from"./ResearchFollowButton-DcTptDpW.js";import{c as re}from"./catalog-qXcKve0z.js";import{C as gt,E as xt,e as bt}from"./ExternalSourceEvalBadge-B3fyun97.js";import{u as yt}from"./preferences-DMhkYrri.js";import{L as ce}from"./LatexTitle-DESKtS30.js";import{S as Ge}from"./switch-hcLL2FH0.js";import{I as wt}from"./Icon-CGRs4BYD.js";import{S as ue}from"./skeleton-DTWi7Ctg.js";import{A as vt,a as jt}from"./alert-BM9Xfuyy.js";import{B as _t}from"./BenchmarkTrendSparkline-Dfex1cLI.js";import{s as St}from"./safeExternalHref-CkBrsh84.js";import{s as kt}from"./slug-BpH-Nkvz.js";import{i as Ct}from"./apiErrors-D0w5By9R.js";import Et from"./NotFound-BeWhm9El.js";import"./researchTopic-NmABF6tT.js";import"./useMutation-BYtVrkc7.js";import"./plus-AztI1566.js";import"./curation-CyyuHfv5.js";import"./hover-card-CIBIV2Hx.js";import"./account-DoluPGSd.js";import"./index-BxR27SAB.js";function ie(e){if(e==null)return null;if(typeof e=="number")return Number.isFinite(e)?e:null;const t=e.includes("±")?e.split("±")[0].trim():e.trim(),r=parseFloat(t);return Number.isFinite(r)?r:null}const Xe=[{label:"All",maxParametersExclusive:void 0},{label:"<10M",maxParametersExclusive:1e7},{label:"<100M",maxParametersExclusive:1e8},{label:"<1B",maxParametersExclusive:1e9},{label:"<3B",maxParametersExclusive:3e9},{label:"<6B",maxParametersExclusive:6e9},{label:"<12B",maxParametersExclusive:12e9},{label:"<32B",maxParametersExclusive:32e9},{label:"<128B",maxParametersExclusive:128e9},{label:"<500B",maxParametersExclusive:5e11}];function Nt(e){const t=e===null?void 0:Number(e);return Xe.some(r=>r.maxParametersExclusive===t)?t:void 0}function Rt(e){return new Intl.NumberFormat("en",{notation:"compact",maximumSignificantDigits:3}).format(e)}function Pt(e){return[e.paper_id,e.task_id,e.dataset_id,e.model_name,e.harness??""].join("|")}function Tt(e){const t=new Map;for(const r of e){const s=Pt(r),n=t.get(s);if(!n){t.set(s,{...r,metrics:{...r.metrics||{}},sourceEvaluationIds:[r.id],ranksByMetric:r.best_metric&&r.best_rank!=null?{[r.best_metric]:r.best_rank}:{},parameterCount:r.num_parameters??null,hasParameterConflict:!1});continue}n.metrics={...n.metrics,...r.metrics||{}},n.sourceEvaluationIds.push(r.id),r.best_metric&&r.best_rank!=null&&(n.ranksByMetric[r.best_metric]=r.best_rank),r.num_parameters!=null&&!n.hasParameterConflict&&(n.parameterCount===null?n.parameterCount=r.num_parameters:n.parameterCount!==r.num_parameters&&(n.parameterCount=null,n.hasParameterConflict=!0))}return Array.from(t.values())}function Ae(e,t){return t===void 0?e:e.filter(r=>r.parameterCount!==null&&r.parameterCounts+n,0);for(const[s,n]of t)if(n>=2&&n*2>r)return s;return null}function Lt(e,t){const r=e.evaluated_on;return r&&r!==t&&r!==$t(e.updated_at)?r:e.paper_published_date||""}function It(e,t,r){if(e.length===0)return{points:[],sota:0,sotaModel:""};const s=Ft(e),n=e.map(u=>{var R;const h=ie((R=u.metrics)==null?void 0:R[t]);return{eval:u,value:h,date:Lt(u,s)}}).filter(u=>u.value!==null&&!!u.date).sort((u,h)=>u.date.localeCompare(h.date)),i=[];let l=null;for(const u of n){const h=l==null?!0:r==="↓"?u.valuel;h&&(l=u.value),i.push({value:u.value,date:u.date,dateLabel:u.date.slice(0,7),modelName:u.eval.model_name||"",paperTitle:u.eval.paper_title||"",paperRouteId:u.eval.paper_arxiv_id||u.eval.paper_id||null,isSota:h})}const d=e.map(u=>{var h;return{eval:u,value:ie((h=u.metrics)==null?void 0:h[t])}}).filter(u=>u.value!==null).sort((u,h)=>r==="↓"?u.value-h.value:h.value-u.value)[0],f=(d==null?void 0:d.value)??0,x=(d==null?void 0:d.eval.model_name)||(d==null?void 0:d.eval.paper_title)||"";return{points:i,sota:f,sotaModel:x}}function At(e,t,r){const s=t?(e??[]).filter(l=>l.task_id===t):e??[],n=s.filter(l=>l.is_open===!1),i=n.reduce((l,c)=>l?(c.best_rank??Number.POSITIVE_INFINITY)<(l.best_rank??Number.POSITIVE_INFINITY)?c:l:c,null);return{visible:r?s.filter(l=>l.is_open!==!1):s,hiddenClosed:n,topHiddenClosed:i}}function Ye(e,t,r,s){const n=t.find(i=>i.id===s);if(e.length===0)return null;if(n!=null&&n.task_id&&e.some(i=>i.id===n.task_id))return n.task_id;if(r){const i=e.find(l=>l.slug===r);if(i)return i.id}if(e.length===1)return e[0].id;if(t.length>0){const i=new Map;for(const d of t)i.set(d.task_id,(i.get(d.task_id)||0)+1);let l=null,c=-1;for(const d of e){const f=i.get(d.id)||0;f>c&&(c=f,l=d.id)}if(l)return l}return e[0].id}function Bt(e){var _,X,Y;const{evaluations:t,tasks:r,taskSlug:s,highlightEvalId:n,parameterBound:i,showMoreMetrics:l,fittingMetricCount:c=1}=e,d=Ye(r,t,s,n),f=r.find(o=>o.id===d)||r[0]||null,x=t.find(o=>o.id===n),u=At(t,d,e.hideClosed),h=Tt(u.visible),R=Ae(h,i),C=e.configuredMetrics.map(o=>o.metric_name),P=Array.from(new Set(h.flatMap(o=>[...o.best_metric?[o.best_metric]:[],...Object.keys(o.metrics||{})]))),S=C.length?C:P,g=new Map;for(const o of h){const m=o.best_metric;!m||ie(o.metrics[m])===null||C.length&&!S.includes(m)||g.set(m,(g.get(m)||0)+1)}const k=((_=[...g].sort((o,m)=>m[1]-o[1])[0])==null?void 0:_[0])||S[0]||"",j=S.find(o=>{var m;return o.toLocaleLowerCase()===((m=e.metric)==null?void 0:m.trim().toLocaleLowerCase())})||(x==null?void 0:x.best_metric)||k,D=((X=e.directions)==null?void 0:X.directions[j])==="lower_is_better"?"↓":"↑",W=j&&S.includes(j)?[j,...S.filter(o=>o!==j)]:S,w=W.length?l?W:W.slice(0,Math.max(1,c)):j?[j]:[],q=R.slice().sort((o,m)=>{const p=ie(o.metrics[j]),y=ie(m.metrics[j]);return p!==null&&y!==null?D==="↓"?p-y:y-p:p!==null?-1:y!==null?1:Be(o,j)-Be(m,j)});let I=null,N=0;const G=q.map((o,m)=>{const p=ie(o.metrics[j]);return p!==null&&p!==I&&(I=p,N=m+1),{evaluation:o,rank:p===null?null:N,isHighlighted:Mt(o,n)}}),{points:z,sota:ee,sotaModel:O}=It(R,j,D),M=i===void 0?e.initialSummary:void 0,U=e.ready.evaluations&&e.ready.tasks&&e.ready.directions&&(!d||e.ready.metrics),K={parameter_coverage_known:h.filter(o=>o.parameterCount!==null).length,parameter_coverage_total:h.length};return{currentTaskId:d,primaryTask:f,activeMetric:j,arrow:D,allowedMetrics:S,orderedMetrics:W,visibleMetrics:w,rows:G,chartPoints:z,highlightedEval:((Y=G.find(o=>o.isHighlighted))==null?void 0:Y.evaluation)||null,hiddenClosedEvals:u.hiddenClosed,hiddenClosedTopEval:u.topHiddenClosed,parameterBound:i,parameterCoverage:K,hasParameterMetadata:K.parameter_coverage_known>0,parameterFilters:Xe.map(o=>({...o,selected:i===o.maxParametersExclusive,disabled:i!==o.maxParametersExclusive&&Ae(h,o.maxParametersExclusive).length===0})),displayedMetric:U?j:M==null?void 0:M.metric,displayedSota:U?ee:M==null?void 0:M.value,displayedSotaModel:U?O:M==null?void 0:M.model_name,isSummaryLoading:!U&&!M,isInitialFilteredViewLoading:i!==void 0&&!U}}function Dt(e,t,r,s=1,n=0){const i=e-t.fixed-(r?t.harness:0);if(t.metric<=0)return 1;const l=Math.floor(i/t.metric);if(lr+pe(t,s),0),harness:pe(t,"--bm-harness-width"),metric:pe(t,"--bm-metric-width")}}const Vt=20;function De(e,t){return e?a.jsx(ce,{title:e}):t||"—"}function Wt({model:e,showHarness:t,setMetric:r,highlightRowRef:s,onFittingMetricCountChange:n}){const{rows:i,visibleMetrics:l,activeMetric:c,arrow:d}=e,[f,x]=L.useState(null);return L.useEffect(()=>{if(!f)return;const u=()=>{f.classList.toggle("has-horizontal-overflow",f.scrollWidth>f.clientWidth);const R=f.firstElementChild;if(!R)return;const C=f.clientWidth,P=Ht(R);f.classList.toggle("unpins-trailing-columns",CS.clientHeight?0:Vt;n(k=>Dt(C,P,t,k,g))},h=new ResizeObserver(u);return h.observe(f),f.firstElementChild&&h.observe(f.firstElementChild),u(),()=>h.disconnect()},[f,t,n]),a.jsx("div",{ref:x,className:"bm-table-scroll",role:"region","aria-label":"Leaderboard metrics",tabIndex:0,children:a.jsxs("table",{id:"benchmark-leaderboard",className:"bm-table",style:{"--bm-metric-count":l.length,"--bm-harness-count":t?1:0},children:[a.jsxs("colgroup",{children:[a.jsx("col",{className:"bm-width-rank"}),a.jsx("col",{className:"bm-width-model"}),a.jsx("col",{className:"bm-width-parameters"}),t&&a.jsx("col",{className:"bm-width-harness"}),l.map(u=>a.jsx("col",{className:"bm-width-metric"},u)),a.jsx("col",{}),a.jsx("col",{className:"bm-width-year"})]}),a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{className:"col-rank",children:"Rank"}),a.jsx("th",{className:"col-model",children:"Model"}),a.jsxs("th",{className:"col-parameters",children:[a.jsx("span",{className:"bm-label-full",children:"Parameters"}),a.jsx("span",{className:"bm-label-short",children:"Params"})]}),t&&a.jsx("th",{className:"col-harness",children:"Harness"}),l.map(u=>{const h=u===c;return a.jsx("th",{className:`col-value ${h?"is-active":""}`,"aria-sort":h?d==="↓"?"ascending":"descending":"none",children:a.jsxs("button",{type:"button",className:"bm-metric-header",onClick:()=>r(u),"aria-pressed":h,title:`Sort by ${u}`,children:[u,h?` ${d}`:""]})},u)}),a.jsx("th",{className:"col-paper",children:"Paper"}),a.jsx("th",{className:"col-year",children:"Year"})]})}),a.jsx("tbody",{children:i.map(({evaluation:u,rank:h,isHighlighted:R})=>{var S;const C=u.paper_arxiv_id||u.paper_id,P=u.paper_title||(u.paper_arxiv_id?`arXiv:${u.paper_arxiv_id}`:null);return a.jsxs("tr",{ref:R?s:void 0,className:R?"is-highlighted":void 0,children:[a.jsx("td",{className:"col-rank",children:h??"—"}),a.jsxs("td",{className:"col-model",children:[R&&a.jsx("span",{className:"bm-row-marker","aria-hidden":"true"}),u.hf_model_url?a.jsx("a",{href:u.hf_model_url,target:"_blank",rel:"noopener noreferrer",className:"bm-model-link",title:`Open ${u.model_name||"model"} on Hugging Face`,children:u.model_name||"—"}):u.model_name||"—",u.is_open===!1&&a.jsx(gt,{}),(u.external??u.is_external)&&a.jsx(xt,{sourceUrl:u.source_url||u.external_source_url||u.result_url})]}),a.jsx("td",{className:"col-parameters",title:u.parameterCount===null?void 0:u.parameterCount.toLocaleString("en-US"),"aria-label":u.parameterCount===null?"Parameters unknown":`${u.parameterCount.toLocaleString("en-US")} parameters`,children:u.parameterCount===null?"—":Rt(u.parameterCount)}),t&&a.jsx("td",{className:"col-harness",children:u.harness||"—"}),l.map(g=>{var j;const k=g===c,B=(j=u.metrics)==null?void 0:j[g];return a.jsx("td",{className:`col-value${k?" is-active":""}${k&&h===1?" is-best":""}`,children:B!=null&&B!==""?le(B):"—"},g)}),a.jsx("td",{className:"col-paper",children:C?a.jsx(ne,{to:`/paper/${C}`,title:u.paper_title||P||void 0,children:De(u.paper_title,P)}):De(u.paper_title,P)}),a.jsx("td",{className:"col-year",children:((S=u.evaluated_on||u.paper_published_date)==null?void 0:S.slice(0,4))||"—"})]},u.id)})})]})})}function He(e){const t=e.length===7?`${e}-01`:e,r=new Date(t).getTime();return Number.isFinite(r)?r:0}const ge=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function xe(e){const t=new Date(e);return{year:t.getFullYear(),month:t.getMonth()}}function Ot(e,t){if(e===t){const{year:d,month:f}=xe(e);return[{timestamp:new Date(d,f,1).getTime(),key:`${d}-${f}`,label:`${ge[f]} ${d}`}]}const r=xe(e),s=xe(t);if(r.year===s.year){const d=s.month-r.month+1;let f=1;const x=12;d>x&&(f=Math.ceil(d/x));const u=[];for(let h=r.month;h<=s.month;h+=f)u.push({timestamp:new Date(r.year,h,1).getTime(),key:`${r.year}-${h}`,label:d<=3?`${ge[h]} ${r.year}`:ge[h]});return u}const n=s.year-r.year+1;let i=1;const l=12;n>l&&(i=Math.ceil(n/l));const c=[];for(let d=r.year;d<=s.year;d+=i)c.push({timestamp:new Date(d,0,1).getTime(),key:String(d),label:String(d)});return c}const Ut=({points:e,metric:t})=>{const r=dt(),[s,n]=L.useState(null),i=880,l=320,c=60,d=30,f=40,x=50,u=e.map(o=>o.value),h=Math.min(...u),C=Math.max(...u)-h||1,P=i-c-d,S=l-f-x,g=e.map(o=>He(o.date)),k=Math.min(...g),B=Math.max(...g),j=B-k||1,D=o=>k===B?c+P/2:c+(o-k)/j*P,W=e.map((o,m)=>{const p=D(He(o.date)),y=(o.value-h)/C,T=f+S*(1-y);return{x:p,y:T,data:o,idx:m}}),w=W.filter(o=>o.data.isSota);let q="";if(w.length>=2){q=`M${w[0].x},${w[0].y}`;for(let o=1;o{const m=o.data.modelName||o.data.paperTitle||"";if(!m)return null;const p=m.length>22?m.slice(0,21)+"…":m,y=p.length*I;let T=o.x-y/2,E=o.x+y/2,v="middle";return Ti-d&&(E=i-d,T=E-y,v="end"),{x:v==="start"?c:v==="end"?i-d:o.x,y:o.y-G,text:p,anchor:v,left:T,right:E}},ee=[],O=w.length>0?z(w[w.length-1]):null;let M=-1/0;for(let o=0;oO.left-N||(M=m.right,ee.push({x:m.x,y:m.y,text:m.text,anchor:m.anchor})))}O&&ee.push({x:O.x,y:O.y,text:O.text,anchor:O.anchor});const U=Ot(k,B),K=5,_=o=>n(m=>m===o?null:m),X=o=>{o&&r(`/paper/${o}`)},Y=(o,m)=>{const y=`${o.data.modelName||o.data.paperTitle||"Unknown model"}: ${le(o.data.value)} on ${o.data.dateLabel}`,T=!!o.data.paperRouteId;return a.jsxs("g",{children:[m,a.jsx("circle",{cx:o.x,cy:o.y,r:"10",fill:"transparent",style:{cursor:T?"pointer":"default",outline:"none"},tabIndex:0,role:T?"link":"img","aria-label":y,onMouseEnter:()=>n(o.idx),onMouseLeave:()=>_(o.idx),onFocus:()=>n(o.idx),onBlur:()=>_(o.idx),onClick:()=>X(o.data.paperRouteId),onKeyDown:E=>{T&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),X(o.data.paperRouteId))},children:a.jsx("title",{children:y})})]},o.idx)};return a.jsxs("svg",{width:"100%",viewBox:`0 0 ${i} ${l}`,style:{display:"block"},children:[a.jsx("text",{x:c-38,y:f+S/2,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-faint)",textAnchor:"middle",transform:`rotate(-90 ${c-38} ${f+S/2})`,children:t}),Array.from({length:K}).map((o,m)=>{const p=m/(K-1),y=f+S*(1-p),T=h+C*p;return a.jsxs("g",{children:[a.jsx("line",{x1:c,y1:y,x2:i-d,y2:y,stroke:"var(--hairline)",strokeWidth:"1"}),a.jsx("text",{x:c-10,y:y+4,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-faint)",textAnchor:"end",children:le(T)})]},m)}),U.map(o=>{const m=D(o.timestamp);return a.jsx("text",{x:m,y:l-x+18,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-soft)",textAnchor:"middle",children:o.label},o.key)}),W.filter(o=>!o.data.isSota).map(o=>{const m=s===o.idx;return Y(o,a.jsx("circle",{cx:o.x,cy:o.y,r:m?3:2,fill:"var(--ink-faint)",opacity:m?1:.45,style:{transition:"r 0.12s ease, opacity 0.12s ease"}}))}),q&&a.jsx("path",{d:q,stroke:"var(--accent)",strokeWidth:"2",fill:"none",strokeLinejoin:"round",strokeLinecap:"round"}),w.map(o=>{const m=s===o.idx;return Y(o,a.jsx("circle",{cx:o.x,cy:o.y,r:m?4.5:3,fill:m?"var(--accent)":"var(--bg-elevated)",stroke:"var(--accent)",strokeWidth:"1.5",style:{transition:"r 0.12s ease, fill 0.12s ease"}}))}),ee.map((o,m)=>a.jsx("text",{x:o.x,y:o.y,fontSize:"9.5",fontFamily:"var(--mono)",fill:"var(--ink-soft)",textAnchor:o.anchor,pointerEvents:"none",style:{paintOrder:"stroke",stroke:"var(--bg-elevated)",strokeWidth:3,strokeLinejoin:"round"},children:o.text},`label-${m}`)),s!==null&&W[s]&&(()=>{const o=W[s],m=o.data.modelName||o.data.paperTitle||"Unknown model",y=`${m.length>40?m.slice(0,39)+"…":m}: ${le(o.data.value)}`,E=Math.max(120,Math.min(340,y.length*6.6+24)),v=30;let H=o.x-E/2;Hi-d&&(H=i-d-E);const Q=o.y-v-14>=f?o.y-v-12:o.y+12;return a.jsxs("g",{pointerEvents:"none",children:[a.jsx("rect",{x:H,y:Q,width:E,height:v,rx:"6",ry:"6",fill:"var(--bg-elevated)",stroke:"var(--hairline-strong)",strokeWidth:"1",style:{filter:"drop-shadow(0 2px 6px rgba(0,0,0,0.08))"}}),a.jsx("text",{x:H+12,y:Q+19,fontSize:"12",fontFamily:"var(--sans)",fill:"var(--ink)",fontWeight:500,children:y})]})})()]})};function qt(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const r=document.implementation.createHTMLDocument(),s=r.createElement("base"),n=r.createElement("a");return r.head.appendChild(s),r.body.appendChild(n),t&&(s.href=t),n.href=e,n.href}const zt=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Z(e){const t=[];for(let r=0,s=e.length;rV||e.height>V)&&(e.width>V&&e.height>V?e.width>e.height?(e.height*=V/e.width,e.width=V):(e.width*=V/e.height,e.height=V):e.width>V?(e.height*=V/e.width,e.width=V):(e.width*=V/e.height,e.height=V))}function Yt(e,t={}){return e.toBlob?new Promise(r=>{e.toBlob(r,t.type?t.type:"image/png",t.quality?t.quality:1)}):new Promise(r=>{const s=window.atob(e.toDataURL(t.type?t.type:void 0,t.quality?t.quality:void 0).split(",")[1]),n=s.length,i=new Uint8Array(n);for(let l=0;l{const s=new Image;s.onload=()=>{s.decode().then(()=>{requestAnimationFrame(()=>t(s))})},s.onerror=r,s.crossOrigin="anonymous",s.decoding="async",s.src=e})}async function Jt(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Zt(e,t,r){const s="http://www.w3.org/2000/svg",n=document.createElementNS(s,"svg"),i=document.createElementNS(s,"foreignObject");return n.setAttribute("width",`${t}`),n.setAttribute("height",`${r}`),n.setAttribute("viewBox",`0 0 ${t} ${r}`),i.setAttribute("width","100%"),i.setAttribute("height","100%"),i.setAttribute("x","0"),i.setAttribute("y","0"),i.setAttribute("externalResourcesRequired","true"),n.appendChild(i),i.appendChild(e),Jt(n)}const A=(e,t)=>{if(e instanceof t)return!0;const r=Object.getPrototypeOf(e);return r===null?!1:r.constructor.name===t.name||A(r,t)};function er(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function tr(e,t){return Je(t).map(r=>{const s=e.getPropertyValue(r),n=e.getPropertyPriority(r);return`${r}: ${s}${n?" !important":""};`}).join(" ")}function rr(e,t,r,s){const n=`.${e}:${t}`,i=r.cssText?er(r):tr(r,s);return document.createTextNode(`${n}{${i}}`)}function Ve(e,t,r,s){const n=window.getComputedStyle(e,r),i=n.getPropertyValue("content");if(i===""||i==="none")return;const l=zt();try{t.className=`${t.className} ${l}`}catch{return}const c=document.createElement("style");c.appendChild(rr(l,r,n,s)),t.appendChild(c)}function ar(e,t,r){Ve(e,t,":before",r),Ve(e,t,":after",r)}const We="application/font-woff",Oe="image/jpeg",sr={woff:We,woff2:We,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Oe,jpeg:Oe,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function nr(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function ve(e){const t=nr(e).toLowerCase();return sr[t]||""}function ir(e){return e.split(/,/)[1]}function ye(e){return e.search(/^(data:)/)!==-1}function lr(e,t){return`data:${t};base64,${e}`}async function et(e,t,r){const s=await fetch(e,t);if(s.status===404)throw new Error(`Resource "${s.url}" not found`);const n=await s.blob();return new Promise((i,l)=>{const c=new FileReader;c.onerror=l,c.onloadend=()=>{try{i(r({res:s,result:c.result}))}catch(d){l(d)}},c.readAsDataURL(n)})}const be={};function or(e,t,r){let s=e.replace(/\?.*/,"");return r&&(s=e),/ttf|otf|eot|woff2?/i.test(s)&&(s=s.replace(/.*\//,"")),t?`[${t}]${s}`:s}async function je(e,t,r){const s=or(e,t,r.includeQueryParams);if(be[s]!=null)return be[s];r.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let n;try{const i=await et(e,r.fetchRequestInit,({res:l,result:c})=>(t||(t=l.headers.get("Content-Type")||""),ir(c)));n=lr(i,t)}catch(i){n=r.imagePlaceholder||"";let l=`Failed to fetch resource: ${e}`;i&&(l=typeof i=="string"?i:i.message),l&&console.warn(l)}return be[s]=n,n}async function cr(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):he(t)}async function dr(e,t){if(e.currentSrc){const i=document.createElement("canvas"),l=i.getContext("2d");i.width=e.clientWidth,i.height=e.clientHeight,l==null||l.drawImage(e,0,0,i.width,i.height);const c=i.toDataURL();return he(c)}const r=e.poster,s=ve(r),n=await je(r,s,t);return he(n)}async function ur(e,t){var r;try{if(!((r=e==null?void 0:e.contentDocument)===null||r===void 0)&&r.body)return await fe(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function mr(e,t){return A(e,HTMLCanvasElement)?cr(e):A(e,HTMLVideoElement)?dr(e,t):A(e,HTMLIFrameElement)?ur(e,t):e.cloneNode(tt(e))}const hr=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",tt=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function fr(e,t,r){var s,n;if(tt(t))return t;let i=[];return hr(e)&&e.assignedNodes?i=Z(e.assignedNodes()):A(e,HTMLIFrameElement)&&(!((s=e.contentDocument)===null||s===void 0)&&s.body)?i=Z(e.contentDocument.body.childNodes):i=Z(((n=e.shadowRoot)!==null&&n!==void 0?n:e).childNodes),i.length===0||A(e,HTMLVideoElement)||await i.reduce((l,c)=>l.then(()=>fe(c,r)).then(d=>{d&&t.appendChild(d)}),Promise.resolve()),t}function pr(e,t,r){const s=t.style;if(!s)return;const n=window.getComputedStyle(e);n.cssText?(s.cssText=n.cssText,s.transformOrigin=n.transformOrigin):Je(r).forEach(i=>{let l=n.getPropertyValue(i);i==="font-size"&&l.endsWith("px")&&(l=`${Math.floor(parseFloat(l.substring(0,l.length-2)))-.1}px`),A(e,HTMLIFrameElement)&&i==="display"&&l==="inline"&&(l="block"),i==="d"&&t.getAttribute("d")&&(l=`path(${t.getAttribute("d")})`),s.setProperty(i,l,n.getPropertyPriority(i))})}function gr(e,t){A(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),A(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function xr(e,t){if(A(e,HTMLSelectElement)){const r=t,s=Array.from(r.children).find(n=>e.value===n.getAttribute("value"));s&&s.setAttribute("selected","")}}function br(e,t,r){return A(t,Element)&&(pr(e,t,r),ar(e,t,r),gr(e,t),xr(e,t)),t}async function yr(e,t){const r=e.querySelectorAll?e.querySelectorAll("use"):[];if(r.length===0)return e;const s={};for(let i=0;imr(s,t)).then(s=>fr(e,s,t)).then(s=>br(e,s,t)).then(s=>yr(s,t))}const rt=/url\((['"]?)([^'"]+?)\1\)/g,wr=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,vr=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function jr(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function _r(e){const t=[];return e.replace(rt,(r,s,n)=>(t.push(n),r)),t.filter(r=>!ye(r))}async function Sr(e,t,r,s,n){try{const i=r?qt(t,r):t,l=ve(t);let c;return n||(c=await je(i,l,s)),e.replace(jr(t),`$1${c}$3`)}catch{}return e}function kr(e,{preferredFontFormat:t}){return t?e.replace(vr,r=>{for(;;){const[s,,n]=wr.exec(r)||[];if(!n)return"";if(n===t)return`src: ${s};`}}):e}function at(e){return e.search(rt)!==-1}async function st(e,t,r){if(!at(e))return e;const s=kr(e,r);return _r(s).reduce((i,l)=>i.then(c=>Sr(c,l,t,r)),Promise.resolve(s))}async function se(e,t,r){var s;const n=(s=t.style)===null||s===void 0?void 0:s.getPropertyValue(e);if(n){const i=await st(n,null,r);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function Cr(e,t){await se("background",e,t)||await se("background-image",e,t),await se("mask",e,t)||await se("-webkit-mask",e,t)||await se("mask-image",e,t)||await se("-webkit-mask-image",e,t)}async function Er(e,t){const r=A(e,HTMLImageElement);if(!(r&&!ye(e.src))&&!(A(e,SVGImageElement)&&!ye(e.href.baseVal)))return;const s=r?e.src:e.href.baseVal,n=await je(s,ve(s),t);await new Promise((i,l)=>{e.onload=i,e.onerror=t.onImageErrorHandler?(...d)=>{try{i(t.onImageErrorHandler(...d))}catch(f){l(f)}}:l;const c=e;c.decode&&(c.decode=i),c.loading==="lazy"&&(c.loading="eager"),r?(e.srcset="",e.src=n):e.href.baseVal=n})}async function Nr(e,t){const s=Z(e.childNodes).map(n=>nt(n,t));await Promise.all(s).then(()=>e)}async function nt(e,t){A(e,Element)&&(await Cr(e,t),await Er(e,t),await Nr(e,t))}function Rr(e,t){const{style:r}=e;t.backgroundColor&&(r.backgroundColor=t.backgroundColor),t.width&&(r.width=`${t.width}px`),t.height&&(r.height=`${t.height}px`);const s=t.style;return s!=null&&Object.keys(s).forEach(n=>{r[n]=s[n]}),e}const Ue={};async function qe(e){let t=Ue[e];if(t!=null)return t;const s=await(await fetch(e)).text();return t={url:e,cssText:s},Ue[e]=t,t}async function ze(e,t){let r=e.cssText;const s=/url\(["']?([^"')]+)["']?\)/g,i=(r.match(/url\([^)]+\)/g)||[]).map(async l=>{let c=l.replace(s,"$1");return c.startsWith("https://")||(c=new URL(c,e.url).href),et(c,t.fetchRequestInit,({result:d})=>(r=r.replace(l,`url(${d})`),[l,d]))});return Promise.all(i).then(()=>r)}function Ke(e){if(e==null)return[];const t=[],r=/(\/\*[\s\S]*?\*\/)/gi;let s=e.replace(r,"");const n=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const d=n.exec(s);if(d===null)break;t.push(d[0])}s=s.replace(n,"");const i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,l="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(l,"gi");for(;;){let d=i.exec(s);if(d===null){if(d=c.exec(s),d===null)break;i.lastIndex=c.lastIndex}else c.lastIndex=i.lastIndex;t.push(d[0])}return t}async function Pr(e,t){const r=[],s=[];return e.forEach(n=>{if("cssRules"in n)try{Z(n.cssRules||[]).forEach((i,l)=>{if(i.type===CSSRule.IMPORT_RULE){let c=l+1;const d=i.href,f=qe(d).then(x=>ze(x,t)).then(x=>Ke(x).forEach(u=>{try{n.insertRule(u,u.startsWith("@import")?c+=1:n.cssRules.length)}catch(h){console.error("Error inserting rule from remote css",{rule:u,error:h})}})).catch(x=>{console.error("Error loading remote css",x.toString())});s.push(f)}})}catch(i){const l=e.find(c=>c.href==null)||document.styleSheets[0];n.href!=null&&s.push(qe(n.href).then(c=>ze(c,t)).then(c=>Ke(c).forEach(d=>{l.insertRule(d,l.cssRules.length)})).catch(c=>{console.error("Error loading remote stylesheet",c)})),console.error("Error inlining remote css file",i)}}),Promise.all(s).then(()=>(e.forEach(n=>{if("cssRules"in n)try{Z(n.cssRules||[]).forEach(i=>{r.push(i)})}catch(i){console.error(`Error while reading CSS rules from ${n.href}`,i)}}),r))}function Tr(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>at(t.style.getPropertyValue("src")))}async function Mr(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=Z(e.ownerDocument.styleSheets),s=await Pr(r,t);return Tr(s)}function it(e){return e.trim().replace(/["']/g,"")}function $r(e){const t=new Set;function r(s){(s.style.fontFamily||getComputedStyle(s).fontFamily).split(",").forEach(i=>{t.add(it(i))}),Array.from(s.children).forEach(i=>{i instanceof HTMLElement&&r(i)})}return r(e),t}async function Fr(e,t){const r=await Mr(e,t),s=$r(e);return(await Promise.all(r.filter(i=>s.has(it(i.style.fontFamily))).map(i=>{const l=i.parentStyleSheet?i.parentStyleSheet.href:null;return st(i.cssText,l,t)}))).join(` +`)}async function Lr(e,t){const r=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Fr(e,t);if(r){const s=document.createElement("style"),n=document.createTextNode(r);s.appendChild(n),e.firstChild?e.insertBefore(s,e.firstChild):e.appendChild(s)}}async function Ir(e,t={}){const{width:r,height:s}=Ze(e,t),n=await fe(e,t,!0);return await Lr(n,t),await nt(n,t),Rr(n,t),await Zt(n,r,s)}async function Ar(e,t={}){const{width:r,height:s}=Ze(e,t),n=await Ir(e,t),i=await he(n),l=document.createElement("canvas"),c=l.getContext("2d"),d=t.pixelRatio||Gt(),f=t.canvasWidth||r,x=t.canvasHeight||s;return l.width=f*d,l.height=x*d,t.skipAutoScale||Xt(l),l.style.width=`${f}`,l.style.height=`${x}`,t.backgroundColor&&(c.fillStyle=t.backgroundColor,c.fillRect(0,0,l.width,l.height)),c.drawImage(i,0,0,l.width,l.height),l}async function Br(e,t={}){const r=await Ar(e,t);return await Yt(r)}const we="#ffffff";function Dr(){return typeof window>"u"?we:window.getComputedStyle(document.documentElement).getPropertyValue("--bg-elevated").trim()||we}function Hr(e){if(typeof window>"u")return we;const t=window.getComputedStyle(e).backgroundColor;return!t||t==="rgba(0, 0, 0, 0)"||t==="transparent"?Dr():t}async function Vr(e){var r,s;if(typeof window>"u"||!((s=(r=window.navigator)==null?void 0:r.clipboard)!=null&&s.write))throw new Error("Clipboard image copy is not supported in this browser.");if(typeof window.ClipboardItem>"u")throw new Error("Clipboard image copy is not supported in this browser.");const t=await Br(e,{pixelRatio:2,cacheBust:!0,backgroundColor:Hr(e)});if(!t)throw new Error("Failed to render screenshot.");await window.navigator.clipboard.write([new window.ClipboardItem({"image/png":t})])}const lt=({targetRef:e,label:t})=>{const{toast:r}=ut(),[s,n]=L.useState("idle"),i=L.useRef(null);L.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]);const l=L.useCallback(async()=>{const d=e.current;if(d){n("copying"),d.classList.add("is-capturing"),d.offsetHeight,await new Promise(f=>window.requestAnimationFrame(()=>f()));try{await Vr(d),n("copied"),r({title:"Screenshot copied",description:`Image of the ${t} copied to your clipboard.`}),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>n("idle"),1500)}catch(f){n("idle"),r({title:"Copy failed",description:f instanceof Error&&f.message?f.message:"Could not copy the screenshot to your clipboard.",variant:"destructive"})}finally{d.classList.remove("is-capturing")}}},[e,t,r]),c=s==="copied"?"Copied":s==="copying"?"Copying…":"Copy image";return a.jsxs("button",{type:"button",className:"bm-copy-btn",onClick:l,disabled:s==="copying","aria-label":`Copy ${t} screenshot to clipboard`,title:`Copy ${t} screenshot to clipboard`,children:[a.jsx(wt,{name:"copy",size:11}),c]})};function Wr({model:e,datasetName:t,hideClosed:r,setHideClosed:s,setMetric:n}){const i=L.useRef(null),{isInitialFilteredViewLoading:l,chartPoints:c,activeMetric:d,allowedMetrics:f,orderedMetrics:x,parameterBound:u}=e;return l||c.length===0?null:a.jsxs("div",{className:"bm-card",ref:i,children:[a.jsxs("div",{className:"bm-card-screenshot-header","aria-hidden":"true",children:[a.jsxs("div",{className:"bm-card-screenshot-title",children:[a.jsx("span",{className:"bm-card-screenshot-eyebrow",children:"Benchmark"}),a.jsx("span",{className:"bm-card-screenshot-name",children:t})]}),a.jsxs("div",{className:"bm-card-screenshot-brand",children:[a.jsxs("span",{className:"brand",children:[a.jsx("span",{className:"brand-mark"}),a.jsxs("span",{className:"brand-name",children:["Papers ",a.jsx("em",{children:"With Code"})]})]}),a.jsx("span",{className:"bm-card-screenshot-url",children:"paperswithcode.co"})]})]}),a.jsxs("div",{className:"bm-card-head",children:[a.jsx("div",{className:"bm-card-title",children:"SOTA progression"}),a.jsxs("div",{className:"bm-card-actions",children:[f.length>1&&a.jsxs("label",{className:"bm-view-select",children:[a.jsx("span",{className:"bm-view-select-label",children:"View"}),a.jsx("select",{value:d,onChange:h=>n(h.target.value),children:x.map(h=>a.jsx("option",{value:h,children:h},h))})]}),a.jsxs("label",{className:"bm-closed-toggle",title:"Show or hide evaluations of closed-source models",children:[a.jsx(Ge,{className:"bm-closed-toggle-switch",checked:!r,onCheckedChange:h=>{s(!h)},"aria-label":"Show closed-source models"}),a.jsx("span",{className:"bm-closed-toggle-label",children:"Closed-source"})]}),a.jsx(lt,{targetRef:i,label:"SOTA chart"})]})]}),a.jsx("div",{className:"bm-chart-wrap",children:a.jsx(Ut,{points:c,metric:d})}),a.jsxs("div",{className:"bm-chart-foot",children:[a.jsx("span",{className:"legend-dot"}),u===void 0?"All models":"Filtered models"," over time · highlighted dots track the running best · hover for the model · click to open the paper"]})]})}function Or(e){if(!e)return null;const t=e.trim(),r=t.match(/^https?:\/\/(?:www\.)?arxiv\.org\/(?:abs|pdf)\/([^/?#]+)/i);if(r!=null&&r[1])return r[1].replace(/\.pdf$/i,"");const s=t.match(/^(?:https?:\/\/(?:www\.)?paperswithcode\.co)?\/paper\/([^/?#]+)/i);return(s==null?void 0:s[1])??null}function Qe(e,t){return e?a.jsx(ce,{title:e}):t||"—"}const ma=()=>{var _e,Se,ke,Ce,Ee,Ne,Re,Pe,Te,Me,$e;const{datasetSlug:e}=mt(),[t,r]=ht(),s=t.get("task")||void 0,n=t.get("eval")||void 0,i=Nt(t.get("max_parameters_exclusive")),{preferences:l,setHideClosedSourceEvals:c}=yt(),d=L.useRef(null),f=L.useRef(!1),x=L.useRef(null),[u,h]=L.useState(null),R=`${e}:${s||""}`,C=u===R,[P,S]=L.useState(1),g=te({queryKey:[...de.dataset(e),"with-paper",s,l.hide_closed_source_evals?"open":"all"],queryFn:()=>re.getDatasetBySlug(e,{include_paper:!0,task:s,is_open:l.hide_closed_source_evals?!0:void 0}),enabled:!!e,staleTime:oe}),k=te({queryKey:ft.byDataset((_e=g.data)==null?void 0:_e.id),queryFn:()=>bt.byDataset(g.data.id),enabled:!!((Se=g.data)!=null&&Se.id),staleTime:5*60*1e3}),B=te({queryKey:[...de.datasetTasks,(ke=g.data)==null?void 0:ke.id],queryFn:()=>re.datasetTasks(g.data.id),enabled:!!((Ce=g.data)!=null&&Ce.id),staleTime:oe}),j=te({queryKey:["metric-directions"],queryFn:()=>re.metricDirections(),staleTime:60*60*1e3}),D=Ye(B.data||[],k.data||[],s,n),W=te({queryKey:[...de.taskBenchmarkTrends,D,l.hide_closed_source_evals?!0:void 0],queryFn:()=>re.trendingBenchmarks(D,{limit:100,min_recent_papers:0,is_open:l.hide_closed_source_evals?!0:void 0}),enabled:!!D&&!!((Ee=g.data)!=null&&Ee.id),staleTime:oe}),w=L.useMemo(()=>{var b;return(((b=W.data)==null?void 0:b.results)||[]).find($=>{var F;return $.id===((F=g.data)==null?void 0:F.id)})||null},[W.data,(Ne=g.data)==null?void 0:Ne.id]),q=te({queryKey:["leaderboard-metrics",(Re=g.data)==null?void 0:Re.id,D],queryFn:()=>re.leaderboardMetrics(g.data.id,D),enabled:!!((Pe=g.data)!=null&&Pe.id)&&!!D,staleTime:oe}),I=Bt({evaluations:k.data||[],tasks:B.data||[],configuredMetrics:q.data||[],directions:j.data,initialSummary:(Te=g.data)==null?void 0:Te.leaderboard_summary,taskSlug:s,highlightEvalId:n,metric:t.get("metric")||void 0,hideClosed:l.hide_closed_source_evals,parameterBound:i,showMoreMetrics:C,fittingMetricCount:P,ready:{evaluations:k.isSuccess,tasks:B.isSuccess,directions:j.isSuccess,metrics:q.isSuccess}}),{primaryTask:N,hiddenClosedEvals:G,hiddenClosedTopEval:z,isSummaryLoading:ee,displayedMetric:O,displayedSota:M,displayedSotaModel:U,isInitialFilteredViewLoading:K,highlightedEval:_,hasParameterMetadata:X,parameterCoverage:Y,orderedMetrics:o}=I;L.useEffect(()=>{if(f.current||!n||!k.data||k.data.length===0)return;const b=d.current;b&&(f.current=!0,b.scrollIntoView({behavior:"smooth",block:"start"}))},[n,k.data]);const m=te({queryKey:de.area(N==null?void 0:N.area_id),queryFn:()=>re.getArea(N.area_id),enabled:!!(N!=null&&N.area_id),staleTime:oe});if(g.isLoading)return a.jsxs("div",{className:"page",children:[a.jsx(ue,{className:"h-12 w-1/2 mb-6"}),a.jsx(ue,{className:"h-64 w-full"})]});if(Ct(g.error))return a.jsx(Et,{});if(g.error||!g.data)return a.jsx("div",{className:"page",children:a.jsx(vt,{variant:"destructive",children:a.jsx(jt,{children:"Benchmark not found."})})});const p=g.data,y=!!p.supports_harness,T=b=>{r($=>{const F=new URLSearchParams($);return b===void 0?F.delete("max_parameters_exclusive"):F.set("max_parameters_exclusive",String(b)),F})},E=b=>{r($=>{const F=new URLSearchParams($);return F.set("metric",b),F})},v=p.introducing_paper??void 0,H=(v==null?void 0:v.arxiv_id)||(v==null?void 0:v.id)||Or(p.paper_url),J=(v==null?void 0:v.title)||p.introducing_paper_title||null,Q=((Me=v==null?void 0:v.published)==null?void 0:Me.slice(0,4))||p.introduced_year||null,ot=!!H||!!p.paper_url||!!J,ct=v!=null&&v.arxiv_id||($e=p.paper_url)!=null&&$e.match(/^https?:\/\/(?:www\.)?arxiv\.org\//i)?`arXiv:${H}`:`Paper ${H}`;return a.jsx("div",{className:"page",children:a.jsxs("div",{className:"bm-page",children:[a.jsxs("div",{className:"breadcrumb",children:[a.jsx(ne,{to:"/tasks",children:"Tasks"}),m.data&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"sep",children:"/"}),a.jsx(ne,{to:`/tasks#area-${kt(m.data.name)}`,children:m.data.name})]}),N&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"sep",children:"/"}),a.jsx(ne,{to:`/tasks/${N.slug||N.id}`,children:N.name})]}),a.jsx("span",{className:"sep",children:"/"}),a.jsx("span",{style:{color:"var(--accent-text)"},children:p.name})]}),a.jsxs("div",{className:"bm-title-row",children:[a.jsx("h1",{className:"bm-title",children:p.name}),w&&a.jsxs("div",{className:"bm-title-trend","aria-label":`${p.name} reporting trend`,children:[a.jsx(_t,{history:w.history,benchmarkName:w.name}),a.jsxs("span",{className:"bm-title-trend-summary",children:[a.jsx("strong",{children:w.recent_paper_count})," ",w.recent_paper_count===1?"paper":"papers",w.rate_change==null?w.recent_paper_count>0&&a.jsx("span",{className:"benchmark-trend-change is-new",children:"new"}):a.jsxs("span",{className:`benchmark-trend-change ${w.rate_change>=1?"is-up":"is-down"}`,children:[w.rate_change>=1?"↑":"↓"," ",w.rate_change.toFixed(1),"×"]})]})]})]}),a.jsx(pt,{kind:"benchmark",entityId:p.id}),a.jsxs("div",{className:"bm-subtitle",children:[ee?a.jsx(ue,{className:"h-5 w-64 bm-summary-skeleton","aria-label":"Loading benchmark summary"}):a.jsxs("span",{children:[O&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"metric-tag",children:O}),a.jsx("span",{style:{color:"var(--hairline-strong)",margin:"0 8px"},children:"·"})]}),U?a.jsxs("span",{children:["Best: ",a.jsx("span",{className:"best-name",children:le(M)})," by ",a.jsx("span",{className:"best-name",style:{fontStyle:"normal"},children:U})]}):a.jsxs("span",{children:[I.rows.length," evaluations"]})]}),p.hf_url&&a.jsxs("a",{className:"bm-action-btn",href:p.hf_url,target:"_blank",rel:"noopener noreferrer",children:[a.jsx("span",{"aria-hidden":"true",children:"🤗"})," View on Hugging Face"]})]}),p.description&&a.jsx("p",{className:"bm-description",children:p.description}),l.hide_closed_source_evals&&G.length>0&&a.jsxs("div",{className:"bm-hidden-closed-notice",children:[a.jsxs("span",{children:[G.length," closed-source ",G.length===1?"row is":"rows are"," hidden",z!=null&&z.model_name?a.jsxs(a.Fragment,{children:[", including ",a.jsx("strong",{children:z.model_name})]}):null,"."]}),a.jsx("button",{type:"button",className:"bm-hidden-closed-action",onClick:()=>{c(!1)},children:"Show closed-source"})]}),ot&&a.jsxs("div",{className:"method-source",style:{marginTop:0,marginBottom:18},children:[a.jsx("span",{className:"method-source-label",children:"Source"}),H?a.jsxs(ne,{to:`/paper/${H}`,target:"_blank",rel:"noopener noreferrer",className:"method-source-link",children:[a.jsx("span",{className:"method-source-title",children:J?a.jsx(ce,{title:J}):ct}),Q&&a.jsx("span",{className:"method-source-meta",children:Q})]}):p.paper_url?a.jsxs("a",{href:St(p.paper_url)??void 0,target:"_blank",rel:"noopener noreferrer",className:"method-source-link",children:[a.jsx("span",{className:"method-source-title",children:J?a.jsx(ce,{title:J}):p.paper_url}),Q&&a.jsx("span",{className:"method-source-meta",children:Q})]}):a.jsxs("div",{className:"method-source-link is-static",children:[a.jsx("span",{className:"method-source-title",children:J?a.jsx(ce,{title:J}):null}),Q&&a.jsx("span",{className:"method-source-meta",children:Q})]})]}),a.jsx(Wr,{model:I,datasetName:p.name,hideClosed:l.hide_closed_source_evals,setHideClosed:c,setMetric:E}),_&&(()=>{var Le,Ie;const b=_.paper_arxiv_id||_.paper_id,$=_.paper_title||(_.paper_arxiv_id?`arXiv:${_.paper_arxiv_id}`:null),F=_.best_metric&&((Le=_.metrics)==null?void 0:Le[_.best_metric])!==void 0?_.best_metric:I.activeMetric,Fe=(Ie=_.metrics)==null?void 0:Ie[F];return a.jsxs("div",{className:"bm-highlight-banner",role:"status",children:[a.jsx("span",{className:"bm-highlight-dot","aria-hidden":"true"}),a.jsxs("div",{className:"bm-highlight-text",children:[a.jsx("span",{className:"bm-highlight-label",children:"Comparing result"}),a.jsxs("span",{className:"bm-highlight-paper",children:[_.model_name||$||"—",_.harness?` · ${_.harness}`:""]}),a.jsxs("span",{className:"bm-highlight-meta",children:[Fe!==void 0&&F?a.jsxs(a.Fragment,{children:[F,": ",le(Fe),$?" · ":""]}):null,b?a.jsx(ne,{to:`/paper/${b}`,children:Qe(_.paper_title,$)}):Qe(_.paper_title,$)]})]})]})})(),a.jsxs("div",{className:"bm-card",ref:x,children:[a.jsxs("div",{className:"bm-card-screenshot-header","aria-hidden":"true",children:[a.jsxs("div",{className:"bm-card-screenshot-title",children:[a.jsx("span",{className:"bm-card-screenshot-eyebrow",children:"Benchmark"}),a.jsx("span",{className:"bm-card-screenshot-name",children:p.name})]}),a.jsxs("div",{className:"bm-card-screenshot-brand",children:[a.jsxs("span",{className:"brand",children:[a.jsx("span",{className:"brand-mark"}),a.jsxs("span",{className:"brand-name",children:["Papers ",a.jsx("em",{children:"With Code"})]})]}),a.jsx("span",{className:"bm-card-screenshot-url",children:"paperswithcode.co"})]})]}),a.jsxs("div",{className:"bm-card-head",children:[a.jsx("div",{className:"bm-card-title",children:"Leaderboard"}),a.jsxs("div",{className:"bm-card-actions",children:[I.allowedMetrics.length>1&&a.jsxs("label",{className:"bm-view-select",children:[a.jsx("span",{className:"bm-view-select-label",children:"View"}),a.jsx("select",{value:I.activeMetric,onChange:b=>E(b.target.value),children:o.map(b=>a.jsx("option",{value:b,children:b},b))})]}),a.jsxs("label",{className:"bm-closed-toggle",title:"Show or hide evaluations of closed-source models",children:[a.jsx(Ge,{className:"bm-closed-toggle-switch",checked:!l.hide_closed_source_evals,onCheckedChange:b=>{c(!b)},"aria-label":"Show closed-source models"}),a.jsx("span",{className:"bm-closed-toggle-label",children:"Closed-source"})]}),!K&&!X&&k.isSuccess?a.jsx("span",{className:"bm-parameter-unavailable",children:"Parameter metadata unavailable"}):null,a.jsx(lt,{targetRef:x,label:"leaderboard"})]})]}),!K&&X&&a.jsxs("div",{className:"bm-parameter-filter-bar",children:[a.jsx("span",{className:"bm-parameter-filter-label",children:"Parameters Size"}),a.jsx("div",{className:"bm-parameter-filter-options",role:"group","aria-label":"Filter leaderboard by parameter size",children:I.parameterFilters.map(b=>{const{selected:$,disabled:F}=b;return a.jsx("button",{type:"button",className:`bm-parameter-filter-option${$?" is-active":""}`,"aria-pressed":$,disabled:F,onClick:()=>T(b.maxParametersExclusive),children:b.label},b.label)})}),a.jsxs("span",{className:"bm-parameter-coverage",children:["Parameters known for ",Y.parameter_coverage_known," of ",Y.parameter_coverage_total," entries"]})]}),k.isLoading||K?a.jsx("div",{style:{padding:16},children:Array.from({length:5}).map((b,$)=>a.jsx(ue,{className:"h-10 w-full mb-2"},$))}):I.rows.length===0?i?a.jsxs("div",{className:"no-results",children:["No known parameter counts match this filter. "," ",a.jsx("button",{type:"button",className:"bm-empty-filter-action",onClick:()=>T(void 0),children:"Show all"})]}):a.jsx("div",{className:"no-results",children:"No evaluations submitted yet."}):a.jsxs(a.Fragment,{children:[o.length>P&&a.jsxs("div",{className:"bm-metric-columns-control",children:[a.jsx("button",{type:"button",className:"bm-metric-columns-toggle","aria-expanded":C,"aria-controls":"benchmark-leaderboard",onClick:()=>h(C?null:R),children:C?"Show fewer metrics":`Show more metrics (${o.length-P})`}),C&&a.jsx("span",{children:"Scroll metrics horizontally; model and paper details stay visible."})]}),a.jsx(Wt,{model:I,showHarness:y,setMetric:E,highlightRowRef:d,onFittingMetricCountChange:S})]})]})]})})};export{ma as default}; diff --git a/assets/BenchmarkTrendSparkline-DhXxdQ2D.js b/assets/BenchmarkTrendSparkline-Dfex1cLI.js similarity index 97% rename from assets/BenchmarkTrendSparkline-DhXxdQ2D.js rename to assets/BenchmarkTrendSparkline-Dfex1cLI.js index 92e67f48e8c023694cb37e0830e0ce7eb4560581..a5f87e6ef8ee26a0ed480b6b2e7d29a86169af7e 100644 --- a/assets/BenchmarkTrendSparkline-DhXxdQ2D.js +++ b/assets/BenchmarkTrendSparkline-Dfex1cLI.js @@ -1 +1 @@ -import{d as C,j as t}from"./index-DyXq7-Tg.js";const g=112,p=42,o=5,m=5,b=new Intl.DateTimeFormat("en",{month:"short",timeZone:"UTC"}),y=(e,d)=>{const r=new Date(`${e}T00:00:00Z`),n=new Date(`${d}T00:00:00Z`);return r.getUTCMonth()===n.getUTCMonth()?`${b.format(r)} ${r.getUTCDate()}–${n.getUTCDate()}`:`${b.format(r)} ${r.getUTCDate()}–${b.format(n)} ${n.getUTCDate()}`},I=({history:e,benchmarkName:d,interactive:r=!1})=>{const[n,x]=C.useState(null),h=e.map(s=>s.paper_count),M=Math.max(1,...h),f=g-o*2,T=p-m*2,v=h.length>1?f/(h.length-1):0,a=h.map((s,c)=>({x:o+v*c,y:m+T-s/M*T})),$=a.map(({x:s,y:c})=>`${s},${c}`).join(" "),_=a.length?`${o},${p-m} ${$} ${a[a.length-1].x},${p-m}`:"",D=h.reduce((s,c)=>s+c,0),u=49,N=14,i=n==null?null:a[n],j=i?Math.min(g-o-u,Math.max(o,i.x-u/2)):0,k=i?i.y>p/2?i.y-N-3:i.y+3:0;return t.jsxs("svg",{className:`benchmark-trend-sparkline${r?" is-interactive":""}`,viewBox:`0 0 ${g} ${p}`,role:r?"group":"img","aria-label":`${d}: ${D} reporting papers across the displayed trend history`,children:[t.jsxs("title",{children:[d,": ",D," reporting papers across the displayed trend history"]}),t.jsx("line",{className:"benchmark-trend-axis",x1:o,y1:p-m,x2:g-o,y2:p-m}),t.jsx("line",{className:"benchmark-trend-axis",x1:o,y1:m,x2:o,y2:p-m}),_&&t.jsx("polygon",{className:"benchmark-trend-area",points:_}),$&&t.jsx("polyline",{className:"benchmark-trend-line",points:$}),r?a.map(({x:s,y:c},l)=>t.jsxs("g",{className:"benchmark-trend-point",tabIndex:0,role:"img","aria-label":`${y(e[l].start_date,e[l].end_date)}: ${e[l].paper_count} ${e[l].paper_count===1?"paper":"papers"}`,onMouseEnter:()=>x(l),onMouseLeave:()=>x(null),onFocus:()=>x(l),onBlur:()=>x(null),children:[t.jsx("circle",{className:"benchmark-trend-point-hit",cx:s,cy:c,r:"5"}),t.jsx("circle",{className:"benchmark-trend-point-mark",cx:s,cy:c,r:"1.8"})]},`${e[l].start_date}-${e[l].end_date}`)):a.length>0&&t.jsx("circle",{className:"benchmark-trend-dot",cx:a[a.length-1].x,cy:a[a.length-1].y,r:"2.6"}),i&&n!=null&&t.jsxs("g",{className:"benchmark-trend-tooltip",pointerEvents:"none",children:[t.jsx("rect",{x:j,y:k,width:u,height:N,rx:"2"}),t.jsx("text",{x:j+3,y:k+5.4,children:y(e[n].start_date,e[n].end_date)}),t.jsxs("text",{className:"benchmark-trend-tooltip-value",x:j+3,y:k+11,children:[e[n].paper_count," ",e[n].paper_count===1?"paper":"papers"]})]})]})};export{I as B}; +import{d as C,j as t}from"./index-CjdUkE4w.js";const g=112,p=42,o=5,m=5,b=new Intl.DateTimeFormat("en",{month:"short",timeZone:"UTC"}),y=(e,d)=>{const r=new Date(`${e}T00:00:00Z`),n=new Date(`${d}T00:00:00Z`);return r.getUTCMonth()===n.getUTCMonth()?`${b.format(r)} ${r.getUTCDate()}–${n.getUTCDate()}`:`${b.format(r)} ${r.getUTCDate()}–${b.format(n)} ${n.getUTCDate()}`},I=({history:e,benchmarkName:d,interactive:r=!1})=>{const[n,x]=C.useState(null),h=e.map(s=>s.paper_count),M=Math.max(1,...h),f=g-o*2,T=p-m*2,v=h.length>1?f/(h.length-1):0,a=h.map((s,c)=>({x:o+v*c,y:m+T-s/M*T})),$=a.map(({x:s,y:c})=>`${s},${c}`).join(" "),_=a.length?`${o},${p-m} ${$} ${a[a.length-1].x},${p-m}`:"",D=h.reduce((s,c)=>s+c,0),u=49,N=14,i=n==null?null:a[n],j=i?Math.min(g-o-u,Math.max(o,i.x-u/2)):0,k=i?i.y>p/2?i.y-N-3:i.y+3:0;return t.jsxs("svg",{className:`benchmark-trend-sparkline${r?" is-interactive":""}`,viewBox:`0 0 ${g} ${p}`,role:r?"group":"img","aria-label":`${d}: ${D} reporting papers across the displayed trend history`,children:[t.jsxs("title",{children:[d,": ",D," reporting papers across the displayed trend history"]}),t.jsx("line",{className:"benchmark-trend-axis",x1:o,y1:p-m,x2:g-o,y2:p-m}),t.jsx("line",{className:"benchmark-trend-axis",x1:o,y1:m,x2:o,y2:p-m}),_&&t.jsx("polygon",{className:"benchmark-trend-area",points:_}),$&&t.jsx("polyline",{className:"benchmark-trend-line",points:$}),r?a.map(({x:s,y:c},l)=>t.jsxs("g",{className:"benchmark-trend-point",tabIndex:0,role:"img","aria-label":`${y(e[l].start_date,e[l].end_date)}: ${e[l].paper_count} ${e[l].paper_count===1?"paper":"papers"}`,onMouseEnter:()=>x(l),onMouseLeave:()=>x(null),onFocus:()=>x(l),onBlur:()=>x(null),children:[t.jsx("circle",{className:"benchmark-trend-point-hit",cx:s,cy:c,r:"5"}),t.jsx("circle",{className:"benchmark-trend-point-mark",cx:s,cy:c,r:"1.8"})]},`${e[l].start_date}-${e[l].end_date}`)):a.length>0&&t.jsx("circle",{className:"benchmark-trend-dot",cx:a[a.length-1].x,cy:a[a.length-1].y,r:"2.6"}),i&&n!=null&&t.jsxs("g",{className:"benchmark-trend-tooltip",pointerEvents:"none",children:[t.jsx("rect",{x:j,y:k,width:u,height:N,rx:"2"}),t.jsx("text",{x:j+3,y:k+5.4,children:y(e[n].start_date,e[n].end_date)}),t.jsxs("text",{className:"benchmark-trend-tooltip-value",x:j+3,y:k+11,children:[e[n].paper_count," ",e[n].paper_count===1?"paper":"papers"]})]})]})};export{I as B}; diff --git a/assets/CatalogEntityPreviewLink-BktpwL3_.js b/assets/CatalogEntityPreviewLink-DY_jhXy9.js similarity index 96% rename from assets/CatalogEntityPreviewLink-BktpwL3_.js rename to assets/CatalogEntityPreviewLink-DY_jhXy9.js index 71f499bcb63467a6bee3a4c26763458ce3ab18d7..be72fdcc5d40746aef417a73592b36332c592374 100644 --- a/assets/CatalogEntityPreviewLink-BktpwL3_.js +++ b/assets/CatalogEntityPreviewLink-DY_jhXy9.js @@ -1,4 +1,4 @@ -import{s as m,a6 as h,V as d,b as g,j as s,L as f,a3 as k}from"./index-DyXq7-Tg.js";import{H as w,a as y,b as v}from"./hover-card-B45EJIn_.js";import{c as l}from"./catalog-CRar2olQ.js";/** +import{s as m,a5 as h,V as d,b as g,j as s,L as f,a3 as k}from"./index-CjdUkE4w.js";import{H as w,a as y,b as v}from"./hover-card-CIBIV2Hx.js";import{c as l}from"./catalog-qXcKve0z.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/ChatView-D06zYumh.js b/assets/ChatView-D06zYumh.js deleted file mode 100644 index 19ee594c860fbef64aa951e98e81200e750efd25..0000000000000000000000000000000000000000 --- a/assets/ChatView-D06zYumh.js +++ /dev/null @@ -1,6 +0,0 @@ -var ir=Object.defineProperty;var or=(e,r,t)=>r in e?ir(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var ee=(e,r,t)=>or(e,typeof r!="symbol"?r+"":r,t);import{s as cr,d,j as n,X as Pt,x as Ht,V as rt,b as Pe,a as Ut,u as lr,e as ur,g as dr,i as pr,a4 as fr,U as hr,L as Ct,_ as mr,$ as gr,a0 as yr,a1 as At,q as _r}from"./index-DyXq7-Tg.js";import{C as br,U as jt,b as wr,f as De,c as xr,g as vr,A as Sr,a as Er}from"./ArtifactWorkspace-Ya79_F5k.js";import{f as Ue,h as Rr,j as Kt,k as Ir,T as kr,e as Wt,l as Cr,m as Ar,n as jr,r as Tr,o as Tt,s as Yt,t as nt,v as He,w as Le,x as Mr,y as Mt,z as Nr,B as Dr,E as ut,F as $t,G as Lr,H as Fr,I as Or,J as qr,D as st,K as Br,L as Pr,M as Je,N as Qe,O as Hr,Q as ze,R as Ge,U as Ur,V as Kr,S as Wr,W as Yr,X as Nt,Y as $r}from"./chatSessions-Ck_dyM0d.js";import{M as Vr}from"./McpShowcase-CLO4HLon.js";import{S as Qr}from"./share-2-fiavn5SS.js";import{c as Xe}from"./chat-Ix1IrIwq.js";import{u as zr,O as Gr}from"./openrouter-o51Eagw8.js";import{q as Vt}from"./queryOptions-C9woPjwX.js";/* empty css */import"./hover-card-B45EJIn_.js";import"./CatalogEntityPreviewLink-BktpwL3_.js";import"./catalog-CRar2olQ.js";import"./github-RNrgGHRT.js";import"./file-text-dvKtHbmD.js";import"./PaperPreviewLink-CpCZSa8K.js";import"./index-mCi_y_l3.js";import"./index-2CvJmBVB.js";import"./katex-DkKDou_j.js";import"./papers-Dh3ljlL0.js";import"./curation-YeS7FBYf.js";import"./useMutation-UWxBeqtn.js";import"./copy-CxR0OKx2.js";import"./thumbs-up-CPLlGli7.js";import"./arrow-left-PA_b6law.js";import"./external-link-orY1Xz1I.js";import"./plus-Yh42pKZz.js";import"./search-8ssWDP68.js";import"./chevron-up-DYSYRyvz.js";import"./AuthorAvatar-B-9xS2Wo.js";import"./AgentLogos-j-Qekw7T.js";/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Jr=cr("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);function Xr(e){const[r,t]=d.useState("calc(100dvh - 60px)");return d.useLayoutEffect(()=>{if(!e)return;const s=document.querySelector(".app-header"),u=window.visualViewport,o=()=>{const a=(u==null?void 0:u.height)??window.innerHeight;t(`${Math.max(0,a-((s==null?void 0:s.offsetHeight)??0))}px`)};o();const p=new ResizeObserver(o);return s&&p.observe(s),u==null||u.addEventListener("resize",o),window.addEventListener("resize",o),()=>{p.disconnect(),u==null||u.removeEventListener("resize",o),window.removeEventListener("resize",o)}},[e]),e?r:"100%"}const Zr="https://huggingface.co/settings/inference-providers",Dt="pwc.chat.billing-notice-dismissed.v1";function es({provider:e}){const[r,t]=d.useState(()=>localStorage.getItem(Dt)==="1");return!Ue()||r||e!=="huggingface"?null:n.jsxs("div",{className:"chat-billing-notice",role:"note",children:[n.jsx("span",{children:"Hugging Face models use the inference permission granted when you start chatting. Included monthly credits are used first, then extra usage requires purchased credits. You can choose organization billing in Settings."}),n.jsxs("div",{className:"chat-billing-notice-actions",children:[n.jsx("a",{href:"/settings",children:"Review billing"}),n.jsx("a",{href:Zr,target:"_blank",rel:"noreferrer",children:"Review usage"}),n.jsx("button",{type:"button",className:"chat-billing-notice-dismiss","aria-label":"Dismiss billing notice",title:"Dismiss",onClick:()=>{localStorage.setItem(Dt,"1"),t(!0)},children:n.jsx(Pt,{size:15,"aria-hidden":"true"})})]})]})}function Lt({variant:e,composerProps:r,provider:t,sponsored:s=!1,paused:u,error:o,suggestions:p=[]}){var h;const a=n.jsxs(n.Fragment,{children:[!s&&n.jsx(es,{provider:t}),u&&n.jsx("div",{id:"chat-paused-description",className:"chat-paused-banner",role:"status",children:"Chat is temporarily disabled. You can keep browsing and editing your conversations. New research runs will return when chat is restored."}),o&&n.jsx("div",{className:"chat-composer-error",role:"alert",children:o}),n.jsx(br,{...r,...e==="empty"?{autoFocus:!0}:{placeholder:(h=r.draft)!=null&&h.text?"Edit and send again…":"Ask a follow-up…"}}),e==="empty"&&n.jsx("div",{className:"chat-examples",children:p.map(L=>n.jsx("button",{type:"button",className:"chat-example",disabled:u,onClick:()=>{var v;return r.onSend({text:L,paperMentions:[],...(v=r.draft)!=null&&v.paperSelection?{paperSelection:r.draft.paperSelection}:{}})},children:L},L))})]});return e==="empty"?a:n.jsx("div",{className:"chat-composer-wrap",children:n.jsxs("div",{className:"chat-composer-inner",children:[a,n.jsx("div",{className:"chat-composer-foot",children:Ue()?n.jsxs(n.Fragment,{children:[t==="huggingface"&&n.jsxs("span",{className:"chat-provider-attribution",children:["Powered by 🤗 ",n.jsx("a",{href:"https://huggingface.co/docs/inference-providers/en/index",target:"_blank",rel:"noreferrer",children:"Inference Providers"}),"."]}),t==="openrouter"&&n.jsxs("span",{className:"chat-provider-attribution",children:["Powered by ",n.jsx("a",{href:"https://openrouter.ai",target:"_blank",rel:"noreferrer",children:"OpenRouter"}),"."]}),t==="openai"&&n.jsx("span",{className:"chat-provider-attribution",children:"Powered by OpenAI."}),n.jsx("span",{children:"The AI assistant can make mistakes. Double-check responses."})]}):n.jsx(n.Fragment,{children:"Assistant preview — responses are simulated."})})]})})}function ts({messages:e,papers:r,busy:t,queuedDraft:s,paperMentionsEnabled:u,archivePending:o,openRouterFallbackEnabled:p,onToggleBlock:a,onEditAndResend:h,onRetryFromProgress:L,onRetryWithLuna:v,onArchiveOld:S,onArchiveOldest:A}){var m,I;const[B,O]=d.useState(null),k=d.useRef(null),j=d.useRef(null),W=d.useRef("bottom"),U=d.useRef(0),se=d.useRef(0),[Q,w]=d.useState(!1),T=d.useRef(null),C=d.useCallback(i=>{W.current=i},[]),_=d.useCallback(()=>{const i=k.current;i&&w(i.scrollHeight-i.scrollTop-i.clientHeight>1)},[]),V=e.filter(i=>i.role==="user"),$=V.length,F=d.useRef($),ne=d.useRef(!1),ue=(m=V[0])==null?void 0:m.id,z=(I=V.at(-1))==null?void 0:I.id;d.useEffect(()=>{t&&O(null)},[t]),d.useLayoutEffect(()=>{const i=k.current;if(i){if($>F.current||t&&!ne.current){const M=Array.from(i.querySelectorAll("[data-message-id]")).at(-1);if(M){const P=i.getBoundingClientRect().top;U.current=i.scrollTop+M.getBoundingClientRect().top-P-24,C("question")}}if(F.current=$,ne.current=t,j.current!==null){i.scrollTop=j.current,j.current=null;return}W.current==="bottom"&&(i.scrollTop=i.scrollHeight),W.current==="question"&&(i.scrollTop=U.current,se.current=i.scrollTop)}},[e,$,t,C]),d.useLayoutEffect(_),d.useEffect(()=>{const i=k.current;if(!i)return;const M=new ResizeObserver(_);return M.observe(i),i.firstElementChild&&M.observe(i.firstElementChild),()=>M.disconnect()},[_]);const J=(i,M)=>{var P;j.current=((P=k.current)==null?void 0:P.scrollTop)??null,a(i,M)};return n.jsxs("div",{className:"chat-conversation-viewport",children:[n.jsx("div",{className:"chat-conversation",ref:k,tabIndex:0,role:"region","aria-label":"Conversation",onWheel:i=>{(i.deltaY<0||W.current==="question")&&C("free")},onTouchStart:i=>{var M;T.current=((M=i.touches[0])==null?void 0:M.clientY)??null},onTouchMove:i=>{var P;const M=(P=i.touches[0])==null?void 0:P.clientY;M!==void 0&&T.current!==null&&(M>T.current||W.current==="question")&&C("free"),T.current=M??null},onKeyDown:i=>{i.target===i.currentTarget&&((["ArrowUp","PageUp","Home"].includes(i.key)||i.key===" "&&i.shiftKey)&&C("free"),["ArrowDown","PageDown","End"," "].includes(i.key)&&W.current==="question"&&C("free"))},onScroll:i=>{const{scrollHeight:M,scrollTop:P,clientHeight:ae}=i.currentTarget,ie=M-P-ae<=1;W.current==="bottom"&&!ie&&C("free");const fe=P-se.current;W.current==="question"&&(fe>1||fe<-1&&!ie)&&C("free"),_()},children:n.jsxs("div",{className:"chat-conversation-inner",children:[e.length===0&&(s==null?void 0:s.text)&&n.jsx(jt,{id:"queued-launch-preview",text:s.text,paperMentions:s.paperMentions,paperSelection:s.paperSelection,isInitial:!0}),e.map(i=>{var M,P,ae,ie;return i.role==="user"?n.jsx(jt,{id:i.id,text:i.text??"",paperMentions:i.paperMentions??[],paperSelection:i.paperSelection,paperMentionsEnabled:u,isInitial:i.id===ue,editingAllowed:!t&&!!i.revision,editing:B===i.id,editNotice:i.id===ue?"Sending will replace this conversation.":i.id===z?"Sending will replace the response.":"Sending will replace the response and all messages after it.",onEdit:()=>O(i.id),onCancel:()=>O(null),onResendDraft:fe=>{const ge=h(i.id,fe);return ge&&O(null),ge}},i.id):n.jsx(wr,{msg:i,papers:r,onToggleBlock:J,onRetryCompaction:!t&&i.id===((M=e.at(-1))==null?void 0:M.id)&&((P=V.at(-1))!=null&&P.revision)?L:void 0,onRetryWithLuna:!t&&i.id===((ae=e.at(-1))==null?void 0:ae.id)&&((ie=V.at(-1))!=null&&ie.revision)?v:void 0,onArchiveOldChats:S,onArchiveOldestChats:A,archivePending:o,hfBilling:null,openRouterFallbackEnabled:p,feedbackEnabled:!0},i.id)})]})}),Q&&n.jsx("button",{type:"button",className:"chat-jump-latest",onClick:()=>{C("bottom");const i=k.current;i&&(i.focus({preventScroll:!0}),i.scrollTop=i.scrollHeight,_())},children:"Jump to latest"})]})}function rs({retryAt:e,onRetry:r,onCancel:t}){const[s,u]=d.useState(()=>Math.max(0,Math.ceil((e-Date.now())/1e3))),o=d.useRef(null);return d.useEffect(()=>{var L;const p=document.activeElement instanceof HTMLElement?document.activeElement:null;(L=o.current)==null||L.focus();const a=()=>u(Math.max(0,Math.ceil((e-Date.now())/1e3)));a();const h=window.setInterval(a,250);return()=>{window.clearInterval(h),p==null||p.focus()}},[e]),n.jsx("div",{className:"chat-capacity-dialog-backdrop",role:"presentation",children:n.jsxs("div",{className:"chat-capacity-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"chat-capacity-dialog-title","aria-describedby":"chat-capacity-dialog-description",onKeyDown:p=>{p.key==="Escape"&&(p.preventDefault(),t())},children:[n.jsx("h2",{id:"chat-capacity-dialog-title",children:"All research slots are currently in use"}),n.jsx("p",{id:"chat-capacity-dialog-description",children:"Your message was not sent or billed. Try again in a few seconds."}),n.jsx("p",{className:"chat-capacity-countdown","aria-live":"polite",children:s>0?`Try again available in ${s} second${s===1?"":"s"}.`:"You can try again now."}),n.jsxs("div",{className:"chat-capacity-dialog-actions",children:[n.jsx("button",{type:"button",className:"chat-capacity-cancel",ref:o,onClick:t,children:"Cancel"}),n.jsx("button",{type:"button",className:"chat-capacity-retry",disabled:s>0,onClick:r,children:"Try again"})]})]})})}function ss({onClose:e}){const r=d.useRef(null);return d.useEffect(()=>{var s;const t=document.activeElement instanceof HTMLElement?document.activeElement:null;return(s=r.current)==null||s.focus(),()=>t==null?void 0:t.focus()},[]),n.jsx("div",{className:"chat-capacity-dialog-backdrop",role:"presentation",children:n.jsxs("div",{className:"chat-capacity-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"chat-disabled-title","aria-describedby":"chat-disabled-description",onKeyDown:t=>{t.key==="Escape"&&(t.preventDefault(),e())},children:[n.jsx("h2",{id:"chat-disabled-title",children:"Chat is temporarily disabled"}),n.jsx("p",{id:"chat-disabled-description",children:"We've temporarily paused new research runs. Your message wasn't sent, and your draft is still here. Please try again later."}),n.jsx("div",{className:"chat-capacity-dialog-actions",children:n.jsx("button",{ref:r,type:"button",className:"chat-capacity-cancel",onClick:e,children:"Keep editing"})})]})})}function ns({url:e,onClose:r}){return e?n.jsx("div",{className:"chat-share-dialog-backdrop",role:"presentation",onMouseDown:r,children:n.jsxs("div",{className:"chat-share-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"chat-share-dialog-title",onMouseDown:t=>t.stopPropagation(),children:[n.jsx("h2",{id:"chat-share-dialog-title",children:"Public link created"}),n.jsx("p",{children:"Anyone with this link can see this conversation. It could not be copied automatically, so copy it manually:"}),n.jsx("input",{readOnly:!0,value:e,"aria-label":"Public conversation link",autoFocus:!0,onFocus:t=>t.currentTarget.select()}),n.jsx("button",{type:"button",onClick:r,children:"Close"})]})}):null}const at="pwc:chat:sidebar-width",it=280,ot=200,ct=480,as=12,lt=e=>Math.max(ot,Math.min(ct,e)),is=()=>{if(typeof window>"u")return it;const e=Number(localStorage.getItem(at));return Number.isFinite(e)&&e>0?lt(e):it};function os({sessions:e,activeSessionId:r,loading:t,error:s,open:u,onClose:o,onNew:p,onNavigate:a,onRename:h,onDelete:L}){const[v,S]=d.useState(is),A=d.useRef(null),B=d.useRef(v),[O,k]=d.useState(null),[j,W]=d.useState(""),[U,se]=d.useState(null),[Q,w]=d.useState(!1),T=[...e].sort((m,I)=>Date.parse(I.updated_at)-Date.parse(m.updated_at)),C=T.filter((m,I)=>I{if(!U)return;const m=()=>se(null),I=i=>{i.key==="Escape"&&m()};return window.addEventListener("click",m),window.addEventListener("keydown",I),()=>{window.removeEventListener("click",m),window.removeEventListener("keydown",I)}},[U]);const $=m=>{k(m.id),W(m.title)},F=async m=>{const I=j.trim();I&&await h(m,I)&&k(null)},ne=(m,I,i)=>se({id:m,x:I,y:i}),ue=m=>{if(!A.current)return;const I=lt(A.current.width+m-A.current.x);B.current=I,S(I)},z=()=>{A.current&&(A.current=null,localStorage.setItem(at,String(B.current)))},J=m=>{const I=lt(m);B.current=I,S(I),localStorage.setItem(at,String(I))};return n.jsxs(n.Fragment,{children:[u&&n.jsx("div",{className:"chat-sidebar-backdrop","aria-hidden":"true",onClick:o}),n.jsxs("aside",{className:`chat-sidebar${u?"":" chat-sidebar-closed"}`,style:{"--chat-sidebar-width":`${v}px`},children:[n.jsxs("div",{className:"chat-sidebar-top",children:[n.jsxs("button",{type:"button",className:"chat-new-chat",onClick:()=>{De()&&p()},children:[n.jsx(Rr,{})," New chat"]}),n.jsx("button",{type:"button",className:"icon-btn",onClick:o,title:"Collapse sidebar",children:n.jsx(Kt,{})})]}),n.jsxs("nav",{className:"chat-sessions","aria-label":"Chat history",children:[t&&n.jsx("div",{className:"chat-sessions-empty",children:"Loading chats…"}),!t&&s&&n.jsx("div",{className:"chat-sessions-empty",children:s}),!t&&!s&&e.length===0&&n.jsx("div",{className:"chat-sessions-empty",children:"Conversations you start will show up here."}),Ir(_).map(m=>n.jsxs("div",{className:"chat-session-group",children:[n.jsx("div",{className:"chat-session-group-label",children:m.label}),m.items.map(I=>n.jsxs("div",{className:`chat-session${I.id===r?" chat-session-active":""}`,role:"button",tabIndex:0,onClick:()=>{De()&&a(I.id)},onKeyDown:i=>{if(i.key==="Enter"&&De()&&a(I.id),i.key==="F2"&&$(I),i.key==="ContextMenu"||i.shiftKey&&i.key==="F10"){i.preventDefault();const M=i.currentTarget.getBoundingClientRect();ne(I.id,M.right-150,M.bottom)}},onContextMenu:i=>{i.preventDefault(),ne(I.id,i.clientX,i.clientY)},children:[O===I.id?n.jsx("input",{className:"chat-session-title-input",value:j,autoFocus:!0,maxLength:80,onClick:i=>i.stopPropagation(),onChange:i=>W(i.target.value),onBlur:()=>void F(I.id),onKeyDown:i=>{i.stopPropagation(),i.key==="Enter"&&F(I.id),i.key==="Escape"&&k(null)}}):n.jsx("span",{className:"chat-session-title",children:I.title}),n.jsx("button",{type:"button",className:"chat-session-menu","aria-label":"Chat actions","aria-haspopup":"menu",title:"Chat actions",onClick:i=>{i.stopPropagation();const M=i.currentTarget.getBoundingClientRect();ne(I.id,M.right-150,M.bottom)},children:"⋯"}),n.jsx("button",{type:"button",className:"chat-session-delete","aria-label":"Delete conversation",onClick:i=>{i.stopPropagation(),De()&&L(I.id)},children:n.jsx(kr,{})})]},I.id))]},m.label)),V>0&&n.jsx("button",{type:"button",className:"chat-sessions-toggle","aria-expanded":Q,onClick:()=>w(m=>!m),children:Q?"Show less":`Show ${V} older ${V===1?"chat":"chats"}`})]}),n.jsx(Vr,{className:"chat-sidebar-tools",canNavigate:De}),n.jsx("div",{className:"chat-sidebar-resize-handle",role:"separator","aria-label":"Resize chat history","aria-orientation":"vertical","aria-valuemin":ot,"aria-valuemax":ct,"aria-valuenow":v,title:"Drag to resize; double-click to reset",tabIndex:0,onPointerDown:m=>{m.button===0&&(A.current={x:m.clientX,width:v},B.current=v,m.currentTarget.setPointerCapture(m.pointerId))},onPointerMove:m=>ue(m.clientX),onPointerUp:z,onPointerCancel:z,onLostPointerCapture:z,onDoubleClick:()=>J(it),onKeyDown:m=>{(m.key==="ArrowLeft"||m.key==="ArrowRight")&&(m.preventDefault(),J(v+(m.key==="ArrowRight"?10:-10))),(m.key==="Home"||m.key==="End")&&(m.preventDefault(),J(m.key==="Home"?ot:ct))}}),U&&n.jsx("div",{className:"chat-session-context-menu",role:"menu",style:{left:U.x,top:U.y},onClick:m=>m.stopPropagation(),children:n.jsx("button",{type:"button",role:"menuitem",autoFocus:!0,onClick:()=>{const m=e.find(I=>I.id===U.id);m&&$(m),se(null)},children:"Rename chat"})})]})]})}function cs({sessionId:e,busy:r,loading:t,hasPaperSelection:s=!1,onError:u}){const{toast:o}=Ht(),[p,a]=d.useState(!1),[h,L]=d.useState(""),v=async()=>{var S;if(!(r||p)&&!(s&&!window.confirm("This public link will include the selected paper passage. Anyone with the link can read that passage. Continue?"))){a(!0);try{const A=await Cr(e),B=new URL(A.public_path,window.location.origin).toString();try{if(!((S=navigator.clipboard)!=null&&S.writeText))throw new Error("Clipboard unavailable");await navigator.clipboard.writeText(B),o({className:"chat-share-toast",duration:5e3,title:"Public link copied to your clipboard",description:"Anyone with this link can see this conversation."})}catch{L(B)}}catch(A){const B=A instanceof Error?A.message:"Could not share this conversation";u(B),o({variant:"destructive",title:"Share failed",description:B})}finally{a(!1)}}};return n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",className:"chat-share-button",onClick:()=>void v(),disabled:r||p||t,"aria-label":"Share conversation",children:[p?n.jsx(Wt,{}):n.jsx(Qr,{"aria-hidden":"true"}),n.jsx("span",{children:"Share"})]}),n.jsx(ns,{url:h,onClose:()=>L("")})]})}const ls=({descriptor:e})=>{const r=xr(),{open:t,register:s,unregister:u}=r,o=rt.useRef(null),p=e.source_head??e.preview_head,a=rt.useMemo(()=>p?{kind:"artifact",schema_version:1,scope:"owner",artifact_id:e.artifact_id,version_id:p.version_id,identifier:"latex-paper",version:p.version,artifact_kind:"latex_paper",title:e.title,status:"ready",preview_mime:"application/pdf",source_language:"latex",total_bytes:0}:null,[e.artifact_id,e.title,p]),h=a?vr(a):null;return rt.useEffect(()=>{if(!(!a||!h))return s(a),o.current!==h&&(o.current=h,t(a)),()=>u(h)},[a,h,t,s,u]),null};function us({messages:e,refreshSessions:r,resetChat:t,restoreDraft:s}){const{toast:u}=Ht(),[o,p]=d.useState(null),a=()=>{const v=[...e].reverse().find(S=>S.role==="user");t(),s({text:(v==null?void 0:v.text)??"",paperMentions:(v==null?void 0:v.paperMentions)??[],...v!=null&&v.paperSelection?{paperSelection:v.paperSelection}:{}})};return{pending:o,archiveOld:async()=>{if(o===null){p("old");try{const v=await jr();if(await r(),v.archived_count===0){u({title:"No chats were archived",description:"There are no inactive chats older than 30 days."});return}a(),u({title:`${v.archived_count} ${v.archived_count===1?"chat":"chats"} archived`,description:"Your question is ready to send again."})}catch(v){u({variant:"destructive",title:"Could not archive old chats",description:v instanceof Error?v.message:"Try again."})}finally{p(null)}}},archiveOldest:async()=>{if(o===null){p("oldest");try{const v=await Ar();await r(),a(),u({title:`${v.archived_count} ${v.archived_count===1?"chat":"chats"} archived`,description:"Your question is ready to send again."})}catch(v){u({variant:"destructive",title:"Could not archive chats",description:v instanceof Error?v.message:"Try again."})}finally{p(null)}}}}}class ds{constructor(r,t=Tr){ee(this,"requestId");ee(this,"firstVisibleAt");ee(this,"streamStartReported",!1);ee(this,"firstVisibleReported",!1);ee(this,"terminalReported",!1);ee(this,"semanticReported",new Set);this.submittedAt=r,this.report=t}recordStreamStart(r,t){this.requestId=r,this.streamStartReported||(this.streamStartReported=!0,this.send({submission_to_stream_start_ms:Math.max(0,t-this.submittedAt)})),this.reportFirstVisible()}recordFirstVisible(r){this.firstVisibleAt===void 0&&(this.firstVisibleAt=r,this.reportFirstVisible())}recordSemantic(r,t){if(this.semanticReported.has(r))return;this.semanticReported.add(r);const s=Math.max(0,t-this.submittedAt);this.send(r==="reasoning"?{submission_to_first_reasoning_delta_ms:s}:r==="tool"?{submission_to_first_tool_call_ms:s}:{submission_to_first_answer_delta_ms:s})}recordTerminal(r){this.terminalReported||(this.terminalReported=!0,this.send({terminal_classification:r}))}reportFirstVisible(){!this.requestId||this.firstVisibleAt===void 0||this.firstVisibleReported||(this.firstVisibleReported=!0,this.send({submission_to_first_visible_delta_ms:Math.max(0,this.firstVisibleAt-this.submittedAt)}))}send(r){this.requestId&&this.report(this.requestId,r)}}const Qt="Preparing research workspace…",zt={preparing_workspace:"Preparing secure workspace…",starting_agent:"Starting research agent…",connecting_model:"Connecting to model…"},Gt=()=>({messages:[],sessionId:null,title:"",phase:"idle"});function Ft(e,r){for(let t=e.length-1;t>=0;t-=1)if(r(e[t]))return t;return-1}function Re(e){if(e.status!==Qt&&!Object.values(zt).includes(e.status))return e;const{status:r,...t}=e;return t}function te(e,r){if(!e.length)return e;const t=e.slice();return t[t.length-1]=r(t[t.length-1]),t}function Ae(e,r,t){return te(e,s=>{const u=Re(s),o=u.blocks??[];return{...u,blocks:o.map((p,a)=>r(p,a,o)?t(p):p)}})}function ps(e,r){switch(r.type){case"stream_start":return r.session_id?{...e,sessionId:r.session_id}:e;case"sandbox_start":case"sandbox_ready":case"workspace_ready":return e;case"lifecycle":return{...e,messages:te(e.messages,t=>{var s;return t.role==="assistant"&&t.streaming&&(((s=t.blocks)==null?void 0:s.length)??0)===0?{...t,status:zt[r.phase]}:t})};case"session_title_start":return{...e,title:""};case"session_title_delta":return{...e,title:`${e.title}${r.text}`.replace(/\s+/g," ").slice(0,80)};case"session_title_done":return{...e,title:r.title};case"compaction_status":return{...e,messages:te(e.messages,t=>({...t,compacting:!!(t.streaming&&r.state==="started")}))};case"reasoning_start":return{...e,messages:te(e.messages,t=>{const s=Re(t);return{...s,blocks:[...(s.blocks??[]).map(u=>u.kind==="reasoning"&&u.active?{...u,active:!1,open:!1}:u),{kind:"reasoning",text:"",active:!0,open:!0}]}})};case"reasoning_delta":return{...e,messages:Ae(e.messages,(t,s,u)=>t.kind==="reasoning"&&Ft(u,o=>o.kind==="reasoning")===s,t=>t.kind==="reasoning"?{...t,text:t.text+r.text}:t)};case"reasoning_end":return{...e,messages:te(e.messages,t=>{const s=t.blocks??[],u=Ft(s,a=>a.kind==="reasoning"&&a.active);if(u<0)return t;const o=s[u];if(o.kind!=="reasoning")return t;const p=s[u-1];return(p==null?void 0:p.kind)==="reasoning"&&p.text===o.text?{...t,blocks:s.filter((a,h)=>h!==u)}:{...t,blocks:s.map((a,h)=>h===u?{...o,active:!1,open:!1}:a)}})};case"tool_call":return{...e,messages:te(e.messages,t=>{const s=Re(t);return{...s,blocks:[...s.blocks??[],{kind:"tool",id:r.id,name:r.name,args:r.args,status:"running",open:!1}]}})};case"tool_call_start":return{...e,messages:te(e.messages,t=>{const s=Re(t);return{...s,blocks:[...s.blocks??[],{kind:"tool",schema_version:2,id:r.id,name:r.name,args:{},argumentText:"",argumentState:"streaming",arguments_redacted:r.redacted,status:"running",open:!1}]}})};case"tool_call_arguments_delta":return{...e,messages:Ae(e.messages,t=>t.kind==="tool"&&t.id===r.id,t=>t.kind==="tool"?{...t,args:r.partial_args,argumentText:r.snapshot?r.delta:`${t.argumentText??""}${r.delta}`,arguments_redacted:t.arguments_redacted||r.redacted}:t)};case"tool_call_arguments_done":return{...e,messages:Ae(e.messages,t=>t.kind==="tool"&&t.id===r.id,t=>t.kind==="tool"?{...t,args:r.args,argumentText:JSON.stringify(r.args),argumentState:"done",arguments_redacted:t.arguments_redacted||r.redacted}:t)};case"app_start":return{...e,messages:te(e.messages,t=>{const s=Re(t);return{...s,blocks:[...s.blocks??[],{kind:"app",schema_version:1,instance_id:r.instance_id,provider:r.provider,server:r.server,tool:r.tool,resource_uri:r.resource_uri,status:"loading",input:r.input,result:{content:[],structuredContent:{},isError:!1},csp:{},permissions:{clipboardWrite:!0},height:525}]}})};case"app_result":return{...e,messages:Ae(e.messages,t=>t.kind==="app"&&t.instance_id===r.id,t=>t.kind==="app"?{...t,status:r.status,result:r.result}:t)};case"tool_result":return{...e,messages:Ae(e.messages,t=>t.kind==="tool"&&t.id===r.id,t=>t.kind!=="tool"?t:r.status?{...t,schema_version:2,status:r.status,took_ms:r.took_ms,content:r.content,metadata:r.metadata,open:r.status!=="success"}:{...t,status:"done",hits:r.hits,took_ms:r.took_ms,results:r.results})};case"artifact_start":return{...e,messages:te(e.messages,t=>{const s=Re(t);return{...s,blocks:[...s.blocks??[],{kind:"artifact",schema_version:1,scope:"owner",publication_id:r.publication_id,identifier:r.identifier,artifact_kind:"posterly",title:r.title,status:"generating",phase:"publishing_poster"}]}})};case"artifact_ready":return{...e,messages:Ae(e.messages,t=>t.kind==="artifact"&&t.publication_id===r.publication_id,t=>t.kind==="artifact"?{...t,artifact_id:r.artifact_id,version_id:r.version_id,identifier:r.identifier,version:r.version,title:r.title,status:"ready",preview_mime:r.preview_mime,source_language:r.source_language,gate_status:r.gate_status,total_bytes:r.total_bytes,phase:void 0}:t)};case"artifact_error":return{...e,messages:Ae(e.messages,t=>t.kind==="artifact"&&t.publication_id===r.publication_id,t=>t.kind==="artifact"?{...t,status:"error",phase:void 0,error_code:r.code,error_message:r.message}:t)};case"answer_delta":return{...e,messages:te(e.messages,t=>{const s=Re(t),u=s.blocks??[],o=u.at(-1);return(o==null?void 0:o.kind)==="answer"&&!o.done?{...s,blocks:[...u.slice(0,-1),{...o,text:o.text+r.text}]}:{...s,blocks:[...u,{kind:"answer",text:r.text,done:!1}]}})};case"done":return{...e,phase:"complete",messages:te(e.messages,t=>({...t,streaming:!1,compacting:!1,followups:r.followups,finishReason:r.finish_reason,citations:r.citations,blocks:(t.blocks??[]).map(s=>s.kind==="answer"?{...s,done:!0}:s.kind==="reasoning"&&s.active?{...s,active:!1,open:!1}:s)}))};case"error":return{...e,phase:"failed",messages:te(e.messages,t=>({...t,streaming:!1,compacting:!1,error:r.message,errorCode:r.code,blocks:(t.blocks??[]).map(s=>s.kind==="reasoning"&&s.active?{...s,active:!1,open:!1}:s.kind==="tool"&&s.status==="running"?{...s,status:"error",open:!0}:s)}))};default:return e}}function fs(e){return te(e,r=>{if(r.role!=="assistant")return r;const t=(r.blocks??[]).flatMap(s=>s.kind==="tool"&&s.status==="running"?[{...s,status:"error",open:!0}]:s.kind==="reasoning"&&s.active?s.text?[{...s,active:!1,open:!1}]:[]:s.kind==="answer"?[{...s,done:!0}]:[s]);return{...r,blocks:t,streaming:!1,compacting:!1,finishReason:"stopped"}})}function hs(e,r){switch(r.type){case"start":return{messages:r.messages,sessionId:r.sessionId,title:"",phase:"streaming"};case"event":return ps(e,r.event);case"load":return{messages:r.messages,sessionId:r.sessionId,title:e.title,phase:"idle"};case"workspace_status":return{...e,messages:te(e.messages,t=>{var s;return t.role==="assistant"&&t.streaming&&(((s=t.blocks)==null?void 0:s.length)??0)===0&&!t.error?{...t,status:Qt}:t})};case"clear_workspace_status":return{...e,messages:te(e.messages,Re)};case"settle":return{...e,phase:"idle",messages:te(e.messages,t=>t.streaming?{...t,streaming:!1,compacting:!1}:t)};case"stop":return{...e,messages:fs(e.messages),phase:"stopped"};case"toggle_block":return{...e,messages:Jt(e.messages,r.messageId,r.blockIndex)};case"reset":return Gt()}}function Jt(e,r,t){return e.map(s=>{var u;return s.id!==r?s:{...s,blocks:(u=s.blocks)==null?void 0:u.map((o,p)=>p===t&&(o.kind==="reasoning"||o.kind==="tool")?{...o,open:!o.open}:o)}})}const Ee={minDelayMs:5,maxDelayMs:80,minRateCharsPerMs:.3,maxBufferedMs:400,arrivalRateTauMs:1e3,arrivalRateHeadroom:1.1,maxPendingChars:64},ms={now:()=>performance.now(),sleep:(e,r)=>new Promise(t=>{if(r!=null&&r.aborted||e<=0){t();return}const s=window.setTimeout(u,e);function u(){r==null||r.removeEventListener("abort",u),window.clearTimeout(s),t()}r==null||r.addEventListener("abort",u,{once:!0})})};function gs(e){return!["stream_start","sandbox_start","sandbox_ready","workspace_ready","session_title_start","session_title_delta","session_title_done"].includes(e.type)}function ys(e,r=!1,t=Ee.maxPendingChars){var u;if(!e)return{pieces:[],pending:""};if(r)return{pieces:[e],pending:""};const s=Intl.Segmenter;if(s){const p=[...new s(void 0,{granularity:"word"}).segment(e)].filter(h=>h.isWordLike);let a=0;if(p.length>1&&(a=p.at(-1).index),p.length&&/\s$/u.test(e)&&(a=e.length),a>0){const h=e.slice(0,a),L=[],S=[...new s(void 0,{granularity:"word"}).segment(h)].filter(A=>A.isWordLike);for(let A=0;AB&&L.push(h.slice(B,O))}return S.length||L.push(h),{pieces:L,pending:e.slice(a)}}}else{const o=[...e.matchAll(/\s+/gu)];if(o.length){const p=[];let a=0;for(const h of o){const L=h.index+h[0].length;p.push(e.slice(a,L)),a=L}return{pieces:p,pending:e.slice(a)}}}return e.length>=t?{pieces:[e.slice(0,t)],pending:e.slice(t)}:{pieces:[],pending:e}}function _s(e,r={}){const t={minDelayMs:r.minDelayMs??Ee.minDelayMs,maxDelayMs:r.maxDelayMs??Ee.maxDelayMs,minRateCharsPerMs:r.minRateCharsPerMs??Ee.minRateCharsPerMs,maxBufferedMs:r.maxBufferedMs??Ee.maxBufferedMs,arrivalRateTauMs:r.arrivalRateTauMs??Ee.arrivalRateTauMs,arrivalRateHeadroom:r.arrivalRateHeadroom??Ee.arrivalRateHeadroom,maxPendingChars:r.maxPendingChars??Ee.maxPendingChars},s=r.clock??ms,u=[];let o="",p=null,a=0,h=!0,L=!1,v=null,S=0,A=s.now(),B=!1;const O=()=>{v==null||v(),v=null},k=(w,T)=>{const C=w.type==="reasoning_delta"||w.type==="answer_delta"?w.text.length:0;u.push({kind:"event",event:w,arrivedAt:T,chars:C}),O()},j=w=>{if(!p||!o)return;const T=ys(o,w,t.maxPendingChars);for(const C of T.pieces)C&&k({type:p,text:C},a),a=s.now();o=T.pending,o||(p=null)},W=w=>{if(!h)return;const T=s.now();if(w.type==="reasoning_delta"||w.type==="answer_delta"){const C=w.type;if(!w.text)return;if(!B){B=!0,S+=w.text.length,A=T;const V=Array.from(w.text)[0];k({type:C,text:V},T);const $=w.text.slice(V.length);if($)for(p=C,o=$,a=T,j(!1);o.length>=t.maxPendingChars;)j(!1);return}p&&p!==C&&j(!0),p||(p=C,a=T),o+=w.text;const _=Math.max(0,T-A);for(S*=Math.exp(-_/t.arrivalRateTauMs),S+=w.text.length,A=T,j(!1);o.length>=t.maxPendingChars;)j(!1);return}gs(w)&&j(!0),k(w,T)},U=(async()=>{var w;try{for await(const T of e)W(T);h&&j(!0)}catch(T){h&&!((w=r.signal)!=null&&w.aborted)&&(j(!0),u.push({kind:"error",error:T,arrivedAt:s.now(),chars:0}))}finally{L=!0,O()}})(),se=()=>u.length||L?Promise.resolve():new Promise(w=>{v=w});return{events:async function*(){var T,C,_,V;let w=Number.NEGATIVE_INFINITY;try{for(;;){if(await se(),!u.length){if(L||!h)return;continue}const $=u[0];if($.kind==="error")throw u.shift(),$.error;if($.chars&&!((T=r.isHidden)!=null&&T.call(r))){const F=s.now(),ne=u.reduce((ae,ie)=>ae+ie.chars,0),ue=((C=u.find(ae=>ae.chars))==null?void 0:C.arrivedAt)??F,z=Math.max(0,t.maxBufferedMs-(F-ue)),J=S*Math.exp(-Math.max(0,F-A)/t.arrivalRateTauMs)/t.arrivalRateTauMs,m=z>0?ne/z:Number.POSITIVE_INFINITY,I=Math.max(t.minRateCharsPerMs,J*t.arrivalRateHeadroom,m),i=Math.min(t.maxDelayMs,Math.max(t.minDelayMs,$.chars/I)),M=Math.max(0,$.arrivedAt+t.maxBufferedMs-F),P=Math.max($.arrivedAt,w+Math.min(i,M));if(await s.sleep(Math.max(0,P-s.now()),r.signal),!h||(_=r.signal)!=null&&_.aborted)return}u.shift(),w=s.now(),yield $.event}}finally{h&&(h=!1,O(),await((V=e.return)==null?void 0:V.call(e,void 0))),await U}}(),takeAcceptedForStop(){var T;if(!h)return[];h=!1,p&&o&&(k({type:p,text:o},a),o="",p=null);const w=u.flatMap(C=>C.kind==="event"&&C.event.type!=="done"&&C.event.type!=="error"?[C.event]:[]);return u.length=0,O(),(T=e.return)==null||T.call(e,void 0),w}}}const Ot=[250,500,1e3],bs=(e,r)=>new Promise(t=>{const s=()=>{window.clearTimeout(u),r.removeEventListener("abort",s),t()},u=window.setTimeout(s,e);r.addEventListener("abort",s,{once:!0})});async function*ws(e,r){let t=e,s=0;for(;;){let u=!1;try{for await(const o of t)(o.type==="done"||o.type==="error")&&(u=!0),yield o;if(u||r.signal.aborted)return;throw new Tt}catch(o){r.onDisconnect();const p=r.getSessionId();if(r.signal.aborted||u||!(o instanceof Tt)||!p||s>=Ot.length)throw o;if(await bs(Ot[s],r.signal),r.signal.aborted)return;s+=1,t=Yt(p,{signal:r.signal,afterSequence:r.getAfterSequence(),onSequence:r.onSequence})}}}const qt=new Set(["openrouter_monthly_budget_exhausted","openrouter_unavailable","openrouter_byok_credential_invalid","openrouter_byok_billing_error","openrouter_byok_rate_limit","hf_inference_billing_exhausted"]),xs=new Set(["paper_context_unavailable","paper_mention_unavailable","paper_mentions_disabled","paper_selection_disabled","paper_selection_requires_reader","paper_selection_paper_mismatch","paper_selection_version_mismatch","paper_selection_page_invalid","paper_selection_too_large","chat_storage_quota_exceeded"]);class vs{constructor(){ee(this,"configuration");ee(this,"lifecycle",Gt());ee(this,"_busy",!1);ee(this,"_pendingCapacity",null);ee(this,"_sawStreamStart",!1);ee(this,"_providerExecuted",!1);ee(this,"_providerStatusChanged",!1);ee(this,"terminal","pending");ee(this,"rejection",null)}get busy(){return this._busy}get pendingCapacity(){return this._pendingCapacity}get sawStreamStart(){return this._sawStreamStart}get sawTerminalEvent(){return this.terminal==="complete"||this.terminal==="error"}get streamFailed(){return this.terminal==="error"||this.terminal==="transport_error"}get admissionRejected(){return this.rejection!==null}get shouldRefreshProvider(){return this._sawStreamStart&&this._providerExecuted||this._providerStatusChanged}finish(){this._busy=!1}queueCapacity(r){this._pendingCapacity=r}cancelCapacity(){this._pendingCapacity=null}projectSession(r){return this._busy&&r===this.sessionId?this.messages:null}get state(){return this.lifecycle}get messages(){return this.lifecycle.messages}get sessionId(){return this.lifecycle.sessionId}transition(r){return this.lifecycle=hs(this.lifecycle,r),this.lifecycle}start(r,t,s){this.configuration=s,this._busy=!0,this._sawStreamStart=this._providerExecuted=this._providerStatusChanged=!1,this.terminal="pending",this.rejection=null,this.transition({type:"start",messages:r,sessionId:t})}restore(r,t=this.sessionId){return this.transition({type:"load",messages:r,sessionId:t})}observe(r){return r.type==="stream_start"&&(this._sawStreamStart=!0,this._providerExecuted=r.provider_execution!==!1),(r.type==="done"||r.type==="error")&&(this.terminal=r.type==="done"?"complete":"error"),r.type==="error"&&qt.has(r.code??"")?(this._providerStatusChanged=!0,!0):!1}reject(r,t){const s=r instanceof nt?r.code:void 0,u=t&&s==="chat_not_busy"?"completed":s==="chat_temporarily_disabled"?"disabled":s==="chat_capacity"?"capacity":xs.has(s??"")?"draft":qt.has(s??"")?"provider":"network";return this.terminal=u==="completed"?"already_complete":"transport_error",this.rejection=u==="disabled"||u==="capacity"||u==="draft"?u:null,this._providerStatusChanged||(this._providerStatusChanged=u==="provider"),u}reset(){this._busy=!1,this._pendingCapacity=null,this.transition({type:"reset"})}}const Ss=750;function Es(e,r){for(let t=e.length-1;t>=0;t-=1)if(r(e[t]))return t;return-1}function Se(e){const r=d.useRef(e);return d.useLayoutEffect(()=>{r.current=e}),d.useCallback((...t)=>r.current(...t),[])}function Rs(e){const[r,t]=d.useState([]),[s,u]=d.useState(!1),[o,p]=d.useState(""),[a]=d.useState(()=>new vs),h=d.useRef(null),L=d.useRef(null),v=d.useRef(null),S=d.useRef(null),A=d.useRef(!1),B=d.useRef(null),O=d.useRef(null),k=d.useRef("cleared"),j=d.useRef(null),[W,U]=d.useState(null),[se,Q]=d.useState(null),w=d.useRef([]),T=d.useRef(null),C=d.useRef(!1),_=d.useRef(e),V=d.useRef(He()),$=d.useRef(0),F=d.useRef(0),ne=d.useRef(e.sessionId);if(ne.current!==e.sessionId){ne.current=e.sessionId;const c=a.projectSession(e.sessionId);c&&t(c),a.sessionId!==e.sessionId&&(F.current+=1,j.current=null)}_.current=e,w.current=r,d.useEffect(()=>()=>{var c;O.current!==null&&window.clearTimeout(O.current),(c=h.current)==null||c.abort(),L.current=null,v.current!==null&&cancelAnimationFrame(v.current),S.current!==null&&window.clearTimeout(S.current),a.cancelCapacity()},[a]),d.useEffect(()=>{a.busy||a.restore(a.messages,e.sessionId)},[e.sessionId,a]),d.useEffect(()=>{const c=a.projectSession(e.sessionId);C.current=c!==null,c&&(t(c),w.current=c)},[e.sessionId,a]);const ue=d.useMemo(()=>{const c={};for(const f of r)for(const E of f.blocks??[])if(E.kind==="tool")for(const b of E.results??[])c[b.route_id]=b;return c},[r]),z=()=>`m${++$.current}_${Date.now().toString(36)}`,J=(c,f=!0)=>{const E=a.state,b=a.transition(c),g=c.type==="event"&&c.event.type==="stream_start"?c.event.session_id:null;return g?_.current.onSessionId(g,E.sessionId,a.configuration):b.sessionId&&b.sessionId!==E.sessionId&&_.current.onSessionId(b.sessionId,E.sessionId,a.configuration),b.title!==E.title&&_.current.onTitle(b.title,b.sessionId),f&&(w.current=b.messages,t(b.messages)),b},m=()=>T.current===F.current||C.current,I=()=>{v.current!==null&&(cancelAnimationFrame(v.current),v.current=null),S.current!==null&&(window.clearTimeout(S.current),S.current=null)},i=()=>{I(),document.visibilityState!=="hidden"&&C.current&&(A.current=!1,w.current=a.messages,t(a.messages))},M=()=>{if(!C.current||document.visibilityState==="hidden"||v.current!==null||S.current!==null)return;const c=()=>{v.current=null,S.current=null,i()};typeof requestAnimationFrame=="function"?v.current=requestAnimationFrame(c):S.current=window.setTimeout(c,0)};d.useEffect(()=>{const c=()=>{document.visibilityState==="visible"&&A.current&&M()};return document.addEventListener("visibilitychange",c),()=>document.removeEventListener("visibilitychange",c)});const P=c=>{if(h.current!==c||(O.current!==null&&(window.clearTimeout(O.current),O.current=null),k.current==="cleared"))return;const f=k.current==="shown";k.current="cleared",f&&J({type:"clear_workspace_status"},m())},ae=(c,f)=>{O.current!==null&&window.clearTimeout(O.current),k.current="armed",O.current=window.setTimeout(()=>{O.current=null,!(k.current!=="armed"||h.current!==c||c.signal.aborted||F.current!==f)&&(k.current="shown",J({type:"workspace_status"},m()))},Ss)},ie=(c,f)=>{const E=j.current;!E||E.controller!==c||E.tracker.recordStreamStart(f,performance.now())},fe=(c,f)=>{const E=j.current;!E||E.controller!==c||E.tracker.recordTerminal(f)};d.useLayoutEffect(()=>{const c=j.current;if(!c)return;const f=r.at(-1);if((f==null?void 0:f.role)!=="assistant"||!(f.blocks??[]).some(g=>g.kind==="tool"||g.kind==="reasoning"&&!!g.text.trim()||g.kind==="answer"&&!!g.text.trim()))return;const b=performance.now();c.tracker.recordFirstVisible(b);for(const g of f.blocks??[])g.kind==="reasoning"&&g.text.trim()?c.tracker.recordSemantic("reasoning",b):g.kind==="tool"?c.tracker.recordSemantic("tool",b):g.kind==="answer"&&g.text.trim()&&c.tracker.recordSemantic("answer",b)},[r]);const ge=(c,f=!0)=>{J({type:"event",event:c},f)},Ke=async(c,f)=>{var g;const E=await(_.current.loadSession??ut)(c);let b=$t(E);return((g=B.current)==null?void 0:g.sessionId)===c&&(b=B.current.messages,B.current=null),F.current!==f&&!(T.current===f&&C.current&&_.current.sessionId===c)?null:(t(b),w.current=b,a.restore(b,c),b)},Ie=(c,f,E,b,g,H,K)=>{const y=++F.current;T.current=y,C.current=!0;const N=new AbortController;h.current=N;const he=c.text;return V.current=c,p(""),t(E),a.start(E,f.session_id,K??{model:_.current.initialModel,webSearchEnabled:!!f.web_search_enabled,reasoningEffort:f.reasoning_effort??Le}),u(!0),j.current=H?null:{controller:N,tracker:new ds(performance.now())},k.current="cleared",(async()=>{var X,G,_e,re,ve,qe;let oe=0;const ce=Y=>{Y>oe&&(oe=Y)};try{const Y=H?Yt(H,{signal:N.signal,onSequence:ce}):Nr(f,{signal:N.signal,onSequence:ce}),q=ws(Y,{signal:N.signal,getSessionId:()=>a.sessionId,onDisconnect:()=>{!N.signal.aborted&&h.current===N&&ge({type:"compaction_status",state:"finished"},m())},getAfterSequence:()=>oe,onSequence:ce}),Z=!H&&Ue()&&Dr(),pe=Z?_s(q,{signal:N.signal,isHidden:()=>document.visibilityState==="hidden"}):null;pe&&(L.current={controller:N,stream:pe});for await(const D of(pe==null?void 0:pe.events)??q){if(N.signal.aborted||h.current!==N)break;D.type==="paper_artifact"&&((G=(X=_.current).onPaperArtifact)==null||G.call(X,D,a.sessionId)),D.type==="stream_start"&&ie(N,D.request_id),D.type==="sandbox_start"&&ae(N,y),(D.type==="sandbox_ready"||D.type==="workspace_ready"||D.type==="lifecycle")&&P(N),(D.type==="reasoning_start"||D.type==="reasoning_delta"||D.type==="tool_call"||D.type==="tool_call_start"||D.type==="tool_call_arguments_delta"||D.type==="tool_call_arguments_done"||D.type==="app_start"||D.type==="app_result"||D.type==="artifact_start"||D.type==="artifact_ready"||D.type==="artifact_error"||D.type==="answer_delta"||D.type==="done"||D.type==="error")&&P(N),a.observe(D)&&m()&&_.current.onInterrupted(c),(D.type==="done"||D.type==="error")&&fe(N,D.type==="error"?"error":"complete");const ke=m(),$e=ke&&!(Z&&document.visibilityState==="hidden"),Ze=D.type==="reasoning_delta"||D.type==="answer_delta"||D.type==="tool_call_arguments_delta",Be=!["stream_start","sandbox_start","sandbox_ready","workspace_ready","session_title_start","session_title_delta","session_title_done","reasoning_delta","answer_delta","tool_call_arguments_delta"].includes(D.type);Z&&Be&&i(),Z&&Ze?(ge(D,!1),A.current||(A.current=ke),M()):(ge(D,$e),Z&&ke&&!$e&&(A.current=!0))}}catch(Y){if(!N.signal.aborted&&h.current===N){const q=a.reject(Y,!!H),Z=q==="completed";if(P(N),!Z)if(q==="disabled")Q({question:he,draft:c}),a.restore(b),F.current===y&&(t(b),w.current=b,p(""));else if(q==="capacity"){const pe=Y instanceof nt?Y.retryAfterSeconds??5:5,D={question:he,draft:c,request:f,optimistic:E,original:b,edit:g,retryAfterSeconds:pe,retryAt:Date.now()+pe*1e3};a.queueCapacity(D),U({question:he,draft:c,retryAt:D.retryAt,retryAfterSeconds:pe}),a.restore(b),F.current===y&&(t(b),w.current=b,p(""))}else fe(N,"network_error"),q==="draft"&&(m()&&_.current.onInterrupted(c),a.restore(b),F.current===y&&(t(b),w.current=b,p(Y instanceof Error?Y.message:"The assistant stream failed."))),q==="provider"&&m()&&_.current.onInterrupted(c);!Z&&!a.admissionRejected&&F.current===y&&ge({type:"error",message:Y instanceof Error?Y.message:"The assistant stream failed.",code:Y instanceof nt?Y.code:void 0})}}finally{if(h.current===N){if(((_e=L.current)==null?void 0:_e.controller)===N&&(i(),L.current=null),P(N),!a.sawTerminalEvent&&!N.signal.aborted&&fe(N,"network_error"),a.finish(),u(!1),a.admissionRejected)_.current.onSettled(f.session_id);else if(!N.signal.aborted){a.shouldRefreshProvider&&((ve=(re=_.current).onProviderTerminal)==null||ve.call(re));const Y=a.sessionId;if(g&&!a.sawStreamStart)a.restore(g.snapshot),F.current===y&&(t(g.snapshot),w.current=g.snapshot,p("Couldn’t resend this message. Your original conversation was restored."));else if(Y){F.current===y&&g&&(a.streamFailed||!a.sawTerminalEvent)&&(a.restore(g.snapshot),t(g.snapshot),w.current=g.snapshot);try{const q=await Ke(Y,y);q&&g&&q.some(Z=>Z.id===g.targetId)&&p("Couldn’t resend this message. Your original conversation was restored.")}catch{F.current===y&&J({type:"settle"})}}else F.current===y&&J({type:"settle"});(!h.current||h.current===N)&&_.current.onSettled(Y)}((qe=j.current)==null?void 0:qe.controller)===N&&(j.current=null)}}})(),!0},je=Se(c=>{var ce,X;const f=typeof c=="string"?He(c.trim()):c,E=f.text;if(!E||E.length>8e3||a.busy||a.pendingCapacity)return!1;const b=w.current,g=[...b].reverse().find(G=>G.role==="user"),H=g!=null&&g.status&&g.status!=="complete"&&g.revision?{replace_message_id:g.id,prior_revision:g.revision}:null,K={id:z(),role:"user",text:E,paperMentions:f.paperMentions,paperSelection:f.paperSelection},y={id:z(),role:"assistant",streaming:!0,blocks:[]},N=H&&g?Es(b,G=>G.id===g.id):-1,he=N<0?[...b,K,y]:[...b.slice(0,N),K,y],oe=(X=(ce=_.current).viewerContext)==null?void 0:X.call(ce);return Ie(f,{message:E,paper_mentions:f.paperMentions.map(({route_id:G,title:_e,start:re,end:ve})=>({route_id:G,title:_e,start:re,end:ve})),session_id:_.current.sessionId,client_message_id:crypto.randomUUID(),web_search_enabled:!!_.current.webSearchEnabled,reasoning_effort:_.current.reasoningEffort??Le,..._.current.primaryPaperRouteId?{primary_paper_route_id:_.current.primaryPaperRouteId}:{},...oe?{viewer_context:oe}:{},...f.paperSelection?{paper_selection:Mt(f.paperSelection)}:{},...!_.current.sessionId&&_.current.initialModel?{initial_model:_.current.initialModel}:{},...H??{}},he,b)}),xe=Se((c,f)=>{var ce,X;const E=typeof f=="string"?He(f.trim()):f,b=E.text;if(!b||b.length>8e3||a.busy||a.pendingCapacity)return!1;const g=w.current.slice(),H=g.findIndex(G=>G.id===c&&G.role==="user");if(H<0)return!1;const K=g[H];if(!_.current.sessionId||!K.revision)return!1;const y={id:K.id,role:"user",text:b,paperMentions:E.paperMentions,paperSelection:E.paperSelection,revision:K.revision+1,status:"generating"},N={id:z(),role:"assistant",streaming:!0,blocks:[]},he=[...g.slice(0,H),y,N],oe=(X=(ce=_.current).viewerContext)==null?void 0:X.call(ce);return Ie(E,{message:b,paper_mentions:E.paperMentions.map(({route_id:G,title:_e,start:re,end:ve})=>({route_id:G,title:_e,start:re,end:ve})),session_id:_.current.sessionId,client_message_id:crypto.randomUUID(),web_search_enabled:!!_.current.webSearchEnabled,reasoning_effort:_.current.reasoningEffort??Le,..._.current.primaryPaperRouteId?{primary_paper_route_id:_.current.primaryPaperRouteId}:{},...oe?{viewer_context:oe}:{},...E.paperSelection?{paper_selection:Mt(E.paperSelection)}:{},replace_message_id:K.id,prior_revision:K.revision},he,g,{targetId:K.id,snapshot:g})}),de=Se(()=>{const c=w.current.slice(),f=[...c].reverse().find(g=>g.role==="user");if(!_.current.sessionId||!(f!=null&&f.revision)||a.busy||a.pendingCapacity)return!1;const E=He(f.text??"Continue the interrupted response from saved progress."),b=[...c,{id:z(),role:"user",text:E.text,paperMentions:[]},{id:z(),role:"assistant",streaming:!0,blocks:[]}];return Ie(E,{message:E.text,session_id:_.current.sessionId,client_message_id:crypto.randomUUID(),retry_message_id:f.id,..._.current.primaryPaperRouteId?{primary_paper_route_id:_.current.primaryPaperRouteId}:{},web_search_enabled:!!_.current.webSearchEnabled,reasoning_effort:_.current.reasoningEffort??Le},b,c)}),Te=Se(()=>{const c=[...w.current].reverse().find(f=>f.role==="user");return c!=null&&c.text?xe(c.id,{text:c.text,paperMentions:c.paperMentions??[],...c.paperSelection?{paperSelection:c.paperSelection}:{}}):!1}),We=d.useCallback(()=>{a.cancelCapacity(),U(null)},[a]),ye=Se(()=>{const c=a.pendingCapacity;return!c||Date.now(){var K,y;if(!h.current)return;const c=h.current;P(c),fe(c,"stopped"),c.abort();const f=((K=L.current)==null?void 0:K.controller)===c?L.current.stream.takeAcceptedForStop():[];L.current=null;for(const N of f)ge(N,!1);i(),h.current=null,((y=j.current)==null?void 0:y.controller)===c&&(j.current=null),a.finish(),u(!1);const E=m(),b=J({type:"stop"},!1).messages;E&&(w.current=b,t(b),_.current.onInterrupted(V.current));const g=a.sessionId;g&&(B.current={sessionId:g,messages:b}),g&&Mr(g).catch(()=>{});const H=++F.current;window.setTimeout(()=>{g&&E&&F.current===H?Ke(g,H).catch(()=>{}).finally(()=>{h.current||_.current.onSettled(g)}):h.current||_.current.onSettled(g)},450)}),Ne=Se((c,f)=>{const E=C.current?a.transition({type:"toggle_block",messageId:c,blockIndex:f}).messages:Jt(w.current,c,f);w.current=E,t(E)}),Ye=d.useCallback(()=>{var c;F.current+=1,O.current!==null&&(window.clearTimeout(O.current),O.current=null),k.current="cleared",(c=h.current)==null||c.abort(),h.current=null,L.current=null,I(),A.current=!1,B.current=null,j.current=null,U(null),a.reset(),T.current=null,C.current=!1,t([]),u(!1),p("")},[a]),Oe=Se((c,f,E=!1,b)=>{var g;if(F.current+=1,O.current!==null&&(window.clearTimeout(O.current),O.current=null),k.current="cleared",I(),A.current=!1,j.current=null,a.cancelCapacity(),U(null),a.busy&&f!==void 0&&f===a.sessionId){C.current=!0,t(a.messages),w.current=a.messages,p("");return}if(C.current=!1,a.busy||((g=h.current)==null||g.abort(),h.current=null,T.current=null,C.current=!1),E&&f&&!a.busy){const H=[...c].reverse().find(K=>K.role==="user");if(H){const K={text:H.text??"",paperMentions:H.paperMentions??[],...H.paperSelection?{paperSelection:H.paperSelection}:{}},y=[...c,{id:`${H.id}-active`,role:"assistant",streaming:!0,blocks:[]}];Ie(K,{message:K.text,session_id:f,client_message_id:"reconnect",web_search_enabled:!!_.current.webSearchEnabled,reasoning_effort:_.current.reasoningEffort??Le},y,c,void 0,f,b);return}}t(c),w.current=c,a.busy||a.restore(c,f??_.current.sessionId),a.busy||u(!1),p("")});return{messages:r,busy:s,activeSessionId:s?a.sessionId:null,activeTitle:a.state.title,activeConfiguration:a.configuration,selectedBusy:s&&a.sessionId===e.sessionId,papers:ue,sessionError:o,capacityRequest:W,disabledRequest:se,send:je,editAndResend:xe,retryFromProgress:de,retryLatest:Te,retryCapacity:ye,cancelCapacity:We,dismissDisabled:()=>Q(null),stop:Me,toggleBlock:Ne,reset:Ye,load:Oe}}const Xt=["chat","openai","usage"],Is=90,Zt="pwc:chat:openai-credits-notice:dismissed";function ks(e=!0){return Pe({queryKey:Xt,queryFn:()=>Xe.getOpenAIUsage(),enabled:e,staleTime:3e4,retry:!1,refetchOnWindowFocus:!0})}function Cs(e,r,t){if(!e||r!=="openai"||e.used_percent["chatSessions",e],detail:(e,r)=>["chatSession",e,r]},Ts=e=>Vt({queryKey:Fe.list(e),queryFn:Lr,staleTime:0,refetchOnWindowFocus:!1,retry:!1}),Bt=(e,r)=>Vt({queryKey:Fe.detail(e,r),queryFn:()=>{if(!r)throw new Error("A saved conversation is required");return ut(r)},staleTime:0,refetchOnWindowFocus:!1,retry:!1}),me=He,Ms=["Summarize the main contributions","Explain in simple terms","Identify the main limitations"],Ns=()=>{const e=sessionStorage.getItem(Je);if(!e)return null;try{return Yr(JSON.parse(e),e)}catch{}return me(e)},Ds=({enabled:e,workspaceKey:r,children:t,onAskAiFix:s})=>e?n.jsx(Sr,{workspaceKey:r,onAskAiFix:s,children:t}):n.jsx(n.Fragment,{children:t}),Ls=({enabled:e,children:r})=>e?n.jsx(Er,{variant:"chat",children:r}):n.jsx(n.Fragment,{children:r}),Fs=({mode:e="general",routeSessionId:r,primaryPaper:t,currentPage:s,paperSelection:u,onPaperSelectionChange:o,onSessionId:p,onReaderSubmit:a,onReaderNewChat:h,onReaderClose:L})=>{var ht,mt,gt,yt,_t,bt,wt,xt,vt,St,Et,Rt,It,kt;const{sessionId:v}=lr(),S=r??(e==="general"?v:void 0),A=ur(),[B,O]=dr(),{user:k,isLoading:j}=Ut(),W=pr(),U=(k==null?void 0:k.hf_subject)??null,se=_r(),Q=Pe({queryKey:["chatAvailability"],queryFn:()=>Xe.getAvailability(),refetchInterval:3e4,retry:!1,enabled:Ue()&&!!k}),w=((ht=Q.data)==null?void 0:ht.status)==="paused"||e==="paper"&&((mt=Q.data)==null?void 0:mt.paper_reader_chat_enabled)===!1,T=Pe({...Ts(U),enabled:!!k&&!j}),C=T.data??[],[_,V]=d.useState(null),[$,F]=d.useState(""),ne=l=>{W.setQueryData(Fe.list(U),x=>l(x??[]))},ue=(l,x)=>{ne(R=>R.map(le=>le.id===l?{...le,...x}:le)),W.setQueryData(Fe.detail(U,l),R=>R&&{...R,...x})},z=d.useRef(Fr()),J=d.useRef(B.get("model")||((gt=z.current)==null?void 0:gt.model)),[m,I]=d.useState(se?Or:qr),[i,M]=d.useState(J.current||st),P=Br(m,i),ae=Pr(m,i),ie=P==="huggingface"&&!ae,fe=zr(!!(k&&P==="openrouter")),ge=ks(Ue()&&!!k&&P==="openai"),[Ke,Ie]=d.useState(()=>As()),je=Cs(ge.data,P,Ke),[xe,de]=d.useState(()=>me()),Te=Le,We=!!((yt=Q.data)!=null&&yt.web_search_available),[ye,Me]=d.useState(()=>{var x,R;const l=(x=B.get("q"))==null?void 0:x.trim();return l?me(l):((R=z.current)==null?void 0:R.draft)??me()}),Ne=d.useRef(!1),Ye=d.useRef(!1),Oe=d.useRef(!1),[c,f]=d.useState(()=>typeof window>"u"||window.innerWidth>900),E=d.useRef(new Set),b=d.useRef(S);b.current=S;const[g,H]=d.useState(void 0),K=d.useCallback(async()=>{await W.invalidateQueries({queryKey:Fe.list(U)})},[W,U]),y=Rs({sessionId:S??null,initialModel:i,webSearchEnabled:We,reasoningEffort:Te,primaryPaperRouteId:e==="paper"?t==null?void 0:t.routeId:void 0,viewerContext:e==="paper"&&s?()=>({page:Math.max(1,Math.min(1e4,s()))}):void 0,loadSession:async l=>{const x=await W.fetchQuery(Bt(U,l));return V(R=>(R==null?void 0:R.sessionId)===l?null:R),x},onSessionId:(l,x,R)=>{W.cancelQueries({queryKey:Fe.list(U)});const le=new Date().toISOString();ne(we=>we.some(Ce=>Ce.id===l)?we.map(Ce=>Ce.id===l?{...Ce,is_busy:!0}:Ce):[{id:l,title:"New chat",selected_model:(R==null?void 0:R.model)??i,created_at:le,updated_at:le,message_count:1,is_busy:!0,web_search_enabled:(R==null?void 0:R.webSearchEnabled)??We,reasoning_effort:(R==null?void 0:R.reasoningEffort)??Te},...we]),(b.current??null)===x&&l!==x&&(e==="paper"?p==null||p(l):A(`/chat/${l}`,{replace:!0}))},onTitle:(l,x)=>{x&&!E.current.has(x)&&ue(x,{title:l})},onSettled:l=>{l&&ue(l,{is_busy:!1}),W.invalidateQueries({queryKey:Xt}),K()},onProviderTerminal:()=>{W.invalidateQueries({queryKey:Gr})},onPaperArtifact:(l,x)=>{x&&V({sessionId:x,descriptor:l.descriptor})},onInterrupted:l=>{de(l),o==null||o(l.paperSelection)}}),N=y.send;d.useEffect(()=>{y.capacityRequest&&(de(y.capacityRequest.draft),o==null||o(y.capacityRequest.draft.paperSelection))},[y.capacityRequest,o]);const he=d.useCallback(l=>{sessionStorage.setItem(Je,JSON.stringify(l)),sessionStorage.setItem(Qe,i),sessionStorage.setItem(Hr,Te),sessionStorage.setItem(ze,"1"),sessionStorage.setItem(Ge,"1");const x=e==="paper"&&t?`/pdf/${t.routeId}`:b.current?`/chat/${b.current}`:"/chat";window.location.href=fr(x,ie)},[e,t,Te,i,ie]),oe=d.useCallback((l,x)=>{sessionStorage.setItem(Je,JSON.stringify(l)),sessionStorage.setItem(Qe,i),sessionStorage.removeItem(ze),sessionStorage.removeItem(Ge),Me(me()),de(l),o==null||o(l.paperSelection),F(x)},[o,i]),ce=d.useCallback(async l=>{const x=o?u?{...l,paperSelection:u}:{text:l.text,paperMentions:l.paperMentions}:l;if(!k){he(x);return}if(ie&&!Ye.current){if(Oe.current)return;Oe.current=!0;try{if(!(await Xe.getInferenceBilling()).connected){if(sessionStorage.getItem(Ge)==="1"){oe(x,"Hugging Face inference authorization was not completed. Your prompt is ready to retry.");return}he(x);return}Ye.current=!0}catch(R){oe(x,R instanceof Error?R.message:"Could not check Hugging Face authorization.");return}finally{Oe.current=!1}}if(sessionStorage.removeItem(ze),!N(x)){oe(x,"Your prompt was not sent. It is ready to retry.");return}sessionStorage.removeItem(Je),sessionStorage.removeItem(Qe),sessionStorage.removeItem(Ge),Ur(),z.current=null,de(me()),o==null||o(void 0),e==="paper"&&(a==null||a())},[he,e,o,a,u,oe,N,k,ie]);d.useEffect(()=>{if(j||!k)return;const l=sessionStorage.getItem(Qe);l&&M(l),Kr().then(le=>{if(I(le.items),!b.current){const we=J.current||l;M(we&&le.items.some(Ce=>Ce.id===we)?we:le.default_model)}});const x=Ns(),R=sessionStorage.getItem(ze)==="1";x&&(o==null||o(x.paperSelection),R?Me(x):de(x))},[j,o,K,k]);const X=y.selectedBusy,{load:G,activeConfiguration:_e}=y,re=Pe({...Bt(U,S??null),enabled:!!(S&&k&&!j&&!X),refetchOnMount:"always"}),ve=!j&&(!k||re.error instanceof hr&&re.error.status===404),qe=Pe({queryKey:["chatSessionPublicShare",S],queryFn:()=>Xe.getSessionPublicShare(S??""),enabled:e==="general"&&!!S&&ve,retry:!1}),Y=(_t=qe.data)==null?void 0:_t.public_path;d.useEffect(()=>{Y&&A(Y,{replace:!0})},[A,Y]);const q=re.data,Z=X||g===(S??null),pe=_&&_.sessionId===S?_.descriptor:q==null?void 0:q.latex_paper,D=(wt=(bt=[...(q==null?void 0:q.messages)??[]].reverse().find(l=>l.role==="user"&&l.viewer_context))==null?void 0:bt.viewer_context)==null?void 0:wt.page;d.useLayoutEffect(()=>{const l=S??null;if(g!==l){if(X){H(l);const x=_e;x&&x.model&&M(x.model);return}if(!l){G([],null),H(null);return}!q||re.isFetching||(H(l),G($t(q),l,q.is_busy,{model:q.selected_model,webSearchEnabled:q.web_search_enabled,reasoningEffort:q.reasoning_effort??"high"}),F(""),M(q.selected_model))}},[S,X,q,G,_e,re.isFetching,g]),d.useEffect(()=>{var le;if(j)return;const l=(le=B.get("q"))==null?void 0:le.trim();if(!l)return;Ne.current=!1;const x=B.get("model");x&&M(x),Me(me(l));const R=new URLSearchParams(B);R.delete("q"),R.delete("model"),O(R,{replace:!0})},[j,B,O]),d.useEffect(()=>{if(j||y.busy||!ye.text||Ne.current||k&&Q.isFetching||S&&!Z)return;const l=window.setTimeout(()=>{if(Ne.current)return;Ne.current=!0,ce(ye).finally(()=>Me(me()))},0);return()=>window.clearTimeout(l)},[j,Q.isFetching,y.busy,ye,S,Z,ce,k]),d.useEffect(()=>{const l=()=>{!k||y.busy||K()};return window.addEventListener("focus",l),()=>window.removeEventListener("focus",l)},[y.busy,K,k]);const ke=()=>{window.innerWidth<=900&&f(!1),G([],null),H(null),de(me()),o==null||o(void 0),e==="paper"?h==null||h():A("/chat")},$e=async(l,x)=>{try{const R=await Nt(l,{title:x});return E.current.add(l),ue(l,R),!0}catch(R){return F(R instanceof Error?R.message:"Rename failed"),!1}},Ze=async l=>{const x=y.busy&&l===y.activeSessionId;if(window.confirm(x?"Stop and delete this chat? This cannot be undone.":"Delete this chat? This cannot be undone.")){x&&y.stop();try{if(x){const R=Date.now()+3e3;for(;(await ut(l)).is_busy;){if(Date.now()>=R)throw new Error("Generation is still stopping. The chat was not deleted.");await new Promise(we=>window.setTimeout(we,150))}}await $r(l),l===S&&ke(),await K()}catch(R){F(R instanceof Error?R.message:"Delete failed")}}},Be=us({messages:y.messages,refreshSessions:K,resetChat:y.reset,restoreDraft:de}),er=async l=>{const x=i;if(M(l),!S)return!0;try{const R=await Nt(S,{selected_model:l});return ue(S,{selected_model:R.selected_model}),F(""),!0}catch(R){return M(x),F(R instanceof Error?R.message:"Model change failed"),!1}},tr=m.some(l=>l.id===st),rr=async()=>{await er(st)&&y.retryLatest()},sr=Xr(e==="general"),dt=C.map(l=>l.id===y.activeSessionId&&y.busy?{...l,is_busy:!0,title:E.current.has(l.id)?l.title:y.activeTitle||l.title}:l),be=dt.find(l=>l.id===S),et=(be==null?void 0:be.primary_paper)??(q==null?void 0:q.primary_paper),tt=y.messages.length===0,Ve=!!(S&&(j||k&&!Z&&!re.isError||qe.isFetching||Y)),pt=!Z&&!Ve&&((xt=re.error)==null?void 0:xt.message),nr=!!((vt=fe.data)!=null&&vt.fallback_enabled),ar=o?u?{...xe,paperSelection:u}:{text:xe.text,paperMentions:xe.paperMentions}:xe,ft={onSend:ce,busy:X,onStop:y.stop,draft:ar,onDraftChange:l=>{o?(de({text:l.text,paperMentions:l.paperMentions}),l.paperSelection!==u&&o(l.paperSelection)):de(l)},disabled:w||j||y.busy&&!X,describedBy:w?"chat-paused-description":void 0,paperMentionsEnabled:!!((St=Q.data)!=null&&St.paper_mentions_enabled),paperSelectionEnabled:((Et=Q.data)==null?void 0:Et.paper_reader_selection_enabled)===!0,paperArtifactsEnabled:e==="general"&&((Rt=Q.data)==null?void 0:Rt.paper_artifacts_enabled)===!0};return n.jsx(Ds,{enabled:e==="general",workspaceKey:S??"new-chat",onAskAiFix:l=>{ce(me(l))},children:n.jsxs("div",{className:`chat-page${e==="paper"?" chat-page--reader":""}`,style:{height:sr},children:[e==="general"&&n.jsx(os,{sessions:dt,activeSessionId:S,loading:T.isLoading,error:$||((It=T.error)==null?void 0:It.message)||"",open:c,onClose:()=>f(!1),onNew:ke,onNavigate:l=>{window.innerWidth<=900&&f(!1),A(`/chat/${l}`)},onRename:$e,onDelete:l=>void Ze(l)}),n.jsx(Ls,{enabled:e==="general",children:n.jsxs("section",{className:"chat-main","data-testid":"active-chat-pane",children:[n.jsxs("div",{className:"chat-topbar",children:[e==="general"&&!c&&n.jsx("button",{type:"button",className:"icon-btn",onClick:()=>f(!0),title:"Open sidebar",children:n.jsx(Kt,{})}),n.jsx("span",{className:"chat-topbar-title",children:Ve?(be==null?void 0:be.title)||"":(be==null?void 0:be.title)||(q==null?void 0:q.title)||(tt?"":"New chat")}),se&&n.jsx("span",{className:"chat-staging-badge",children:"Staging"}),e==="general"&&S&&et&&n.jsx(Ct,{className:"chat-reader-action",to:`/pdf/${et.route_id}`,onClick:l=>{if(!De()){l.preventDefault();return}const x=et.route_id;sessionStorage.setItem(`pwc:reader:session:${x}`,S),D&&sessionStorage.setItem(`pwc:reader:page:${x}`,String(D))},children:"Open reader"}),S&&Z&&!tt&&n.jsx(cs,{sessionId:S,busy:X,loading:Ve,hasPaperSelection:y.messages.some(l=>!!l.paperSelection),onError:F}),e==="paper"&&n.jsxs(mr,{children:[n.jsx(gr,{asChild:!0,children:n.jsx("button",{type:"button",className:"icon-btn chat-reader-icon-btn","aria-label":"Chat options",title:"Chat options",children:n.jsx(Jr,{"aria-hidden":"true"})})}),n.jsxs(yr,{align:"end",children:[n.jsx(At,{onSelect:ke,children:"New chat"}),n.jsx(At,{asChild:!0,children:n.jsx(Ct,{to:"/chat",children:"All chats"})})]})]}),e==="paper"&&L&&n.jsx("button",{type:"button",className:"icon-btn chat-reader-icon-btn",onClick:L,"aria-label":"Close chat",title:"Close chat",children:n.jsx(Pt,{"aria-hidden":"true"})})]}),je&&n.jsxs("div",{className:"chat-credits-notice",role:"status",children:[n.jsx("span",{children:je.message}),n.jsx("button",{type:"button",className:"chat-credits-notice-close","aria-label":"Dismiss credits notice",onClick:()=>{js(je.resetsAt),Ie(je.resetsAt)},children:"×"})]}),e==="general"&&pe&&n.jsx(ls,{descriptor:pe}),Ve&&!ye.text?n.jsxs("div",{className:"chat-session-loading",role:"status","aria-live":"polite",children:[n.jsx(Wt,{}),n.jsx("span",{children:"Loading conversation…"})]}):pt?n.jsxs("div",{className:"chat-session-load-error",role:"alert",children:[n.jsx("p",{children:pt}),n.jsx("button",{type:"button",onClick:()=>{re.refetch()},children:"Try again"})]}):tt&&!ye.text?n.jsx("div",{className:"chat-empty",children:n.jsxs("div",{className:"chat-empty-inner",children:[n.jsx("div",{className:"chat-empty-eyebrow",children:e==="paper"?"Paper chat":"Research chat"}),n.jsx("h1",{className:"chat-empty-title",children:e==="paper"?"Ask about this paper":n.jsxs(n.Fragment,{children:["Ask ",n.jsx("em",{children:"Papers With Code"})]})}),n.jsx("p",{className:"chat-empty-sub",children:e==="paper"?"Questions are grounded in the open paper. Add up to three other papers with @.":"Answers are grounded in a live hybrid search over papers, tasks, and benchmarks — with citations you can follow."}),se&&n.jsx("p",{className:"chat-staging-access-note",children:"This is a limited staging preview. Only approved Hugging Face users can start chats."}),n.jsx(Lt,{variant:"empty",composerProps:ft,provider:P,sponsored:ae,paused:w,error:y.sessionError,suggestions:e==="paper"?Ms:Wr})]})}):n.jsxs(n.Fragment,{children:[n.jsx(ts,{messages:y.messages,papers:y.papers,busy:X,queuedDraft:ye.text?ye:void 0,paperMentionsEnabled:!!((kt=Q.data)!=null&&kt.paper_mentions_enabled),archivePending:Be.pending,openRouterFallbackEnabled:nr,onToggleBlock:y.toggleBlock,onEditAndResend:y.editAndResend,onRetryFromProgress:y.retryFromProgress,onRetryWithLuna:tr?()=>void rr():void 0,onArchiveOld:()=>void Be.archiveOld(),onArchiveOldest:()=>void Be.archiveOldest()}),n.jsx(Lt,{variant:"followup",composerProps:ft,provider:P,sponsored:ae,paused:w,error:y.sessionError})]})]})}),y.capacityRequest&&n.jsx(rs,{retryAt:y.capacityRequest.retryAt,onCancel:y.cancelCapacity,onRetry:()=>{y.retryCapacity()&&(de(me()),o==null||o(void 0))}}),y.disabledRequest&&n.jsx(ss,{onClose:()=>{var x;const l=((x=y.disabledRequest)==null?void 0:x.draft)??xe;de(l),o==null||o(l.paperSelection),y.dismissDisabled(),Q.refetch()}})]})})},Os=e=>{const{user:r}=Ut();return n.jsx(Fs,{...e},(r==null?void 0:r.hf_subject)??"guest")},gn=()=>n.jsx(Os,{});export{Os as ChatExperience,gn as default}; diff --git a/assets/ChatView-DeilSeCH.js b/assets/ChatView-DeilSeCH.js new file mode 100644 index 0000000000000000000000000000000000000000..a2b5b59ff63d644fa8ef567d5c60ebc237e65dff --- /dev/null +++ b/assets/ChatView-DeilSeCH.js @@ -0,0 +1,6 @@ +var It=Object.defineProperty;var Nt=(t,e,r)=>e in t?It(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var se=(t,e,r)=>Nt(t,typeof e!="symbol"?e+"":e,r);import{s as Dt,d as l,j as s,X as yt,x as bt,b as Re,L as wt,_ as Lt,$ as Ft,a0 as Pt,a1 as nt,V as Oe,g as vt,e as St,q as _t,i as xt,h as Bt,a as Et,u as Ot,A as qt}from"./index-CjdUkE4w.js";import{C as Ut,U as at,b as Ht,f as Ce,A as Wt,a as zt,c as Kt,g as Qt,h as Vt,i as Pe,j as Yt,k as it,t as $t,l as Gt,E as Xt,m as Jt,n as Zt,o as ot}from"./chatLifecycle-B6B3Dpfi.js";import{g as Ie,h as es,j as Ct,k as ts,T as ss,e as Rt,l as Te,m as We,r as rs,n as ns,o as oe,D as ze,s as as,t as is,v as os,w as cs,x as ls,y as us,z as ds,B as hs,C as ps,E as Xe,F as fs,G as ct,H as jt,I as lt,J as Ke,f as ms,K as gs,L as ys,M as At,N as bs,O as ws,Q as vs,R as Ss,S as _s}from"./chatSessions-9VEG8seW.js";import{M as xs}from"./McpShowcase-Bo79ATLK.js";import{c as ce}from"./chat-B1EBF720.js";import{S as Es}from"./share-2-Nvga0TP8.js";import{u as qe}from"./useMutation-BYtVrkc7.js";import{u as Cs,O as Rs}from"./openrouter-B-ghWDkd.js";/* empty css */import"./hover-card-CIBIV2Hx.js";import"./CatalogEntityPreviewLink-DY_jhXy9.js";import"./catalog-qXcKve0z.js";import"./github-4bW4WI_e.js";import"./file-text-CHlxsNJC.js";import"./PaperPreviewLink-zGfFNaz6.js";import"./index-tLcwYp0U.js";import"./index-Dj6aE-6E.js";import"./katex-DkKDou_j.js";import"./papers-DgZwjF3K.js";import"./curation-CyyuHfv5.js";import"./thumbs-up-Dn_5H93T.js";import"./copy-SoF5zg-g.js";import"./queryOptions-C9woPjwX.js";import"./arrow-left-CkQb0MI4.js";import"./external-link-CTLWFJ8S.js";import"./plus-AztI1566.js";import"./search-DxMn7VKI.js";import"./chevron-up-BwiJ46dh.js";import"./AuthorAvatar-D9249Frl.js";import"./AgentLogos-xoTIu0NB.js";/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const js=Dt("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);function As(t){const[e,r]=l.useState("calc(100dvh - 60px)");return l.useLayoutEffect(()=>{if(!t)return;const n=document.querySelector(".app-header"),o=window.visualViewport,a=()=>{const d=(o==null?void 0:o.height)??window.innerHeight;r(`${Math.max(0,d-((n==null?void 0:n.offsetHeight)??0))}px`)};a();const u=new ResizeObserver(a);return n&&u.observe(n),o==null||o.addEventListener("resize",a),window.addEventListener("resize",a),()=>{u.disconnect(),o==null||o.removeEventListener("resize",a),window.removeEventListener("resize",a)}},[t]),t?e:"100%"}const ks="https://huggingface.co/settings/inference-providers",ut="pwc.chat.billing-notice-dismissed.v1";function Ms({provider:t}){const[e,r]=l.useState(()=>localStorage.getItem(ut)==="1");return!Ie()||e||t!=="huggingface"?null:s.jsxs("div",{className:"chat-billing-notice",role:"note",children:[s.jsx("span",{children:"Hugging Face models use the inference permission granted when you start chatting. Included monthly credits are used first, then extra usage requires purchased credits. You can choose organization billing in Settings."}),s.jsxs("div",{className:"chat-billing-notice-actions",children:[s.jsx("a",{href:"/settings",children:"Review billing"}),s.jsx("a",{href:ks,target:"_blank",rel:"noreferrer",children:"Review usage"}),s.jsx("button",{type:"button",className:"chat-billing-notice-dismiss","aria-label":"Dismiss billing notice",title:"Dismiss",onClick:()=>{localStorage.setItem(ut,"1"),r(!0)},children:s.jsx(yt,{size:15,"aria-hidden":"true"})})]})]})}function dt({variant:t,composerProps:e,provider:r,sponsored:n=!1,paused:o,error:a,suggestions:u=[]}){var h;const d=s.jsxs(s.Fragment,{children:[!n&&s.jsx(Ms,{provider:r}),o&&s.jsx("div",{id:"chat-paused-description",className:"chat-paused-banner",role:"status",children:"Chat is temporarily disabled. You can keep browsing and editing your conversations. New research runs will return when chat is restored."}),a&&s.jsx("div",{className:"chat-composer-error",role:"alert",children:a}),s.jsx(Ut,{...e,...t==="empty"?{autoFocus:!0}:{placeholder:(h=e.draft)!=null&&h.text?"Edit and send again…":"Ask a follow-up…"}}),t==="empty"&&s.jsx("div",{className:"chat-examples",children:u.map(y=>s.jsx("button",{type:"button",className:"chat-example",disabled:o,onClick:()=>{var C;return e.onSend({text:y,paperMentions:[],...(C=e.draft)!=null&&C.paperSelection?{paperSelection:e.draft.paperSelection}:{}})},children:y},y))})]});return t==="empty"?d:s.jsx("div",{className:"chat-composer-wrap",children:s.jsxs("div",{className:"chat-composer-inner",children:[d,s.jsx("div",{className:"chat-composer-foot",children:Ie()?s.jsxs(s.Fragment,{children:[r==="huggingface"&&s.jsxs("span",{className:"chat-provider-attribution",children:["Powered by 🤗 ",s.jsx("a",{href:"https://huggingface.co/docs/inference-providers/en/index",target:"_blank",rel:"noreferrer",children:"Inference Providers"}),"."]}),r==="openrouter"&&s.jsxs("span",{className:"chat-provider-attribution",children:["Powered by ",s.jsx("a",{href:"https://openrouter.ai",target:"_blank",rel:"noreferrer",children:"OpenRouter"}),"."]}),r==="openai"&&s.jsx("span",{className:"chat-provider-attribution",children:"Powered by OpenAI."}),s.jsx("span",{children:"The AI assistant can make mistakes. Double-check responses."})]}):s.jsx(s.Fragment,{children:"Assistant preview — responses are simulated."})})]})})}function Ts({messages:t,papers:e,busy:r,queuedDraft:n,paperMentionsEnabled:o,archivePending:a,openRouterFallbackEnabled:u,onToggleBlock:d,onEditAndResend:h,onRetryFromProgress:y,onRetryWithLuna:C,onArchiveOld:p,onArchiveOldest:m}){var b,S;const[A,E]=l.useState(null),R=l.useRef(null),v=l.useRef(null),j=l.useRef("bottom"),W=l.useRef(0),G=l.useRef(0),[D,k]=l.useState(!1),T=l.useRef(null),L=l.useCallback(i=>{j.current=i},[]),Q=l.useCallback(()=>{const i=R.current;i&&k(i.scrollHeight-i.scrollTop-i.clientHeight>1)},[]),B=t.filter(i=>i.role==="user"),F=B.length,q=l.useRef(F),ee=l.useRef(!1),ie=(b=B[0])==null?void 0:b.id,te=(S=B.at(-1))==null?void 0:S.id;l.useEffect(()=>{r&&E(null)},[r]),l.useLayoutEffect(()=>{const i=R.current;if(i){if(F>q.current||r&&!ee.current){const I=Array.from(i.querySelectorAll("[data-message-id]")).at(-1);if(I){const z=i.getBoundingClientRect().top;W.current=i.scrollTop+I.getBoundingClientRect().top-z-24,L("question")}}if(q.current=F,ee.current=r,v.current!==null){i.scrollTop=v.current,v.current=null;return}j.current==="bottom"&&(i.scrollTop=i.scrollHeight),j.current==="question"&&(i.scrollTop=W.current,G.current=i.scrollTop)}},[t,F,r,L]),l.useLayoutEffect(Q),l.useEffect(()=>{const i=R.current;if(!i)return;const I=new ResizeObserver(Q);return I.observe(i),i.firstElementChild&&I.observe(i.firstElementChild),()=>I.disconnect()},[Q]);const $=(i,I)=>{var z;v.current=((z=R.current)==null?void 0:z.scrollTop)??null,d(i,I)};return s.jsxs("div",{className:"chat-conversation-viewport",children:[s.jsx("div",{className:"chat-conversation",ref:R,tabIndex:0,role:"region","aria-label":"Conversation",onWheel:i=>{(i.deltaY<0||j.current==="question")&&L("free")},onTouchStart:i=>{var I;T.current=((I=i.touches[0])==null?void 0:I.clientY)??null},onTouchMove:i=>{var z;const I=(z=i.touches[0])==null?void 0:z.clientY;I!==void 0&&T.current!==null&&(I>T.current||j.current==="question")&&L("free"),T.current=I??null},onKeyDown:i=>{i.target===i.currentTarget&&((["ArrowUp","PageUp","Home"].includes(i.key)||i.key===" "&&i.shiftKey)&&L("free"),["ArrowDown","PageDown","End"," "].includes(i.key)&&j.current==="question"&&L("free"))},onScroll:i=>{const{scrollHeight:I,scrollTop:z,clientHeight:re}=i.currentTarget,K=I-z-re<=1;j.current==="bottom"&&!K&&L("free");const ue=z-G.current;j.current==="question"&&(ue>1||ue<-1&&!K)&&L("free"),Q()},children:s.jsxs("div",{className:"chat-conversation-inner",children:[t.length===0&&(n==null?void 0:n.text)&&s.jsx(at,{id:"queued-launch-preview",text:n.text,paperMentions:n.paperMentions,paperSelection:n.paperSelection,isInitial:!0}),t.map(i=>{var I,z,re,K;return i.role==="user"?s.jsx(at,{id:i.id,text:i.text??"",paperMentions:i.paperMentions??[],paperSelection:i.paperSelection,paperMentionsEnabled:o,isInitial:i.id===ie,editingAllowed:!r&&!!i.revision,editing:A===i.id,editNotice:i.id===ie?"Sending will replace this conversation.":i.id===te?"Sending will replace the response.":"Sending will replace the response and all messages after it.",onEdit:()=>E(i.id),onCancel:()=>E(null),onResendDraft:ue=>{const fe=h(i.id,ue);return fe&&E(null),fe}},i.id):s.jsx(Ht,{msg:i,papers:e,onToggleBlock:$,onRetryCompaction:!r&&i.id===((I=t.at(-1))==null?void 0:I.id)&&((z=B.at(-1))!=null&&z.revision)?y:void 0,onRetryWithLuna:!r&&i.id===((re=t.at(-1))==null?void 0:re.id)&&((K=B.at(-1))!=null&&K.revision)?C:void 0,onArchiveOldChats:p,onArchiveOldestChats:m,archivePending:a,hfBilling:null,openRouterFallbackEnabled:u,feedbackEnabled:!0},i.id)})]})}),D&&s.jsx("button",{type:"button",className:"chat-jump-latest",onClick:()=>{L("bottom");const i=R.current;i&&(i.focus({preventScroll:!0}),i.scrollTop=i.scrollHeight,Q())},children:"Jump to latest"})]})}function Is({retryAt:t,onRetry:e,onCancel:r}){const[n,o]=l.useState(()=>Math.max(0,Math.ceil((t-Date.now())/1e3))),a=l.useRef(null);return l.useEffect(()=>{var y;const u=document.activeElement instanceof HTMLElement?document.activeElement:null;(y=a.current)==null||y.focus();const d=()=>o(Math.max(0,Math.ceil((t-Date.now())/1e3)));d();const h=window.setInterval(d,250);return()=>{window.clearInterval(h),u==null||u.focus()}},[t]),s.jsx("div",{className:"chat-capacity-dialog-backdrop",role:"presentation",children:s.jsxs("div",{className:"chat-capacity-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"chat-capacity-dialog-title","aria-describedby":"chat-capacity-dialog-description",onKeyDown:u=>{u.key==="Escape"&&(u.preventDefault(),r())},children:[s.jsx("h2",{id:"chat-capacity-dialog-title",children:"All research slots are currently in use"}),s.jsx("p",{id:"chat-capacity-dialog-description",children:"Your message was not sent or billed. Try again in a few seconds."}),s.jsx("p",{className:"chat-capacity-countdown","aria-live":"polite",children:n>0?`Try again available in ${n} second${n===1?"":"s"}.`:"You can try again now."}),s.jsxs("div",{className:"chat-capacity-dialog-actions",children:[s.jsx("button",{type:"button",className:"chat-capacity-cancel",ref:a,onClick:r,children:"Cancel"}),s.jsx("button",{type:"button",className:"chat-capacity-retry",disabled:n>0,onClick:e,children:"Try again"})]})]})})}function Ns({onClose:t}){const e=l.useRef(null);return l.useEffect(()=>{var n;const r=document.activeElement instanceof HTMLElement?document.activeElement:null;return(n=e.current)==null||n.focus(),()=>r==null?void 0:r.focus()},[]),s.jsx("div",{className:"chat-capacity-dialog-backdrop",role:"presentation",children:s.jsxs("div",{className:"chat-capacity-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"chat-disabled-title","aria-describedby":"chat-disabled-description",onKeyDown:r=>{r.key==="Escape"&&(r.preventDefault(),t())},children:[s.jsx("h2",{id:"chat-disabled-title",children:"Chat is temporarily disabled"}),s.jsx("p",{id:"chat-disabled-description",children:"We've temporarily paused new research runs. Your message wasn't sent, and your draft is still here. Please try again later."}),s.jsx("div",{className:"chat-capacity-dialog-actions",children:s.jsx("button",{ref:e,type:"button",className:"chat-capacity-cancel",onClick:t,children:"Keep editing"})})]})})}function Ds({url:t,onClose:e}){return t?s.jsx("div",{className:"chat-share-dialog-backdrop",role:"presentation",onMouseDown:e,children:s.jsxs("div",{className:"chat-share-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"chat-share-dialog-title",onMouseDown:r=>r.stopPropagation(),children:[s.jsx("h2",{id:"chat-share-dialog-title",children:"Public link created"}),s.jsx("p",{children:"Anyone with this link can see this conversation. It could not be copied automatically, so copy it manually:"}),s.jsx("input",{readOnly:!0,value:t,"aria-label":"Public conversation link",autoFocus:!0,onFocus:r=>r.currentTarget.select()}),s.jsx("button",{type:"button",onClick:e,children:"Close"})]})}):null}const Qe="pwc:chat:sidebar-width",Ve=280,Ye=200,$e=480,Ls=12,Ge=t=>Math.max(Ye,Math.min($e,t)),Fs=()=>{if(typeof window>"u")return Ve;const t=Number(localStorage.getItem(Qe));return Number.isFinite(t)&&t>0?Ge(t):Ve};function Ps({sessions:t,activeSessionId:e,loading:r,error:n,open:o,onClose:a,onNew:u,onNavigate:d,onRename:h,onDelete:y}){const[C,p]=l.useState(Fs),m=l.useRef(null),A=l.useRef(C),[E,R]=l.useState(null),[v,j]=l.useState(""),[W,G]=l.useState(null),[D,k]=l.useState(!1),T=[...t].sort((b,S)=>Date.parse(S.updated_at)-Date.parse(b.updated_at)),L=T.filter((b,S)=>S{if(!W)return;const b=()=>G(null),S=i=>{i.key==="Escape"&&b()};return window.addEventListener("click",b),window.addEventListener("keydown",S),()=>{window.removeEventListener("click",b),window.removeEventListener("keydown",S)}},[W]);const F=b=>{R(b.id),j(b.title)},q=async b=>{const S=v.trim();S&&await h(b,S)&&R(null)},ee=(b,S,i)=>G({id:b,x:S,y:i}),ie=b=>{if(!m.current)return;const S=Ge(m.current.width+b-m.current.x);A.current=S,p(S)},te=()=>{m.current&&(m.current=null,localStorage.setItem(Qe,String(A.current)))},$=b=>{const S=Ge(b);A.current=S,p(S),localStorage.setItem(Qe,String(S))};return s.jsxs(s.Fragment,{children:[o&&s.jsx("div",{className:"chat-sidebar-backdrop","aria-hidden":"true",onClick:a}),s.jsxs("aside",{className:`chat-sidebar${o?"":" chat-sidebar-closed"}`,style:{"--chat-sidebar-width":`${C}px`},children:[s.jsxs("div",{className:"chat-sidebar-top",children:[s.jsxs("button",{type:"button",className:"chat-new-chat",onClick:()=>{Ce()&&u()},children:[s.jsx(es,{})," New chat"]}),s.jsx("button",{type:"button",className:"icon-btn",onClick:a,title:"Collapse sidebar",children:s.jsx(Ct,{})})]}),s.jsxs("nav",{className:"chat-sessions","aria-label":"Chat history",children:[r&&s.jsx("div",{className:"chat-sessions-empty",children:"Loading chats…"}),!r&&n&&s.jsx("div",{className:"chat-sessions-empty",children:n}),!r&&!n&&t.length===0&&s.jsx("div",{className:"chat-sessions-empty",children:"Conversations you start will show up here."}),ts(Q).map(b=>s.jsxs("div",{className:"chat-session-group",children:[s.jsx("div",{className:"chat-session-group-label",children:b.label}),b.items.map(S=>s.jsxs("div",{className:`chat-session${S.id===e?" chat-session-active":""}`,role:"button",tabIndex:0,onClick:()=>{Ce()&&d(S.id)},onKeyDown:i=>{if(i.key==="Enter"&&Ce()&&d(S.id),i.key==="F2"&&F(S),i.key==="ContextMenu"||i.shiftKey&&i.key==="F10"){i.preventDefault();const I=i.currentTarget.getBoundingClientRect();ee(S.id,I.right-150,I.bottom)}},onContextMenu:i=>{i.preventDefault(),ee(S.id,i.clientX,i.clientY)},children:[E===S.id?s.jsx("input",{className:"chat-session-title-input",value:v,autoFocus:!0,maxLength:80,onClick:i=>i.stopPropagation(),onChange:i=>j(i.target.value),onBlur:()=>void q(S.id),onKeyDown:i=>{i.stopPropagation(),i.key==="Enter"&&q(S.id),i.key==="Escape"&&R(null)}}):s.jsx("span",{className:"chat-session-title",children:S.title}),s.jsx("button",{type:"button",className:"chat-session-menu","aria-label":"Chat actions","aria-haspopup":"menu",title:"Chat actions",onClick:i=>{i.stopPropagation();const I=i.currentTarget.getBoundingClientRect();ee(S.id,I.right-150,I.bottom)},children:"⋯"}),s.jsx("button",{type:"button",className:"chat-session-delete","aria-label":"Delete conversation",onClick:i=>{i.stopPropagation(),Ce()&&y(S.id)},children:s.jsx(ss,{})})]},S.id))]},b.label)),B>0&&s.jsx("button",{type:"button",className:"chat-sessions-toggle","aria-expanded":D,onClick:()=>k(b=>!b),children:D?"Show less":`Show ${B} older ${B===1?"chat":"chats"}`})]}),s.jsx(xs,{className:"chat-sidebar-tools",canNavigate:Ce}),s.jsx("div",{className:"chat-sidebar-resize-handle",role:"separator","aria-label":"Resize chat history","aria-orientation":"vertical","aria-valuemin":Ye,"aria-valuemax":$e,"aria-valuenow":C,title:"Drag to resize; double-click to reset",tabIndex:0,onPointerDown:b=>{b.button===0&&(m.current={x:b.clientX,width:C},A.current=C,b.currentTarget.setPointerCapture(b.pointerId))},onPointerMove:b=>ie(b.clientX),onPointerUp:te,onPointerCancel:te,onLostPointerCapture:te,onDoubleClick:()=>$(Ve),onKeyDown:b=>{(b.key==="ArrowLeft"||b.key==="ArrowRight")&&(b.preventDefault(),$(C+(b.key==="ArrowRight"?10:-10))),(b.key==="Home"||b.key==="End")&&(b.preventDefault(),$(b.key==="Home"?Ye:$e))}}),W&&s.jsx("div",{className:"chat-session-context-menu",role:"menu",style:{left:W.x,top:W.y},onClick:b=>b.stopPropagation(),children:s.jsx("button",{type:"button",role:"menuitem",autoFocus:!0,onClick:()=>{const b=t.find(S=>S.id===W.id);b&&F(b),G(null)},children:"Rename chat"})})]})]})}function Bs({sessionId:t,busy:e,loading:r,hasPaperSelection:n=!1,onError:o}){const{toast:a}=bt(),[u,d]=l.useState(!1),[h,y]=l.useState(""),C=async()=>{var p;if(!(e||u)&&!(n&&!window.confirm("This public link will include the selected paper passage. Anyone with the link can read that passage. Continue?"))){d(!0);try{const m=await ce.createOrRefreshShare(t),A=new URL(m.public_path,window.location.origin).toString();try{if(!((p=navigator.clipboard)!=null&&p.writeText))throw new Error("Clipboard unavailable");await navigator.clipboard.writeText(A),a({className:"chat-share-toast",duration:5e3,title:"Public link copied to your clipboard",description:"Anyone with this link can see this conversation."})}catch{y(A)}}catch(m){const A=m instanceof Error?m.message:"Could not share this conversation";o(A),a({variant:"destructive",title:"Share failed",description:A})}finally{d(!1)}}};return s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"chat-share-button",onClick:()=>void C(),disabled:e||u||r,"aria-label":"Share conversation",children:[u?s.jsx(Rt,{}):s.jsx(Es,{"aria-hidden":"true"}),s.jsx("span",{children:"Share"})]}),s.jsx(Ds,{url:h,onClose:()=>y("")})]})}const kt=["chat","openai","usage"],Os=90,Mt="pwc:chat:openai-credits-notice:dismissed";function qs(t=!0){return Re({queryKey:kt,queryFn:()=>ce.getOpenAIUsage(),enabled:t,staleTime:3e4,retry:!1,refetchOnWindowFocus:!0})}function Us(t,e,r){if(!t||e!=="openai"||t.used_percentt?s.jsx(Wt,{workspaceKey:e,onAskAiFix:n,children:r}):s.jsx(s.Fragment,{children:r}),Ks=({enabled:t,children:e})=>t?s.jsx(zt,{variant:"chat",children:e}):s.jsx(s.Fragment,{children:e}),Qs=({provider:t,enabled:e})=>{const r=qs(e),[n,o]=Oe.useState(()=>Hs()),a=Us(r.data,t,n);return a?s.jsxs("div",{className:"chat-credits-notice",role:"status",children:[s.jsx("span",{children:a.message}),s.jsx("button",{type:"button",className:"chat-credits-notice-close","aria-label":"Dismiss credits notice",onClick:()=>{Ws(a.resetsAt),o(a.resetsAt)},children:"×"})]}):null},Vs=({onNewChat:t,onClose:e})=>s.jsxs(s.Fragment,{children:[s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",className:"icon-btn chat-reader-icon-btn","aria-label":"Chat options",title:"Chat options",children:s.jsx(js,{"aria-hidden":"true"})})}),s.jsxs(Pt,{align:"end",children:[s.jsx(nt,{onSelect:t,children:"New chat"}),s.jsx(nt,{asChild:!0,children:s.jsx(wt,{to:"/chat",children:"All chats"})})]})]}),e&&s.jsx("button",{type:"button",className:"icon-btn chat-reader-icon-btn",onClick:e,"aria-label":"Close chat",title:"Close chat",children:s.jsx(yt,{"aria-hidden":"true"})})]}),Ys=({routeId:t,sessionId:e,page:r})=>s.jsx(wt,{className:"chat-reader-action",to:`/pdf/${t}`,onClick:n=>{if(!Ce()){n.preventDefault();return}sessionStorage.setItem(`pwc:reader:session:${t}`,e),r&&sessionStorage.setItem(`pwc:reader:page:${t}`,String(r))},children:"Open reader"}),$s=({mode:t,staging:e,children:r})=>s.jsx("div",{className:"chat-empty",children:s.jsxs("div",{className:"chat-empty-inner",children:[s.jsx("div",{className:"chat-empty-eyebrow",children:t==="paper"?"Paper chat":"Research chat"}),s.jsx("h1",{className:"chat-empty-title",children:t==="paper"?"Ask about this paper":s.jsxs(s.Fragment,{children:["Ask ",s.jsx("em",{children:"Papers With Code"})]})}),s.jsx("p",{className:"chat-empty-sub",children:t==="paper"?"Questions are grounded in the open paper. Add up to three other papers with @.":"Answers are grounded in a live hybrid search over papers, tasks, and benchmarks — with citations you can follow."}),e&&s.jsx("p",{className:"chat-staging-access-note",children:"This is a limited staging preview. Only approved Hugging Face users can start chats."}),r]})}),Gs=({descriptor:t})=>{const e=Kt(),{open:r,register:n,unregister:o}=e,a=Oe.useRef(null),u=t.source_head??t.preview_head,d=Oe.useMemo(()=>u?{kind:"artifact",schema_version:1,scope:"owner",artifact_id:t.artifact_id,version_id:u.version_id,identifier:"latex-paper",version:u.version,artifact_kind:"latex_paper",title:t.title,status:"ready",preview_mime:"application/pdf",source_language:"latex",total_bytes:0}:null,[t.artifact_id,t.title,u]),h=d?Qt(d):null;return Oe.useEffect(()=>{if(!(!d||!h))return n(d),a.current!==h&&(a.current=h,r(d)),()=>o(h)},[d,h,r,n,o]),null},Xs={old:"Could not archive old chats",oldest:"Could not archive chats"};function Js({messages:t,refreshSessions:e,resetChat:r,restoreDraft:n}){const{toast:o}=bt(),a=qe({mutationFn:async h=>{const y=h==="old"?await ce.archiveOldChats():await ce.archiveOldestChats();return await e(),y},onSuccess:({archived_count:h},y)=>{if(y==="old"&&h===0){o({title:"No chats were archived",description:"There are no inactive chats older than 30 days."});return}const C=Te(t);r(),n(We(C)),o({title:`${h} ${h===1?"chat":"chats"} archived`,description:"Your question is ready to send again."})},onError:(h,y)=>{o({variant:"destructive",title:Xs[y],description:h instanceof Error?h.message:"Try again."})}}),u=a.isPending?a.variables??null:null,d=async h=>{u===null&&await a.mutateAsync(h).catch(()=>{})};return{pending:u,archiveOld:()=>d("old"),archiveOldest:()=>d("oldest")}}function Zs({pendingDraft:t,setPendingDraft:e,blocked:r,authLoading:n,signedIn:o,send:a,restoreDraft:u,setSelectedModel:d,onPaperSelectionChange:h}){const[y,C]=vt(),p=l.useRef(!1);l.useEffect(()=>{if(n||!o)return;const m=rs();m&&(m.draft.paperSelection&&(h==null||h(m.draft.paperSelection)),m.autoSend?e(m.draft):(u(m.draft),ns()))},[n,h,u,e,o]),l.useEffect(()=>{var R;if(n)return;const m=(R=y.get("q"))==null?void 0:R.trim();if(!m)return;p.current=!1;const A=y.get("model");A&&d(A),e(oe(m));const E=new URLSearchParams(y);E.delete("q"),E.delete("model"),C(E,{replace:!0})},[n,y,e,C,d]),l.useEffect(()=>{if(r||!t.text||p.current)return;const m=window.setTimeout(()=>{p.current||(p.current=!0,a(t).finally(()=>e(oe())))},0);return()=>window.clearTimeout(m)},[r,t,a,e])}function er(t,e){var a;const r=St(),n=Re({queryKey:["chatSessionPublicShare",t],queryFn:()=>ce.getSessionPublicShare(t??""),enabled:!!t&&e,retry:!1}),o=(a=n.data)==null?void 0:a.public_path;return l.useEffect(()=>{o&&r(o,{replace:!0})},[r,o]),{pending:n.isFetching||!!o}}function tr({userId:t,signedIn:e,authLoading:r,requestedModel:n,routeSessionIdRef:o}){const a=l.useRef(n),u=l.useRef(null),[d,h]=l.useState(n||ze),y=l.useCallback(R=>{a.current=R,h(R)},[]),p=Re({...Vt(t),enabled:e&&!r}).data,m=(p==null?void 0:p.items)??(_t()?as:is);l.useEffect(()=>{if(r||!e)return;const R=os();u.current=R,R&&h(R)},[r,e]),l.useEffect(()=>{if(!p||o.current)return;const R=a.current||u.current;h(R&&p.items.some(v=>v.id===R)?R:p.default_model)},[p,o]);const A=cs(m,d),E=ls(m,d);return{models:m,selectedModel:d,setSelectedModel:y,provider:A,sponsored:E,userBilledInference:A==="huggingface"&&!E,lunaAvailable:m.some(R=>R.id===ze)}}const sr=3e3,rr=150,He=(t,e)=>t instanceof Error?t.message:e;function nr(t){const e=xt(),r=l.useCallback(u=>{e.setQueryData(Pe.list(t),d=>u(d??[]))},[e,t]),n=l.useCallback((u,d)=>{r(h=>h.map(y=>y.id===u?{...y,...d}:y)),e.setQueryData(Pe.detail(t,u),h=>h&&{...h,...d})},[e,r,t]),o=l.useCallback(async()=>{await e.invalidateQueries({queryKey:Pe.list(t)})},[e,t]);return{markSessionBusy:l.useCallback((u,d)=>{e.cancelQueries({queryKey:Pe.list(t)});const h=new Date().toISOString();r(y=>y.some(C=>C.id===u)?y.map(C=>C.id===u?{...C,is_busy:!0}:C):[{id:u,title:"New chat",selected_model:d.model,created_at:h,updated_at:h,message_count:1,is_busy:!0,web_search_enabled:d.webSearchEnabled,reasoning_effort:d.reasoningEffort},...y])},[e,r,t]),patchSession:n,refreshSessions:o}}function ar({routeSessionId:t,selectedModel:e,setSelectedModel:r,patchSession:n,onRenamed:o,refreshSessions:a,onError:u,onSelectedDeleted:d,isActive:h,stopActive:y}){const C=qe({mutationFn:({id:v,title:j})=>ce.updateSession(v,{title:j}),onSuccess:(v,{id:j})=>{o(j),n(j,v)},onError:v=>u(He(v,"Rename failed"))}),p=qe({mutationFn:async({id:v,active:j})=>{if(j){const W=Date.now()+sr;for(;(await ce.getSession(v)).is_busy;){if(Date.now()>=W)throw new Error("Generation is still stopping. The chat was not deleted.");await new Promise(D=>window.setTimeout(D,rr))}}await ce.removeSession(v),v===t&&d(),await a()},onError:v=>u(He(v,"Delete failed"))}),m=qe({mutationFn:({sessionId:v,model:j})=>ce.updateSession(v,{selected_model:j}),onSuccess:(v,{sessionId:j})=>{n(j,{selected_model:v.selected_model}),u("")},onError:(v,{previous:j})=>{r(j),u(He(v,"Model change failed"))}});return{rename:(v,j)=>C.mutateAsync({id:v,title:j}).then(()=>!0,()=>!1),remove:async v=>{const j=h(v);window.confirm(j?"Stop and delete this chat? This cannot be undone.":"Delete this chat? This cannot be undone.")&&(j&&y(),await p.mutateAsync({id:v,active:j}).catch(()=>{}))},changeModel:async v=>{const j=e;return r(v),t?m.mutateAsync({sessionId:t,model:v,previous:j}).then(()=>!0,()=>!1):!0}}}function ir({returnTo:t,selectedModel:e,reasoningEffort:r,userBilledInference:n,onPromptRestored:o}){const a=l.useRef(!1),u=l.useRef(!1),d=l.useCallback(p=>{us(p,e,r),window.location.href=Bt(t(),{authorizeInference:n})},[r,t,e,n]),h=l.useCallback((p,m)=>{ds(p,e),o(p,m)},[o,e]),y=l.useCallback(async p=>{if(u.current)return!1;u.current=!0;try{return(await ce.getInferenceBilling()).connected?(a.current=!0,!0):hs()?(h(p,"Hugging Face inference authorization was not completed. Your prompt is ready to retry."),!1):(d(p),!1)}catch(m){return h(p,m instanceof Error?m.message:"Could not check Hugging Face authorization."),!1}finally{u.current=!1}},[d,h]);return{authorizeSend:l.useCallback((p,m)=>m?n&&!a.current?y(p):!0:(d(p),!1),[d,y,n]),restorePrompt:h}}function or(t,e,r){return{message:e,...r,web_search_enabled:!!t.webSearchEnabled,reasoning_effort:t.reasoningEffort??Xe}}function Tt(t){return t.primaryPaperRouteId?{primary_paper_route_id:t.primaryPaperRouteId}:{}}function ht(t,e){var n;const r=(n=t.viewerContext)==null?void 0:n.call(t);return{paper_mentions:e.paperMentions.map(({route_id:o,title:a,start:u,end:d})=>({route_id:o,title:a,start:u,end:d})),...Tt(t),...r?{viewer_context:r}:{},...e.paperSelection?{paper_selection:ps(e.paperSelection)}:{}}}class cr{constructor(e,r=fs){se(this,"requestId");se(this,"firstVisibleAt");se(this,"streamStartReported",!1);se(this,"firstVisibleReported",!1);se(this,"terminalReported",!1);se(this,"semanticReported",new Set);this.submittedAt=e,this.report=r}recordStreamStart(e,r){this.requestId=e,this.streamStartReported||(this.streamStartReported=!0,this.send({submission_to_stream_start_ms:Math.max(0,r-this.submittedAt)})),this.reportFirstVisible()}recordFirstVisible(e){this.firstVisibleAt===void 0&&(this.firstVisibleAt=e,this.reportFirstVisible())}recordSemantic(e,r){if(this.semanticReported.has(e))return;this.semanticReported.add(e);const n=Math.max(0,r-this.submittedAt);this.send(e==="reasoning"?{submission_to_first_reasoning_delta_ms:n}:e==="tool"?{submission_to_first_tool_call_ms:n}:{submission_to_first_answer_delta_ms:n})}recordTerminal(e){this.terminalReported||(this.terminalReported=!0,this.send({terminal_classification:e}))}reportFirstVisible(){!this.requestId||this.firstVisibleAt===void 0||this.firstVisibleReported||(this.firstVisibleReported=!0,this.send({submission_to_first_visible_delta_ms:Math.max(0,this.firstVisibleAt-this.submittedAt)}))}send(e){this.requestId&&this.report(this.requestId,e)}}const ye={minDelayMs:5,maxDelayMs:80,minRateCharsPerMs:.3,maxBufferedMs:400,arrivalRateTauMs:1e3,arrivalRateHeadroom:1.1,maxPendingChars:64},lr={now:()=>performance.now(),sleep:(t,e)=>new Promise(r=>{if(e!=null&&e.aborted||t<=0){r();return}const n=window.setTimeout(o,t);function o(){e==null||e.removeEventListener("abort",o),window.clearTimeout(n),r()}e==null||e.addEventListener("abort",o,{once:!0})})};function ur(t){return!["stream_start","sandbox_start","sandbox_ready","workspace_ready","session_title_start","session_title_delta","session_title_done"].includes(t.type)}function dr(t,e=!1,r=ye.maxPendingChars){var o;if(!t)return{pieces:[],pending:""};if(e)return{pieces:[t],pending:""};const n=Intl.Segmenter;if(n){const u=[...new n(void 0,{granularity:"word"}).segment(t)].filter(h=>h.isWordLike);let d=0;if(u.length>1&&(d=u.at(-1).index),u.length&&/\s$/u.test(t)&&(d=t.length),d>0){const h=t.slice(0,d),y=[],p=[...new n(void 0,{granularity:"word"}).segment(h)].filter(m=>m.isWordLike);for(let m=0;mA&&y.push(h.slice(A,E))}return p.length||y.push(h),{pieces:y,pending:t.slice(d)}}}else{const a=[...t.matchAll(/\s+/gu)];if(a.length){const u=[];let d=0;for(const h of a){const y=h.index+h[0].length;u.push(t.slice(d,y)),d=y}return{pieces:u,pending:t.slice(d)}}}return t.length>=r?{pieces:[t.slice(0,r)],pending:t.slice(r)}:{pieces:[],pending:t}}function hr(t,e={}){const r={minDelayMs:e.minDelayMs??ye.minDelayMs,maxDelayMs:e.maxDelayMs??ye.maxDelayMs,minRateCharsPerMs:e.minRateCharsPerMs??ye.minRateCharsPerMs,maxBufferedMs:e.maxBufferedMs??ye.maxBufferedMs,arrivalRateTauMs:e.arrivalRateTauMs??ye.arrivalRateTauMs,arrivalRateHeadroom:e.arrivalRateHeadroom??ye.arrivalRateHeadroom,maxPendingChars:e.maxPendingChars??ye.maxPendingChars},n=e.clock??lr,o=[];let a="",u=null,d=0,h=!0,y=!1,C=null,p=0,m=n.now(),A=!1;const E=()=>{C==null||C(),C=null},R=(k,T)=>{const L=k.type==="reasoning_delta"||k.type==="answer_delta"?k.text.length:0;o.push({kind:"event",event:k,arrivedAt:T,chars:L}),E()},v=k=>{if(!u||!a)return;const T=dr(a,k,r.maxPendingChars);for(const L of T.pieces)L&&R({type:u,text:L},d),d=n.now();a=T.pending,a||(u=null)},j=k=>{if(!h)return;const T=n.now();if(k.type==="reasoning_delta"||k.type==="answer_delta"){const L=k.type;if(!k.text)return;if(!A){A=!0,p+=k.text.length,m=T;const B=Array.from(k.text)[0];R({type:L,text:B},T);const F=k.text.slice(B.length);if(F)for(u=L,a=F,d=T,v(!1);a.length>=r.maxPendingChars;)v(!1);return}u&&u!==L&&v(!0),u||(u=L,d=T),a+=k.text;const Q=Math.max(0,T-m);for(p*=Math.exp(-Q/r.arrivalRateTauMs),p+=k.text.length,m=T,v(!1);a.length>=r.maxPendingChars;)v(!1);return}ur(k)&&v(!0),R(k,T)},W=(async()=>{var k;try{for await(const T of t)j(T);h&&v(!0)}catch(T){h&&!((k=e.signal)!=null&&k.aborted)&&(v(!0),o.push({kind:"error",error:T,arrivedAt:n.now(),chars:0}))}finally{y=!0,E()}})(),G=()=>o.length||y?Promise.resolve():new Promise(k=>{C=k});return{events:async function*(){var T,L,Q,B;let k=Number.NEGATIVE_INFINITY;try{for(;;){if(await G(),!o.length){if(y||!h)return;continue}const F=o[0];if(F.kind==="error")throw o.shift(),F.error;if(F.chars&&!((T=e.isHidden)!=null&&T.call(e))){const q=n.now(),ee=o.reduce((re,K)=>re+K.chars,0),ie=((L=o.find(re=>re.chars))==null?void 0:L.arrivedAt)??q,te=Math.max(0,r.maxBufferedMs-(q-ie)),$=p*Math.exp(-Math.max(0,q-m)/r.arrivalRateTauMs)/r.arrivalRateTauMs,b=te>0?ee/te:Number.POSITIVE_INFINITY,S=Math.max(r.minRateCharsPerMs,$*r.arrivalRateHeadroom,b),i=Math.min(r.maxDelayMs,Math.max(r.minDelayMs,F.chars/S)),I=Math.max(0,F.arrivedAt+r.maxBufferedMs-q),z=Math.max(F.arrivedAt,k+Math.min(i,I));if(await n.sleep(Math.max(0,z-n.now()),e.signal),!h||(Q=e.signal)!=null&&Q.aborted)return}o.shift(),k=n.now(),yield F.event}}finally{h&&(h=!1,E(),await((B=t.return)==null?void 0:B.call(t,void 0))),await W}}(),takeAcceptedForStop(){var T;if(!h)return[];h=!1,u&&a&&(R({type:u,text:a},d),a="",u=null);const k=o.flatMap(L=>L.kind==="event"&&L.event.type!=="done"&&L.event.type!=="error"?[L.event]:[]);return o.length=0,E(),(T=t.return)==null||T.call(t,void 0),k}}}const pt=[250,500,1e3],pr=(t,e)=>new Promise(r=>{const n=()=>{window.clearTimeout(o),e.removeEventListener("abort",n),r()},o=window.setTimeout(n,t);e.addEventListener("abort",n,{once:!0})});async function*fr(t,e){let r=t,n=0;for(;;){let o=!1;try{for await(const a of r)(a.type==="done"||a.type==="error")&&(o=!0),yield a;if(o||e.signal.aborted)return;throw new ct}catch(a){e.onDisconnect();const u=e.getSessionId();if(e.signal.aborted||o||!(a instanceof ct)||!u||n>=pt.length)throw a;if(await pr(pt[n],e.signal),e.signal.aborted)return;n+=1,r=jt(u,{signal:e.signal,afterSequence:e.getAfterSequence(),onSequence:e.onSequence})}}}class mr{constructor(){se(this,"configuration");se(this,"lifecycle",Yt());se(this,"_phase",{status:"idle"});se(this,"_pendingCapacity",null);se(this,"view",{messages:[],sessionError:"",disabledRequest:null});se(this,"snapshot",this.buildSnapshot());se(this,"listeners",new Set);se(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));se(this,"getSnapshot",()=>this.snapshot)}buildSnapshot(){return{...this.view,busy:this.busy,capacityRequest:this._pendingCapacity}}publish(){const e=this.buildSnapshot(),r=this.snapshot;if(!Object.keys(e).every(n=>e[n]===r[n])){this.snapshot=e;for(const n of this.listeners)n()}}get visibleMessages(){return this.view.messages}present(e){this.view={...this.view,...e},this.publish()}get phase(){return this._phase}get busy(){return this._phase.status==="streaming"}get pendingCapacity(){return this._pendingCapacity}get sawStreamStart(){return this._phase.status!=="idle"&&this._phase.streamStart!==null}get sawTerminalEvent(){return this._phase.status!=="idle"&&(this._phase.terminal==="complete"||this._phase.terminal==="error")}get streamFailed(){return this._phase.status!=="idle"&&(this._phase.terminal==="error"||this._phase.terminal==="transport_error"||this._phase.terminal==="admission_rejected")}get admissionRejected(){return this._phase.status!=="idle"&&this._phase.terminal==="admission_rejected"}get shouldRefreshProvider(){var e;return this._phase.status==="idle"?!1:!!((e=this._phase.streamStart)!=null&&e.providerExecuted)||this._phase.providerStatusChanged}progress(e){this._phase.status!=="idle"&&(this._phase={...this._phase,...e})}finish(){this._phase.status==="streaming"&&(this._phase={...this._phase,status:"settled"}),this.publish()}queueCapacity(e){this._pendingCapacity=e,this.publish()}cancelCapacity(){this._pendingCapacity=null,this.publish()}projectSession(e){return this.busy&&e===this.sessionId?this.messages:null}get state(){return this.lifecycle}get messages(){return this.lifecycle.messages}get sessionId(){return this.lifecycle.sessionId}transition(e,r=!1){return this.lifecycle=it(this.lifecycle,e),r&&(this.view={...this.view,messages:this.lifecycle.messages}),this.publish(),this.lifecycle}start(e,r,n){this.configuration=n,this._phase={status:"streaming",streamStart:null,providerStatusChanged:!1,terminal:"pending"},this.view={...this.view,messages:e,sessionError:""},this.transition({type:"start",messages:e,sessionId:r})}restore(e,{sessionId:r=this.sessionId,show:n=!1,view:o}={}){return this.lifecycle=it(this.lifecycle,{type:"load",messages:e,sessionId:r}),this.view={...this.view,...n?{messages:e}:{},...o},this.publish(),this.lifecycle}observe(e){return e.type==="stream_start"&&this.progress({streamStart:{providerExecuted:e.provider_execution!==!1}}),(e.type==="done"||e.type==="error")&&this.progress({terminal:e.type==="done"?"complete":"error"}),e.type==="error"&<(e.code)==="provider"?(this.progress({providerStatusChanged:!0}),!0):!1}reject(e,r){const n=e instanceof Ke?e.code:void 0,o=lt(n),a=r&&n==="chat_not_busy"?"completed":n==="chat_temporarily_disabled"?"disabled":n==="chat_capacity"?"capacity":o==="draft"?"draft":o==="provider"?"provider":"network";return this.progress({terminal:a==="completed"?"already_complete":a==="disabled"||a==="capacity"||a==="draft"?"admission_rejected":"transport_error",...a==="provider"?{providerStatusChanged:!0}:{}}),a}reset(){this._phase={status:"idle"},this._pendingCapacity=null,this.view={...this.view,messages:[],sessionError:""},this.transition({type:"reset"})}}const gr=750,yr=8e3,ft="The assistant stream failed.",mt="Couldn’t resend this message. Your original conversation was restored.";function he(t){const e=l.useRef(t);return l.useLayoutEffect(()=>{e.current=t}),l.useCallback((...r)=>e.current(...r),[])}const Be=t=>({id:t,role:"assistant",streaming:!0,blocks:[]});function br(t){const[e]=l.useState(()=>new mr),r=l.useSyncExternalStore(e.subscribe,e.getSnapshot),n=l.useRef(t);n.current=t;const o=l.useRef(null),a=l.useRef(0),u=l.useRef(null),d=l.useRef(!1),h=l.useRef(t.sessionId),y=l.useRef(null),C=l.useRef(null),p=l.useRef(!1),m=l.useRef({state:"cleared",timer:null}),A=l.useRef(null),E=l.useRef(null),R=l.useRef(oe()),v=l.useRef(0),W=(h.current!==t.sessionId?e.projectSession(t.sessionId):null)??r.messages,G=r.busy,D=()=>{var c;(c=C.current)==null||c.cancel(),C.current=null},k=()=>{const c=m.current;c.timer!==null&&window.clearTimeout(c.timer),m.current={state:"cleared",timer:null}},T=he(()=>{var f;const{timer:c}=m.current;c!==null&&window.clearTimeout(c),(f=o.current)==null||f.abort(),y.current=null,D(),e.cancelCapacity()});l.useEffect(()=>T,[T]),l.useLayoutEffect(()=>{h.current!==t.sessionId&&(h.current=t.sessionId,e.sessionId!==t.sessionId&&(a.current+=1,A.current=null));const c=e.projectSession(t.sessionId);d.current=c!==null,c&&e.present({messages:c})},[t.sessionId,e]),l.useEffect(()=>{e.busy||e.restore(e.messages,{sessionId:t.sessionId})},[t.sessionId,e]);const L=l.useMemo(()=>ms(W),[W]),Q=()=>`m${++v.current}_${Date.now().toString(36)}`,B=(c,f=!0)=>{const x=e.state,_=e.transition(c,f),w=c.type==="event"&&c.event.type==="stream_start"?c.event.session_id:null;return w?n.current.onSessionId(w,x.sessionId,e.configuration):_.sessionId&&_.sessionId!==x.sessionId&&n.current.onSessionId(_.sessionId,x.sessionId,e.configuration),_.title!==x.title&&n.current.onTitle(_.title,_.sessionId),_},F=(c,f=!0)=>{B({type:"event",event:c},f)},q=()=>u.current===a.current||d.current,ee=(c,f,x,_={})=>{const w=a.current===f;e.restore(c,{show:w,view:{..._,...w?{sessionError:x}:{}}})},ie=()=>{D(),document.visibilityState!=="hidden"&&d.current&&(p.current=!1,e.present({messages:e.messages}))},te=()=>{if(!d.current||document.visibilityState==="hidden"||C.current!==null)return;const c=()=>{C.current=null,ie()};if(typeof requestAnimationFrame=="function"){const f=requestAnimationFrame(c);C.current={cancel:()=>cancelAnimationFrame(f)}}else{const f=window.setTimeout(c,0);C.current={cancel:()=>window.clearTimeout(f)}}};l.useEffect(()=>{const c=()=>{document.visibilityState==="visible"&&p.current&&te()};return document.addEventListener("visibilitychange",c),()=>document.removeEventListener("visibilitychange",c)});const $=c=>{if(o.current!==c)return;const{state:f}=m.current;k(),f==="shown"&&B({type:"clear_workspace_status"},q())},b=(c,f)=>{const{timer:x}=m.current;x!==null&&window.clearTimeout(x);const _=window.setTimeout(()=>{m.current={...m.current,timer:null},!(m.current.state!=="armed"||o.current!==c||c.signal.aborted||a.current!==f)&&(m.current={state:"shown",timer:null},B({type:"workspace_status"},q()))},gr);m.current={state:"armed",timer:_}},S=(c,f)=>{const x=A.current;!x||x.controller!==c||x.tracker.recordStreamStart(f,performance.now())},i=(c,f)=>{const x=A.current;!x||x.controller!==c||x.tracker.recordTerminal(f)};l.useLayoutEffect(()=>{const c=A.current;if(!c)return;const f=W.at(-1);if((f==null?void 0:f.role)!=="assistant"||!(f.blocks??[]).some(w=>w.kind==="tool"||w.kind==="reasoning"&&!!w.text.trim()||w.kind==="answer"&&!!w.text.trim()))return;const _=performance.now();c.tracker.recordFirstVisible(_);for(const w of f.blocks??[])w.kind==="reasoning"&&w.text.trim()?c.tracker.recordSemantic("reasoning",_):w.kind==="tool"?c.tracker.recordSemantic("tool",_):w.kind==="answer"&&w.text.trim()&&c.tracker.recordSemantic("answer",_)},[W]);const I=async(c,f)=>{var P;const _=await(n.current.loadSession??(U=>ce.getSession(U)))(c);let w=At(_);return((P=E.current)==null?void 0:P.sessionId)===c&&(w=E.current.messages,E.current=null),a.current!==f&&!(u.current===f&&d.current&&n.current.sessionId===c)?null:(e.restore(w,{sessionId:c,show:!0}),w)},z=(c,f)=>or(n.current,c,f),re=c=>{const f=typeof c=="string"?oe(c.trim()):c;return!f.text||f.text.length>yr||e.busy||e.pendingCapacity?null:f},K=(c,f,x,_,w,P,U)=>{const H=++a.current;u.current=H,d.current=!0;const M=new AbortController;o.current=M;const X=c.text;return R.current=c,e.start(x,f.session_id,U??{model:n.current.initialModel,webSearchEnabled:!!f.web_search_enabled,reasoningEffort:f.reasoning_effort??Xe}),A.current=P?null:{controller:M,tracker:new cr(performance.now())},m.current={...m.current,state:"cleared"},(async()=>{var ve,ke,Fe,_e,xe,Ee;let me=0;const O=V=>{V>me&&(me=V)};try{const V=P?jt(P,{signal:M.signal,onSequence:O}):gs(f,{signal:M.signal,onSequence:O}),ne=fr(V,{signal:M.signal,getSessionId:()=>e.sessionId,onDisconnect:()=>{!M.signal.aborted&&o.current===M&&F({type:"compaction_status",state:"finished"},q())},getAfterSequence:()=>me,onSequence:O}),ae=!P&&Ie()&&ys(),J=ae?hr(ne,{signal:M.signal,isHidden:()=>document.visibilityState==="hidden"}):null;J&&(y.current={controller:M,stream:J});for await(const le of(J==null?void 0:J.events)??ne){if(M.signal.aborted||o.current!==M)break;const de=Xt[le.type];le.type==="paper_artifact"&&((ke=(ve=n.current).onPaperArtifact)==null||ke.call(ve,le,e.sessionId)),le.type==="stream_start"&&S(M,le.request_id),de.workspaceStatus==="arm"&&b(M,H),de.workspaceStatus==="clear"&&$(M),e.observe(le)&&q()&&n.current.onInterrupted(c),de.terminal&&i(M,de.terminal);const ge=q(),Me=ge&&!(ae&&document.visibilityState==="hidden");ae&&de.presentation==="structural"&&ie(),ae&&de.presentation==="delta"?(F(le,!1),p.current||(p.current=ge),te()):(F(le,Me),ae&&ge&&!Me&&(p.current=!0))}}catch(V){if(!M.signal.aborted&&o.current===M){const ne=e.reject(V,!!P);if($(M),ne!=="completed")if(ne==="disabled")ee(_,H,"",{disabledRequest:{question:X,draft:c}});else if(ne==="capacity"){const ae=V instanceof Ke?V.retryAfterSeconds??5:5;e.queueCapacity({question:X,draft:c,request:f,optimistic:x,original:_,edit:w,retryAfterSeconds:ae,retryAt:Date.now()+ae*1e3}),ee(_,H,"")}else i(M,"network_error"),ne==="draft"&&(q()&&n.current.onInterrupted(c),ee(_,H,V instanceof Error?V.message:ft)),ne==="provider"&&q()&&n.current.onInterrupted(c);ne!=="completed"&&!e.admissionRejected&&a.current===H&&F({type:"error",message:V instanceof Error?V.message:ft,code:V instanceof Ke?V.code:void 0})}}finally{if(o.current===M){if(((Fe=y.current)==null?void 0:Fe.controller)===M&&(ie(),y.current=null),$(M),!e.sawTerminalEvent&&!M.signal.aborted&&i(M,"network_error"),e.finish(),e.admissionRejected)n.current.onSettled(f.session_id);else if(!M.signal.aborted){e.shouldRefreshProvider&&((xe=(_e=n.current).onProviderTerminal)==null||xe.call(_e));const V=e.sessionId,ne=a.current===H;if(w&&!e.sawStreamStart)ee(w.snapshot,H,mt);else if(V){ne&&w&&(e.streamFailed||!e.sawTerminalEvent)&&e.restore(w.snapshot,{show:!0});try{const ae=await I(V,H);ae&&w&&ae.some(J=>J.id===w.targetId)&&e.present({sessionError:mt})}catch{a.current===H&&B({type:"settle"})}}else ne&&B({type:"settle"});(!o.current||o.current===M)&&n.current.onSettled(V)}((Ee=A.current)==null?void 0:Ee.controller)===M&&(A.current=null)}}})(),!0},ue=he(c=>{const f=re(c);if(!f)return!1;const x=e.visibleMessages,_=Te(x),w=_!=null&&_.status&&_.status!=="complete"&&_.revision?{replace_message_id:_.id,prior_revision:_.revision}:null,P={id:Q(),role:"user",text:f.text,paperMentions:f.paperMentions,paperSelection:f.paperSelection},U=Be(Q()),H=w&&_?Gt(x,O=>O.id===_.id):-1,M=H<0?[...x,P,U]:[...x.slice(0,H),P,U],{sessionId:X,initialModel:me}=n.current;return K(f,z(f.text,{session_id:X,client_message_id:crypto.randomUUID(),...ht(n.current,f),...!X&&me?{initial_model:me}:{},...w??{}}),M,x)}),fe=he((c,f)=>{const x=re(f);if(!x)return!1;const _=e.visibleMessages.slice(),w=_.findIndex(X=>X.id===c&&X.role==="user");if(w<0)return!1;const P=_[w],{sessionId:U}=n.current;if(!U||!P.revision)return!1;const H={id:P.id,role:"user",text:x.text,paperMentions:x.paperMentions,paperSelection:x.paperSelection,revision:P.revision+1,status:"generating"},M=[..._.slice(0,w),H,Be(Q())];return K(x,z(x.text,{session_id:U,client_message_id:crypto.randomUUID(),...ht(n.current,x),replace_message_id:P.id,prior_revision:P.revision}),M,_,{targetId:P.id,snapshot:_})}),be=he(()=>{const c=e.visibleMessages.slice(),f=Te(c),{sessionId:x}=n.current;if(!x||!(f!=null&&f.revision)||e.busy||e.pendingCapacity)return!1;const _=oe(f.text??"Continue the interrupted response from saved progress."),w=[...c,{id:Q(),role:"user",text:_.text,paperMentions:[]},Be(Q())];return K(_,z(_.text,{session_id:x,client_message_id:crypto.randomUUID(),retry_message_id:f.id,...Tt(n.current)}),w,c)}),Ne=he(()=>{const c=Te(e.visibleMessages);return c!=null&&c.text?fe(c.id,We(c)):!1}),De=l.useCallback(()=>{e.cancelCapacity()},[e]),Se=he(()=>{const c=e.pendingCapacity;return!c||Date.now(){var U,H;if(!o.current)return;const c=o.current;$(c),i(c,"stopped"),c.abort();const f=((U=y.current)==null?void 0:U.controller)===c?y.current.stream.takeAcceptedForStop():[];y.current=null;for(const M of f)F(M,!1);ie(),o.current=null,((H=A.current)==null?void 0:H.controller)===c&&(A.current=null),e.finish();const x=q(),_=B({type:"stop"},x).messages;x&&n.current.onInterrupted(R.current);const w=e.sessionId;w&&(E.current={sessionId:w,messages:_}),w&&ce.cancelSession(w).catch(()=>{});const P=++a.current;window.setTimeout(()=>{w&&x&&a.current===P?I(w,P).catch(()=>{}).finally(()=>{o.current||n.current.onSettled(w)}):o.current||n.current.onSettled(w)},450)}),Ae=he((c,f)=>{d.current?e.transition({type:"toggle_block",messageId:c,blockIndex:f},!0):e.present({messages:$t(e.visibleMessages,c,f)})}),we=()=>{a.current+=1,k(),D(),p.current=!1,A.current=null},pe=()=>{var c;(c=o.current)==null||c.abort(),o.current=null,u.current=null},N=he(()=>{we(),pe(),y.current=null,E.current=null,d.current=!1,e.reset()}),Le=he((c,f,x=!1,_)=>{if(we(),e.cancelCapacity(),e.busy&&f!==void 0&&f===e.sessionId){d.current=!0,e.present({messages:e.messages,sessionError:""});return}if(d.current=!1,e.busy||pe(),x&&f&&!e.busy){const w=Te(c);if(w){const P=We(w),U=[...c,Be(`${w.id}-active`)];K(P,z(P.text,{session_id:f,client_message_id:"reconnect"}),U,c,void 0,f,_);return}}e.busy?e.present({messages:c,sessionError:""}):e.restore(c,{sessionId:f??n.current.sessionId,show:!0,view:{sessionError:""}})}),Ue=r.capacityRequest;return{messages:W,busy:G,activeSessionId:G?e.sessionId:null,activeTitle:e.state.title,activeConfiguration:e.configuration,selectedBusy:G&&e.sessionId===t.sessionId,papers:L,sessionError:r.sessionError,capacityRequest:Ue,disabledRequest:r.disabledRequest,send:ue,editAndResend:fe,retryFromProgress:be,retryLatest:Ne,retryCapacity:Se,cancelCapacity:De,dismissDisabled:()=>e.present({disabledRequest:null}),stop:je,toggleBlock:Ae,reset:N,load:Le}}const gt=(t,e,r)=>e?r?{...t,paperSelection:r}:{text:t.text,paperMentions:t.paperMentions}:t,wr=({mode:t="general",routeSessionId:e,primaryPaper:r,currentPage:n,paperSelection:o,onPaperSelectionChange:a,onSessionId:u,onReaderSubmit:d,onReaderNewChat:h,onReaderClose:y})=>{var Ze,et,tt,st,rt;const{sessionId:C}=Ot(),p=e??(t==="general"?C:void 0),m=St(),[A]=vt(),{user:E,isLoading:R}=Et(),v=xt(),j=(E==null?void 0:E.hf_subject)??null,W=_t(),G=Re({...Jt(),enabled:Ie()&&!!E}),D=G.data,k=(D==null?void 0:D.status)==="paused"||t==="paper"&&(D==null?void 0:D.paper_reader_chat_enabled)===!1,T=Re({...Zt(j),enabled:!!E&&!R}),L=T.data??[],{markSessionBusy:Q,patchSession:B,refreshSessions:F}=nr(j),[q,ee]=l.useState(null),[ie,te]=l.useState(""),[$]=l.useState(bs),b=l.useRef(p);b.current=p;const S=tr({userId:j,signedIn:!!E,authLoading:R,requestedModel:A.get("model")||($==null?void 0:$.model),routeSessionIdRef:b}),{selectedModel:i,setSelectedModel:I}=S,z=Cs(!!(E&&S.provider==="openrouter")),[re,K]=l.useState(()=>oe()),ue=Xe,fe=!!(D!=null&&D.web_search_available),[be,Ne]=l.useState(()=>{var Y;const g=(Y=A.get("q"))==null?void 0:Y.trim();return g?oe(g):($==null?void 0:$.draft)??oe()}),[De,Se]=l.useState(()=>typeof window>"u"||window.innerWidth>900),je=l.useRef(new Set),[Ae,we]=l.useState(void 0),pe=l.useCallback(g=>{K(g),a==null||a(g.paperSelection)},[a]),N=br({sessionId:p??null,initialModel:i,webSearchEnabled:fe,reasoningEffort:ue,primaryPaperRouteId:t==="paper"?r==null?void 0:r.routeId:void 0,viewerContext:t==="paper"&&n?()=>({page:Math.max(1,Math.min(1e4,n()))}):void 0,loadSession:async g=>{const Y=await v.fetchQuery(ot(j,g));return ee(Z=>(Z==null?void 0:Z.sessionId)===g?null:Z),Y},onSessionId:(g,Y,Z)=>{Q(g,{model:(Z==null?void 0:Z.model)??i,webSearchEnabled:(Z==null?void 0:Z.webSearchEnabled)??fe,reasoningEffort:(Z==null?void 0:Z.reasoningEffort)??ue}),(b.current??null)===Y&&g!==Y&&(t==="paper"?u==null||u(g):m(`/chat/${g}`,{replace:!0}))},onTitle:(g,Y)=>{Y&&!je.current.has(Y)&&B(Y,{title:g})},onSettled:g=>{g&&B(g,{is_busy:!1}),v.invalidateQueries({queryKey:kt}),F()},onProviderTerminal:()=>{v.invalidateQueries({queryKey:Rs})},onPaperArtifact:(g,Y)=>{Y&&ee({sessionId:Y,descriptor:g.descriptor})},onInterrupted:pe}),Le=N.send;l.useEffect(()=>{N.capacityRequest&&pe(N.capacityRequest.draft)},[N.capacityRequest,pe]);const Ue=l.useCallback(()=>t==="paper"&&r?`/pdf/${r.routeId}`:b.current?`/chat/${b.current}`:"/chat",[t,r]),c=l.useCallback((g,Y)=>{Ne(oe()),pe(g),te(Y)},[pe]),f=ir({returnTo:Ue,selectedModel:i,reasoningEffort:ue,userBilledInference:S.userBilledInference,onPromptRestored:c}),{authorizeSend:x,restorePrompt:_}=f,w=!!a,P=l.useCallback(async g=>{const Y=gt(g,w,o),Z=x(Y,!!E);if(!(Z!==!0&&!await Z)){if(ws(),!Le(Y)){_(Y,"Your prompt was not sent. It is ready to retry.");return}vs(),K(oe()),a==null||a(void 0),t==="paper"&&(d==null||d())}},[x,t,a,d,o,w,_,Le,E]),U=N.selectedBusy,{load:H,activeConfiguration:M}=N,X=Re({...ot(j,p??null),enabled:!!(p&&E&&!R&&!U),refetchOnMount:"always"}),me=er(t==="general"?p:void 0,!R&&(!E||X.error instanceof qt&&X.error.status===404)),O=X.data,ve=U||Ae===(p??null),ke=q&&q.sessionId===p?q.descriptor:O==null?void 0:O.latex_paper,Fe=(et=(Ze=[...(O==null?void 0:O.messages)??[]].reverse().find(g=>g.role==="user"&&g.viewer_context))==null?void 0:Ze.viewer_context)==null?void 0:et.page;l.useLayoutEffect(()=>{const g=p??null;if(Ae!==g){if(U){we(g),M!=null&&M.model&&I(M.model);return}if(!g){H([],null),we(null);return}!O||X.isFetching||(we(g),H(At(O),g,O.is_busy,{model:O.selected_model,webSearchEnabled:O.web_search_enabled,reasoningEffort:O.reasoning_effort??"high"}),te(""),I(O.selected_model))}},[p,U,O,H,M,X.isFetching,Ae,I]),Zs({pendingDraft:be,setPendingDraft:Ne,blocked:R||N.busy||!!E&&G.isFetching||!!(p&&!ve),authLoading:R,signedIn:!!E,send:P,restoreDraft:K,setSelectedModel:I,onPaperSelectionChange:a}),l.useEffect(()=>{const g=()=>{!E||N.busy||F()};return window.addEventListener("focus",g),()=>window.removeEventListener("focus",g)},[N.busy,F,E]);const _e=()=>{window.innerWidth<=900&&Se(!1),H([],null),we(null),K(oe()),a==null||a(void 0),t==="paper"?h==null||h():m("/chat")},xe=ar({routeSessionId:p,selectedModel:i,setSelectedModel:I,patchSession:B,onRenamed:g=>je.current.add(g),refreshSessions:F,onError:te,onSelectedDeleted:_e,isActive:g=>N.busy&&g===N.activeSessionId,stopActive:N.stop}),Ee=Js({messages:N.messages,refreshSessions:F,resetChat:N.reset,restoreDraft:K}),V=async()=>{await xe.changeModel(ze)&&N.retryLatest()},ne=As(t==="general"),ae=L.map(g=>g.id===N.activeSessionId&&N.busy?{...g,is_busy:!0,title:je.current.has(g.id)?g.title:N.activeTitle||g.title}:g),J=ae.find(g=>g.id===p),le=(J==null?void 0:J.primary_paper)??(O==null?void 0:O.primary_paper),de=N.messages.length===0,ge=!!(p&&(R||E&&!ve&&!X.isError||me.pending)),Me=!ve&&!ge&&((tt=X.error)==null?void 0:tt.message),Je={composerProps:{onSend:P,busy:U,onStop:N.stop,draft:gt(re,w,o),onDraftChange:g=>{a?(K({text:g.text,paperMentions:g.paperMentions}),g.paperSelection!==o&&a(g.paperSelection)):K(g)},disabled:k||R||N.busy&&!U,describedBy:k?"chat-paused-description":void 0,paperMentionsEnabled:!!(D!=null&&D.paper_mentions_enabled),paperSelectionEnabled:(D==null?void 0:D.paper_reader_selection_enabled)===!0,paperArtifactsEnabled:t==="general"&&(D==null?void 0:D.paper_artifacts_enabled)===!0},provider:S.provider,sponsored:S.sponsored,paused:k,error:N.sessionError};return s.jsx(zs,{enabled:t==="general",workspaceKey:p??"new-chat",onAskAiFix:g=>{P(oe(g))},children:s.jsxs("div",{className:`chat-page${t==="paper"?" chat-page--reader":""}`,style:{height:ne},children:[t==="general"&&s.jsx(Ps,{sessions:ae,activeSessionId:p,loading:T.isLoading,error:ie||((st=T.error)==null?void 0:st.message)||"",open:De,onClose:()=>Se(!1),onNew:_e,onNavigate:g=>{window.innerWidth<=900&&Se(!1),m(`/chat/${g}`)},onRename:xe.rename,onDelete:g=>void xe.remove(g)}),s.jsx(Ks,{enabled:t==="general",children:s.jsxs("section",{className:"chat-main","data-testid":"active-chat-pane",children:[s.jsxs("div",{className:"chat-topbar",children:[t==="general"&&!De&&s.jsx("button",{type:"button",className:"icon-btn",onClick:()=>Se(!0),title:"Open sidebar",children:s.jsx(Ct,{})}),s.jsx("span",{className:"chat-topbar-title",children:ge?(J==null?void 0:J.title)||"":(J==null?void 0:J.title)||(O==null?void 0:O.title)||(de?"":"New chat")}),W&&s.jsx("span",{className:"chat-staging-badge",children:"Staging"}),t==="general"&&p&&le&&s.jsx(Ys,{routeId:le.route_id,sessionId:p,page:Fe}),p&&ve&&!de&&s.jsx(Bs,{sessionId:p,busy:U,loading:ge,hasPaperSelection:N.messages.some(g=>!!g.paperSelection),onError:te}),t==="paper"&&s.jsx(Vs,{onNewChat:_e,onClose:y})]}),s.jsx(Qs,{provider:S.provider,enabled:Ie()&&!!E&&S.provider==="openai"}),t==="general"&&ke&&s.jsx(Gs,{descriptor:ke}),ge&&!be.text?s.jsxs("div",{className:"chat-session-loading",role:"status","aria-live":"polite",children:[s.jsx(Rt,{}),s.jsx("span",{children:"Loading conversation…"})]}):Me?s.jsxs("div",{className:"chat-session-load-error",role:"alert",children:[s.jsx("p",{children:Me}),s.jsx("button",{type:"button",onClick:()=>{X.refetch()},children:"Try again"})]}):de&&!be.text?s.jsx($s,{mode:t,staging:W,children:s.jsx(dt,{variant:"empty",...Je,suggestions:t==="paper"?Ss:_s})}):s.jsxs(s.Fragment,{children:[s.jsx(Ts,{messages:N.messages,papers:N.papers,busy:U,queuedDraft:be.text?be:void 0,paperMentionsEnabled:!!(D!=null&&D.paper_mentions_enabled),archivePending:Ee.pending,openRouterFallbackEnabled:!!((rt=z.data)!=null&&rt.fallback_enabled),onToggleBlock:N.toggleBlock,onEditAndResend:N.editAndResend,onRetryFromProgress:N.retryFromProgress,onRetryWithLuna:S.lunaAvailable?()=>void V():void 0,onArchiveOld:()=>void Ee.archiveOld(),onArchiveOldest:()=>void Ee.archiveOldest()}),s.jsx(dt,{variant:"followup",...Je})]})]})}),N.capacityRequest&&s.jsx(Is,{retryAt:N.capacityRequest.retryAt,onCancel:N.cancelCapacity,onRetry:()=>{N.retryCapacity()&&(K(oe()),a==null||a(void 0))}}),N.disabledRequest&&s.jsx(Ns,{onClose:()=>{var g;pe(((g=N.disabledRequest)==null?void 0:g.draft)??re),N.dismissDisabled(),G.refetch()}})]})})},vr=t=>{const{user:e}=Et();return s.jsx(wr,{...t},(e==null?void 0:e.hf_subject)??"guest")},Zr=()=>s.jsx(vr,{});export{vr as ChatExperience,Zr as default}; diff --git a/assets/ConferenceDetailView-DgDeLFoO.js b/assets/ConferenceDetailView-CujSkc9V.js similarity index 82% rename from assets/ConferenceDetailView-DgDeLFoO.js rename to assets/ConferenceDetailView-CujSkc9V.js index 2182fe822d80e8ad9956bea90c44baea72691bdb..f6b368431eed2315fc2e8a6f9a09a5821e29d640 100644 --- a/assets/ConferenceDetailView-DgDeLFoO.js +++ b/assets/ConferenceDetailView-CujSkc9V.js @@ -1 +1 @@ -import{u as y,b as k,d as _,j as e,L as h,T as S}from"./index-DyXq7-Tg.js";import{a as f,A as b,b as E}from"./AreaSection-BxnKzNK0.js";import{M as j}from"./MarkdownText-CUzPoC9Y.js";import{c as A}from"./catalog-CRar2olQ.js";import{i as C}from"./apiErrors-BSvbQBb0.js";import{s as F}from"./areas-Dvi8w2dp.js";import{c as T,h as L}from"./colors-BkWRhvFI.js";import{C as $}from"./conferenceListings-BnmhBx-_.js";import{f as w}from"./deadlines-BH32v7D1.js";import{d as D}from"./transform-D46m70Qr.js";import{S as P}from"./skeleton-C3IIzpSL.js";import{A as M,a as R}from"./alert-gbJBhAVE.js";import{s as B}from"./safeExternalHref-CkBrsh84.js";import I from"./NotFound-DV_nwcxG.js";/* empty css */import"./PaperPreviewLink-CpCZSa8K.js";import"./index-mCi_y_l3.js";import"./index-2CvJmBVB.js";import"./katex-DkKDou_j.js";import"./hover-card-B45EJIn_.js";import"./papers-Dh3ljlL0.js";import"./curation-YeS7FBYf.js";import"./useMutation-UWxBeqtn.js";const ce=()=>{var g,x;const{confSlug:o}=y(),t=k({queryKey:["conference-areas-with-tasks",o],queryFn:()=>A.conferenceAreasWithTasks(o),enabled:!!o,staleTime:S}),m=_.useMemo(()=>{var a;return F(((a=t.data)==null?void 0:a.results)??[])},[t.data]),s=(g=t.data)==null?void 0:g.conference,d=((x=t.data)==null?void 0:x.total_paper_count)??0,N=$.filter(a=>{var r;return(((r=t.data)==null?void 0:r[a.countKey])??0)>0});if(C(t.error))return e.jsx(I,{});if(t.error)return e.jsx("div",{className:"page",children:e.jsx(M,{variant:"destructive",children:e.jsx(R,{children:"Failed to load conference. Please try again."})})});const p=s?w(s.start_date,s.end_date):null,u=s?[s.venue,s.location].filter(Boolean).join(", "):null,n=s==null?void 0:s.name;return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:s!=null&&s.image_url?"task-hero-grid":void 0,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--accent-text)",letterSpacing:"0.1em",marginBottom:8},children:"CONFERENCE"}),e.jsx("h1",{className:"feed-title",children:n??e.jsx(P,{className:"h-10 w-64 inline-block"})}),e.jsxs("div",{className:"feed-subtitle",style:{display:"flex",flexDirection:"column",gap:4},children:[p&&e.jsx("span",{children:p}),u&&e.jsx("span",{children:u}),(s==null?void 0:s.url)&&e.jsx("a",{href:B(s.url)??void 0,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent-text)"},children:s.url.replace(/^https?:\/\//,"")}),(s==null?void 0:s.hf_url)&&e.jsxs("a",{className:"bm-action-btn",href:s.hf_url,target:"_blank",rel:"noopener noreferrer",style:{alignSelf:"flex-start",marginTop:4},children:[e.jsx("span",{"aria-hidden":"true",children:"🤗"})," View on Hugging Face"]})]}),(s==null?void 0:s.description)&&e.jsx(j,{className:"method-description",text:s.description})]}),(s==null?void 0:s.image_url)&&e.jsxs("figure",{className:"task-figure-card",children:[e.jsx("div",{className:"task-figure-img-wrap",children:e.jsx("img",{className:"task-figure-img",src:s.image_url,alt:n?`${n} visual`:"Conference visual",onError:a=>{var r,c;(c=(r=a.currentTarget.parentElement)==null?void 0:r.parentElement)==null||c.style.setProperty("display","none")}})}),e.jsxs("figcaption",{children:["Figure · ",n??"Conference",s.image_credit&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx(j,{className:"task-image-credit",text:s.image_credit})]})]})]})]}),!t.isLoading&&d>0&&e.jsx(f,{title:"Browse papers",description:"All accepted papers, plus oral, spotlight, outstanding, and best paper finalists.",meta:`${d.toLocaleString()} papers`,style:{marginTop:48},children:N.map(a=>{var r;return e.jsxs(h,{to:`/conferences/${o}/${a.slug}`,className:"tag-cell",children:[e.jsxs("div",{className:"name",children:[e.jsx("span",{className:"dot",style:{background:a.dotColor}}),a.label]}),e.jsx("div",{className:"meta",children:e.jsxs("span",{children:[(((r=t.data)==null?void 0:r[a.countKey])??0).toLocaleString()," papers"]})})]},a.slug)})}),t.isLoading?e.jsx(b,{tiles:6,tileClassName:"h-24"}):m.map(a=>{const r=a.tasks;if(r.length===0)return null;const c=r.reduce((i,l)=>i+(l.paper_count||0),0);return e.jsx(f,{title:a.name,description:a.description,meta:`${r.length} ${r.length===1?"task":"tasks"} · ${c.toLocaleString()} papers`,children:r.map(i=>{const l=i.slug||"",v=T(L(l));return e.jsxs(h,{to:`/conferences/${o}/${l}`,className:"tag-cell",children:[e.jsxs("div",{className:"name",children:[e.jsx("span",{className:"dot",style:{background:v.dot}}),D(i.name,l)]}),e.jsx("div",{className:"meta",children:e.jsxs("span",{children:[(i.paper_count??0).toLocaleString()," papers"]})})]},i.id)})},a.id)}),e.jsx(E,{areas:m})]})};export{ce as default}; +import{u as y,b as k,d as _,j as e,L as h,T as S}from"./index-CjdUkE4w.js";import{a as f,A as b,b as E}from"./AreaSection-iYSRoy6-.js";import{M as j}from"./MarkdownText-MrITlqRE.js";import{c as A}from"./catalog-qXcKve0z.js";import{i as C}from"./apiErrors-D0w5By9R.js";import{s as F}from"./areas-Dvi8w2dp.js";import{c as T,h as L}from"./colors-BkWRhvFI.js";import{C as $}from"./conferenceListings-BnmhBx-_.js";import{f as w}from"./deadlines-BH32v7D1.js";import{d as D}from"./transform-CRNzYLch.js";import{S as P}from"./skeleton-DTWi7Ctg.js";import{A as M,a as R}from"./alert-BM9Xfuyy.js";import{s as B}from"./safeExternalHref-CkBrsh84.js";import I from"./NotFound-BeWhm9El.js";/* empty css */import"./PaperPreviewLink-zGfFNaz6.js";import"./index-tLcwYp0U.js";import"./index-Dj6aE-6E.js";import"./katex-DkKDou_j.js";import"./hover-card-CIBIV2Hx.js";import"./papers-DgZwjF3K.js";import"./curation-CyyuHfv5.js";import"./useMutation-BYtVrkc7.js";const ce=()=>{var g,x;const{confSlug:o}=y(),t=k({queryKey:["conference-areas-with-tasks",o],queryFn:()=>A.conferenceAreasWithTasks(o),enabled:!!o,staleTime:S}),m=_.useMemo(()=>{var a;return F(((a=t.data)==null?void 0:a.results)??[])},[t.data]),s=(g=t.data)==null?void 0:g.conference,d=((x=t.data)==null?void 0:x.total_paper_count)??0,N=$.filter(a=>{var r;return(((r=t.data)==null?void 0:r[a.countKey])??0)>0});if(C(t.error))return e.jsx(I,{});if(t.error)return e.jsx("div",{className:"page",children:e.jsx(M,{variant:"destructive",children:e.jsx(R,{children:"Failed to load conference. Please try again."})})});const p=s?w(s.start_date,s.end_date):null,u=s?[s.venue,s.location].filter(Boolean).join(", "):null,n=s==null?void 0:s.name;return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:s!=null&&s.image_url?"task-hero-grid":void 0,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--accent-text)",letterSpacing:"0.1em",marginBottom:8},children:"CONFERENCE"}),e.jsx("h1",{className:"feed-title",children:n??e.jsx(P,{className:"h-10 w-64 inline-block"})}),e.jsxs("div",{className:"feed-subtitle",style:{display:"flex",flexDirection:"column",gap:4},children:[p&&e.jsx("span",{children:p}),u&&e.jsx("span",{children:u}),(s==null?void 0:s.url)&&e.jsx("a",{href:B(s.url)??void 0,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent-text)"},children:s.url.replace(/^https?:\/\//,"")}),(s==null?void 0:s.hf_url)&&e.jsxs("a",{className:"bm-action-btn",href:s.hf_url,target:"_blank",rel:"noopener noreferrer",style:{alignSelf:"flex-start",marginTop:4},children:[e.jsx("span",{"aria-hidden":"true",children:"🤗"})," View on Hugging Face"]})]}),(s==null?void 0:s.description)&&e.jsx(j,{className:"method-description",text:s.description})]}),(s==null?void 0:s.image_url)&&e.jsxs("figure",{className:"task-figure-card",children:[e.jsx("div",{className:"task-figure-img-wrap",children:e.jsx("img",{className:"task-figure-img",src:s.image_url,alt:n?`${n} visual`:"Conference visual",onError:a=>{var r,c;(c=(r=a.currentTarget.parentElement)==null?void 0:r.parentElement)==null||c.style.setProperty("display","none")}})}),e.jsxs("figcaption",{children:["Figure · ",n??"Conference",s.image_credit&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx(j,{className:"task-image-credit",text:s.image_credit})]})]})]})]}),!t.isLoading&&d>0&&e.jsx(f,{title:"Browse papers",description:"All accepted papers, plus oral, spotlight, outstanding, and best paper finalists.",meta:`${d.toLocaleString()} papers`,style:{marginTop:48},children:N.map(a=>{var r;return e.jsxs(h,{to:`/conferences/${o}/${a.slug}`,className:"tag-cell",children:[e.jsxs("div",{className:"name",children:[e.jsx("span",{className:"dot",style:{background:a.dotColor}}),a.label]}),e.jsx("div",{className:"meta",children:e.jsxs("span",{children:[(((r=t.data)==null?void 0:r[a.countKey])??0).toLocaleString()," papers"]})})]},a.slug)})}),t.isLoading?e.jsx(b,{tiles:6,tileClassName:"h-24"}):m.map(a=>{const r=a.tasks;if(r.length===0)return null;const c=r.reduce((i,l)=>i+(l.paper_count||0),0);return e.jsx(f,{title:a.name,description:a.description,meta:`${r.length} ${r.length===1?"task":"tasks"} · ${c.toLocaleString()} papers`,children:r.map(i=>{const l=i.slug||"",v=T(L(l));return e.jsxs(h,{to:`/conferences/${o}/${l}`,className:"tag-cell",children:[e.jsxs("div",{className:"name",children:[e.jsx("span",{className:"dot",style:{background:v.dot}}),D(i.name,l)]}),e.jsx("div",{className:"meta",children:e.jsxs("span",{children:[(i.paper_count??0).toLocaleString()," papers"]})})]},i.id)})},a.id)}),e.jsx(E,{areas:m})]})};export{ce as default}; diff --git a/assets/ConferenceTaskView-BvWfAecx.js b/assets/ConferenceTaskView-BrixcLRv.js similarity index 79% rename from assets/ConferenceTaskView-BvWfAecx.js rename to assets/ConferenceTaskView-BrixcLRv.js index 31943bdf5902cc9f9b1678e40d2678c788f60800..eac1532db4dba296963e691c45e3257ee6a20a59 100644 --- a/assets/ConferenceTaskView-BvWfAecx.js +++ b/assets/ConferenceTaskView-BrixcLRv.js @@ -1 +1 @@ -import{u as S,b as _,p as R,d as C,j as e,L as x,o as M,T as E}from"./index-DyXq7-Tg.js";import{u as L,b as Q,a as q}from"./PaperFeed-EBt97iOL.js";import{M as g}from"./MarkdownText-CUzPoC9Y.js";import{c as F}from"./catalog-CRar2olQ.js";import{p as B}from"./papers-Dh3ljlL0.js";import{i as A}from"./apiErrors-BSvbQBb0.js";import{C as O}from"./conferenceListings-BnmhBx-_.js";import{t as z,d as H}from"./transform-D46m70Qr.js";import{u as I}from"./usePapers-B0s20UcU.js";import{A as K,a as $}from"./alert-gbJBhAVE.js";import V from"./NotFound-DV_nwcxG.js";import"./PaperCard-57p1OSGy.js";import"./AuthorAvatar-B-9xS2Wo.js";import"./SotaBadges-vbLLOUtT.js";import"./colors-BkWRhvFI.js";import"./Icon-T4LYkEQj.js";import"./LatexTitle-Bkyz3jCs.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-CTBEUp7Y.js";import"./skeleton-C3IIzpSL.js";import"./useIntersectionObserver-D6_Iig9a.js";/* empty css */import"./PaperPreviewLink-CpCZSa8K.js";import"./index-mCi_y_l3.js";import"./index-2CvJmBVB.js";import"./katex-DkKDou_j.js";import"./hover-card-B45EJIn_.js";import"./useMutation-UWxBeqtn.js";import"./curation-YeS7FBYf.js";import"./useInfiniteQuery-BYh2zN-T.js";const D={"iclr-2026/outstanding":"ICLR 2026 recognized two Outstanding Papers and one Honorable Mention. [Read the announcement](https://blog.iclr.cc/2026/04/23/announcing-the-iclr-2026-outstanding-papers/).","icml-2026/outstanding":"ICML 2026 recognized two Outstanding Papers and five Honorable Mentions. [Read the announcement](https://blog.icml.cc/2026/07/05/announcing-the-icml-2026-awards/).","cvpr-2026/best-paper-finalists":"CVPR 2026 recognized fifteen Best Paper Award finalists, including the winners. [Read the announcement](https://x.com/CVPR/status/2062912519522717978)."},Pe=()=>{var b,y,v,P,k,w;const{confSlug:t,taskSlug:n}=S(),p=L(),a=O.find(r=>r.slug===n),u=!!(a!=null&&a.award),i=_({queryKey:["conference",t],queryFn:()=>F.getConference(t),enabled:!!t,staleTime:E}),c=_({queryKey:M.task(n),queryFn:()=>F.getTask(n),enabled:!!n&&!a,staleTime:E}),l=I([...R.feeds.conference,t,n,p.filters],r=>B.forConference(t,{...p.filters,task:a?void 0:n,presentation:a==null?void 0:a.presentation,page:r,page_size:12}),{enabled:!!t}),f=C.useMemo(()=>{var r;return((r=l.data)==null?void 0:r.pages.flatMap(o=>o.results))??[]},[l.data]),h=C.useMemo(()=>f.map(z),[f]),d=(a==null?void 0:a.label)??H(((b=c.data)==null?void 0:b.name)||n||"",((y=c.data)==null?void 0:y.slug)||n),j=D[`${t}/${n}`],N=((P=(v=l.data)==null?void 0:v.pages[0])==null?void 0:P.count)??((k=i.data)==null?void 0:k.paper_count)??0,s=c.data;return A(i.error)||A(c.error)?e.jsx(V,{}):i.error||c.error||l.error?e.jsx("div",{className:"page",children:e.jsx(K,{variant:"destructive",children:e.jsx($,{children:"Failed to load conference papers. Please try again."})})}):e.jsxs("div",{className:"page",children:[e.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[e.jsx(x,{to:"/",children:"Home"}),e.jsx("span",{children:" / "}),e.jsx(x,{to:"/conferences",children:"Conferences"}),e.jsx("span",{children:" / "}),e.jsx(x,{to:`/conferences/${t}`,children:((w=i.data)==null?void 0:w.name)??t}),e.jsx("span",{children:" / "}),e.jsx("span",{children:d})]}),e.jsxs("div",{className:!a&&(s!=null&&s.image_url)?"task-hero-grid":void 0,style:{marginTop:16,marginBottom:28},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--accent-text)",letterSpacing:"0.1em",marginBottom:8},children:a?"BROWSE PAPERS":"TASK"}),e.jsx("h1",{className:"domain-mega-title",children:d}),j&&e.jsx(g,{className:"task-explainer",text:j}),!a&&(s==null?void 0:s.description)&&e.jsx(g,{className:"task-explainer",text:s.description}),i.data&&e.jsxs("div",{className:"task-quickstats",style:{marginTop:12},children:[e.jsxs("span",{children:[e.jsx("span",{className:"num",children:N.toLocaleString()}),"PAPERS"]}),e.jsx("span",{children:i.data.name})]})]}),!a&&(s==null?void 0:s.image_url)&&e.jsxs("figure",{className:"task-figure-card",children:[e.jsx("div",{className:"task-figure-img-wrap",children:e.jsx("img",{className:"task-figure-img",src:s.image_url,alt:`${d} schematic`,onError:r=>{var o,m;(m=(o=r.currentTarget.parentElement)==null?void 0:o.parentElement)==null||m.style.setProperty("display","none")}})}),e.jsxs("figcaption",{children:["Figure · ",d,s.image_credit&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx(g,{className:"task-image-credit",text:s.image_credit})]})]})]})]}),e.jsxs("div",{className:"task-section-head",children:[e.jsx("div",{className:"task-section-eyebrow",children:u?"Award papers":"Conference papers · sort below"}),e.jsxs("div",{className:"task-section-title",children:["Papers ",e.jsxs("span",{className:"meta",children:["[",N.toLocaleString(),"]"]})]})]}),e.jsx(Q,{feed:p,sorts:u?null:void 0,children:!u&&e.jsxs("div",{className:"results-count",children:[h.length," loaded in ",e.jsx("span",{children:d})]})}),e.jsx(q,{query:l,cards:h,empty:"No papers found for this selection.",cardHeader:r=>{var T;const o=(T=f[r])==null?void 0:T.conference_award,m=o==="outstanding"?"Outstanding Paper":o==="honorable_mention"?"Honorable Mention":o==="best_paper_finalist"&&(a==null?void 0:a.presentation)!=="best_paper_finalist"?"Best Paper Finalist":null;return m&&e.jsx("div",{className:"conference-award-label",children:m})}})]})};export{Pe as default}; +import{u as S,b as _,p as R,d as C,j as e,L as x,o as M,T as E}from"./index-CjdUkE4w.js";import{u as L,b as Q,a as q}from"./PaperFeed-D3FZw29k.js";import{M as g}from"./MarkdownText-MrITlqRE.js";import{c as F}from"./catalog-qXcKve0z.js";import{p as B}from"./papers-DgZwjF3K.js";import{i as A}from"./apiErrors-D0w5By9R.js";import{C as O}from"./conferenceListings-BnmhBx-_.js";import{t as z,d as H}from"./transform-CRNzYLch.js";import{u as I}from"./usePapers-BZThqZCx.js";import{A as K,a as $}from"./alert-BM9Xfuyy.js";import V from"./NotFound-BeWhm9El.js";import"./PaperCard-dvXhr75r.js";import"./AuthorAvatar-D9249Frl.js";import"./SotaBadges-CyScuNCv.js";import"./colors-BkWRhvFI.js";import"./Icon-CGRs4BYD.js";import"./LatexTitle-DESKtS30.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-Df5_dywQ.js";import"./skeleton-DTWi7Ctg.js";import"./useIntersectionObserver-Ch6RpsSk.js";/* empty css */import"./PaperPreviewLink-zGfFNaz6.js";import"./index-tLcwYp0U.js";import"./index-Dj6aE-6E.js";import"./katex-DkKDou_j.js";import"./hover-card-CIBIV2Hx.js";import"./useMutation-BYtVrkc7.js";import"./curation-CyyuHfv5.js";import"./useInfiniteQuery-DeZTTVbI.js";const D={"iclr-2026/outstanding":"ICLR 2026 recognized two Outstanding Papers and one Honorable Mention. [Read the announcement](https://blog.iclr.cc/2026/04/23/announcing-the-iclr-2026-outstanding-papers/).","icml-2026/outstanding":"ICML 2026 recognized two Outstanding Papers and five Honorable Mentions. [Read the announcement](https://blog.icml.cc/2026/07/05/announcing-the-icml-2026-awards/).","cvpr-2026/best-paper-finalists":"CVPR 2026 recognized fifteen Best Paper Award finalists, including the winners. [Read the announcement](https://x.com/CVPR/status/2062912519522717978)."},Pe=()=>{var b,y,v,P,k,w;const{confSlug:t,taskSlug:n}=S(),p=L(),a=O.find(r=>r.slug===n),u=!!(a!=null&&a.award),i=_({queryKey:["conference",t],queryFn:()=>F.getConference(t),enabled:!!t,staleTime:E}),c=_({queryKey:M.task(n),queryFn:()=>F.getTask(n),enabled:!!n&&!a,staleTime:E}),l=I([...R.feeds.conference,t,n,p.filters],r=>B.forConference(t,{...p.filters,task:a?void 0:n,presentation:a==null?void 0:a.presentation,page:r,page_size:12}),{enabled:!!t}),f=C.useMemo(()=>{var r;return((r=l.data)==null?void 0:r.pages.flatMap(o=>o.results))??[]},[l.data]),h=C.useMemo(()=>f.map(z),[f]),d=(a==null?void 0:a.label)??H(((b=c.data)==null?void 0:b.name)||n||"",((y=c.data)==null?void 0:y.slug)||n),j=D[`${t}/${n}`],N=((P=(v=l.data)==null?void 0:v.pages[0])==null?void 0:P.count)??((k=i.data)==null?void 0:k.paper_count)??0,s=c.data;return A(i.error)||A(c.error)?e.jsx(V,{}):i.error||c.error||l.error?e.jsx("div",{className:"page",children:e.jsx(K,{variant:"destructive",children:e.jsx($,{children:"Failed to load conference papers. Please try again."})})}):e.jsxs("div",{className:"page",children:[e.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[e.jsx(x,{to:"/",children:"Home"}),e.jsx("span",{children:" / "}),e.jsx(x,{to:"/conferences",children:"Conferences"}),e.jsx("span",{children:" / "}),e.jsx(x,{to:`/conferences/${t}`,children:((w=i.data)==null?void 0:w.name)??t}),e.jsx("span",{children:" / "}),e.jsx("span",{children:d})]}),e.jsxs("div",{className:!a&&(s!=null&&s.image_url)?"task-hero-grid":void 0,style:{marginTop:16,marginBottom:28},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--accent-text)",letterSpacing:"0.1em",marginBottom:8},children:a?"BROWSE PAPERS":"TASK"}),e.jsx("h1",{className:"domain-mega-title",children:d}),j&&e.jsx(g,{className:"task-explainer",text:j}),!a&&(s==null?void 0:s.description)&&e.jsx(g,{className:"task-explainer",text:s.description}),i.data&&e.jsxs("div",{className:"task-quickstats",style:{marginTop:12},children:[e.jsxs("span",{children:[e.jsx("span",{className:"num",children:N.toLocaleString()}),"PAPERS"]}),e.jsx("span",{children:i.data.name})]})]}),!a&&(s==null?void 0:s.image_url)&&e.jsxs("figure",{className:"task-figure-card",children:[e.jsx("div",{className:"task-figure-img-wrap",children:e.jsx("img",{className:"task-figure-img",src:s.image_url,alt:`${d} schematic`,onError:r=>{var o,m;(m=(o=r.currentTarget.parentElement)==null?void 0:o.parentElement)==null||m.style.setProperty("display","none")}})}),e.jsxs("figcaption",{children:["Figure · ",d,s.image_credit&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx(g,{className:"task-image-credit",text:s.image_credit})]})]})]})]}),e.jsxs("div",{className:"task-section-head",children:[e.jsx("div",{className:"task-section-eyebrow",children:u?"Award papers":"Conference papers · sort below"}),e.jsxs("div",{className:"task-section-title",children:["Papers ",e.jsxs("span",{className:"meta",children:["[",N.toLocaleString(),"]"]})]})]}),e.jsx(Q,{feed:p,sorts:u?null:void 0,children:!u&&e.jsxs("div",{className:"results-count",children:[h.length," loaded in ",e.jsx("span",{children:d})]})}),e.jsx(q,{query:l,cards:h,empty:"No papers found for this selection.",cardHeader:r=>{var T;const o=(T=f[r])==null?void 0:T.conference_award,m=o==="outstanding"?"Outstanding Paper":o==="honorable_mention"?"Honorable Mention":o==="best_paper_finalist"&&(a==null?void 0:a.presentation)!=="best_paper_finalist"?"Best Paper Finalist":null;return m&&e.jsx("div",{className:"conference-award-label",children:m})}})]})};export{Pe as default}; diff --git a/assets/ConferencesIndexView-DJVYKUiz.js b/assets/ConferencesIndexView-CS7nG4hL.js similarity index 76% rename from assets/ConferencesIndexView-DJVYKUiz.js rename to assets/ConferencesIndexView-CS7nG4hL.js index d3f1e532add052124a29b6ecee7453609474b119..561251067413bbb5269760609dddd1374473f95e 100644 --- a/assets/ConferencesIndexView-DJVYKUiz.js +++ b/assets/ConferencesIndexView-CS7nG4hL.js @@ -1 +1 @@ -import{b as d,d as m,j as e,L as c,T as p}from"./index-DyXq7-Tg.js";import{c as u}from"./catalog-CRar2olQ.js";import{f}from"./deadlines-BH32v7D1.js";import{A as h,a as x}from"./alert-gbJBhAVE.js";import{A as g,a as j}from"./AreaSection-BxnKzNK0.js";import{T as N}from"./TaxonomySuggestionTile-jIiLMp4q.js";import"./skeleton-C3IIzpSL.js";import"./SignInToEditDialog-B-oWVno5.js";import"./button-DZeAbOf2.js";import"./input-DJqCAbs7.js";import"./textarea-DPixlM5U.js";import"./searchable-select-DiDLwvbI.js";import"./popover-CTBEUp7Y.js";import"./dialog-CfM0Uql2.js";import"./search-8ssWDP68.js";import"./loader-circle-C75KLEgx.js";import"./useMutation-UWxBeqtn.js";import"./submissions-Cz_J-Ha2.js";import"./plus-Yh42pKZz.js";const v=r=>{var t;if(r.year!=null)return r.year;if(r.start_date)return Number(r.start_date.slice(0,4));const a=(t=r.slug.match(/-(\d{4})$/))==null?void 0:t[1];return a?Number(a):0},_=(r,a)=>{if(r.start_date&&a.start_date){const t=r.start_date.localeCompare(a.start_date);if(t!==0)return t}else{if(r.start_date)return-1;if(a.start_date)return 1}return r.name.localeCompare(a.name)},Q=()=>{const r=d({queryKey:["conferences"],queryFn:()=>u.conferences(),staleTime:p}),a=m.useMemo(()=>{var i;if(!((i=r.data)!=null&&i.results))return null;const t={};return r.data.results.forEach(n=>{const s=v(n);(t[s]||(t[s]=[])).push(n)}),Object.values(t).forEach(n=>n.sort(_)),Object.keys(t).map(Number).sort((n,s)=>s-n).map(n=>({year:n,conferences:t[n]}))},[r.data]);return r.error?e.jsx("div",{className:"page",children:e.jsx(h,{variant:"destructive",children:e.jsx(x,{children:"Failed to load conferences. Please try again."})})}):e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["All ",e.jsx("em",{children:"Conferences"})]}),e.jsx("div",{className:"feed-subtitle",children:"Browse accepted papers from major AI conferences, grouped by research area and task."}),e.jsxs("div",{className:"conference-deadlines-link",children:["Find deadlines for upcoming conferences"," ",e.jsx(c,{to:"/ai-deadlines",className:"underline underline-offset-2 hover:text-foreground",children:"here"}),". Conference information is based on"," ",e.jsx("a",{href:"https://huggingface.co/ai-conferences",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Hugging Face AI Conferences"}),"."]})]})}),r.isLoading?e.jsx(g,{sections:2,tiles:3,tileClassName:"h-32"}):a==null?void 0:a.map(({year:t,conferences:i})=>{const n=i.reduce((s,o)=>s+(o.paper_count??0),0);return e.jsxs(j,{title:t>0?String(t):"Unknown year",meta:`${i.length} ${i.length===1?"conference":"conferences"} · ${n.toLocaleString()} papers`,children:[i.map(s=>{const o=f(s.start_date,s.end_date),l=[s.venue,s.location].filter(Boolean).join(", ");return e.jsxs(c,{to:`/conferences/${s.slug}`,className:"tag-cell",children:[e.jsx("div",{className:"name",children:s.name}),e.jsxs("div",{className:"meta",style:{display:"flex",flexDirection:"column",gap:4},children:[o&&e.jsx("span",{children:o}),l&&e.jsx("span",{children:l}),e.jsxs("span",{children:[(s.paper_count??0).toLocaleString()," papers"]})]})]},s.id)}),e.jsx(N,{kind:"conference"})]},t)})]})};export{Q as default}; +import{b as d,d as m,j as e,L as c,T as p}from"./index-CjdUkE4w.js";import{c as u}from"./catalog-qXcKve0z.js";import{f}from"./deadlines-BH32v7D1.js";import{A as h,a as x}from"./alert-BM9Xfuyy.js";import{A as g,a as j}from"./AreaSection-iYSRoy6-.js";import{T as N}from"./TaxonomySuggestionTile-ByzqhBFs.js";import"./skeleton-DTWi7Ctg.js";import"./SignInToEditDialog-rWxdYNRK.js";import"./button-DetZl_ch.js";import"./input-7i-rZ7fA.js";import"./textarea-biscLKBK.js";import"./searchable-select-EPf13F1I.js";import"./popover-Df5_dywQ.js";import"./dialog-BzX9PD3v.js";import"./search-DxMn7VKI.js";import"./loader-circle-xTdSzHv_.js";import"./useMutation-BYtVrkc7.js";import"./submissions-CQ6M0giV.js";import"./plus-AztI1566.js";const v=r=>{var t;if(r.year!=null)return r.year;if(r.start_date)return Number(r.start_date.slice(0,4));const a=(t=r.slug.match(/-(\d{4})$/))==null?void 0:t[1];return a?Number(a):0},_=(r,a)=>{if(r.start_date&&a.start_date){const t=r.start_date.localeCompare(a.start_date);if(t!==0)return t}else{if(r.start_date)return-1;if(a.start_date)return 1}return r.name.localeCompare(a.name)},Q=()=>{const r=d({queryKey:["conferences"],queryFn:()=>u.conferences(),staleTime:p}),a=m.useMemo(()=>{var i;if(!((i=r.data)!=null&&i.results))return null;const t={};return r.data.results.forEach(n=>{const s=v(n);(t[s]||(t[s]=[])).push(n)}),Object.values(t).forEach(n=>n.sort(_)),Object.keys(t).map(Number).sort((n,s)=>s-n).map(n=>({year:n,conferences:t[n]}))},[r.data]);return r.error?e.jsx("div",{className:"page",children:e.jsx(h,{variant:"destructive",children:e.jsx(x,{children:"Failed to load conferences. Please try again."})})}):e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["All ",e.jsx("em",{children:"Conferences"})]}),e.jsx("div",{className:"feed-subtitle",children:"Browse accepted papers from major AI conferences, grouped by research area and task."}),e.jsxs("div",{className:"conference-deadlines-link",children:["Find deadlines for upcoming conferences"," ",e.jsx(c,{to:"/ai-deadlines",className:"underline underline-offset-2 hover:text-foreground",children:"here"}),". Conference information is based on"," ",e.jsx("a",{href:"https://huggingface.co/ai-conferences",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Hugging Face AI Conferences"}),"."]})]})}),r.isLoading?e.jsx(g,{sections:2,tiles:3,tileClassName:"h-32"}):a==null?void 0:a.map(({year:t,conferences:i})=>{const n=i.reduce((s,o)=>s+(o.paper_count??0),0);return e.jsxs(j,{title:t>0?String(t):"Unknown year",meta:`${i.length} ${i.length===1?"conference":"conferences"} · ${n.toLocaleString()} papers`,children:[i.map(s=>{const o=f(s.start_date,s.end_date),l=[s.venue,s.location].filter(Boolean).join(", ");return e.jsxs(c,{to:`/conferences/${s.slug}`,className:"tag-cell",children:[e.jsx("div",{className:"name",children:s.name}),e.jsxs("div",{className:"meta",style:{display:"flex",flexDirection:"column",gap:4},children:[o&&e.jsx("span",{children:o}),l&&e.jsx("span",{children:l}),e.jsxs("span",{children:[(s.paper_count??0).toLocaleString()," papers"]})]})]},s.id)}),e.jsx(N,{kind:"conference"})]},t)})]})};export{Q as default}; diff --git a/assets/CronDashboard-kqcQ1rzf.js b/assets/CronDashboard-BgGmgfB6.js similarity index 95% rename from assets/CronDashboard-kqcQ1rzf.js rename to assets/CronDashboard-BgGmgfB6.js index c13b8917252f3deb2a7d4c4b601dd2d38ccf8a0c..7f0c21209ee21070dcf1a0d97996610c12775802 100644 --- a/assets/CronDashboard-kqcQ1rzf.js +++ b/assets/CronDashboard-BgGmgfB6.js @@ -1,4 +1,4 @@ -import{s as O,d as h,M as is,A as cs,j as e,z as ie,af as ls,R as ds,N as os,D as oe,P as ms,F as us,O as Ae,G as L,b as G,I as $,i as xe,U as Re,L as pe,a as hs,q as xs}from"./index-DyXq7-Tg.js";import{u as P}from"./useMutation-UWxBeqtn.js";import{t as ge,f as v,a as S,S as Te,o as ue,C as g,b as N,c as b,d as F,e as j,g as C}from"./CronDashboard-qYV75PLc.js";import{B as I}from"./badge-e6t3GCyf.js";import{B as y}from"./button-DZeAbOf2.js";import{C as ps,a as gs}from"./chevron-up-DYSYRyvz.js";import{D as fe}from"./database-DflzbaZ5.js";import{T as js}from"./trending-up-OM6wBVvQ.js";import{A as ne}from"./activity-S-FQ6Anu.js";import{F as Ne}from"./file-text-dvKtHbmD.js";import{T as Ee,I as vs}from"./triangle-alert-uZ3fXFkp.js";import{E as Y}from"./external-link-orY1Xz1I.js";import{C as Z,R as be}from"./refresh-cw-DYXzpRir.js";import{L as R}from"./loader-circle-C75KLEgx.js";import{C as je}from"./circle-check-GGlu5UCV.js";import{c as M,A as _s}from"./codex-DFj4KHqP.js";import{u as fs}from"./useInfiniteQuery-BYh2zN-T.js";import{p as Me}from"./paperEdits-CIjFYfYE.js";import{c as me}from"./catalog-CRar2olQ.js";import{c as ye}from"./chat-Ix1IrIwq.js";/** +import{s as O,d as h,N as is,B as cs,j as e,z as ie,af as ls,R as ds,O as os,E as oe,P as ms,G as us,Q as Ae,I as L,b as G,J as $,i as xe,A as Re,L as pe,a as hs,q as xs}from"./index-CjdUkE4w.js";import{u as P}from"./useMutation-BYtVrkc7.js";import{t as ge,f as v,a as S,S as Te,o as ue,C as g,b as N,c as b,d as F,e as j,g as C}from"./CronDashboard-Di5xM1py.js";import{B as D}from"./badge-C8r6F6JD.js";import{B as y}from"./button-DetZl_ch.js";import{C as ps,a as gs}from"./chevron-up-BwiJ46dh.js";import{D as fe}from"./database-b_ekt_5x.js";import{T as js}from"./trending-up-BMb-8Pi8.js";import{A as ne}from"./activity--6WvmXv2.js";import{F as Ne}from"./file-text-CHlxsNJC.js";import{T as Ee,I as vs}from"./triangle-alert-DF8Mdy0J.js";import{E as Y}from"./external-link-CTLWFJ8S.js";import{C as Z,R as be}from"./refresh-cw-BuRFYuxm.js";import{L as R}from"./loader-circle-xTdSzHv_.js";import{C as je}from"./circle-check-B2vTBhyc.js";import{c as M,A as _s}from"./codex-CgFzL2AI.js";import{u as fs}from"./useInfiniteQuery-DeZTTVbI.js";import{p as Me}from"./paperEdits-C_3nZTKz.js";import{c as me}from"./catalog-qXcKve0z.js";import{c as ye}from"./chat-B1EBF720.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. @@ -33,4 +33,4 @@ import{s as O,d as h,M as is,A as cs,j as e,z as ie,af as ls,R as ds,N as os,D a * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ks=O("FileClock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"37hlfg"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}],["path",{d:"M9.5 17.5 8 16.25V14",key:"1o80t2"}]]);var ce="Tabs",[Cs]=us(ce,[Ae]),De=Ae(),[Ss,ve]=Cs(ce),Ie=h.forwardRef((s,r)=>{const{__scopeTabs:t,value:c,onValueChange:i,defaultValue:d,orientation:o="horizontal",dir:_,activationMode:x="automatic",...u}=s,p=is(_),[n,f]=cs({prop:c,onChange:i,defaultProp:d??"",caller:ce});return e.jsx(Ss,{scope:t,baseId:ls(),value:n,onValueChange:f,orientation:o,dir:p,activationMode:x,children:e.jsx(ie.div,{dir:p,"data-orientation":o,...u,ref:r})})});Ie.displayName=ce;var Oe="TabsList",Je=h.forwardRef((s,r)=>{const{__scopeTabs:t,loop:c=!0,...i}=s,d=ve(Oe,t),o=De(t);return e.jsx(ds,{asChild:!0,...o,orientation:d.orientation,dir:d.dir,loop:c,children:e.jsx(ie.div,{role:"tablist","aria-orientation":d.orientation,...i,ref:r})})});Je.displayName=Oe;var Be="TabsTrigger",Ue=h.forwardRef((s,r)=>{const{__scopeTabs:t,value:c,disabled:i=!1,...d}=s,o=ve(Be,t),_=De(t),x=ze(o.baseId,c),u=Ke(o.baseId,c),p=c===o.value;return e.jsx(os,{asChild:!0,..._,focusable:!i,active:p,children:e.jsx(ie.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:x,...d,ref:r,onMouseDown:oe(s.onMouseDown,n=>{!i&&n.button===0&&n.ctrlKey===!1?o.onValueChange(c):n.preventDefault()}),onKeyDown:oe(s.onKeyDown,n=>{[" ","Enter"].includes(n.key)&&o.onValueChange(c)}),onFocus:oe(s.onFocus,()=>{const n=o.activationMode!=="manual";!p&&!i&&n&&o.onValueChange(c)})})})});Ue.displayName=Be;var He="TabsContent",We=h.forwardRef((s,r)=>{const{__scopeTabs:t,value:c,forceMount:i,children:d,...o}=s,_=ve(He,t),x=ze(_.baseId,c),u=Ke(_.baseId,c),p=c===_.value,n=h.useRef(p);return h.useEffect(()=>{const f=requestAnimationFrame(()=>n.current=!1);return()=>cancelAnimationFrame(f)},[]),e.jsx(ms,{present:i||p,children:({present:f})=>e.jsx(ie.div,{"data-state":p?"active":"inactive","data-orientation":_.orientation,role:"tabpanel","aria-labelledby":x,hidden:!f,id:u,tabIndex:0,...o,ref:r,style:{...s.style,animationDuration:n.current?"0s":void 0},children:f&&d})})});We.displayName=He;function ze(s,r){return`${s}-trigger-${r}`}function Ke(s,r){return`${s}-content-${r}`}var $s=Ie,Ge=Je,Qe=Ue,Ve=We;const Ls=$s,Xe=h.forwardRef(({className:s,...r},t)=>e.jsx(Ge,{ref:t,className:L("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",s),...r}));Xe.displayName=Ge.displayName;const H=h.forwardRef(({className:s,...r},t)=>e.jsx(Qe,{ref:t,className:L("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",s),...r}));H.displayName=Qe.displayName;const W=h.forwardRef(({className:s,...r},t)=>e.jsx(Ve,{ref:t,className:L("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...r}));W.displayName=Ve.displayName;function A({tone:s,className:r,...t}){return e.jsx(I,{variant:"outline",className:L(ge(s),r),...t})}function te(s){return s==null?"N/A":s<60?`${s.toFixed(1)}s`:s<3600?`${(s/60).toFixed(1)}m`:`${(s/3600).toFixed(1)}h`}function Ye(s){return s.available?s.status==="completed"?s.conclusion??"completed":s.status??"unknown":"Unavailable"}function X(s){return s.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function ke({title:s,budget:r,profile:t}){const c=r.cost_policy==="unmetered_hf"||r.budget_enforced===!1,i=Math.min(100,r.current_exposure_usd/r.ceiling_usd*100),d=c?"Unmetered HF":r.affordable_jobs===0&&r.desired_jobs>0?"No shard fits":r.affordable_jobs0?"Now":"No scheduled admission"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"cron-label",children:"Unknown terminal reserve"}),e.jsxs("div",{children:[S(r.unknown_terminal_reservation_usd??0)," · ",(r.unknown_terminal_reservation_count??0).toLocaleString()," jobs"]})]})]}),t&&e.jsxs("div",{className:"text-xs cron-muted",children:["Profile ",e.jsx("strong",{children:t.profile_id})," · max ",t.max_papers.toLocaleString()," papers · hard ",te(t.hard_timeout_seconds)," · soft ",te(t.soft_deadline_seconds)]}),e.jsx("p",{className:"text-xs cron-muted",children:c?"HF owns this workload, so monetary admission is disabled; concurrency and timeout limits still apply. Runtime cost remains an operational estimate.":"Projected exposure is an admission-control estimate, not a provider invoice. Each launch reserves the full timeout until actual runtime is known."})]})}const Ps={healthy:je,degraded:Ee,broken:Z,running:R,stuck:Z,unknown:Ns};function Fs({status:s,isRunning:r}){const t=r?"running":s,c=Ps[t];return e.jsx(c,{className:`cron-status-icon ${ge(t)}${t==="running"?" animate-spin":""}`})}function Ce({label:s,axis:r}){return e.jsxs(A,{tone:r.status,title:r.reason,children:[s,": ",r.status]})}function Se({icon:s,title:r,metrics:t}){return e.jsxs("div",{children:[e.jsxs("div",{className:"cron-section-heading",children:[e.jsx(s,{className:"h-4 w-4"}),e.jsx("h4",{children:r})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(t).map(([c,i])=>e.jsxs("div",{className:"cron-metric-card",children:[e.jsx("div",{className:"cron-label",children:X(c)}),e.jsx("div",{className:"text-lg font-semibold",children:typeof i=="number"?i.toLocaleString():i})]},c))})]})}function As({workflow:s}){return e.jsxs("div",{children:[e.jsxs("div",{className:"cron-section-heading",children:[e.jsx(ne,{className:"h-4 w-4"}),e.jsx("h4",{children:"GitHub Actions"})]}),e.jsxs("div",{className:"cron-metric-card space-y-2 text-sm",children:[[["Workflow",s.workflow_file],["Run",s.run_id??"N/A"],["Status",Ye(s)],...s.updated_at?[["Updated",v(s.updated_at)]]:[]].map(([r,t])=>e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"cron-label",children:r}),e.jsx("span",{className:r==="Workflow"?"font-mono text-xs":void 0,children:t})]},r)),s.failed_jobs&&s.failed_jobs.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"cron-label mb-1",children:"Failed jobs"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:s.failed_jobs.map(r=>e.jsx(A,{tone:"broken",children:r},r))})]}),s.job_conclusions&&Object.keys(s.job_conclusions).length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"cron-label mb-1",children:"Job conclusions"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:Object.entries(s.job_conclusions).map(([r,t])=>e.jsxs(I,{variant:"outline",children:[r,": ",t??"running"]},r))})]}),(s.error||s.view_error)&&e.jsx("div",{className:"cron-message cron-message--error",children:s.error??s.view_error})]})]})}const Rs={COMPLETED:"healthy",ERROR:"broken",CANCELED:"broken",RUNNING:"running"},$e={success:"healthy",partial:"degraded",interrupted:"degraded",infrastructure_failure:"broken",worker_failure:"broken",active:"running"};function Ts({job:s}){const r=s.progress,t=(r==null?void 0:r.omitted_images)??0,c=r!=null&&r.total_papers?Math.min(100,r.processed_papers/r.total_papers*100):0;return e.jsxs("div",{className:"cron-metric-card space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-semibold",children:[s.mode??"unknown"," · shard ",s.shard_id??"N/A"," · attempt ",s.provider_attempt??1]}),e.jsx("div",{className:"font-mono text-xs cron-muted truncate",children:s.id})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{tone:Rs[s.stage]??"unknown",children:s.stage.toLowerCase()}),s.effective_outcome&&e.jsxs(A,{tone:$e[s.effective_outcome]??"unknown",children:["output: ",s.effective_outcome.replace(/_/g," ")]}),s.failure_cause&&e.jsxs(A,{tone:$e[s.effective_outcome??""]??"unknown",children:["cause: ",s.failure_cause.replace(/_/g," ")]}),s.url&&e.jsx("a",{href:s.url,target:"_blank",rel:"noreferrer","aria-label":`Open Hugging Face Job ${s.id}`,className:"cron-info-text",children:e.jsx(Y,{className:"h-4 w-4"})})]})]}),r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between gap-3 text-xs cron-muted mb-1",children:[e.jsxs("span",{children:[r.processed_papers.toLocaleString()," / ",r.total_papers.toLocaleString()," papers"]}),e.jsxs("span",{children:[c.toFixed(0),"%"]})]}),e.jsx("div",{className:"cron-progress-track",children:e.jsx("div",{className:"cron-progress-value",style:{width:`${c}%`}})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-sm",children:[e.jsxs("span",{children:[e.jsx("strong",{children:r.succeeded_papers.toLocaleString()})," succeeded"]}),e.jsxs("span",{children:[e.jsx("strong",{children:r.failed_papers.toLocaleString()})," failed"]}),e.jsxs("span",{children:[e.jsx("strong",{children:r.already_existed_papers.toLocaleString()})," skipped"]}),e.jsxs("span",{children:[e.jsx("strong",{children:r.extracted_images.toLocaleString()})," images"]})]}),t>0&&e.jsxs("div",{className:"text-xs cron-muted",children:[e.jsx("strong",{children:t.toLocaleString()})," unresolved image references omitted after final retry"]}),r.updated_at&&e.jsxs("div",{className:"text-xs cron-muted",children:["Progress updated ",v(r.updated_at)]}),(r.fatal_error||r.error_samples.length>0)&&e.jsxs("div",{className:"cron-message cron-message--error space-y-1",children:[r.fatal_error&&e.jsx("div",{children:r.fatal_error}),r.error_samples.map(i=>e.jsxs("div",{children:[e.jsx("span",{className:"font-mono",children:i.arxiv_id}),": ",i.error]},`${i.arxiv_id}:${i.error}`))]})]}):e.jsx("div",{className:"text-sm cron-muted",children:"Waiting for the shard progress checkpoint."}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs cron-muted",children:[s.hardware&&e.jsx("span",{children:s.hardware}),s.created_at&&e.jsxs("span",{children:["Created ",v(s.created_at)]}),s.duration_seconds!=null&&e.jsxs("span",{children:["Duration ",te(s.duration_seconds)]})]}),s.stage_message&&e.jsx("div",{className:"cron-message cron-message--warning",children:s.stage_message})]})}function Es({monitor:s,loading:r,error:t}){var c,i;return e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("div",{className:"cron-section-heading",children:[e.jsx(vs,{className:"h-4 w-4"}),e.jsx("h4",{children:"Hugging Face OCR shards"})]}),r&&e.jsxs("div",{className:"cron-metric-card flex items-center gap-2 text-sm cron-muted",children:[e.jsx(R,{className:"h-4 w-4 animate-spin"})," Loading remote Jobs…"]}),!!t&&e.jsx("div",{className:"cron-message cron-message--error",children:"Could not load Hugging Face Jobs."}),s&&!s.available&&e.jsx("div",{className:"cron-message cron-message--warning",children:s.error??"Hugging Face monitoring is unavailable."}),(s==null?void 0:s.available)&&e.jsxs(e.Fragment,{children:[s.budgets.live&&s.budgets.backfill&&e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-3 mb-3",children:[e.jsx(ke,{title:"Live paper Markdown GPU policy",budget:s.budgets.live,profile:(c=s.selected_profiles)==null?void 0:c.live}),e.jsx(ke,{title:"Full backfill GPU policy",budget:s.budgets.backfill,profile:(i=s.selected_profiles)==null?void 0:i.backfill})]}),e.jsxs("div",{className:`cron-message mb-3 ${(s.summary.unresolved_mount_failures??0)>0?"cron-message--error":""}`,children:[e.jsx("strong",{children:"Logical shard health:"})," ",(s.summary.logical_shards??0).toLocaleString()," logical shards / ",(s.summary.provider_attempts??0).toLocaleString()," provider attempts · ",(s.summary.recovered_mount_failures??0).toLocaleString()," recovered mount failures · ",(s.summary.unresolved_mount_failures??0).toLocaleString()," unresolved"]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-3",children:Object.entries(s.summary).map(([d,o])=>e.jsxs("div",{className:"cron-metric-card",children:[e.jsx("div",{className:"cron-label",children:X(d)}),e.jsx("div",{className:"text-lg font-semibold",children:o.toLocaleString()})]},d))}),e.jsx("p",{className:"text-xs cron-muted mb-3",children:"Efficiency and backlog-clearance costs are admission-control estimates, not provider invoices."}),s.coverage&&Object.keys(s.coverage).length>0&&e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-3 mb-3",children:Object.values(s.coverage).map(d=>e.jsxs("div",{className:"cron-metric-card space-y-2 text-sm",children:[e.jsx("div",{className:"font-semibold",children:d.scope==="full"?"Full catalog coverage":"Recent 14-day coverage"}),e.jsxs("div",{className:"text-lg font-semibold",children:[d.coverage_percentage.toFixed(2),"%"]}),e.jsxs("div",{children:[d.canonical_markdown_count.toLocaleString()," canonical / ",d.eligible_papers.toLocaleString()," eligible · ",d.missing_count.toLocaleString()," missing"]}),e.jsxs("div",{className:"cron-muted",children:["Copied from upstream this reconciliation: ",d.copied_from_upstream_count.toLocaleString()]}),e.jsxs("div",{className:"cron-muted",children:["7-day Δ eligible ",d.eligible_delta_7d??"collecting"," · canonical ",d.canonical_delta_7d??"collecting"," · missing ",d.missing_delta_7d??"collecting"]})]},d.scope))}),s.jobs.length===0?e.jsx("div",{className:"cron-metric-card text-sm cron-muted",children:"No OCR shards have been launched yet."}):e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-3",children:s.jobs.map(d=>e.jsx(Ts,{job:d},d.id))})]})]})}function Ms({job:s,expanded:r,onToggle:t,autoRefresh:c=!1}){var p;const i=!!(s.work_metrics&&Object.keys(s.work_metrics).length),d=!!(s.db_metrics&&Object.keys(s.db_metrics).length),o=s.job_name==="paper_markdown_backfill",_=G({queryKey:$.paperMarkdownJobs,queryFn:()=>ue.getPaperMarkdownJobs(),enabled:o,refetchInterval:c?3e4:!1,retry:!1}),x=o?(p=_.data)==null?void 0:p.budgets.live:void 0,u=(x==null?void 0:x.cost_policy)==="unmetered_hf"||(x==null?void 0:x.budget_enforced)===!1;return e.jsxs("div",{className:"cron-job-card",children:[e.jsx("button",{type:"button",className:"cron-job-summary",onClick:t,"aria-expanded":r,children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx(Fs,{status:s.status,isRunning:s.is_running}),e.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("h3",{className:"font-semibold",children:s.display_name}),s.critical&&e.jsx(I,{variant:"outline",className:"text-[10px] uppercase tracking-wide",children:"Critical"}),s.lock_stale&&e.jsx(A,{tone:"broken",children:"Held lock"}),e.jsx(Ce,{label:"Execution",axis:s.execution_health}),e.jsx(Ce,{label:"Output",axis:s.output_health}),r?e.jsx(ps,{className:"h-4 w-4 cron-muted"}):e.jsx(gs,{className:"h-4 w-4 cron-muted"})]}),e.jsx("p",{className:"text-sm cron-muted mb-2",children:s.status_reason}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-2 text-sm cron-muted",children:[e.jsxs("span",{className:"cron-fact",children:[e.jsx(qe,{}),"Log: ",v(s.last_run)]}),e.jsxs("span",{className:"cron-fact",children:[e.jsx(fe,{}),"DB: ",v(s.last_db_write)]}),s.recent_write_count!=null&&e.jsxs("span",{className:"cron-fact",children:[e.jsx(js,{}),"Recent writes: ",s.recent_write_count.toLocaleString()]}),s.duration!=null&&e.jsxs("span",{className:"cron-fact",children:[e.jsx(ne,{}),"Duration: ",te(s.duration)]}),s.schedule&&e.jsxs("span",{className:"cron-fact md:col-span-2",children:[e.jsx(we,{}),e.jsx("span",{className:"font-mono text-xs",children:s.schedule})]}),s.log_status&&e.jsxs("span",{className:"cron-fact",children:[e.jsx(Ne,{}),"Log status: ",s.log_status]}),s.workflow_status&&e.jsxs("span",{className:"cron-fact",children:[e.jsx(ne,{}),"Actions: ",Ye(s.workflow_status)]})]}),s.work_summary&&e.jsx("div",{className:"cron-message",children:s.work_summary}),s.error&&e.jsxs("div",{className:"cron-message cron-message--error",children:[e.jsx("strong",{children:"Error: "}),s.error]}),s.diagnostics&&e.jsx("div",{className:"cron-message cron-message--warning",children:s.diagnostics}),x&&e.jsxs("div",{className:`cron-message ${x.can_launch_planned?"":"cron-message--error"}`,children:[e.jsx("strong",{children:"Live GPU policy:"})," ",u?"unmetered on HF":`${S(x.current_exposure_usd)} current / ${S(x.ceiling_usd)} cap`," · ",x.affordable_jobs," of ",x.desired_jobs," planned",u?"":` · projects ${S(x.projected_usd)} · rolling 30 days`]})]})]}),e.jsx(A,{tone:s.status,children:s.status})]})}),r&&e.jsx("div",{className:"cron-job-details",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"cron-section-heading",children:[e.jsx(we,{className:"h-4 w-4"}),e.jsx("h4",{children:"Scheduler evidence"})]}),e.jsx("div",{className:"cron-metric-card space-y-2 text-sm",children:[["Scheduler",s.execution_health.scheduler??"unknown"],["Last expected",v(s.execution_health.last_expected_at??null)],["Last started",v(s.execution_health.last_started_at??null)],["Last completed",v(s.execution_health.last_completed_at??null)],["Next expected",v(s.execution_health.next_expected_at??null)]].map(([n,f])=>e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"cron-label",children:n}),e.jsx("span",{children:f})]},n))})]}),s.work_metrics&&i&&e.jsx(Se,{icon:Ne,title:"Log Metrics",metrics:s.work_metrics}),s.db_metrics&&d&&e.jsx(Se,{icon:fe,title:"Database Metrics",metrics:s.db_metrics}),s.workflow_status&&e.jsx(As,{workflow:s.workflow_status}),o&&e.jsx(Es,{monitor:_.data,loading:_.isLoading,error:_.error}),s.diagnostic_groups&&Object.values(s.diagnostic_groups).some(n=>n.length>0)&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("div",{className:"cron-section-heading",children:[e.jsx(Ee,{className:"h-4 w-4"}),e.jsx("h4",{children:"Diagnostics by cause"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Object.entries(s.diagnostic_groups).filter(([,n])=>n.length>0).map(([n,f])=>e.jsxs("div",{className:"cron-metric-card",children:[e.jsx("div",{className:"cron-label mb-1",children:X(n)}),e.jsx("ul",{className:"list-disc pl-4 text-sm space-y-1",children:f.map(k=>e.jsx("li",{children:k},k))})]},n))})]}),s.health_findings&&s.health_findings.some(n=>n.state!=="healthy")&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("div",{className:"cron-section-heading",children:[e.jsx(Te,{className:"h-4 w-4"}),e.jsx("h4",{children:"Deterministic contract findings"})]}),e.jsxs("div",{className:"cron-metric-card space-y-3 text-sm",children:[s.health_findings.filter(n=>n.state!=="healthy").map(n=>e.jsxs("div",{children:[e.jsx(A,{tone:n.state,children:n.state})," ",e.jsx("strong",{children:X(n.contract)}),": ",n.summary,Object.entries(n.evidence).length>0&&e.jsx("div",{className:"mt-1 text-xs cron-muted",children:Object.entries(n.evidence).map(([f,k])=>e.jsxs("span",{className:"mr-3",children:[X(f),": ",String(k)]},f))})]},`${n.plane}-${n.contract}`)),e.jsxs("div",{className:"flex gap-4",children:[s.operator_url&&e.jsxs("a",{className:"cron-info-text inline-flex items-center gap-1",href:s.operator_url,children:["Open operator ",e.jsx(Y,{className:"h-3.5 w-3.5"})]}),s.run_url&&e.jsxs("a",{className:"cron-info-text inline-flex items-center gap-1",href:s.run_url,target:"_blank",rel:"noreferrer",children:["Open run ",e.jsx(Y,{className:"h-3.5 w-3.5"})]})]})]})]})]})})]})}const Ze=h.forwardRef(({className:s,...r},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:L("w-full caption-bottom text-sm",s),...r})}));Ze.displayName="Table";const es=h.forwardRef(({className:s,...r},t)=>e.jsx("thead",{ref:t,className:L("[&_tr]:border-b",s),...r}));es.displayName="TableHeader";const ss=h.forwardRef(({className:s,...r},t)=>e.jsx("tbody",{ref:t,className:L("[&_tr:last-child]:border-0",s),...r}));ss.displayName="TableBody";const qs=h.forwardRef(({className:s,...r},t)=>e.jsx("tfoot",{ref:t,className:L("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...r}));qs.displayName="TableFooter";const he=h.forwardRef(({className:s,...r},t)=>e.jsx("tr",{ref:t,className:L("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",s),...r}));he.displayName="TableRow";const z=h.forwardRef(({className:s,...r},t)=>e.jsx("th",{ref:t,className:L("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",s),...r}));z.displayName="TableHead";const K=h.forwardRef(({className:s,...r},t)=>e.jsx("td",{ref:t,className:L("p-4 align-middle [&:has([role=checkbox])]:pr-0",s),...r}));K.displayName="TableCell";const Ds=h.forwardRef(({className:s,...r},t)=>e.jsx("caption",{ref:t,className:L("mt-4 text-sm text-muted-foreground",s),...r}));Ds.displayName="TableCaption";const as={queued:"unknown",dispatching:"running",running:"running",completed:"healthy",failed:"broken",canceled:"unknown",awaiting_markdown:"unknown"},rs={queued:"queued",dispatching:"dispatching",running:"running",completed:"completed",failed:"failed",canceled:"canceled",awaiting_markdown:"waiting for Markdown"},Le={"add-evals":"Add evals","enrich-paper":"Enrich paper","resolve-model-paper":"Resolve model release","review-benchmark-gaps":"Review benchmark gaps","add-benchmark":"Add benchmark"},Is={queued:ws,dispatching:R,running:bs,completed:je,failed:Z,canceled:ys,awaiting_markdown:ks};function Os({status:s}){const r=Is[s];return e.jsxs(A,{tone:as[s],children:[e.jsx(r,{className:`mr-1 h-3.5 w-3.5 ${s==="dispatching"?"animate-spin":""}`}),rs[s]]})}function Js(s){return s.status==="awaiting_markdown"?_s:s.error?s.error:s.report?s.report:s.status==="completed"&&s.applied_at?"Changes applied to the paper.":s.status==="completed"?"Completed without a recorded mutation.":null}function Pe({mutationResult:s}){const r=s==null?void 0:s.skipped_configured_leaderboards;return!Array.isArray(r)||r.length===0?null:e.jsxs("div",{className:"mt-2 rounded border border-amber-500 bg-amber-50 p-2 text-xs text-amber-900",children:[e.jsxs("div",{className:"font-medium",children:["Skipped configured leaderboards (",r.length,")"]}),e.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-4",children:r.map((t,c)=>e.jsxs("li",{children:[t.benchmark," · ",t.disposition," · task ",t.task_id," / dataset ",t.dataset_id,t.metric?` / ${t.metric}`:"",t.value!=null?` = ${t.value}`:"",t.detail?` — ${t.detail}`:""]},c))})]})}function Bs({autoRefresh:s}){var D;const r=xe(),[t,c]=h.useState(""),[i,d]=h.useState(""),[o,_]=h.useState(""),[x,u]=h.useState(""),[p,n]=h.useState(""),[f,k]=h.useState({}),J={trigger:t,status:i,policy_version:o,cohort_date:x,review_status:p},{data:m,isLoading:Q,isFetching:ee,error:B}=G({queryKey:[...$.codexPaperJobs,J],queryFn:()=>M.listJobs(100,J),refetchInterval:s?1e4:!1,retry:!1}),T=()=>r.invalidateQueries({queryKey:$.codexPaperJobs}),se=P({mutationFn:a=>M.retryJob(a),onSuccess:T}),le=P({mutationFn:a=>M.cancelJob(a),onSuccess:T}),de=P({mutationFn:a=>M.retryTrace(a),onSuccess:T}),V=P({mutationFn:a=>M.setScheduler(a),onSuccess:T}),q=P({mutationFn:({id:a,dataset:l,task:w,metric:re})=>M.promoteBenchmarkCandidate(a,{dataset_id:Number(l),task_id:Number(w),best_metric:re.trim()}),onSuccess:T}),E=P({mutationFn:a=>M.rollbackBenchmarkCandidate(a),onSuccess:T}),ae=B instanceof Re&&B.status===404;return e.jsxs(g,{className:"mb-8",children:[e.jsx(N,{children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xl",children:"Codex paper jobs"}),e.jsx(F,{children:"Durable queue, two-stage daily workflows, traces, and benchmark-gap follow-up"})]}),ee&&!Q&&e.jsxs("span",{className:"flex items-center gap-2 text-xs cron-muted",children:[e.jsx(R,{className:"h-3.5 w-3.5 animate-spin"})," Syncing with Hugging Face"]})]})}),e.jsxs(j,{children:[Q&&e.jsxs("div",{className:"flex items-center justify-center py-10 cron-muted",children:[e.jsx(R,{className:"mr-2 h-5 w-5 animate-spin"})," Loading paper jobs…"]}),B&&!ae&&e.jsx("div",{className:"cron-message cron-message--error mb-4",children:B.message}),ae&&e.jsx("p",{className:"py-4 text-sm cron-muted",children:"Codex paper jobs are not enabled in this environment."}),m&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`cron-message mb-5 ${m.scheduler.paused_at?"cron-message--error":""}`,children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:["Scheduled dispatch: ",m.scheduler.paused_at?"paused":m.scheduler.dispatch_enabled?"enabled":"disabled"]}),m.scheduler.pause_reason&&e.jsx("div",{className:"mt-1 text-xs",children:m.scheduler.pause_reason}),e.jsxs("div",{className:"mt-1 text-xs cron-muted",children:["Canary ",m.scheduler.canary_released?"released":"active"," · Queue age ",m.scheduler.queue_age_level]}),e.jsxs("div",{className:"mt-1 text-xs cron-muted",children:["Scheduled usage today ",m.scheduler.usage.current_day_tokens.toLocaleString()," tokens · ",m.scheduler.usage.mode==="enforced"?`pause threshold ${((D=m.scheduler.usage.pause_threshold_tokens)==null?void 0:D.toLocaleString())??"not established"}`:"first-week alert-only baseline"," · trailing median ",m.scheduler.usage.trailing_seven_day_median_tokens.toLocaleString()]})]}),e.jsx(y,{size:"sm",variant:m.scheduler.paused_at||!m.scheduler.dispatch_enabled?"default":"outline",disabled:V.isPending,onClick:()=>V.mutate(m.scheduler.paused_at||!m.scheduler.dispatch_enabled?"resume":"pause"),children:m.scheduler.paused_at?"Acknowledge & resume":m.scheduler.dispatch_enabled?"Pause scheduled dispatch":"Enable scheduled dispatch"})]})}),e.jsxs("div",{className:"mb-5 grid grid-cols-2 gap-3 sm:grid-cols-4 lg:grid-cols-8",children:[["queued","awaiting_markdown","dispatching","running","completed","failed","canceled"].map(a=>e.jsxs("div",{className:"cron-metric-card",children:[e.jsx("div",{className:"cron-label capitalize",children:rs[a]}),e.jsx("div",{className:"mt-1 text-xl font-semibold",children:m.summary[a]})]},a)),e.jsxs("div",{className:"cron-metric-card",children:[e.jsx("div",{className:"cron-label",children:"Total"}),e.jsx("div",{className:"mt-1 text-xl font-semibold",children:m.summary.total})]})]}),e.jsxs("div",{className:"mb-5 grid gap-3 sm:grid-cols-5",children:[e.jsxs("select",{"aria-label":"Trigger",className:"rounded border px-2 py-1 text-sm",value:t,onChange:a=>c(a.target.value),children:[e.jsx("option",{value:"",children:"All triggers"}),e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"hf-daily-cron",children:"HF daily cron"}),e.jsx("option",{value:"hf-trending-cron",children:"HF trending cron"}),e.jsx("option",{value:"benchmark-gap-cron",children:"Benchmark gap cron"}),e.jsx("option",{value:"model-release-radar",children:"Release radar"})]}),e.jsxs("select",{"aria-label":"Status",className:"rounded border px-2 py-1 text-sm",value:i,onChange:a=>d(a.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),Object.keys(as).map(a=>e.jsx("option",{children:a},a))]}),e.jsx("input",{"aria-label":"Policy version",className:"rounded border px-2 py-1 text-sm",placeholder:"Policy version",value:o,onChange:a=>_(a.target.value)}),e.jsx("input",{"aria-label":"Cohort date",type:"date",className:"rounded border px-2 py-1 text-sm",value:x,onChange:a=>u(a.target.value)}),e.jsxs("select",{"aria-label":"Review status",className:"rounded border px-2 py-1 text-sm",value:p,onChange:a=>n(a.target.value),children:[e.jsx("option",{value:"",children:"All review states"}),e.jsx("option",{value:"unreviewed",children:"Unreviewed"}),e.jsx("option",{value:"approved",children:"Approved"}),e.jsx("option",{value:"corrected",children:"Corrected"})]})]}),m.jobs.length===0?e.jsx("p",{className:"py-8 text-center text-sm cron-muted",children:"No paper curation jobs have been submitted yet."}):e.jsxs(Ze,{children:[e.jsx(es,{children:e.jsxs(he,{children:[e.jsx(z,{children:"Status"}),e.jsx(z,{children:"Paper"}),e.jsx(z,{children:"Action"}),e.jsx(z,{children:"Requested"}),e.jsx(z,{children:"Execution"})]})}),e.jsx(ss,{children:m.jobs.map(a=>{const l=Js(a);return e.jsxs(he,{children:[e.jsx(K,{className:"align-top",children:e.jsx(Os,{status:a.status})}),e.jsx(K,{className:"min-w-[260px] align-top",children:a.paper_route?e.jsxs(e.Fragment,{children:[e.jsx(pe,{to:`/paper/${encodeURIComponent(a.paper_route)}`,className:"font-medium hover:underline",children:a.paper_title}),e.jsxs("div",{className:"mt-1 text-xs cron-muted",children:["Paper #",a.paper_id]})]}):a.kind==="review-benchmark-gaps"?e.jsx("span",{className:"font-medium",children:"Benchmark-gap backlog"}):a.kind==="add-benchmark"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"Benchmark candidate"}),e.jsx("div",{className:"mt-1 text-xs cron-muted",children:a.benchmark_candidate_id})]}):a.release_signal_id?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"Release radar signal"}),e.jsxs("div",{className:"mt-1 text-xs cron-muted",children:["Signal ",a.release_signal_id]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"Trending model discovery"}),e.jsxs("div",{className:"mt-1 text-xs cron-muted",children:["Candidate ",a.candidate_id]})]})}),e.jsxs(K,{className:"whitespace-nowrap align-top",children:[Le[a.kind],a.applied_at&&e.jsxs("div",{className:"mt-1 flex items-center gap-1 text-xs cron-status--healthy",children:[e.jsx(je,{className:"h-3.5 w-3.5"})," Applied"]})]}),e.jsxs(K,{className:"whitespace-nowrap align-top",children:[e.jsx("div",{children:v(a.created_at)}),e.jsxs("div",{className:"mt-1 text-xs cron-muted",children:["@",a.requested_by]})]}),e.jsxs(K,{className:"max-w-[360px] align-top",children:[a.hf_job_url?e.jsxs("a",{href:a.hf_job_url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 hover:underline",children:["Hugging Face Job ",e.jsx(Y,{className:"h-3.5 w-3.5"})]}):e.jsx("span",{className:"cron-muted",children:"Waiting to dispatch"}),l&&e.jsx("p",{className:`mt-2 line-clamp-3 text-xs ${a.error&&a.status!=="awaiting_markdown"?"text-red-700":"cron-muted"}`,title:l,children:l}),e.jsx(Pe,{mutationResult:a.mutation_result}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[["failed","canceled"].includes(a.status)&&e.jsx(y,{size:"sm",variant:"outline",onClick:()=>se.mutate(a.id),children:"Retry"}),["queued","awaiting_markdown","dispatching","running"].includes(a.status)&&e.jsx(y,{size:"sm",variant:"outline",onClick:()=>le.mutate(a.id),children:"Cancel"}),a.trace_status==="finalize_failed"&&e.jsx(y,{size:"sm",variant:"outline",onClick:()=>de.mutate(a.id),children:"Retry trace"})]})]})]},a.id)})})]}),m.workflows.length>0&&e.jsxs("div",{className:"mt-8 space-y-3",children:[e.jsx("h3",{className:"text-base font-semibold",children:"Scheduled paper workflows"}),m.workflows.map(a=>e.jsxs("details",{className:"rounded-md border p-3",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium",children:["Paper #",a.paper_id," · ",a.cohort_date," · ",a.status," · ",a.policy_version]}),e.jsxs("div",{className:"mt-3 space-y-3 text-xs",children:[a.error&&e.jsx("div",{className:"text-red-700",children:a.error}),a.stages.map(l=>{var w;return e.jsxs("div",{className:"rounded border p-3",children:[e.jsxs("div",{className:"font-medium",children:[Le[l.kind]," · ",l.status," · trace ",l.trace_status," · review ",l.audit_status]}),e.jsxs("div",{className:"mt-1 cron-muted",children:["model ",l.model??"—"," · reasoning ",l.reasoning_effort??"—"," · tokens ",(l.input_tokens??0)+(l.output_tokens??0)," · duration ",l.duration_ms??0," ms · attempts ",l.attempt_count]}),l.error&&e.jsx("div",{className:"mt-2 text-red-700",children:l.error}),l.report&&e.jsx("div",{className:"mt-2 whitespace-pre-wrap rounded border p-2",children:l.report}),l.url_candidates&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{children:"URL candidates and provenance"}),e.jsx("pre",{className:"mt-2 max-h-52 overflow-auto whitespace-pre-wrap",children:JSON.stringify(l.url_candidates,null,2)})]}),l.validation_summary&&e.jsx("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap",children:JSON.stringify(l.validation_summary,null,2)}),Array.isArray((w=l.validation_summary)==null?void 0:w.manual_or_legacy_evaluation_rows_affected)&&l.validation_summary.manual_or_legacy_evaluation_rows_affected.length>0&&e.jsxs("div",{className:"mt-2 rounded border border-amber-500 bg-amber-50 p-2 font-medium text-amber-900",children:["Manual or legacy evaluation rows changed: ",l.validation_summary.manual_or_legacy_evaluation_rows_affected.join(", "),". Review the evidence and before/after diff."]}),l.proposal&&e.jsx("pre",{className:"mt-2 max-h-52 overflow-auto whitespace-pre-wrap",children:JSON.stringify(l.proposal,null,2)}),e.jsx(Pe,{mutationResult:l.mutation_result}),l.mutation_result&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{children:"Accepted callback result and before/after state"}),e.jsx("pre",{className:"mt-2 max-h-64 overflow-auto whitespace-pre-wrap",children:JSON.stringify(l.mutation_result,null,2)})]}),l.trace_status==="complete"&&e.jsxs("a",{className:"mt-2 inline-flex items-center gap-1 hover:underline",href:M.traceUrl(l.id),target:"_blank",rel:"noreferrer",children:["Authenticated trace manifest ",e.jsx(Y,{className:"h-3.5 w-3.5"})]})]},l.id)})]})]},a.id))]}),m.benchmark_candidates.length>0&&e.jsxs("div",{className:"mt-8 space-y-3",children:[e.jsx("h3",{className:"text-base font-semibold",children:"Benchmark-gap backlog"}),m.benchmark_candidates.map(a=>{var re,_e;const l=f[a.id]??{dataset:"",task:((re=a.task_ids[0])==null?void 0:re.toString())??"",metric:""},w=Number(l.dataset)>0&&Number(l.task)>0&&l.metric.trim().length>0;return e.jsxs("div",{className:"rounded-md border p-3 text-xs",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"font-medium",children:[a.canonical_name," · ",a.gap_type," · ",a.status]}),e.jsxs("div",{className:"cron-muted",children:[a.distinct_paper_count," paper",a.distinct_paper_count===1?"":"s"," · ",a.confidence??"unknown"," confidence"]})]}),a.canonical_url&&e.jsx("a",{className:"mt-1 block hover:underline",href:a.canonical_url,target:"_blank",rel:"noreferrer",children:a.canonical_url}),e.jsxs("div",{className:"mt-1 cron-muted",children:["Task evidence: ",a.task_ids.join(", ")||"none"," · Papers: ",a.evidence_paper_ids.join(", ")]}),a.review_reason&&e.jsxs("div",{className:"mt-1",children:["Review",a.reviewed_at?` ${v(a.reviewed_at)}`:"",": ",a.review_reason,a.deferred_until&&` · deferred until ${v(a.deferred_until)}`]}),a.resolution&&e.jsxs("div",{className:"mt-1 cron-muted",children:["Dataset #",a.resolution.dataset_id," · task #",a.resolution.task_id," · ",a.resolution.primary_metric,a.resolution.rolled_back_at&&` · rolled back ${v(a.resolution.rolled_back_at)}`]}),a.status==="promoted"&&((_e=a.resolution)==null?void 0:_e.created)&&!a.resolution.rolled_back_at&&e.jsx(y,{className:"mt-2",size:"sm",variant:"outline",disabled:E.isPending,onClick:()=>E.mutate(a.id),children:"Roll back automatic benchmark"}),!["promoted","merged"].includes(a.status)&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[["dataset","task","metric"].map(U=>e.jsx("input",{"aria-label":`${a.canonical_name} ${U}`,className:"w-36 rounded border px-2 py-1",placeholder:U==="metric"?"Exact metric":`${U} ID`,value:l[U],onChange:ns=>k(ts=>({...ts,[a.id]:{...l,[U]:ns.target.value}}))},U)),e.jsx(y,{size:"sm",variant:"outline",disabled:!w||q.isPending,onClick:()=>q.mutate({id:a.id,...l}),children:"Promote & requeue evidence papers"})]})]},a.id)}),q.error&&e.jsx("div",{className:"cron-message cron-message--error",children:q.error.message}),E.error&&e.jsx("div",{className:"cron-message cron-message--error",children:E.error.message})]}),e.jsxs("p",{className:"mt-4 text-xs cron-muted",children:["Showing the 100 most recent jobs · Queue totals include full history · Updated ",v(m.timestamp)]})]})]})]})}function Us(){const[s,r]=h.useState(()=>new Date().toISOString().slice(0,10)),[t,c]=h.useState(1),i=G({queryKey:["paper-edit-digest",s,t],queryFn:()=>Me.digest(s,t),enabled:!!s});return e.jsxs("section",{className:"space-y-3 rounded border p-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Daily paper edits"}),e.jsxs("label",{className:"flex items-center gap-2",children:["UTC date ",e.jsx("input",{type:"date",value:s,onChange:d=>{r(d.target.value),c(1)}})]}),i.isLoading&&e.jsx("p",{children:"Loading daily summary…"}),i.error&&e.jsx("p",{role:"alert",children:i.error.message}),i.data&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[i.data.edits," published changes · ",i.data.papers," papers · ",i.data.contributors," contributors"]}),e.jsx("ul",{className:"space-y-1",children:i.data.rows.map((d,o)=>e.jsxs("li",{children:[e.jsxs(pe,{className:"underline",to:`/paper/${d.paper_id}`,children:["Paper ",d.paper_id]})," · @",d.actor_username??"admin"," · ",d.edits," changes"]},o))}),e.jsxs("div",{className:"flex gap-2",children:[t>1&&e.jsx(y,{variant:"outline",onClick:()=>c(t-1),children:"Previous"}),i.data.has_more&&e.jsx(y,{variant:"outline",onClick:()=>c(t+1),children:"Next"})]})]})]})}const Hs=()=>{var _,x,u,p;const s=xe(),r=fs({queryKey:$.catalogAudit,queryFn:({pageParam:n})=>me.audit(n),initialPageParam:void 0,getNextPageParam:n=>n.next_cursor??void 0}),t=((_=r.data)==null?void 0:_.pages.flatMap(n=>n.events))??[],c=()=>s.invalidateQueries({queryKey:$.catalogAudit}),i=P({mutationFn:()=>me.acknowledgeAudit(),onSuccess:c}),d=P({mutationFn:n=>me.rollbackEvent(n),onSuccess:c}),o=P({mutationFn:({subject:n,suspended:f})=>Me.suspend(n,f),onSuccess:c});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Us,{}),(d.error||o.error)&&e.jsx("p",{role:"alert",children:(x=d.error||o.error)==null?void 0:x.message}),e.jsxs(g,{children:[e.jsxs(N,{className:"flex-row items-center justify-between",children:[e.jsx(b,{children:"Catalog mutation audit"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[((p=(u=r.data)==null?void 0:u.pages[0])==null?void 0:p.unread_contributor_count)??0," unread contributor changes"]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>i.mutate(),disabled:i.isPending,children:"Mark read"})]})]}),e.jsxs(j,{className:"space-y-3",children:[r.isLoading&&e.jsx("p",{children:"Loading audit history…"}),r.error&&e.jsx("p",{className:"text-destructive",children:"Audit history unavailable."}),t.map(n=>e.jsxs("article",{className:`rounded-md border p-3 ${n.operation==="delete"||n.rollback_eligible===!1?"border-red-500 bg-red-50/50":""}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("strong",{children:[n.operation," ",n.entity_type," ",n.entity_id]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",n.actor_username??n.actor_role," ·"," ",new Date(n.created_at).toLocaleString()]})]}),e.jsxs("details",{className:"mt-2 text-xs",children:[e.jsx("summary",{children:"Inspect snapshots"}),e.jsx("pre",{className:"mt-2 max-h-80 overflow-auto rounded bg-muted p-3",children:JSON.stringify({before:n.before,after:n.after},null,2)})]}),n.actor_role==="contributor"&&n.actor_hf_subject&&e.jsx(y,{className:"mt-3 mr-2",variant:"outline",size:"sm",disabled:o.isPending,onClick:()=>o.mutate({subject:n.actor_hf_subject,suspended:!n.editing_suspended}),children:n.editing_suspended?"Restore editing access":"Suspend editing access"}),!n.rollback_of_event_id&&e.jsx(y,{className:"mt-3",variant:"outline",size:"sm",onClick:()=>d.mutate(n.id),disabled:d.isPending||n.rollback_eligible===!1,children:n.rollback_eligible===!1?"Rollback conflict":"Roll back if unchanged"})]},n.id)),r.hasNextPage&&e.jsx(y,{variant:"outline",onClick:()=>r.fetchNextPage(),disabled:r.isFetchingNextPage,children:r.isFetchingNextPage?"Loading…":"Load older events"})]})]})]})},Fe={hourly:"running",daily:"healthy",weekly:"degraded",systemd:"running"},Ws=({data:s,loading:r,error:t})=>{const[c,i]=h.useState("staging-current"),d={"staging-current":"Starter staging · $75 warning / $100 trip / no Environment cap","staging-production-era":"Staging with production · $15 / $20 / $25",production:"Production · $175 / $200 / $225"};if(r)return e.jsxs("div",{className:"flex items-center py-12",children:[e.jsx(R,{className:"h-6 w-6 animate-spin mr-3"}),"Loading chat compute…"]});if(t||!s)return e.jsx(g,{className:"cron-status--broken",children:e.jsx(j,{className:"pt-6",children:"Chat compute accounting is unavailable."})});const o=Math.min(100,s.effective_microusd/s.application_cap_microusd*100),_=s.circuit_state==="tripped"?"Chat disabled":s.circuit_state==="warning"?"Operator warning":"Enabled",x=s.reconciliation_state==="fresh"?"Fresh":s.reconciliation_state==="stale"?"Stale":"Unavailable";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid md:grid-cols-4 gap-4",children:[e.jsxs(g,{className:s.circuit_state==="tripped"?"cron-status--broken":s.circuit_state==="warning"?"cron-status--degraded":"",children:[e.jsx(N,{children:e.jsx(b,{className:"text-sm",children:"Circuit"})}),e.jsxs(j,{children:[e.jsx("div",{className:"text-2xl font-bold",children:_}),e.jsx("p",{className:"text-xs cron-muted",children:s.trip_reason??"Policy armed"})]})]}),e.jsxs(g,{children:[e.jsx(N,{children:e.jsx(b,{className:"text-sm",children:"Month to date"})}),e.jsxs(j,{children:[e.jsx("div",{className:"text-2xl font-bold",children:C(s.effective_microusd)}),e.jsx("div",{role:"progressbar","aria-label":"Application cap used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o),className:"h-2 rounded bg-muted mt-3",children:e.jsx("div",{className:"h-2 rounded bg-primary",style:{width:`${o}%`}})})]})]}),e.jsxs(g,{children:[e.jsx(N,{children:e.jsx(b,{className:"text-sm",children:"Application headroom"})}),e.jsxs(j,{children:[e.jsx("div",{className:"text-2xl font-bold",children:C(s.remaining_microusd)}),e.jsxs("p",{className:"text-xs cron-muted",children:["Cap ",C(s.application_cap_microusd)]})]})]}),e.jsxs(g,{children:[e.jsx(N,{children:e.jsx(b,{className:"text-sm",children:"Live compute"})}),e.jsxs(j,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.live_count}),e.jsxs("p",{className:"text-xs cron-muted",children:[s.termination_uncertain_count," termination uncertain"]})]})]})]}),e.jsxs(g,{children:[e.jsxs(N,{children:[e.jsx(b,{children:"Accounting and policy"}),e.jsxs(F,{children:[s.environment," · cycle ",s.billing_cycle]})]}),e.jsxs(j,{className:"grid md:grid-cols-3 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Environment record"}),e.jsx("br",{}),s.environment," · ",s.provider_mode==="starter_workspace"?"Starter Workspace":"Team isolated"]}),e.jsxs("label",{children:[e.jsx("strong",{children:"Policy profile"}),e.jsxs("select",{"aria-label":"Chat compute policy profile",value:c,onChange:u=>i(u.target.value),className:"block mt-1",children:[e.jsx("option",{value:"staging-current",children:"Staging now"}),e.jsx("option",{value:"staging-production-era",children:"Staging with production"}),e.jsx("option",{value:"production",children:"Production"})]}),e.jsxs("span",{className:"text-xs cron-muted",children:[d[c]," · Workspace $250"]})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Conservative estimate"}),e.jsx("br",{}),C(s.estimated_microusd)]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Provider-reported floor"}),e.jsx("br",{}),C(s.provider_floor_microusd)," · ",e.jsx(I,{children:x})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Provider backstops"}),e.jsx("br",{}),s.environment_cap_microusd===null?"Starter: no Environment cap":`Environment ${C(s.environment_cap_microusd)}`," · Workspace ",C(s.workspace_cap_microusd)]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Active thresholds"}),e.jsx("br",{}),"Warning ",C(s.warning_microusd)," · trip ",C(s.application_cap_microusd)]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Policy allocation"}),e.jsx("br",{}),"Starter staging $75/$100 with no Environment cap · future Team staging $15/$20/$25 · production $175/$200/$225 · workspace $250"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Cycle end"}),e.jsx("br",{}),v(s.cycle_end_at)]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Last metered"}),e.jsx("br",{}),s.last_metered_at?v(s.last_metered_at):"Unavailable"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Provider reconciliation"}),e.jsx("br",{}),s.last_reconciled_at?v(s.last_reconciled_at):"Unavailable",s.last_reconciliation_attempt_at?` · attempted ${v(s.last_reconciliation_attempt_at)}`:"",s.next_reconciliation_at?` · next ${v(s.next_reconciliation_at)}`:""]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Burn projection"}),e.jsx("br",{}),s.burn_rate_microusd_per_hour===null?"Not enough data":`${C(s.burn_rate_microusd_per_hour)}/hour${s.projected_cap_hit_at?` · cap ${v(s.projected_cap_hit_at)}`:""}`]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Prior cycle"}),e.jsx("br",{}),s.prior_cycle?`${s.prior_cycle.billing_cycle} · ${C(s.prior_cycle.effective_microusd)}`:"Not enough data"]})]})]}),e.jsxs(g,{children:[e.jsx(N,{children:e.jsx(b,{children:"Live lifecycle"})}),e.jsx(j,{className:"text-sm",children:Object.entries(s.live_states).map(([u,p])=>e.jsxs("span",{className:"mr-4",children:[u,": ",p]},u))})]}),e.jsxs(g,{children:[e.jsx(N,{children:e.jsx(b,{children:"Daily spend"})}),e.jsx(j,{children:s.daily_spend.length?e.jsx("ul",{className:"space-y-1 text-sm",children:s.daily_spend.map(u=>e.jsxs("li",{children:[u.date,": blank ",C(u.blank_pool_microusd)," · assigned ",C(u.assigned_microusd)]},u.date))}):e.jsx("p",{className:"cron-muted",children:"No compute recorded in this cycle."})})]}),e.jsxs(g,{children:[e.jsxs(N,{children:[e.jsx(b,{children:"Recent circuit events"}),e.jsx(F,{children:"Runbook: docs/chat-sandbox-spend-runbook.md"})]}),e.jsx(j,{children:s.events.length?e.jsx("ul",{className:"space-y-2 text-sm",children:s.events.map(u=>e.jsxs("li",{children:[e.jsx(I,{children:u.severity})," ",u.type," · ",v(u.created_at)]},u.id))}):e.jsx("p",{className:"cron-muted",children:"No events in this cycle."})})]})]})},zs=({data:s,loading:r,error:t})=>{if(r)return e.jsxs("div",{className:"flex items-center py-8",children:[e.jsx(R,{className:"h-5 w-5 animate-spin mr-3"}),"Loading web-search budget…"]});if(t||!s)return e.jsx(g,{className:"cron-status--broken",children:e.jsx(j,{className:"pt-6",children:"Web-search budget accounting is unavailable."})});const c=Math.min(100,s.call_count/s.hard_limit_calls*100);return e.jsxs(g,{className:s.circuit_state==="tripped"?"cron-status--broken":s.circuit_state==="warning"||s.circuit_state==="cooldown"?"cron-status--degraded":"",children:[e.jsxs(N,{children:[e.jsx(b,{children:"Web search"}),e.jsxs(F,{children:[s.environment," · UTC cycle ",s.billing_cycle," · provider details are admin-only"]})]}),e.jsxs(j,{className:"space-y-4",children:[e.jsxs("div",{className:"grid md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Circuit"}),e.jsx("br",{}),s.circuit_state,s.trip_reason?` · ${s.trip_reason}`:""]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Calls"}),e.jsx("br",{}),s.call_count," / ",s.hard_limit_calls," · ",s.success_count," successful"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Remaining"}),e.jsx("br",{}),s.remaining_calls]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Warning"}),e.jsx("br",{}),s.warning_calls," calls"]})]}),e.jsx("div",{role:"progressbar","aria-label":"Web-search monthly budget used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(c),className:"h-2 rounded bg-muted",children:e.jsx("div",{className:"h-2 rounded bg-primary",style:{width:`${c}%`}})}),e.jsxs("p",{className:"text-xs cron-muted",children:["Cycle ends ",v(s.cycle_end_at)," · provider-reported cost $",(s.provider_cost_microusd/1e6).toFixed(4),s.last_latency_ms!==null?` · last ${s.last_latency_ms} ms / ${s.last_result_count??0} results`:"",s.cooldown_until?` · cooldown until ${v(s.cooldown_until)}`:"",s.last_provider_error_class?` · last provider error ${s.last_provider_error_class}`:""]}),s.events.length>0&&e.jsx("ul",{className:"space-y-1 text-sm",children:s.events.map(i=>e.jsxs("li",{children:[i.type," · ",v(i.created_at),i.error_class?` · ${i.error_class}`:""]},i.id))})]})]})},Ks=({data:s})=>s!=null&&s.snapshot_stale?e.jsx(g,{className:"mb-6 cron-status--degraded",role:"status",children:e.jsx(j,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsx(R,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{children:["Refreshing status… Current snapshot is ",Math.ceil(s.snapshot_age_seconds)," seconds old."]})]})})}):null,Gs=(s,r)=>s!=null&&s.snapshot_stale||s!=null&&s.refreshing?5e3:r?3e4:!1,pa=()=>{const s=xs(),r=xe(),[t,c]=h.useState(!0),[i,d]=h.useState(""),[o,_]=h.useState(""),[x,u]=h.useState(new Set),{user:p}=hs(),{data:n,isLoading:f,error:k}=G({queryKey:$.cronStatus,queryFn:()=>ue.getCronStatus(),refetchInterval:a=>Gs(a.state.data,t),retry:!1}),J=G({queryKey:$.chatSandboxSpend(o),queryFn:()=>ye.getSandboxSpend(o||void 0),refetchInterval:t?3e4:!1,retry:!1}),m=G({queryKey:$.chatWebSearchBudget,queryFn:()=>ye.getWebSearchBudget(),enabled:s,refetchInterval:t?3e4:!1,retry:!1}),Q=P({mutationFn:()=>Promise.all([r.cancelQueries({queryKey:$.cronStatus}).then(()=>r.fetchQuery({queryKey:$.cronStatus,queryFn:()=>ue.getCronStatus(!0),retry:!1})),r.refetchQueries({queryKey:$.all,type:"active",predicate:a=>a.queryKey[1]!==$.cronStatus[1]})])}),ee=k instanceof Re&&k.status===401?"Unauthorized. Sign in with an allowlisted Hugging Face admin account.":k instanceof Error?k.message:void 0,B=a=>{u(l=>{const w=new Set(l);return w.has(a)?w.delete(a):w.add(a),w})},T=(n==null?void 0:n.jobs.filter(a=>a.dashboard_group==="leaderboard_sync"))??[],se=(n==null?void 0:n.jobs.filter(a=>a.category!=="manual"&&a.dashboard_group!=="leaderboard_sync"))??[],le=se.filter(a=>a.critical),de=se.filter(a=>!a.critical),V=(n==null?void 0:n.manual_operations)??[],q=!!(f||Q.isPending||n!=null&&n.refreshing),E=de.reduce((a,l)=>(a[l.category]||(a[l.category]=[]),a[l.category].push(l),a),{}),ae=Object.keys(E).sort((a,l)=>{const w=["systemd","hourly","daily","weekly","backfill"];return w.indexOf(a)-w.indexOf(l)}),D=a=>e.jsx(Ms,{job:a,expanded:x.has(a.job_name),onToggle:()=>B(a.job_name),autoRefresh:t},a.job_name);return e.jsx("div",{className:"cron-dashboard","data-shadcn":!0,children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[e.jsx("div",{className:"mb-8",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center gap-3",children:[e.jsx(ne,{className:"h-8 w-8 cron-info-text"}),"Admin Dashboard"]}),e.jsx("p",{className:"mt-2 cron-muted",children:"Paper curation queue and operational health for scheduled jobs"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(y,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(pe,{to:"/autonomous-operations",children:"Autonomous operations"})}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>c(!t),className:t?"cron-status--running":"",children:[e.jsx(be,{className:`h-4 w-4 mr-2 ${t?"animate-spin":""}`}),"Auto-refresh ",t?"ON":"OFF"]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>Q.mutate(),disabled:q,children:[e.jsx(be,{className:`h-4 w-4 mr-2 ${q?"animate-spin":""}`}),"Refresh"]})]})]})}),e.jsx(g,{className:"mb-6",children:e.jsx(j,{className:"pt-6",children:e.jsxs("p",{className:"text-sm cron-muted",children:["Signed in as ",e.jsxs("span",{className:"font-semibold",children:["@",p==null?void 0:p.username]}),". Health checks prefer database freshness over log completion so silent no-work failures surface as degraded or broken. Expanded jobs include deterministic scheduler, log, lock, durable-data, throughput, backlog, and semantic contract evidence with direct operator and run links."]})})}),e.jsx(Ks,{data:n}),e.jsxs(Ls,{defaultValue:"critical-jobs",children:[e.jsxs(Xe,{className:"grid h-auto w-full grid-cols-2 sm:w-auto sm:grid-cols-5",children:[e.jsx(H,{value:"critical-jobs",children:"Critical Jobs"}),e.jsx(H,{value:"leaderboard-syncs",children:"Leaderboard Syncs"}),e.jsx(H,{value:"codex-paper-jobs",children:"Codex Paper Jobs"}),e.jsx(H,{value:"catalog-audit",children:"Catalog Audit"}),e.jsx(H,{value:"chat-compute",children:"Chat Compute"})]}),e.jsxs(W,{value:"critical-jobs",className:"mt-6",children:[f&&e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(R,{className:"h-8 w-8 animate-spin cron-info-text"}),e.jsx("span",{className:"ml-3 cron-muted",children:"Loading CRON jobs status..."})]}),k&&e.jsx(g,{className:"cron-status--broken",children:e.jsx(j,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Z,{className:"h-5 w-5"}),e.jsx("p",{children:ee??"Failed to load CRON jobs status. Please try again."})]})})}),n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-6",children:["healthy","degraded","broken","running","stuck","unknown"].map(a=>e.jsxs(g,{children:[e.jsx(N,{className:"pb-2",children:e.jsx(b,{className:"text-sm font-medium cron-muted capitalize",children:a})}),e.jsx(j,{children:e.jsx("div",{className:"text-2xl font-bold",children:n.summary[a]})})]},a))}),n.summary.critical_issues.length>0&&e.jsxs(g,{className:"mb-6 cron-status--broken",children:[e.jsx(N,{children:e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Te,{className:"h-5 w-5"}),"Critical job issues"]})}),e.jsx(j,{children:e.jsx("ul",{className:"list-disc pl-5 space-y-1 text-sm",children:n.summary.critical_issues.map(a=>e.jsx("li",{children:a},a))})})]}),e.jsxs(g,{className:"mb-8",children:[e.jsx(N,{children:e.jsx(b,{className:"text-base",children:"What to check next"})}),e.jsxs(j,{children:[e.jsx("p",{className:"text-sm cron-muted",children:n.summary.what_to_check_next}),e.jsxs("p",{className:"mt-2 text-xs cron-muted flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4"}),"Last updated: ",v(n.timestamp)," · Health score:"," ",n.summary.health_score.toFixed(0),"%"]})]})]}),e.jsxs(g,{className:`mb-8 ${n.summary.coverage.coverage_gaps?"cron-status--broken":""}`,children:[e.jsxs(N,{children:[e.jsx(b,{className:"text-base",children:"Coverage"}),e.jsx(F,{children:"Registry and deployed scheduler inventory"})]}),e.jsxs(j,{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"cron-label",children:"Registered"}),e.jsx("div",{className:"text-2xl font-bold",children:n.summary.coverage.registered_scheduled_duties})]}),e.jsxs("div",{children:[e.jsx("span",{className:"cron-label",children:"Discovered"}),e.jsx("div",{className:"text-2xl font-bold",children:n.summary.coverage.discovered_scheduled_duties})]}),e.jsxs("div",{children:[e.jsx("span",{className:"cron-label",children:"Monitored"}),e.jsx("div",{className:"text-2xl font-bold",children:n.summary.coverage.monitored_duties})]}),e.jsxs("div",{children:[e.jsx("span",{className:"cron-label",children:"Gaps"}),e.jsx("div",{className:"text-2xl font-bold",children:n.summary.coverage.coverage_gaps})]})]})]}),e.jsxs(g,{className:"mb-8",children:[e.jsxs(N,{children:[e.jsx(b,{className:"text-xl",children:"Critical jobs"}),e.jsx(F,{children:"Writers whose stale output breaks the live site"})]}),e.jsx(j,{className:"space-y-4",children:le.map(D)})]}),e.jsx("div",{className:"space-y-6",children:ae.map(a=>e.jsxs(g,{children:[e.jsx(N,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(b,{className:"text-xl capitalize flex items-center gap-2",children:[e.jsx(I,{className:ge(Fe[a]??Fe.hourly),children:a}),e.jsx("span",{children:"Supporting jobs"})]}),e.jsxs(F,{children:[E[a].length," job",E[a].length!==1?"s":""]})]})}),e.jsx(j,{className:"space-y-4",children:E[a].map(D)})]},a))}),V.length>0&&e.jsxs(g,{className:"mt-6",children:[e.jsxs(N,{children:[e.jsx(b,{className:"text-xl",children:"Manual operations"}),e.jsx(F,{children:"Visible invocation history; excluded from scheduled health and coverage"})]}),e.jsx(j,{className:"space-y-4",children:V.map(D)})]})]})]}),e.jsxs(W,{value:"leaderboard-syncs",className:"mt-6",children:[f&&e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(R,{className:"h-8 w-8 animate-spin cron-info-text"}),e.jsx("span",{className:"ml-3 cron-muted",children:"Loading leaderboard sync status..."})]}),k&&e.jsx(g,{className:"cron-status--broken",children:e.jsx(j,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Z,{className:"h-5 w-5"}),e.jsx("p",{children:ee??"Failed to load leaderboard sync status. Please try again."})]})})}),n&&e.jsxs(g,{children:[e.jsx(N,{children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xl",children:"Leaderboard syncs"}),e.jsx(F,{children:"Recurring imports from externally maintained benchmark leaderboards"})]}),e.jsxs(I,{children:[T.length," jobs"]})]})}),e.jsx(j,{className:"space-y-4",children:T.map(D)})]})]}),e.jsx(W,{value:"codex-paper-jobs",className:"mt-6",children:e.jsx(Bs,{autoRefresh:t})}),e.jsx(W,{value:"catalog-audit",className:"mt-6",children:e.jsx(Hs,{})}),e.jsxs(W,{value:"chat-compute",className:"mt-6",children:[e.jsxs(g,{className:"mb-6",children:[e.jsxs(N,{children:[e.jsx(b,{children:"Environment record"}),e.jsx(F,{children:"Leave blank for live staging, or enter the isolated environment printed by the spend qualification command."})]}),e.jsxs(j,{className:"flex gap-2",children:[e.jsx("input",{"aria-label":"Chat compute environment record",value:i,onChange:a=>d(a.target.value),placeholder:"staging-q-example",className:"flex-1 rounded border px-3 py-2"}),e.jsx(y,{onClick:()=>_(i.trim()),children:"Load"})]})]}),e.jsx(Ws,{data:J.data,loading:J.isLoading,error:J.error}),s&&e.jsx("div",{className:"mt-6",children:e.jsx(zs,{data:m.data,loading:m.isLoading,error:m.error})})]})]})]})})};export{Ws as ChatComputePanel,Ks as CronSnapshotNotice,Gs as cronStatusRefetchInterval,pa as default}; + */const ks=O("FileClock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"37hlfg"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}],["path",{d:"M9.5 17.5 8 16.25V14",key:"1o80t2"}]]);var ce="Tabs",[Cs]=us(ce,[Ae]),Ie=Ae(),[Ss,ve]=Cs(ce),De=h.forwardRef((s,r)=>{const{__scopeTabs:t,value:c,onValueChange:i,defaultValue:d,orientation:o="horizontal",dir:_,activationMode:x="automatic",...u}=s,p=is(_),[n,f]=cs({prop:c,onChange:i,defaultProp:d??"",caller:ce});return e.jsx(Ss,{scope:t,baseId:ls(),value:n,onValueChange:f,orientation:o,dir:p,activationMode:x,children:e.jsx(ie.div,{dir:p,"data-orientation":o,...u,ref:r})})});De.displayName=ce;var Oe="TabsList",Je=h.forwardRef((s,r)=>{const{__scopeTabs:t,loop:c=!0,...i}=s,d=ve(Oe,t),o=Ie(t);return e.jsx(ds,{asChild:!0,...o,orientation:d.orientation,dir:d.dir,loop:c,children:e.jsx(ie.div,{role:"tablist","aria-orientation":d.orientation,...i,ref:r})})});Je.displayName=Oe;var Be="TabsTrigger",Ue=h.forwardRef((s,r)=>{const{__scopeTabs:t,value:c,disabled:i=!1,...d}=s,o=ve(Be,t),_=Ie(t),x=ze(o.baseId,c),u=Ke(o.baseId,c),p=c===o.value;return e.jsx(os,{asChild:!0,..._,focusable:!i,active:p,children:e.jsx(ie.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:x,...d,ref:r,onMouseDown:oe(s.onMouseDown,n=>{!i&&n.button===0&&n.ctrlKey===!1?o.onValueChange(c):n.preventDefault()}),onKeyDown:oe(s.onKeyDown,n=>{[" ","Enter"].includes(n.key)&&o.onValueChange(c)}),onFocus:oe(s.onFocus,()=>{const n=o.activationMode!=="manual";!p&&!i&&n&&o.onValueChange(c)})})})});Ue.displayName=Be;var He="TabsContent",We=h.forwardRef((s,r)=>{const{__scopeTabs:t,value:c,forceMount:i,children:d,...o}=s,_=ve(He,t),x=ze(_.baseId,c),u=Ke(_.baseId,c),p=c===_.value,n=h.useRef(p);return h.useEffect(()=>{const f=requestAnimationFrame(()=>n.current=!1);return()=>cancelAnimationFrame(f)},[]),e.jsx(ms,{present:i||p,children:({present:f})=>e.jsx(ie.div,{"data-state":p?"active":"inactive","data-orientation":_.orientation,role:"tabpanel","aria-labelledby":x,hidden:!f,id:u,tabIndex:0,...o,ref:r,style:{...s.style,animationDuration:n.current?"0s":void 0},children:f&&d})})});We.displayName=He;function ze(s,r){return`${s}-trigger-${r}`}function Ke(s,r){return`${s}-content-${r}`}var $s=De,Ge=Je,Qe=Ue,Ve=We;const Ls=$s,Xe=h.forwardRef(({className:s,...r},t)=>e.jsx(Ge,{ref:t,className:L("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",s),...r}));Xe.displayName=Ge.displayName;const H=h.forwardRef(({className:s,...r},t)=>e.jsx(Qe,{ref:t,className:L("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",s),...r}));H.displayName=Qe.displayName;const W=h.forwardRef(({className:s,...r},t)=>e.jsx(Ve,{ref:t,className:L("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...r}));W.displayName=Ve.displayName;function A({tone:s,className:r,...t}){return e.jsx(D,{variant:"outline",className:L(ge(s),r),...t})}function te(s){return s==null?"N/A":s<60?`${s.toFixed(1)}s`:s<3600?`${(s/60).toFixed(1)}m`:`${(s/3600).toFixed(1)}h`}function Ye(s){return s.available?s.status==="completed"?s.conclusion??"completed":s.status??"unknown":"Unavailable"}function X(s){return s.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function ke({title:s,budget:r,profile:t}){const c=r.cost_policy==="unmetered_hf"||r.budget_enforced===!1,i=Math.min(100,r.current_exposure_usd/r.ceiling_usd*100),d=c?"Unmetered HF":r.affordable_jobs===0&&r.desired_jobs>0?"No shard fits":r.affordable_jobs0?"Now":"No scheduled admission"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"cron-label",children:"Unknown terminal reserve"}),e.jsxs("div",{children:[S(r.unknown_terminal_reservation_usd??0)," · ",(r.unknown_terminal_reservation_count??0).toLocaleString()," jobs"]})]})]}),t&&e.jsxs("div",{className:"text-xs cron-muted",children:["Profile ",e.jsx("strong",{children:t.profile_id})," · max ",t.max_papers.toLocaleString()," papers · hard ",te(t.hard_timeout_seconds)," · soft ",te(t.soft_deadline_seconds)]}),e.jsx("p",{className:"text-xs cron-muted",children:c?"HF owns this workload, so monetary admission is disabled; concurrency and timeout limits still apply. Runtime cost remains an operational estimate.":"Projected exposure is an admission-control estimate, not a provider invoice. Each launch reserves the full timeout until actual runtime is known."})]})}const Ps={healthy:je,degraded:Ee,broken:Z,running:R,stuck:Z,unknown:Ns};function Fs({status:s,isRunning:r}){const t=r?"running":s,c=Ps[t];return e.jsx(c,{className:`cron-status-icon ${ge(t)}${t==="running"?" animate-spin":""}`})}function Ce({label:s,axis:r}){return e.jsxs(A,{tone:r.status,title:r.reason,children:[s,": ",r.status]})}function Se({icon:s,title:r,metrics:t}){return e.jsxs("div",{children:[e.jsxs("div",{className:"cron-section-heading",children:[e.jsx(s,{className:"h-4 w-4"}),e.jsx("h4",{children:r})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(t).map(([c,i])=>e.jsxs("div",{className:"cron-metric-card",children:[e.jsx("div",{className:"cron-label",children:X(c)}),e.jsx("div",{className:"text-lg font-semibold",children:typeof i=="number"?i.toLocaleString():i})]},c))})]})}function As({workflow:s}){return e.jsxs("div",{children:[e.jsxs("div",{className:"cron-section-heading",children:[e.jsx(ne,{className:"h-4 w-4"}),e.jsx("h4",{children:"GitHub Actions"})]}),e.jsxs("div",{className:"cron-metric-card space-y-2 text-sm",children:[[["Workflow",s.workflow_file],["Run",s.run_id??"N/A"],["Status",Ye(s)],...s.updated_at?[["Updated",v(s.updated_at)]]:[]].map(([r,t])=>e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"cron-label",children:r}),e.jsx("span",{className:r==="Workflow"?"font-mono text-xs":void 0,children:t})]},r)),s.failed_jobs&&s.failed_jobs.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"cron-label mb-1",children:"Failed jobs"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:s.failed_jobs.map(r=>e.jsx(A,{tone:"broken",children:r},r))})]}),s.job_conclusions&&Object.keys(s.job_conclusions).length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"cron-label mb-1",children:"Job conclusions"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:Object.entries(s.job_conclusions).map(([r,t])=>e.jsxs(D,{variant:"outline",children:[r,": ",t??"running"]},r))})]}),(s.error||s.view_error)&&e.jsx("div",{className:"cron-message cron-message--error",children:s.error??s.view_error})]})]})}const Rs={COMPLETED:"healthy",ERROR:"broken",CANCELED:"broken",RUNNING:"running"},$e={success:"healthy",partial:"degraded",interrupted:"degraded",infrastructure_failure:"broken",worker_failure:"broken",active:"running"};function Ts({job:s}){const r=s.progress,t=(r==null?void 0:r.omitted_images)??0,c=r!=null&&r.total_papers?Math.min(100,r.processed_papers/r.total_papers*100):0;return e.jsxs("div",{className:"cron-metric-card space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-semibold",children:[s.mode??"unknown"," · shard ",s.shard_id??"N/A"," · attempt ",s.provider_attempt??1]}),e.jsx("div",{className:"font-mono text-xs cron-muted truncate",children:s.id})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{tone:Rs[s.stage]??"unknown",children:s.stage.toLowerCase()}),s.effective_outcome&&e.jsxs(A,{tone:$e[s.effective_outcome]??"unknown",children:["output: ",s.effective_outcome.replace(/_/g," ")]}),s.failure_cause&&e.jsxs(A,{tone:$e[s.effective_outcome??""]??"unknown",children:["cause: ",s.failure_cause.replace(/_/g," ")]}),s.url&&e.jsx("a",{href:s.url,target:"_blank",rel:"noreferrer","aria-label":`Open Hugging Face Job ${s.id}`,className:"cron-info-text",children:e.jsx(Y,{className:"h-4 w-4"})})]})]}),r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between gap-3 text-xs cron-muted mb-1",children:[e.jsxs("span",{children:[r.processed_papers.toLocaleString()," / ",r.total_papers.toLocaleString()," papers"]}),e.jsxs("span",{children:[c.toFixed(0),"%"]})]}),e.jsx("div",{className:"cron-progress-track",children:e.jsx("div",{className:"cron-progress-value",style:{width:`${c}%`}})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-sm",children:[e.jsxs("span",{children:[e.jsx("strong",{children:r.succeeded_papers.toLocaleString()})," succeeded"]}),e.jsxs("span",{children:[e.jsx("strong",{children:r.failed_papers.toLocaleString()})," failed"]}),e.jsxs("span",{children:[e.jsx("strong",{children:r.already_existed_papers.toLocaleString()})," skipped"]}),e.jsxs("span",{children:[e.jsx("strong",{children:r.extracted_images.toLocaleString()})," images"]})]}),t>0&&e.jsxs("div",{className:"text-xs cron-muted",children:[e.jsx("strong",{children:t.toLocaleString()})," unresolved image references omitted after final retry"]}),r.updated_at&&e.jsxs("div",{className:"text-xs cron-muted",children:["Progress updated ",v(r.updated_at)]}),(r.fatal_error||r.error_samples.length>0)&&e.jsxs("div",{className:"cron-message cron-message--error space-y-1",children:[r.fatal_error&&e.jsx("div",{children:r.fatal_error}),r.error_samples.map(i=>e.jsxs("div",{children:[e.jsx("span",{className:"font-mono",children:i.arxiv_id}),": ",i.error]},`${i.arxiv_id}:${i.error}`))]})]}):e.jsx("div",{className:"text-sm cron-muted",children:"Waiting for the shard progress checkpoint."}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs cron-muted",children:[s.hardware&&e.jsx("span",{children:s.hardware}),s.created_at&&e.jsxs("span",{children:["Created ",v(s.created_at)]}),s.duration_seconds!=null&&e.jsxs("span",{children:["Duration ",te(s.duration_seconds)]})]}),s.stage_message&&e.jsx("div",{className:"cron-message cron-message--warning",children:s.stage_message})]})}function Es({monitor:s,loading:r,error:t}){var c,i;return e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("div",{className:"cron-section-heading",children:[e.jsx(vs,{className:"h-4 w-4"}),e.jsx("h4",{children:"Hugging Face OCR shards"})]}),r&&e.jsxs("div",{className:"cron-metric-card flex items-center gap-2 text-sm cron-muted",children:[e.jsx(R,{className:"h-4 w-4 animate-spin"})," Loading remote Jobs…"]}),!!t&&e.jsx("div",{className:"cron-message cron-message--error",children:"Could not load Hugging Face Jobs."}),s&&!s.available&&e.jsx("div",{className:"cron-message cron-message--warning",children:s.error??"Hugging Face monitoring is unavailable."}),(s==null?void 0:s.available)&&e.jsxs(e.Fragment,{children:[s.budgets.live&&s.budgets.backfill&&e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-3 mb-3",children:[e.jsx(ke,{title:"Live paper Markdown GPU policy",budget:s.budgets.live,profile:(c=s.selected_profiles)==null?void 0:c.live}),e.jsx(ke,{title:"Full backfill GPU policy",budget:s.budgets.backfill,profile:(i=s.selected_profiles)==null?void 0:i.backfill})]}),e.jsxs("div",{className:`cron-message mb-3 ${(s.summary.unresolved_mount_failures??0)>0?"cron-message--error":""}`,children:[e.jsx("strong",{children:"Logical shard health:"})," ",(s.summary.logical_shards??0).toLocaleString()," logical shards / ",(s.summary.provider_attempts??0).toLocaleString()," provider attempts · ",(s.summary.recovered_mount_failures??0).toLocaleString()," recovered mount failures · ",(s.summary.unresolved_mount_failures??0).toLocaleString()," unresolved"]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-3",children:Object.entries(s.summary).map(([d,o])=>e.jsxs("div",{className:"cron-metric-card",children:[e.jsx("div",{className:"cron-label",children:X(d)}),e.jsx("div",{className:"text-lg font-semibold",children:o.toLocaleString()})]},d))}),e.jsx("p",{className:"text-xs cron-muted mb-3",children:"Efficiency and backlog-clearance costs are admission-control estimates, not provider invoices."}),s.coverage&&Object.keys(s.coverage).length>0&&e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-3 mb-3",children:Object.values(s.coverage).map(d=>e.jsxs("div",{className:"cron-metric-card space-y-2 text-sm",children:[e.jsx("div",{className:"font-semibold",children:d.scope==="full"?"Full catalog coverage":"Recent 14-day coverage"}),e.jsxs("div",{className:"text-lg font-semibold",children:[d.coverage_percentage.toFixed(2),"%"]}),e.jsxs("div",{children:[d.canonical_markdown_count.toLocaleString()," canonical / ",d.eligible_papers.toLocaleString()," eligible · ",d.missing_count.toLocaleString()," missing"]}),e.jsxs("div",{className:"cron-muted",children:["Copied from upstream this reconciliation: ",d.copied_from_upstream_count.toLocaleString()]}),e.jsxs("div",{className:"cron-muted",children:["7-day Δ eligible ",d.eligible_delta_7d??"collecting"," · canonical ",d.canonical_delta_7d??"collecting"," · missing ",d.missing_delta_7d??"collecting"]})]},d.scope))}),s.jobs.length===0?e.jsx("div",{className:"cron-metric-card text-sm cron-muted",children:"No OCR shards have been launched yet."}):e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-3",children:s.jobs.map(d=>e.jsx(Ts,{job:d},d.id))})]})]})}function Ms({job:s,expanded:r,onToggle:t,autoRefresh:c=!1}){var p;const i=!!(s.work_metrics&&Object.keys(s.work_metrics).length),d=!!(s.db_metrics&&Object.keys(s.db_metrics).length),o=s.job_name==="paper_markdown_backfill",_=G({queryKey:$.paperMarkdownJobs,queryFn:()=>ue.getPaperMarkdownJobs(),enabled:o,refetchInterval:c?3e4:!1,retry:!1}),x=o?(p=_.data)==null?void 0:p.budgets.live:void 0,u=(x==null?void 0:x.cost_policy)==="unmetered_hf"||(x==null?void 0:x.budget_enforced)===!1;return e.jsxs("div",{className:"cron-job-card",children:[e.jsx("button",{type:"button",className:"cron-job-summary",onClick:t,"aria-expanded":r,children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx(Fs,{status:s.status,isRunning:s.is_running}),e.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("h3",{className:"font-semibold",children:s.display_name}),s.critical&&e.jsx(D,{variant:"outline",className:"text-[10px] uppercase tracking-wide",children:"Critical"}),s.lock_stale&&e.jsx(A,{tone:"broken",children:"Held lock"}),e.jsx(Ce,{label:"Execution",axis:s.execution_health}),e.jsx(Ce,{label:"Output",axis:s.output_health}),r?e.jsx(ps,{className:"h-4 w-4 cron-muted"}):e.jsx(gs,{className:"h-4 w-4 cron-muted"})]}),e.jsx("p",{className:"text-sm cron-muted mb-2",children:s.status_reason}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-2 text-sm cron-muted",children:[e.jsxs("span",{className:"cron-fact",children:[e.jsx(qe,{}),"Log: ",v(s.last_run)]}),e.jsxs("span",{className:"cron-fact",children:[e.jsx(fe,{}),"DB: ",v(s.last_db_write)]}),s.recent_write_count!=null&&e.jsxs("span",{className:"cron-fact",children:[e.jsx(js,{}),"Recent writes: ",s.recent_write_count.toLocaleString()]}),s.duration!=null&&e.jsxs("span",{className:"cron-fact",children:[e.jsx(ne,{}),"Duration: ",te(s.duration)]}),s.schedule&&e.jsxs("span",{className:"cron-fact md:col-span-2",children:[e.jsx(we,{}),e.jsx("span",{className:"font-mono text-xs",children:s.schedule})]}),s.log_status&&e.jsxs("span",{className:"cron-fact",children:[e.jsx(Ne,{}),"Log status: ",s.log_status]}),s.workflow_status&&e.jsxs("span",{className:"cron-fact",children:[e.jsx(ne,{}),"Actions: ",Ye(s.workflow_status)]})]}),s.work_summary&&e.jsx("div",{className:"cron-message",children:s.work_summary}),s.error&&e.jsxs("div",{className:"cron-message cron-message--error",children:[e.jsx("strong",{children:"Error: "}),s.error]}),s.diagnostics&&e.jsx("div",{className:"cron-message cron-message--warning",children:s.diagnostics}),x&&e.jsxs("div",{className:`cron-message ${x.can_launch_planned?"":"cron-message--error"}`,children:[e.jsx("strong",{children:"Live GPU policy:"})," ",u?"unmetered on HF":`${S(x.current_exposure_usd)} current / ${S(x.ceiling_usd)} cap`," · ",x.affordable_jobs," of ",x.desired_jobs," planned",u?"":` · projects ${S(x.projected_usd)} · rolling 30 days`]})]})]}),e.jsx(A,{tone:s.status,children:s.status})]})}),r&&e.jsx("div",{className:"cron-job-details",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"cron-section-heading",children:[e.jsx(we,{className:"h-4 w-4"}),e.jsx("h4",{children:"Scheduler evidence"})]}),e.jsx("div",{className:"cron-metric-card space-y-2 text-sm",children:[["Scheduler",s.execution_health.scheduler??"unknown"],["Last expected",v(s.execution_health.last_expected_at??null)],["Last started",v(s.execution_health.last_started_at??null)],["Last completed",v(s.execution_health.last_completed_at??null)],["Next expected",v(s.execution_health.next_expected_at??null)]].map(([n,f])=>e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"cron-label",children:n}),e.jsx("span",{children:f})]},n))})]}),s.work_metrics&&i&&e.jsx(Se,{icon:Ne,title:"Log Metrics",metrics:s.work_metrics}),s.db_metrics&&d&&e.jsx(Se,{icon:fe,title:"Database Metrics",metrics:s.db_metrics}),s.workflow_status&&e.jsx(As,{workflow:s.workflow_status}),o&&e.jsx(Es,{monitor:_.data,loading:_.isLoading,error:_.error}),s.diagnostic_groups&&Object.values(s.diagnostic_groups).some(n=>n.length>0)&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("div",{className:"cron-section-heading",children:[e.jsx(Ee,{className:"h-4 w-4"}),e.jsx("h4",{children:"Diagnostics by cause"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Object.entries(s.diagnostic_groups).filter(([,n])=>n.length>0).map(([n,f])=>e.jsxs("div",{className:"cron-metric-card",children:[e.jsx("div",{className:"cron-label mb-1",children:X(n)}),e.jsx("ul",{className:"list-disc pl-4 text-sm space-y-1",children:f.map(k=>e.jsx("li",{children:k},k))})]},n))})]}),s.health_findings&&s.health_findings.some(n=>n.state!=="healthy")&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("div",{className:"cron-section-heading",children:[e.jsx(Te,{className:"h-4 w-4"}),e.jsx("h4",{children:"Deterministic contract findings"})]}),e.jsxs("div",{className:"cron-metric-card space-y-3 text-sm",children:[s.health_findings.filter(n=>n.state!=="healthy").map(n=>e.jsxs("div",{children:[e.jsx(A,{tone:n.state,children:n.state})," ",e.jsx("strong",{children:X(n.contract)}),": ",n.summary,Object.entries(n.evidence).length>0&&e.jsx("div",{className:"mt-1 text-xs cron-muted",children:Object.entries(n.evidence).map(([f,k])=>e.jsxs("span",{className:"mr-3",children:[X(f),": ",String(k)]},f))})]},`${n.plane}-${n.contract}`)),e.jsxs("div",{className:"flex gap-4",children:[s.operator_url&&e.jsxs("a",{className:"cron-info-text inline-flex items-center gap-1",href:s.operator_url,children:["Open operator ",e.jsx(Y,{className:"h-3.5 w-3.5"})]}),s.run_url&&e.jsxs("a",{className:"cron-info-text inline-flex items-center gap-1",href:s.run_url,target:"_blank",rel:"noreferrer",children:["Open run ",e.jsx(Y,{className:"h-3.5 w-3.5"})]})]})]})]})]})})]})}const Ze=h.forwardRef(({className:s,...r},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:L("w-full caption-bottom text-sm",s),...r})}));Ze.displayName="Table";const es=h.forwardRef(({className:s,...r},t)=>e.jsx("thead",{ref:t,className:L("[&_tr]:border-b",s),...r}));es.displayName="TableHeader";const ss=h.forwardRef(({className:s,...r},t)=>e.jsx("tbody",{ref:t,className:L("[&_tr:last-child]:border-0",s),...r}));ss.displayName="TableBody";const qs=h.forwardRef(({className:s,...r},t)=>e.jsx("tfoot",{ref:t,className:L("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...r}));qs.displayName="TableFooter";const he=h.forwardRef(({className:s,...r},t)=>e.jsx("tr",{ref:t,className:L("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",s),...r}));he.displayName="TableRow";const z=h.forwardRef(({className:s,...r},t)=>e.jsx("th",{ref:t,className:L("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",s),...r}));z.displayName="TableHead";const K=h.forwardRef(({className:s,...r},t)=>e.jsx("td",{ref:t,className:L("p-4 align-middle [&:has([role=checkbox])]:pr-0",s),...r}));K.displayName="TableCell";const Is=h.forwardRef(({className:s,...r},t)=>e.jsx("caption",{ref:t,className:L("mt-4 text-sm text-muted-foreground",s),...r}));Is.displayName="TableCaption";const as={queued:"unknown",dispatching:"running",running:"running",completed:"healthy",failed:"broken",canceled:"unknown",awaiting_markdown:"unknown"},rs={queued:"queued",dispatching:"dispatching",running:"running",completed:"completed",failed:"failed",canceled:"canceled",awaiting_markdown:"waiting for Markdown"},Le={"add-evals":"Add evals","enrich-paper":"Enrich paper","resolve-model-paper":"Resolve model release","review-benchmark-gaps":"Review benchmark gaps","add-benchmark":"Add benchmark"},Ds={queued:ws,dispatching:R,running:bs,completed:je,failed:Z,canceled:ys,awaiting_markdown:ks};function Os({status:s}){const r=Ds[s];return e.jsxs(A,{tone:as[s],children:[e.jsx(r,{className:`mr-1 h-3.5 w-3.5 ${s==="dispatching"?"animate-spin":""}`}),rs[s]]})}function Js(s){return s.status==="awaiting_markdown"?_s:s.error?s.error:s.report?s.report:s.status==="completed"&&s.applied_at?"Changes applied to the paper.":s.status==="completed"?"Completed without a recorded mutation.":null}function Pe({mutationResult:s}){const r=s==null?void 0:s.skipped_configured_leaderboards;return!Array.isArray(r)||r.length===0?null:e.jsxs("div",{className:"mt-2 rounded border border-amber-500 bg-amber-50 p-2 text-xs text-amber-900",children:[e.jsxs("div",{className:"font-medium",children:["Skipped configured leaderboards (",r.length,")"]}),e.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-4",children:r.map((t,c)=>e.jsxs("li",{children:[t.benchmark," · ",t.disposition," · task ",t.task_id," / dataset ",t.dataset_id,t.metric?` / ${t.metric}`:"",t.value!=null?` = ${t.value}`:"",t.detail?` — ${t.detail}`:""]},c))})]})}function Bs({autoRefresh:s}){var I;const r=xe(),[t,c]=h.useState(""),[i,d]=h.useState(""),[o,_]=h.useState(""),[x,u]=h.useState(""),[p,n]=h.useState(""),[f,k]=h.useState({}),J={trigger:t,status:i,policy_version:o,cohort_date:x,review_status:p},{data:m,isLoading:Q,isFetching:ee,error:B}=G({queryKey:[...$.codexPaperJobs,J],queryFn:()=>M.listJobs(100,J),refetchInterval:s?1e4:!1,retry:!1}),T=()=>r.invalidateQueries({queryKey:$.codexPaperJobs}),se=P({mutationFn:a=>M.retryJob(a),onSuccess:T}),le=P({mutationFn:a=>M.cancelJob(a),onSuccess:T}),de=P({mutationFn:a=>M.retryTrace(a),onSuccess:T}),V=P({mutationFn:a=>M.setScheduler(a),onSuccess:T}),q=P({mutationFn:({id:a,dataset:l,task:w,metric:re})=>M.promoteBenchmarkCandidate(a,{dataset_id:Number(l),task_id:Number(w),best_metric:re.trim()}),onSuccess:T}),E=P({mutationFn:a=>M.rollbackBenchmarkCandidate(a),onSuccess:T}),ae=B instanceof Re&&B.status===404;return e.jsxs(g,{className:"mb-8",children:[e.jsx(N,{children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xl",children:"Codex paper jobs"}),e.jsx(F,{children:"Durable queue, two-stage daily workflows, traces, and benchmark-gap follow-up"})]}),ee&&!Q&&e.jsxs("span",{className:"flex items-center gap-2 text-xs cron-muted",children:[e.jsx(R,{className:"h-3.5 w-3.5 animate-spin"})," Syncing with Hugging Face"]})]})}),e.jsxs(j,{children:[Q&&e.jsxs("div",{className:"flex items-center justify-center py-10 cron-muted",children:[e.jsx(R,{className:"mr-2 h-5 w-5 animate-spin"})," Loading paper jobs…"]}),B&&!ae&&e.jsx("div",{className:"cron-message cron-message--error mb-4",children:B.message}),ae&&e.jsx("p",{className:"py-4 text-sm cron-muted",children:"Codex paper jobs are not enabled in this environment."}),m&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`cron-message mb-5 ${m.scheduler.paused_at?"cron-message--error":""}`,children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:["Scheduled dispatch: ",m.scheduler.paused_at?"paused":m.scheduler.dispatch_enabled?"enabled":"disabled"]}),m.scheduler.pause_reason&&e.jsx("div",{className:"mt-1 text-xs",children:m.scheduler.pause_reason}),e.jsxs("div",{className:"mt-1 text-xs cron-muted",children:["Canary ",m.scheduler.canary_released?"released":"active"," · Queue age ",m.scheduler.queue_age_level]}),e.jsxs("div",{className:"mt-1 text-xs cron-muted",children:["Scheduled usage today ",m.scheduler.usage.current_day_tokens.toLocaleString()," tokens · ",m.scheduler.usage.mode==="enforced"?`pause threshold ${((I=m.scheduler.usage.pause_threshold_tokens)==null?void 0:I.toLocaleString())??"not established"}`:"first-week alert-only baseline"," · trailing median ",m.scheduler.usage.trailing_seven_day_median_tokens.toLocaleString()]})]}),e.jsx(y,{size:"sm",variant:m.scheduler.paused_at||!m.scheduler.dispatch_enabled?"default":"outline",disabled:V.isPending,onClick:()=>V.mutate(m.scheduler.paused_at||!m.scheduler.dispatch_enabled?"resume":"pause"),children:m.scheduler.paused_at?"Acknowledge & resume":m.scheduler.dispatch_enabled?"Pause scheduled dispatch":"Enable scheduled dispatch"})]})}),e.jsxs("div",{className:"mb-5 grid grid-cols-2 gap-3 sm:grid-cols-4 lg:grid-cols-8",children:[["queued","awaiting_markdown","dispatching","running","completed","failed","canceled"].map(a=>e.jsxs("div",{className:"cron-metric-card",children:[e.jsx("div",{className:"cron-label capitalize",children:rs[a]}),e.jsx("div",{className:"mt-1 text-xl font-semibold",children:m.summary[a]})]},a)),e.jsxs("div",{className:"cron-metric-card",children:[e.jsx("div",{className:"cron-label",children:"Total"}),e.jsx("div",{className:"mt-1 text-xl font-semibold",children:m.summary.total})]})]}),e.jsxs("div",{className:"mb-5 grid gap-3 sm:grid-cols-5",children:[e.jsxs("select",{"aria-label":"Trigger",className:"rounded border px-2 py-1 text-sm",value:t,onChange:a=>c(a.target.value),children:[e.jsx("option",{value:"",children:"All triggers"}),e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"hf-daily-cron",children:"HF daily cron"}),e.jsx("option",{value:"hf-trending-cron",children:"HF trending cron"}),e.jsx("option",{value:"benchmark-gap-cron",children:"Benchmark gap cron"}),e.jsx("option",{value:"model-release-radar",children:"Release radar"})]}),e.jsxs("select",{"aria-label":"Status",className:"rounded border px-2 py-1 text-sm",value:i,onChange:a=>d(a.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),Object.keys(as).map(a=>e.jsx("option",{children:a},a))]}),e.jsx("input",{"aria-label":"Policy version",className:"rounded border px-2 py-1 text-sm",placeholder:"Policy version",value:o,onChange:a=>_(a.target.value)}),e.jsx("input",{"aria-label":"Cohort date",type:"date",className:"rounded border px-2 py-1 text-sm",value:x,onChange:a=>u(a.target.value)}),e.jsxs("select",{"aria-label":"Review status",className:"rounded border px-2 py-1 text-sm",value:p,onChange:a=>n(a.target.value),children:[e.jsx("option",{value:"",children:"All review states"}),e.jsx("option",{value:"unreviewed",children:"Unreviewed"}),e.jsx("option",{value:"approved",children:"Approved"}),e.jsx("option",{value:"corrected",children:"Corrected"})]})]}),m.jobs.length===0?e.jsx("p",{className:"py-8 text-center text-sm cron-muted",children:"No paper curation jobs have been submitted yet."}):e.jsxs(Ze,{children:[e.jsx(es,{children:e.jsxs(he,{children:[e.jsx(z,{children:"Status"}),e.jsx(z,{children:"Paper"}),e.jsx(z,{children:"Action"}),e.jsx(z,{children:"Requested"}),e.jsx(z,{children:"Execution"})]})}),e.jsx(ss,{children:m.jobs.map(a=>{const l=Js(a);return e.jsxs(he,{children:[e.jsx(K,{className:"align-top",children:e.jsx(Os,{status:a.status})}),e.jsx(K,{className:"min-w-[260px] align-top",children:a.paper_route?e.jsxs(e.Fragment,{children:[e.jsx(pe,{to:`/paper/${encodeURIComponent(a.paper_route)}`,className:"font-medium hover:underline",children:a.paper_title}),e.jsxs("div",{className:"mt-1 text-xs cron-muted",children:["Paper #",a.paper_id]})]}):a.kind==="review-benchmark-gaps"?e.jsx("span",{className:"font-medium",children:"Benchmark-gap backlog"}):a.kind==="add-benchmark"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"Benchmark candidate"}),e.jsx("div",{className:"mt-1 text-xs cron-muted",children:a.benchmark_candidate_id})]}):a.release_signal_id?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"Release radar signal"}),e.jsxs("div",{className:"mt-1 text-xs cron-muted",children:["Signal ",a.release_signal_id]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"Trending model discovery"}),e.jsxs("div",{className:"mt-1 text-xs cron-muted",children:["Candidate ",a.candidate_id]})]})}),e.jsxs(K,{className:"whitespace-nowrap align-top",children:[Le[a.kind],a.applied_at&&e.jsxs("div",{className:"mt-1 flex items-center gap-1 text-xs cron-status--healthy",children:[e.jsx(je,{className:"h-3.5 w-3.5"})," Applied"]})]}),e.jsxs(K,{className:"whitespace-nowrap align-top",children:[e.jsx("div",{children:v(a.created_at)}),e.jsxs("div",{className:"mt-1 text-xs cron-muted",children:["@",a.requested_by]})]}),e.jsxs(K,{className:"max-w-[360px] align-top",children:[a.hf_job_url?e.jsxs("a",{href:a.hf_job_url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 hover:underline",children:["Hugging Face Job ",e.jsx(Y,{className:"h-3.5 w-3.5"})]}):e.jsx("span",{className:"cron-muted",children:"Waiting to dispatch"}),l&&e.jsx("p",{className:`mt-2 line-clamp-3 text-xs ${a.error&&a.status!=="awaiting_markdown"?"text-red-700":"cron-muted"}`,title:l,children:l}),e.jsx(Pe,{mutationResult:a.mutation_result}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[["failed","canceled"].includes(a.status)&&e.jsx(y,{size:"sm",variant:"outline",onClick:()=>se.mutate(a.id),children:"Retry"}),["queued","awaiting_markdown","dispatching","running"].includes(a.status)&&e.jsx(y,{size:"sm",variant:"outline",onClick:()=>le.mutate(a.id),children:"Cancel"}),a.trace_status==="finalize_failed"&&e.jsx(y,{size:"sm",variant:"outline",onClick:()=>de.mutate(a.id),children:"Retry trace"})]})]})]},a.id)})})]}),m.workflows.length>0&&e.jsxs("div",{className:"mt-8 space-y-3",children:[e.jsx("h3",{className:"text-base font-semibold",children:"Scheduled paper workflows"}),m.workflows.map(a=>e.jsxs("details",{className:"rounded-md border p-3",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium",children:["Paper #",a.paper_id," · ",a.cohort_date," · ",a.status," · ",a.policy_version]}),e.jsxs("div",{className:"mt-3 space-y-3 text-xs",children:[a.error&&e.jsx("div",{className:"text-red-700",children:a.error}),a.stages.map(l=>{var w;return e.jsxs("div",{className:"rounded border p-3",children:[e.jsxs("div",{className:"font-medium",children:[Le[l.kind]," · ",l.status," · trace ",l.trace_status," · review ",l.audit_status]}),e.jsxs("div",{className:"mt-1 cron-muted",children:["model ",l.model??"—"," · reasoning ",l.reasoning_effort??"—"," · tokens ",(l.input_tokens??0)+(l.output_tokens??0)," · duration ",l.duration_ms??0," ms · attempts ",l.attempt_count]}),l.error&&e.jsx("div",{className:"mt-2 text-red-700",children:l.error}),l.report&&e.jsx("div",{className:"mt-2 whitespace-pre-wrap rounded border p-2",children:l.report}),l.url_candidates&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{children:"URL candidates and provenance"}),e.jsx("pre",{className:"mt-2 max-h-52 overflow-auto whitespace-pre-wrap",children:JSON.stringify(l.url_candidates,null,2)})]}),l.validation_summary&&e.jsx("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap",children:JSON.stringify(l.validation_summary,null,2)}),Array.isArray((w=l.validation_summary)==null?void 0:w.manual_or_legacy_evaluation_rows_affected)&&l.validation_summary.manual_or_legacy_evaluation_rows_affected.length>0&&e.jsxs("div",{className:"mt-2 rounded border border-amber-500 bg-amber-50 p-2 font-medium text-amber-900",children:["Manual or legacy evaluation rows changed: ",l.validation_summary.manual_or_legacy_evaluation_rows_affected.join(", "),". Review the evidence and before/after diff."]}),l.proposal&&e.jsx("pre",{className:"mt-2 max-h-52 overflow-auto whitespace-pre-wrap",children:JSON.stringify(l.proposal,null,2)}),e.jsx(Pe,{mutationResult:l.mutation_result}),l.mutation_result&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{children:"Accepted callback result and before/after state"}),e.jsx("pre",{className:"mt-2 max-h-64 overflow-auto whitespace-pre-wrap",children:JSON.stringify(l.mutation_result,null,2)})]}),l.trace_status==="complete"&&e.jsxs("a",{className:"mt-2 inline-flex items-center gap-1 hover:underline",href:M.traceUrl(l.id),target:"_blank",rel:"noreferrer",children:["Authenticated trace manifest ",e.jsx(Y,{className:"h-3.5 w-3.5"})]})]},l.id)})]})]},a.id))]}),m.benchmark_candidates.length>0&&e.jsxs("div",{className:"mt-8 space-y-3",children:[e.jsx("h3",{className:"text-base font-semibold",children:"Benchmark-gap backlog"}),m.benchmark_candidates.map(a=>{var re,_e;const l=f[a.id]??{dataset:"",task:((re=a.task_ids[0])==null?void 0:re.toString())??"",metric:""},w=Number(l.dataset)>0&&Number(l.task)>0&&l.metric.trim().length>0;return e.jsxs("div",{className:"rounded-md border p-3 text-xs",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"font-medium",children:[a.canonical_name," · ",a.gap_type," · ",a.status]}),e.jsxs("div",{className:"cron-muted",children:[a.distinct_paper_count," paper",a.distinct_paper_count===1?"":"s"," · ",a.confidence??"unknown"," confidence"]})]}),a.canonical_url&&e.jsx("a",{className:"mt-1 block hover:underline",href:a.canonical_url,target:"_blank",rel:"noreferrer",children:a.canonical_url}),e.jsxs("div",{className:"mt-1 cron-muted",children:["Task evidence: ",a.task_ids.join(", ")||"none"," · Papers: ",a.evidence_paper_ids.join(", ")]}),a.review_reason&&e.jsxs("div",{className:"mt-1",children:["Review",a.reviewed_at?` ${v(a.reviewed_at)}`:"",": ",a.review_reason,a.deferred_until&&` · deferred until ${v(a.deferred_until)}`]}),a.resolution&&e.jsxs("div",{className:"mt-1 cron-muted",children:["Dataset #",a.resolution.dataset_id," · task #",a.resolution.task_id," · ",a.resolution.primary_metric,a.resolution.rolled_back_at&&` · rolled back ${v(a.resolution.rolled_back_at)}`]}),a.status==="promoted"&&((_e=a.resolution)==null?void 0:_e.created)&&!a.resolution.rolled_back_at&&e.jsx(y,{className:"mt-2",size:"sm",variant:"outline",disabled:E.isPending,onClick:()=>E.mutate(a.id),children:"Roll back automatic benchmark"}),!["promoted","merged"].includes(a.status)&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[["dataset","task","metric"].map(U=>e.jsx("input",{"aria-label":`${a.canonical_name} ${U}`,className:"w-36 rounded border px-2 py-1",placeholder:U==="metric"?"Exact metric":`${U} ID`,value:l[U],onChange:ns=>k(ts=>({...ts,[a.id]:{...l,[U]:ns.target.value}}))},U)),e.jsx(y,{size:"sm",variant:"outline",disabled:!w||q.isPending,onClick:()=>q.mutate({id:a.id,...l}),children:"Promote & requeue evidence papers"})]})]},a.id)}),q.error&&e.jsx("div",{className:"cron-message cron-message--error",children:q.error.message}),E.error&&e.jsx("div",{className:"cron-message cron-message--error",children:E.error.message})]}),e.jsxs("p",{className:"mt-4 text-xs cron-muted",children:["Showing the 100 most recent jobs · Queue totals include full history · Updated ",v(m.timestamp)]})]})]})]})}function Us(){const[s,r]=h.useState(()=>new Date().toISOString().slice(0,10)),[t,c]=h.useState(1),i=G({queryKey:["paper-edit-digest",s,t],queryFn:()=>Me.digest(s,t),enabled:!!s});return e.jsxs("section",{className:"space-y-3 rounded border p-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Daily paper edits"}),e.jsxs("label",{className:"flex items-center gap-2",children:["UTC date ",e.jsx("input",{type:"date",value:s,onChange:d=>{r(d.target.value),c(1)}})]}),i.isLoading&&e.jsx("p",{children:"Loading daily summary…"}),i.error&&e.jsx("p",{role:"alert",children:i.error.message}),i.data&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[i.data.edits," published changes · ",i.data.papers," papers · ",i.data.contributors," contributors"]}),e.jsx("ul",{className:"space-y-1",children:i.data.rows.map((d,o)=>e.jsxs("li",{children:[e.jsxs(pe,{className:"underline",to:`/paper/${d.paper_id}`,children:["Paper ",d.paper_id]})," · @",d.actor_username??"admin"," · ",d.edits," changes"]},o))}),e.jsxs("div",{className:"flex gap-2",children:[t>1&&e.jsx(y,{variant:"outline",onClick:()=>c(t-1),children:"Previous"}),i.data.has_more&&e.jsx(y,{variant:"outline",onClick:()=>c(t+1),children:"Next"})]})]})]})}const Hs=()=>{var _,x,u,p;const s=xe(),r=fs({queryKey:$.catalogAudit,queryFn:({pageParam:n})=>me.audit(n),initialPageParam:void 0,getNextPageParam:n=>n.next_cursor??void 0}),t=((_=r.data)==null?void 0:_.pages.flatMap(n=>n.events))??[],c=()=>s.invalidateQueries({queryKey:$.catalogAudit}),i=P({mutationFn:()=>me.acknowledgeAudit(),onSuccess:c}),d=P({mutationFn:n=>me.rollbackEvent(n),onSuccess:c}),o=P({mutationFn:({subject:n,suspended:f})=>Me.suspend(n,f),onSuccess:c});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Us,{}),(d.error||o.error)&&e.jsx("p",{role:"alert",children:(x=d.error||o.error)==null?void 0:x.message}),e.jsxs(g,{children:[e.jsxs(N,{className:"flex-row items-center justify-between",children:[e.jsx(b,{children:"Catalog mutation audit"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[((p=(u=r.data)==null?void 0:u.pages[0])==null?void 0:p.unread_contributor_count)??0," unread contributor changes"]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>i.mutate(),disabled:i.isPending,children:"Mark read"})]})]}),e.jsxs(j,{className:"space-y-3",children:[r.isLoading&&e.jsx("p",{children:"Loading audit history…"}),r.error&&e.jsx("p",{className:"text-destructive",children:"Audit history unavailable."}),t.map(n=>e.jsxs("article",{className:`rounded-md border p-3 ${n.operation==="delete"||n.rollback_eligible===!1?"border-red-500 bg-red-50/50":""}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("strong",{children:[n.operation," ",n.entity_type," ",n.entity_id]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",n.actor_username??n.actor_role," ·"," ",new Date(n.created_at).toLocaleString()]})]}),e.jsxs("details",{className:"mt-2 text-xs",children:[e.jsx("summary",{children:"Inspect snapshots"}),e.jsx("pre",{className:"mt-2 max-h-80 overflow-auto rounded bg-muted p-3",children:JSON.stringify({before:n.before,after:n.after},null,2)})]}),n.actor_role==="contributor"&&n.actor_hf_subject&&e.jsx(y,{className:"mt-3 mr-2",variant:"outline",size:"sm",disabled:o.isPending,onClick:()=>o.mutate({subject:n.actor_hf_subject,suspended:!n.editing_suspended}),children:n.editing_suspended?"Restore editing access":"Suspend editing access"}),!n.rollback_of_event_id&&e.jsx(y,{className:"mt-3",variant:"outline",size:"sm",onClick:()=>d.mutate(n.id),disabled:d.isPending||n.rollback_eligible===!1,children:n.rollback_eligible===!1?"Rollback conflict":"Roll back if unchanged"})]},n.id)),r.hasNextPage&&e.jsx(y,{variant:"outline",onClick:()=>r.fetchNextPage(),disabled:r.isFetchingNextPage,children:r.isFetchingNextPage?"Loading…":"Load older events"})]})]})]})},Fe={hourly:"running",daily:"healthy",weekly:"degraded",systemd:"running"},Ws=({data:s,loading:r,error:t})=>{const[c,i]=h.useState("staging-current"),d={"staging-current":"Starter staging · $75 warning / $100 trip / no Environment cap","staging-production-era":"Staging with production · $15 / $20 / $25",production:"Production · $175 / $200 / $225"};if(r)return e.jsxs("div",{className:"flex items-center py-12",children:[e.jsx(R,{className:"h-6 w-6 animate-spin mr-3"}),"Loading chat compute…"]});if(t||!s)return e.jsx(g,{className:"cron-status--broken",children:e.jsx(j,{className:"pt-6",children:"Chat compute accounting is unavailable."})});const o=Math.min(100,s.effective_microusd/s.application_cap_microusd*100),_=s.circuit_state==="tripped"?"Chat disabled":s.circuit_state==="warning"?"Operator warning":"Enabled",x=s.reconciliation_state==="fresh"?"Fresh":s.reconciliation_state==="stale"?"Stale":"Unavailable";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid md:grid-cols-4 gap-4",children:[e.jsxs(g,{className:s.circuit_state==="tripped"?"cron-status--broken":s.circuit_state==="warning"?"cron-status--degraded":"",children:[e.jsx(N,{children:e.jsx(b,{className:"text-sm",children:"Circuit"})}),e.jsxs(j,{children:[e.jsx("div",{className:"text-2xl font-bold",children:_}),e.jsx("p",{className:"text-xs cron-muted",children:s.trip_reason??"Policy armed"})]})]}),e.jsxs(g,{children:[e.jsx(N,{children:e.jsx(b,{className:"text-sm",children:"Month to date"})}),e.jsxs(j,{children:[e.jsx("div",{className:"text-2xl font-bold",children:C(s.effective_microusd)}),e.jsx("div",{role:"progressbar","aria-label":"Application cap used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o),className:"h-2 rounded bg-muted mt-3",children:e.jsx("div",{className:"h-2 rounded bg-primary",style:{width:`${o}%`}})})]})]}),e.jsxs(g,{children:[e.jsx(N,{children:e.jsx(b,{className:"text-sm",children:"Application headroom"})}),e.jsxs(j,{children:[e.jsx("div",{className:"text-2xl font-bold",children:C(s.remaining_microusd)}),e.jsxs("p",{className:"text-xs cron-muted",children:["Cap ",C(s.application_cap_microusd)]})]})]}),e.jsxs(g,{children:[e.jsx(N,{children:e.jsx(b,{className:"text-sm",children:"Live compute"})}),e.jsxs(j,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.live_count}),e.jsxs("p",{className:"text-xs cron-muted",children:[s.termination_uncertain_count," termination uncertain"]})]})]})]}),e.jsxs(g,{children:[e.jsxs(N,{children:[e.jsx(b,{children:"Accounting and policy"}),e.jsxs(F,{children:[s.environment," · cycle ",s.billing_cycle]})]}),e.jsxs(j,{className:"grid md:grid-cols-3 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Environment record"}),e.jsx("br",{}),s.environment," · ",s.provider_mode==="starter_workspace"?"Starter Workspace":"Team isolated"]}),e.jsxs("label",{children:[e.jsx("strong",{children:"Policy profile"}),e.jsxs("select",{"aria-label":"Chat compute policy profile",value:c,onChange:u=>i(u.target.value),className:"block mt-1",children:[e.jsx("option",{value:"staging-current",children:"Staging now"}),e.jsx("option",{value:"staging-production-era",children:"Staging with production"}),e.jsx("option",{value:"production",children:"Production"})]}),e.jsxs("span",{className:"text-xs cron-muted",children:[d[c]," · Workspace $250"]})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Conservative estimate"}),e.jsx("br",{}),C(s.estimated_microusd)]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Provider-reported floor"}),e.jsx("br",{}),C(s.provider_floor_microusd)," · ",e.jsx(D,{children:x})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Provider backstops"}),e.jsx("br",{}),s.environment_cap_microusd===null?"Starter: no Environment cap":`Environment ${C(s.environment_cap_microusd)}`," · Workspace ",C(s.workspace_cap_microusd)]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Active thresholds"}),e.jsx("br",{}),"Warning ",C(s.warning_microusd)," · trip ",C(s.application_cap_microusd)]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Policy allocation"}),e.jsx("br",{}),"Starter staging $75/$100 with no Environment cap · future Team staging $15/$20/$25 · production $175/$200/$225 · workspace $250"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Cycle end"}),e.jsx("br",{}),v(s.cycle_end_at)]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Last metered"}),e.jsx("br",{}),s.last_metered_at?v(s.last_metered_at):"Unavailable"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Provider reconciliation"}),e.jsx("br",{}),s.last_reconciled_at?v(s.last_reconciled_at):"Unavailable",s.last_reconciliation_attempt_at?` · attempted ${v(s.last_reconciliation_attempt_at)}`:"",s.next_reconciliation_at?` · next ${v(s.next_reconciliation_at)}`:""]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Burn projection"}),e.jsx("br",{}),s.burn_rate_microusd_per_hour===null?"Not enough data":`${C(s.burn_rate_microusd_per_hour)}/hour${s.projected_cap_hit_at?` · cap ${v(s.projected_cap_hit_at)}`:""}`]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Prior cycle"}),e.jsx("br",{}),s.prior_cycle?`${s.prior_cycle.billing_cycle} · ${C(s.prior_cycle.effective_microusd)}`:"Not enough data"]})]})]}),e.jsxs(g,{children:[e.jsx(N,{children:e.jsx(b,{children:"Live lifecycle"})}),e.jsx(j,{className:"text-sm",children:Object.entries(s.live_states).map(([u,p])=>e.jsxs("span",{className:"mr-4",children:[u,": ",p]},u))})]}),e.jsxs(g,{children:[e.jsx(N,{children:e.jsx(b,{children:"Daily spend"})}),e.jsx(j,{children:s.daily_spend.length?e.jsx("ul",{className:"space-y-1 text-sm",children:s.daily_spend.map(u=>e.jsxs("li",{children:[u.date,": blank ",C(u.blank_pool_microusd)," · assigned ",C(u.assigned_microusd)]},u.date))}):e.jsx("p",{className:"cron-muted",children:"No compute recorded in this cycle."})})]}),e.jsxs(g,{children:[e.jsxs(N,{children:[e.jsx(b,{children:"Recent circuit events"}),e.jsx(F,{children:"Runbook: docs/chat-sandbox-spend-runbook.md"})]}),e.jsx(j,{children:s.events.length?e.jsx("ul",{className:"space-y-2 text-sm",children:s.events.map(u=>e.jsxs("li",{children:[e.jsx(D,{children:u.severity})," ",u.type," · ",v(u.created_at)]},u.id))}):e.jsx("p",{className:"cron-muted",children:"No events in this cycle."})})]})]})},zs=({data:s,loading:r,error:t})=>{if(r)return e.jsxs("div",{className:"flex items-center py-8",children:[e.jsx(R,{className:"h-5 w-5 animate-spin mr-3"}),"Loading web-search budget…"]});if(t||!s)return e.jsx(g,{className:"cron-status--broken",children:e.jsx(j,{className:"pt-6",children:"Web-search budget accounting is unavailable."})});const c=Math.min(100,s.call_count/s.hard_limit_calls*100);return e.jsxs(g,{className:s.circuit_state==="tripped"?"cron-status--broken":s.circuit_state==="warning"||s.circuit_state==="cooldown"?"cron-status--degraded":"",children:[e.jsxs(N,{children:[e.jsx(b,{children:"Web search"}),e.jsxs(F,{children:[s.environment," · UTC cycle ",s.billing_cycle," · provider details are admin-only"]})]}),e.jsxs(j,{className:"space-y-4",children:[e.jsxs("div",{className:"grid md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Circuit"}),e.jsx("br",{}),s.circuit_state,s.trip_reason?` · ${s.trip_reason}`:""]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Calls"}),e.jsx("br",{}),s.call_count," / ",s.hard_limit_calls," · ",s.success_count," successful"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Remaining"}),e.jsx("br",{}),s.remaining_calls]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Warning"}),e.jsx("br",{}),s.warning_calls," calls"]})]}),e.jsx("div",{role:"progressbar","aria-label":"Web-search monthly budget used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(c),className:"h-2 rounded bg-muted",children:e.jsx("div",{className:"h-2 rounded bg-primary",style:{width:`${c}%`}})}),e.jsxs("p",{className:"text-xs cron-muted",children:["Cycle ends ",v(s.cycle_end_at)," · provider-reported cost $",(s.provider_cost_microusd/1e6).toFixed(4),s.last_latency_ms!==null?` · last ${s.last_latency_ms} ms / ${s.last_result_count??0} results`:"",s.cooldown_until?` · cooldown until ${v(s.cooldown_until)}`:"",s.last_provider_error_class?` · last provider error ${s.last_provider_error_class}`:""]}),s.events.length>0&&e.jsx("ul",{className:"space-y-1 text-sm",children:s.events.map(i=>e.jsxs("li",{children:[i.type," · ",v(i.created_at),i.error_class?` · ${i.error_class}`:""]},i.id))})]})]})},Ks=({data:s})=>s!=null&&s.snapshot_stale?e.jsx(g,{className:"mb-6 cron-status--degraded",role:"status",children:e.jsx(j,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsx(R,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{children:["Refreshing status… Current snapshot is ",Math.ceil(s.snapshot_age_seconds)," seconds old."]})]})})}):null,Gs=(s,r)=>s!=null&&s.snapshot_stale||s!=null&&s.refreshing?5e3:r?3e4:!1,pa=()=>{const s=xs(),r=xe(),[t,c]=h.useState(!0),[i,d]=h.useState(""),[o,_]=h.useState(""),[x,u]=h.useState(new Set),{user:p}=hs(),{data:n,isLoading:f,error:k}=G({queryKey:$.cronStatus,queryFn:()=>ue.getCronStatus(),refetchInterval:a=>Gs(a.state.data,t),retry:!1}),J=G({queryKey:$.chatSandboxSpend(o),queryFn:()=>ye.getSandboxSpend(o||void 0),refetchInterval:t?3e4:!1,retry:!1}),m=G({queryKey:$.chatWebSearchBudget,queryFn:()=>ye.getWebSearchBudget(),enabled:s,refetchInterval:t?3e4:!1,retry:!1}),Q=P({mutationFn:()=>Promise.all([r.cancelQueries({queryKey:$.cronStatus}).then(()=>r.fetchQuery({queryKey:$.cronStatus,queryFn:()=>ue.getCronStatus(!0),retry:!1})),r.refetchQueries({queryKey:$.all,type:"active",predicate:a=>a.queryKey[1]!==$.cronStatus[1]})])}),ee=k instanceof Re&&k.status===401?"Unauthorized. Sign in with an allowlisted Hugging Face admin account.":k instanceof Error?k.message:void 0,B=a=>{u(l=>{const w=new Set(l);return w.has(a)?w.delete(a):w.add(a),w})},T=(n==null?void 0:n.jobs.filter(a=>a.dashboard_group==="leaderboard_sync"))??[],se=(n==null?void 0:n.jobs.filter(a=>a.category!=="manual"&&a.dashboard_group!=="leaderboard_sync"))??[],le=se.filter(a=>a.critical),de=se.filter(a=>!a.critical),V=(n==null?void 0:n.manual_operations)??[],q=!!(f||Q.isPending||n!=null&&n.refreshing),E=de.reduce((a,l)=>(a[l.category]||(a[l.category]=[]),a[l.category].push(l),a),{}),ae=Object.keys(E).sort((a,l)=>{const w=["systemd","hourly","daily","weekly","backfill"];return w.indexOf(a)-w.indexOf(l)}),I=a=>e.jsx(Ms,{job:a,expanded:x.has(a.job_name),onToggle:()=>B(a.job_name),autoRefresh:t},a.job_name);return e.jsx("div",{className:"cron-dashboard","data-shadcn":!0,children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[e.jsx("div",{className:"mb-8",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center gap-3",children:[e.jsx(ne,{className:"h-8 w-8 cron-info-text"}),"Admin Dashboard"]}),e.jsx("p",{className:"mt-2 cron-muted",children:"Paper curation queue and operational health for scheduled jobs"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(y,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(pe,{to:"/autonomous-operations",children:"Autonomous operations"})}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>c(!t),className:t?"cron-status--running":"",children:[e.jsx(be,{className:`h-4 w-4 mr-2 ${t?"animate-spin":""}`}),"Auto-refresh ",t?"ON":"OFF"]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>Q.mutate(),disabled:q,children:[e.jsx(be,{className:`h-4 w-4 mr-2 ${q?"animate-spin":""}`}),"Refresh"]})]})]})}),e.jsx(g,{className:"mb-6",children:e.jsx(j,{className:"pt-6",children:e.jsxs("p",{className:"text-sm cron-muted",children:["Signed in as ",e.jsxs("span",{className:"font-semibold",children:["@",p==null?void 0:p.username]}),". Health checks prefer database freshness over log completion so silent no-work failures surface as degraded or broken. Expanded jobs include deterministic scheduler, log, lock, durable-data, throughput, backlog, and semantic contract evidence with direct operator and run links."]})})}),e.jsx(Ks,{data:n}),e.jsxs(Ls,{defaultValue:"critical-jobs",children:[e.jsxs(Xe,{className:"grid h-auto w-full grid-cols-2 sm:w-auto sm:grid-cols-5",children:[e.jsx(H,{value:"critical-jobs",children:"Critical Jobs"}),e.jsx(H,{value:"leaderboard-syncs",children:"Leaderboard Syncs"}),e.jsx(H,{value:"codex-paper-jobs",children:"Codex Paper Jobs"}),e.jsx(H,{value:"catalog-audit",children:"Catalog Audit"}),e.jsx(H,{value:"chat-compute",children:"Chat Compute"})]}),e.jsxs(W,{value:"critical-jobs",className:"mt-6",children:[f&&e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(R,{className:"h-8 w-8 animate-spin cron-info-text"}),e.jsx("span",{className:"ml-3 cron-muted",children:"Loading CRON jobs status..."})]}),k&&e.jsx(g,{className:"cron-status--broken",children:e.jsx(j,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Z,{className:"h-5 w-5"}),e.jsx("p",{children:ee??"Failed to load CRON jobs status. Please try again."})]})})}),n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-6",children:["healthy","degraded","broken","running","stuck","unknown"].map(a=>e.jsxs(g,{children:[e.jsx(N,{className:"pb-2",children:e.jsx(b,{className:"text-sm font-medium cron-muted capitalize",children:a})}),e.jsx(j,{children:e.jsx("div",{className:"text-2xl font-bold",children:n.summary[a]})})]},a))}),n.summary.critical_issues.length>0&&e.jsxs(g,{className:"mb-6 cron-status--broken",children:[e.jsx(N,{children:e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Te,{className:"h-5 w-5"}),"Critical job issues"]})}),e.jsx(j,{children:e.jsx("ul",{className:"list-disc pl-5 space-y-1 text-sm",children:n.summary.critical_issues.map(a=>e.jsx("li",{children:a},a))})})]}),e.jsxs(g,{className:"mb-8",children:[e.jsx(N,{children:e.jsx(b,{className:"text-base",children:"What to check next"})}),e.jsxs(j,{children:[e.jsx("p",{className:"text-sm cron-muted",children:n.summary.what_to_check_next}),e.jsxs("p",{className:"mt-2 text-xs cron-muted flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4"}),"Last updated: ",v(n.timestamp)," · Health score:"," ",n.summary.health_score.toFixed(0),"%"]})]})]}),e.jsxs(g,{className:`mb-8 ${n.summary.coverage.coverage_gaps?"cron-status--broken":""}`,children:[e.jsxs(N,{children:[e.jsx(b,{className:"text-base",children:"Coverage"}),e.jsx(F,{children:"Registry and deployed scheduler inventory"})]}),e.jsxs(j,{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"cron-label",children:"Registered"}),e.jsx("div",{className:"text-2xl font-bold",children:n.summary.coverage.registered_scheduled_duties})]}),e.jsxs("div",{children:[e.jsx("span",{className:"cron-label",children:"Discovered"}),e.jsx("div",{className:"text-2xl font-bold",children:n.summary.coverage.discovered_scheduled_duties})]}),e.jsxs("div",{children:[e.jsx("span",{className:"cron-label",children:"Monitored"}),e.jsx("div",{className:"text-2xl font-bold",children:n.summary.coverage.monitored_duties})]}),e.jsxs("div",{children:[e.jsx("span",{className:"cron-label",children:"Gaps"}),e.jsx("div",{className:"text-2xl font-bold",children:n.summary.coverage.coverage_gaps})]})]})]}),e.jsxs(g,{className:"mb-8",children:[e.jsxs(N,{children:[e.jsx(b,{className:"text-xl",children:"Critical jobs"}),e.jsx(F,{children:"Writers whose stale output breaks the live site"})]}),e.jsx(j,{className:"space-y-4",children:le.map(I)})]}),e.jsx("div",{className:"space-y-6",children:ae.map(a=>e.jsxs(g,{children:[e.jsx(N,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(b,{className:"text-xl capitalize flex items-center gap-2",children:[e.jsx(D,{className:ge(Fe[a]??Fe.hourly),children:a}),e.jsx("span",{children:"Supporting jobs"})]}),e.jsxs(F,{children:[E[a].length," job",E[a].length!==1?"s":""]})]})}),e.jsx(j,{className:"space-y-4",children:E[a].map(I)})]},a))}),V.length>0&&e.jsxs(g,{className:"mt-6",children:[e.jsxs(N,{children:[e.jsx(b,{className:"text-xl",children:"Manual operations"}),e.jsx(F,{children:"Visible invocation history; excluded from scheduled health and coverage"})]}),e.jsx(j,{className:"space-y-4",children:V.map(I)})]})]})]}),e.jsxs(W,{value:"leaderboard-syncs",className:"mt-6",children:[f&&e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(R,{className:"h-8 w-8 animate-spin cron-info-text"}),e.jsx("span",{className:"ml-3 cron-muted",children:"Loading leaderboard sync status..."})]}),k&&e.jsx(g,{className:"cron-status--broken",children:e.jsx(j,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Z,{className:"h-5 w-5"}),e.jsx("p",{children:ee??"Failed to load leaderboard sync status. Please try again."})]})})}),n&&e.jsxs(g,{children:[e.jsx(N,{children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xl",children:"Leaderboard syncs"}),e.jsx(F,{children:"Recurring imports from externally maintained benchmark leaderboards"})]}),e.jsxs(D,{children:[T.length," jobs"]})]})}),e.jsx(j,{className:"space-y-4",children:T.map(I)})]})]}),e.jsx(W,{value:"codex-paper-jobs",className:"mt-6",children:e.jsx(Bs,{autoRefresh:t})}),e.jsx(W,{value:"catalog-audit",className:"mt-6",children:e.jsx(Hs,{})}),e.jsxs(W,{value:"chat-compute",className:"mt-6",children:[e.jsxs(g,{className:"mb-6",children:[e.jsxs(N,{children:[e.jsx(b,{children:"Environment record"}),e.jsx(F,{children:"Leave blank for live staging, or enter the isolated environment printed by the spend qualification command."})]}),e.jsxs(j,{className:"flex gap-2",children:[e.jsx("input",{"aria-label":"Chat compute environment record",value:i,onChange:a=>d(a.target.value),placeholder:"staging-q-example",className:"flex-1 rounded border px-3 py-2"}),e.jsx(y,{onClick:()=>_(i.trim()),children:"Load"})]})]}),e.jsx(Ws,{data:J.data,loading:J.isLoading,error:J.error}),s&&e.jsx("div",{className:"mt-6",children:e.jsx(zs,{data:m.data,loading:m.isLoading,error:m.error})})]})]})]})})};export{Ws as ChatComputePanel,Ks as CronSnapshotNotice,Gs as cronStatusRefetchInterval,pa as default}; diff --git a/assets/CronDashboard-qYV75PLc.js b/assets/CronDashboard-Di5xM1py.js similarity index 97% rename from assets/CronDashboard-qYV75PLc.js rename to assets/CronDashboard-Di5xM1py.js index e0f6c9d268dae7a7d6cf7b6df61eb6d9535f71ea..5294b2f8548ee218076d236f211d3dfba2550e79 100644 --- a/assets/CronDashboard-qYV75PLc.js +++ b/assets/CronDashboard-Di5xM1py.js @@ -1,4 +1,4 @@ -import{s as c,d as a,j as r,G as n,ac as u}from"./index-DyXq7-Tg.js";/** +import{s as c,d as a,j as r,I as n,ac as u}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/ExternalSourceEvalBadge-K3r45EmO.js b/assets/ExternalSourceEvalBadge-B3fyun97.js similarity index 94% rename from assets/ExternalSourceEvalBadge-K3r45EmO.js rename to assets/ExternalSourceEvalBadge-B3fyun97.js index c88a555b62e6e4ed2fe2d8cf1acf9c8b34c74e5d..aaf4b2473c14cde055428ded0e731e6bea87ccd6 100644 --- a/assets/ExternalSourceEvalBadge-K3r45EmO.js +++ b/assets/ExternalSourceEvalBadge-B3fyun97.js @@ -1 +1 @@ -import{p as o}from"./curation-YeS7FBYf.js";import{ac as g,j as a,L as l}from"./index-DyXq7-Tg.js";import{H as u,a as c,b as d}from"./hover-card-B45EJIn_.js";import{s as m}from"./safeExternalHref-CkBrsh84.js";class b{constructor(e){this.request=e}list(e={}){const t=new URLSearchParams(Object.entries(e).filter(r=>r[1]!==void 0).map(([r,n])=>[r,String(n)])).toString();return this.request(`/evaluations/${t?`?${t}`:""}`,{cache:"no-store"})}get(e){return this.request(`/evaluations/${e}`)}async byPaper(e){return this.allPages({paper_id:Number(e),ordering:"-benchmark_popularity"})}async byDataset(e,t){return this.allPages({dataset_id:Number(e),best_metric:t,ordering:"best_rank"})}async byLeaderboard(e,t,r={}){return this.allPages({dataset_id:Number(e),task_id:Number(t),ordering:"best_rank",...r})}create(e){return this.request("/evaluations/",{method:"POST",body:JSON.stringify(e)})}update(e,t){return this.request(`/evaluations/${e}`,{method:"PUT",body:JSON.stringify(t)})}delete(e){return this.request(`/evaluations/${e}`,{method:"DELETE"})}primeCurationState(e,t=!1){return o.primeEvaluations(e,t)}batch(e,t){return o.mutateEvaluations(e,t,"/evaluations/batch",{method:"POST",body:JSON.stringify({paper_id:e,operations:t})})}async allPages(e){const r=await this.list({...e,page_size:100});if(!r.next_page)return r.results;const n=Math.ceil(r.count/100),p=await Promise.all(Array.from({length:n-1},(i,h)=>this.list({...e,page:h+2,page_size:100})));return[r,...p].flatMap(i=>i.results)}}const w=new b(g),j=()=>a.jsxs(u,{openDelay:120,closeDelay:120,children:[a.jsx(c,{asChild:!0,children:a.jsx("button",{type:"button",className:"bm-closed-source-tag","aria-label":"Closed-source model",children:"closed"})}),a.jsxs(d,{side:"top",align:"start",className:"w-auto max-w-[260px] p-3 text-sm leading-snug",children:["This is an evaluation of a closed-source model. You can disable viewing these in your"," ",a.jsx(l,{to:"/settings",className:"closed-eval-tooltip-link",children:"settings"}),"."]})]});function x(s){if(!s)return"Evaluation sourced outside this paper";const e=s.toLowerCase();if(e.includes("open-asr-leaderboard"))return"Open ASR Leaderboard";if(e.includes("arcprize.org"))return"ARC Prize Leaderboard";if(e.includes("frontierswe.com"))return"FrontierSWE";if(e.includes("deepswe.datacurve.ai"))return"DeepSWE";try{const t=new URL(s,"https://paperswithcode.co");return t.pathname.startsWith("/paper/")?"Source paper":t.hostname.replace(/^www\./,"")}catch{return s}}const E=({sourceUrl:s})=>{const e=m(s),t=typeof s=="string"&&s.startsWith("/paper/")?s:null,r=x(s);return a.jsxs(u,{openDelay:120,closeDelay:120,children:[a.jsx(c,{asChild:!0,children:a.jsx("button",{type:"button",className:"bm-external-source-tag","aria-label":`Externally sourced evaluation: ${r}`,children:"External"})}),a.jsxs(d,{side:"top",align:"start",className:"w-auto max-w-[280px] p-3 text-sm leading-snug",children:["This score was sourced outside this paper.",t?a.jsxs(a.Fragment,{children:[" ",a.jsx(l,{to:t,target:"_blank",rel:"noopener noreferrer",className:"external-eval-tooltip-link",children:r}),"."]}):e?a.jsxs(a.Fragment,{children:[" ",a.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"external-eval-tooltip-link",children:r}),"."]}):a.jsxs(a.Fragment,{children:[" ",r,"."]})]})]})};export{j as C,E,w as e}; +import{p as o}from"./curation-CyyuHfv5.js";import{ac as g,j as a,L as l}from"./index-CjdUkE4w.js";import{H as u,a as c,b as d}from"./hover-card-CIBIV2Hx.js";import{s as m}from"./safeExternalHref-CkBrsh84.js";class b{constructor(e){this.request=e}list(e={}){const t=new URLSearchParams(Object.entries(e).filter(r=>r[1]!==void 0).map(([r,n])=>[r,String(n)])).toString();return this.request(`/evaluations/${t?`?${t}`:""}`,{cache:"no-store"})}get(e){return this.request(`/evaluations/${e}`)}async byPaper(e){return this.allPages({paper_id:Number(e),ordering:"-benchmark_popularity"})}async byDataset(e,t){return this.allPages({dataset_id:Number(e),best_metric:t,ordering:"best_rank"})}async byLeaderboard(e,t,r={}){return this.allPages({dataset_id:Number(e),task_id:Number(t),ordering:"best_rank",...r})}create(e){return this.request("/evaluations/",{method:"POST",body:JSON.stringify(e)})}update(e,t){return this.request(`/evaluations/${e}`,{method:"PUT",body:JSON.stringify(t)})}delete(e){return this.request(`/evaluations/${e}`,{method:"DELETE"})}primeCurationState(e,t=!1){return o.primeEvaluations(e,t)}batch(e,t){return o.mutateEvaluations(e,t,"/evaluations/batch",{method:"POST",body:JSON.stringify({paper_id:e,operations:t})})}async allPages(e){const r=await this.list({...e,page_size:100});if(!r.next_page)return r.results;const n=Math.ceil(r.count/100),p=await Promise.all(Array.from({length:n-1},(i,h)=>this.list({...e,page:h+2,page_size:100})));return[r,...p].flatMap(i=>i.results)}}const w=new b(g),j=()=>a.jsxs(u,{openDelay:120,closeDelay:120,children:[a.jsx(c,{asChild:!0,children:a.jsx("button",{type:"button",className:"bm-closed-source-tag","aria-label":"Closed-source model",children:"closed"})}),a.jsxs(d,{side:"top",align:"start",className:"w-auto max-w-[260px] p-3 text-sm leading-snug",children:["This is an evaluation of a closed-source model. You can disable viewing these in your"," ",a.jsx(l,{to:"/settings",className:"closed-eval-tooltip-link",children:"settings"}),"."]})]});function x(s){if(!s)return"Evaluation sourced outside this paper";const e=s.toLowerCase();if(e.includes("open-asr-leaderboard"))return"Open ASR Leaderboard";if(e.includes("arcprize.org"))return"ARC Prize Leaderboard";if(e.includes("frontierswe.com"))return"FrontierSWE";if(e.includes("deepswe.datacurve.ai"))return"DeepSWE";try{const t=new URL(s,"https://paperswithcode.co");return t.pathname.startsWith("/paper/")?"Source paper":t.hostname.replace(/^www\./,"")}catch{return s}}const E=({sourceUrl:s})=>{const e=m(s),t=typeof s=="string"&&s.startsWith("/paper/")?s:null,r=x(s);return a.jsxs(u,{openDelay:120,closeDelay:120,children:[a.jsx(c,{asChild:!0,children:a.jsx("button",{type:"button",className:"bm-external-source-tag","aria-label":`Externally sourced evaluation: ${r}`,children:"External"})}),a.jsxs(d,{side:"top",align:"start",className:"w-auto max-w-[280px] p-3 text-sm leading-snug",children:["This score was sourced outside this paper.",t?a.jsxs(a.Fragment,{children:[" ",a.jsx(l,{to:t,target:"_blank",rel:"noopener noreferrer",className:"external-eval-tooltip-link",children:r}),"."]}):e?a.jsxs(a.Fragment,{children:[" ",a.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"external-eval-tooltip-link",children:r}),"."]}):a.jsxs(a.Fragment,{children:[" ",r,"."]})]})]})};export{j as C,E,w as e}; diff --git a/assets/FeedView-tA68x8iy.js b/assets/FeedView-BZs7imUl.js similarity index 93% rename from assets/FeedView-tA68x8iy.js rename to assets/FeedView-BZs7imUl.js index b57c9d4adb93e5102efc28d199769e6943d178d2..538a1193cd29d7c9e1e0bc27d63668e7ae555dca 100644 --- a/assets/FeedView-tA68x8iy.js +++ b/assets/FeedView-BZs7imUl.js @@ -1 +1 @@ -import{j as e,L as F,a as _e,c as Ce,b as H,r as ne,d as h,h as Ee,C as Fe,T as Q,e as je,f as Le,g as Ae,p as se,i as De,k as Re,l as re,m as ve,n as Me,o as qe}from"./index-DyXq7-Tg.js";import{S as Ie}from"./sparkles-CcIiUzzc.js";import{D as Oe,a as He,b as $e}from"./dialog-CfM0Uql2.js";import{c as J}from"./catalog-CRar2olQ.js";import{u as Ne,a as Se,b as ke,T as me,s as ze,c as Ke,r as ee,d as ge,e as fe,f as Be}from"./researchTopic-DbX0eko-.js";import{d as le,t as Ue}from"./transform-D46m70Qr.js";import{P as Ge}from"./plus-Yh42pKZz.js";import{A as Qe}from"./arrow-right-BzPanrWZ.js";import{r as We,P as Xe,w as Ye,a as Ze}from"./PaperFeed-EBt97iOL.js";import{M as Ve}from"./McpShowcase-CLO4HLon.js";import{u as Je,a as es,P as ss,i as ts,A as as,b as os,S as $,c as is,D as te,q as ns,d as rs}from"./chatSessions-Ck_dyM0d.js";import{c as ls}from"./chat-Ix1IrIwq.js";import{u as cs}from"./usePapers-B0s20UcU.js";import{p as xe}from"./papers-Dh3ljlL0.js";import{S as ae}from"./skeleton-C3IIzpSL.js";import{A as oe,a as ie}from"./alert-gbJBhAVE.js";import"./useMutation-UWxBeqtn.js";import"./PaperCard-57p1OSGy.js";import"./AuthorAvatar-B-9xS2Wo.js";import"./SotaBadges-vbLLOUtT.js";import"./colors-BkWRhvFI.js";import"./Icon-T4LYkEQj.js";import"./LatexTitle-Bkyz3jCs.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-CTBEUp7Y.js";import"./useIntersectionObserver-D6_Iig9a.js";import"./AgentLogos-j-Qekw7T.js";import"./useInfiniteQuery-BYh2zN-T.js";import"./curation-YeS7FBYf.js";function ds({onBuild:r}){return e.jsxs("section",{className:"following-intro","aria-labelledby":"following-intro-title",children:[e.jsx("h2",{id:"following-intro-title",children:"Build your personal research feed"}),e.jsx("p",{className:"following-intro-lead",children:"Describe a topic in your own words, or follow the tasks, benchmarks, authors, and organizations you care about, and this page collects their latest papers and results in one place."}),r&&e.jsxs("button",{type:"button",className:"research-topic-save following-intro-topic",onClick:r,children:[e.jsx(Ie,{"aria-hidden":"true"}),"Build your feed"]}),e.jsxs("p",{className:"following-intro-note",children:["Matching papers also arrive as a weekly email, which you can turn off in"," ",e.jsx(F,{to:"/settings",children:"Settings"}),"."]})]})}const we=16;function us({open:r,onOpenChange:o}){return e.jsx(Oe,{open:r,onOpenChange:o,children:e.jsx(He,{className:"topic-dialog","aria-describedby":void 0,children:e.jsx(ps,{onDone:()=>o(!1)})})})}function ps({onDone:r}){var W,X,Y,Z,O,z,B;const{user:o}=_e(),m=Ce(),l=H({queryKey:ne.topic(o==null?void 0:o.hf_subject),queryFn:ee.topic,enabled:!!o}),t=Ne(),w=H({queryKey:["trending-tasks-follow"],queryFn:()=>J.trendingTasks({limit:we,level:0}),staleTime:Q}),y=H({queryKey:["trending-methods-follow"],queryFn:()=>J.trendingMethods({limit:we}),staleTime:Q}),c=H({queryKey:["research-follow-suggestions"],queryFn:ee.followSuggestions,staleTime:Q}),j=(n=[])=>n.map(p=>({id:String(p.entity_id),name:p.name,image:p.image_url})),[S,L]=h.useState(null),[P,v]=h.useState([]),_=Se(),M=ke(),b=((W=l.data)==null?void 0:W.text)??"",i=S??b,d=i.trim().replace(/\s+/g," "),C=((X=l.data)==null?void 0:X.status)==="failed"&&d===b,A=d.length>=3&&(d!==b||C),D=_.isPending||M.isPending,a=(n,p)=>{var N;return((N=t.data)==null?void 0:N.some(k=>k.kind===n&&String(k.entity_id)===p))??!1},g=(n,p)=>{var N;return((N=P.find(k=>k.kind===n&&k.id===p))==null?void 0:N.follow)??a(n,p)},f=P.filter(n=>n.follow!==a(n.kind,n.id)),E=!D&&(A||f.length>0),R=(n,p,N)=>v(k=>[...k.filter(U=>U.kind!==n||U.id!==p),{kind:n,id:p,name:N,follow:!g(n,p)}]),q=()=>{if(!E)return;if(!o){A&&ze(d),f.length&&Ke(f),window.location.href=Ee(`${m.pathname}${m.search}`);return}const n=[...f.length?[M.mutateAsync(f)]:[],...A?[_.mutateAsync(d)]:[]];Promise.allSettled(n).then(p=>{p.every(N=>N.status==="fulfilled")&&r()})},I=(n,p,N,k)=>{const V=[...(t.data??[]).filter(x=>x.kind===p).map(x=>({id:String(x.entity_id),name:x.name,slug:x.url.split("/").pop(),image:x.image_url})),...N.filter(x=>!a(p,x.id)).map(x=>({...x,suggested:!0}))];return V.length>0&&e.jsxs("div",{className:"topic-dialog-group",children:[e.jsx("h3",{children:n}),e.jsxs(hs,{children:[V.map(x=>{const G=g(p,x.id),K=p==="task"?le(x.name,x.slug??void 0):x.name;return e.jsxs("button",{type:"button",className:"topic-dialog-chip","aria-pressed":G,disabled:D,"data-suggested":"suggested"in x||void 0,onClick:()=>R(p,x.id,K),children:[G?e.jsx(Fe,{"aria-hidden":"true"}):e.jsx(Ge,{"aria-hidden":"true"}),(p==="author"||p==="organization")&&e.jsx(ms,{kind:p,name:K,src:x.image}),K]},x.id)}),k&&e.jsxs(F,{to:k.to,className:"topic-dialog-browse",children:[k.label,e.jsx(Qe,{"aria-hidden":"true"})]})]})]})};return e.jsxs("form",{className:"topic-dialog-form",onSubmit:n=>{n.preventDefault(),q()},children:[e.jsx($e,{className:"topic-dialog-title",children:b||(Y=t.data)!=null&&Y.length?"Edit your research feed":"Build your research feed"}),e.jsxs("div",{className:"topic-dialog-group",children:[e.jsx("h3",{children:e.jsx("label",{htmlFor:"topic-dialog-input",children:"Describe a topic in your own words"})}),e.jsx("p",{className:"topic-dialog-hint",children:"A model reads every new paper and adds the ones that match to your Following feed."}),e.jsx("textarea",{id:"topic-dialog-input",className:"research-topic-input",rows:4,maxLength:me,"aria-label":"Research topic",placeholder:"e.g. diffusion policies for robot manipulation, or speculative decoding for LLM inference",value:i,onChange:n=>L(n.target.value),onKeyDown:n=>{n.key==="Enter"&&!n.shiftKey&&!n.nativeEvent.isComposing&&(n.preventDefault(),q())}}),e.jsxs("span",{className:"research-topic-count",children:[i.length,"/",me]})]}),I("Trending tasks","task",((Z=w.data)==null?void 0:Z.results)??[],{to:"/tasks",label:"Browse tasks"}),I("Trending methods","method",((O=y.data)==null?void 0:O.results)??[],{to:"/methods",label:"Browse methods"}),I("Benchmarks","benchmark",[],{to:"/tasks",label:"Browse benchmarks"}),I("Popular authors","author",j((z=c.data)==null?void 0:z.authors)),I("Popular organizations","organization",j((B=c.data)==null?void 0:B.organizations),{to:"/organizations",label:"Browse organizations"}),(_.error||M.error)&&e.jsx("p",{className:"settings-token-error",role:"alert",children:"Could not save your feed. Please try again."}),e.jsxs("div",{className:"topic-dialog-actions",children:[b&&e.jsx("button",{type:"button",className:"research-follow-action topic-dialog-remove",disabled:D,onClick:()=>_.mutate(null,{onSuccess:r}),children:"Remove topic"}),e.jsx("button",{type:"button",className:"research-follow-action",disabled:D,onClick:r,children:"Cancel"}),e.jsx("button",{type:"submit",className:"research-topic-save",disabled:!E,children:f.some(n=>n.follow===!1)?"Save":f.length?"Follow":C?"Retry":b?"Update topic":"Follow"})]})]})}function hs({children:r}){const o=h.useRef(null);return h.useLayoutEffect(()=>{const m=o.current;if(!m)return;const l=()=>{const t=[...m.children],w=t.filter(c=>c.dataset.suggested);w.forEach(c=>{c.hidden=!1});const y=()=>new Set(t.filter(c=>!c.hidden).map(c=>c.offsetTop)).size;for(let c=w.length-1;c>=0&&y()>2;c--)w[c].hidden=!0};return l(),window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)}),e.jsx("div",{ref:o,className:"topic-dialog-chips",children:r})}function ms({kind:r,name:o,src:m}){const[l,t]=h.useState(!1);if(m&&!l)return e.jsx("img",{className:`topic-dialog-chip-image is-${r}`,src:m,alt:"",loading:"lazy",onError:()=>t(!0)});if(r!=="author")return null;const w=o.split(/\s+/).filter(Boolean).map(y=>y[0]).slice(0,2).join("").toUpperCase();return e.jsx("span",{className:"topic-dialog-chip-image is-author is-initials","aria-hidden":"true",children:w})}const be=45,gs=1800,fs=25,xs=350,ws=r=>{const[o,m]=h.useState($[0].slice(0,1)),[l,t]=h.useState(0);return h.useEffect(()=>{var L,P;if(!r)return;if((P=(L=window.matchMedia)==null?void 0:L.call(window,"(prefers-reduced-motion: reduce)"))!=null&&P.matches){m($[0]),t(0);return}let w=0,y=1,c=!1,j;m($[0].slice(0,y)),t(0);const S=()=>{const v=$[w];if(!c){if(y+=1,m(v.slice(0,y)),y===v.length){c=!0,j=window.setTimeout(S,gs);return}j=window.setTimeout(S,be);return}if(y-=1,m(v.slice(0,y)),y===0){c=!1,w=(w+1)%$.length,t(w),j=window.setTimeout(S,xs);return}j=window.setTimeout(S,fs)};return j=window.setTimeout(S,be),()=>window.clearTimeout(j)},[r]),{placeholder:o,prompt:$[l]}},bs=()=>{var D;const r=je(),o=ve(),[m,l]=h.useState({text:"",paperMentions:[]}),t=m.text,[w,y]=h.useState(0),[c,j]=h.useState(!1),[S,L]=h.useState(null),{placeholder:P,prompt:v}=ws(!t),_=h.useRef(null),M=H({queryKey:["chatAvailability"],queryFn:()=>ls.getAvailability(),retry:!1,enabled:re()}),b=re()&&((D=M.data)==null?void 0:D.paper_mentions_enabled)!==!1,i=Je({draft:m,onChange:l,enabled:b,textareaRef:_}),d=es(m,i.open),C=t?d.completion:v;h.useLayoutEffect(()=>{const a=_.current;if(!a)return;const g=()=>{if(a.style.height="auto",t){a.style.height=`${Math.min(is(a),160)}px`;return}const f=a.placeholder,E=$.reduce((R,q)=>(a.placeholder=q,Math.max(R,a.scrollHeight)),0);a.placeholder=f,a.style.height=`${Math.min(E,160)}px`};return g(),window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[t,C]);const A=async(a=m)=>{const g=a.text.trim();if(!(!g||c)){if(o){const f=new URLSearchParams({q:g,model:te}),E=`${Me}?${f}`,R=window.open(E,"_blank");if(!R){L(E);return}R.opener=null,L(null),l({text:"",paperMentions:[]});return}j(!0),ns(a,te);try{const f=await rs(te);r(`/chat/${f.id}`)}catch{r("/chat")}}};return e.jsxs(e.Fragment,{children:[!o&&e.jsx("div",{className:"ask-home-new",children:"Hint: type @ to bring papers into context, or press Tab to use a suggestion"}),e.jsxs("div",{className:"ask-home",children:[e.jsxs("div",{className:"ask-home-row",children:[e.jsxs("div",{className:"ask-home-textarea-wrap",children:[e.jsx(ss,{text:m.text,mentions:m.paperMentions,scrollTop:w,variant:"home",completion:t?C:""}),e.jsx("textarea",{ref:_,rows:1,value:t,placeholder:P,"aria-label":"Ask the assistant",disabled:c,onChange:a=>{i.updateText(a.target.value,a.target.selectionStart),d.trackCaret(a.target)},onSelect:a=>{i.refresh(a.currentTarget.selectionStart),d.trackCaret(a.currentTarget)},onClick:a=>{i.refresh(a.currentTarget.selectionStart),d.trackCaret(a.currentTarget)},onScroll:a=>y(a.currentTarget.scrollTop),onBlur:a=>{var g,f;(f=(g=a.relatedTarget)==null?void 0:g.closest)!=null&&f.call(g,".chat-paper-picker")||window.setTimeout(i.close,0)},onKeyDown:a=>{if(!i.keyDown(a)){if(ts(a)&&C){a.preventDefault();const g=t+C;i.updateText(g,g.length),window.requestAnimationFrame(()=>{var f;return(f=_.current)==null?void 0:f.setSelectionRange(g.length,g.length)});return}a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),A())}},role:b?"combobox":void 0,"aria-expanded":b?i.open:void 0,"aria-controls":i.open?i.pickerId:void 0,"aria-activedescendant":i.open&&i.results.length?`${i.optionIdPrefix}-${i.activeIndex}`:void 0,"aria-autocomplete":b?"list":void 0,"aria-describedby":i.message?"ask-home-paper-mention-message":void 0})]}),e.jsx("button",{type:"button",className:`chat-send${t.trim()?" chat-send-on":""}`,onClick:()=>void A(),disabled:!t.trim()||c,"aria-label":"Ask the assistant",children:e.jsx(as,{})})]}),S&&e.jsx("div",{className:"chat-paper-mention-message",role:"alert",children:e.jsx("a",{href:S,target:"_blank",rel:"noreferrer",children:"Open this question on paperswithcode.co"})}),i.message&&e.jsx("div",{id:"ask-home-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:i.message}),e.jsx(os,{open:i.open,query:i.query,results:i.results,activeIndex:i.activeIndex,loading:i.loading,error:i.error,onSelect:i.select,id:i.pickerId,optionIdPrefix:i.optionIdPrefix})]})]})},Te={task:"Tasks",method:"Methods",benchmark:"Benchmarks",author:"Authors",organization:"Orgs"},ys=Object.keys(Te),js=30,ye=40,vs=async r=>{const o=await r;return{results:o.results.map(m=>({paper:m})),next_page:o.next_page}},Ns=({mode:r})=>{var G,K,ce,de,ue,pe,he;const o=r==="following",m=je(),l=Le(),t=l==null?void 0:l.user,[w,y]=Ae(),c=We(w,void 0,o?"month":"week"),j=s=>{const u=new URLSearchParams(w);u.delete("order_by"),u.delete("only");const T=u.toString();m(T?`${s}?${T}`:s)},S=s=>{const u=new URLSearchParams(w);s?u.set("only","topic"):u.delete("only");const T=u.toString();return T?`/following?${T}`:"/following"},L=H({queryKey:qe.topTasksSidebar,queryFn:()=>J.topTasks(8),staleTime:Q}),P=H({queryKey:["trending-tasks-sidebar"],queryFn:()=>J.trendingTasks({limit:8,level:0}),staleTime:Q}),v=o&&w.get("only")==="topic",_={start_date:c.startDate,end_date:c.endDate},M={...c,topicOnly:v},b=cs(o?[...se.feeds.following,t==null?void 0:t.hf_subject,M]:[...r==="x"?se.feeds.xTrending:se.feeds.trending,_],async s=>{if(o){const T=await ee.following(s,M),Pe=T.length===ye?s+ye:null;return{results:T,next_page:Pe}}const u={..._,page:s,page_size:js,include_resources:!0};return vs(r==="x"?xe.xTrending(u):xe.list({...u,order_by:"trending",order_dir:"desc",latest_only:!0}))},{enabled:!o||!!t,initialPage:o?0:1}),i=Ne(o),d=H({queryKey:ne.topic(t==null?void 0:t.hf_subject),queryFn:ee.topic,enabled:o&&!!t,refetchInterval:s=>s.state.data&&["pending","running"].includes(s.state.data.status)?1e4:!1}),C=!!d.data&&["pending","running"].includes(d.data.status),A=d.data?d.data.label??d.data.text:"",[D,a]=h.useState(!1),g=De(),f=h.useRef(!1);h.useEffect(()=>{f.current&&!C&&g.invalidateQueries({queryKey:ne.feed(t==null?void 0:t.hf_subject)}),f.current=C},[C,g,t==null?void 0:t.hf_subject]);const E=o&&!!t&&((G=i.data)==null?void 0:G.length)===0&&d.isSuccess&&!d.data,R=o&&!(l!=null&&l.isLoading)&&!t||E,q=!!t||!Re(),[I,W]=h.useState(!1),[X]=h.useState(()=>!!ge()||fe().length>0),[Y,Z]=h.useState(!1);!I&&(d.data||(K=i.data)!=null&&K.length)&&W(!0),R&&!Y&&(Z(!0),q&&!I&&!X&&a(!0));const O=Se(),{mutate:z}=O,B=h.useRef(!1);h.useEffect(()=>{var u;const s=ge();!t||!d.isSuccess||!s||B.current||(B.current=!0,s===((u=d.data)==null?void 0:u.text)?Be():z(s))},[t,d.isSuccess,d.data,z]);const n=ke(),{mutate:p}=n,N=h.useRef(!1);h.useEffect(()=>{const s=fe();!t||!s.length||N.current||(N.current=!0,p(s))},[t,p]);const k=h.useMemo(()=>ys.map(s=>{var u;return{kind:s,follows:o?((u=i.data)==null?void 0:u.filter(T=>T.kind===s))??[]:[]}}).filter(s=>s.follows.length>0),[o,i.data]),U=o&&(!!(l!=null&&l.isLoading)||!!t&&!E),V=h.useMemo(()=>{var s;return((s=b.data)==null?void 0:s.pages.flatMap(u=>u.results.map(T=>({...Ue(T.paper),followReasons:T.reasons}))))??[]},[b.data]),x=b.error;return e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["Trending ",e.jsx("em",{children:"Research"})]}),e.jsx("div",{className:"feed-subtitle",children:r==="x"?"Papers people share most on X, picked daily":"Curated daily from arXiv and Hugging Face"})]})}),e.jsxs("div",{className:"layout-with-sidebar",children:[e.jsxs("aside",{className:"sidebar feed-sidebar",children:[U?e.jsxs("div",{className:"sidebar-section sidebar-section-follows",children:[e.jsx("div",{className:"sidebar-label",children:"You follow"}),((l==null?void 0:l.isLoading)||i.isLoading)&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:4}).map((s,u)=>e.jsx(ae,{className:"h-5 w-full"},u))}),i.isError&&e.jsx("div",{style:{fontSize:12,color:"var(--ink-faint)"},children:"Couldn't load your follows."}),e.jsxs("div",{className:"sidebar-links",children:[d.data&&e.jsxs("div",{className:`sidebar-follow-topic ${v?"active":""}`,children:[e.jsxs(F,{to:S(!v),className:"sidebar-link sidebar-follow-link",title:v?"Show papers from everything you follow":`Show only papers about “${d.data.text}”`,"aria-current":v?"true":void 0,children:[e.jsx("span",{className:"sidebar-follow-kind",children:"Topic"}),e.jsx("span",{className:"sidebar-follow-name",children:A})]}),e.jsx("button",{type:"button",className:"sidebar-follow-edit","aria-label":"Edit topic","aria-expanded":D,onClick:()=>a(!0),children:"edit"})]}),k.map(s=>e.jsxs("div",{className:"sidebar-follow-group",children:[e.jsx("span",{className:"sidebar-follow-kind",children:Te[s.kind]}),s.follows.map(u=>e.jsx(F,{to:u.url,className:"sidebar-link sidebar-follow-link",children:e.jsx("span",{className:"sidebar-follow-name",children:u.name})},u.entity_id))]},s.kind))]}),e.jsx(F,{to:"/settings",className:"sidebar-follow-manage",children:"Manage in Settings"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sidebar-section sidebar-section-top-domains",children:[e.jsx("div",{className:"sidebar-label",children:"Top Domains"}),L.isLoading&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:6}).map((s,u)=>e.jsx(ae,{className:"h-5 w-full"},u))}),e.jsxs("div",{className:"sidebar-links",children:[(ce=L.data)==null?void 0:ce.map(s=>e.jsxs(F,{to:`/tasks/${s.slug}`,className:"sidebar-link",children:[le(s.name,s.slug),s.paper_count!=null&&e.jsx("span",{className:"count",children:s.paper_count})]},s.id)),e.jsx(F,{to:"/tasks",className:"sidebar-link sidebar-link-more",children:"all domains →"})]})]}),e.jsxs("div",{className:"sidebar-section sidebar-section-trending-domains",children:[e.jsx("div",{className:"sidebar-label",children:"Trending Domains"}),P.isLoading&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:6}).map((s,u)=>e.jsx(ae,{className:"h-5 w-full"},u))}),((ue=(de=P.data)==null?void 0:de.results)==null?void 0:ue.length)===0&&!P.isLoading&&e.jsx("div",{style:{fontSize:12,color:"var(--ink-faint)"},children:"No domains gaining momentum right now."}),e.jsx("div",{className:"sidebar-links",children:(he=(pe=P.data)==null?void 0:pe.results)==null?void 0:he.map(s=>e.jsxs(F,{to:`/tasks/${s.slug}`,className:"sidebar-link",children:[le(s.name,s.slug),e.jsxs("span",{className:"count",children:[s.share_lift.toFixed(1),"x"]})]},s.id))})]})]}),e.jsx(Ve,{})]}),e.jsxs("div",{className:"feed-main",children:[(re()||ve())&&e.jsx("div",{className:"feed-chat",children:e.jsx(bs,{})}),e.jsxs("div",{className:"feed-content",children:[e.jsxs("div",{className:"sort-bar home-feed-sort-bar",children:[e.jsx("div",{className:"paper-feed-toolbar-controls",children:e.jsxs("div",{className:"sort-options",children:[e.jsx("button",{className:`sort-btn ${r==="trending"?"active":""}`,onClick:()=>j("/"),children:"trending"}),e.jsx("button",{className:`sort-btn ${r==="x"?"active":""}`,onClick:()=>j("/x-trending"),children:"trending (X)"}),e.jsx("button",{className:`sort-btn ${o?"active":""}`,onClick:()=>j("/following"),children:"following"})]})}),e.jsx(Xe,{startDate:c.startDate,endDate:c.endDate,onChange:s=>y(Ye(w,s))})]}),x&&e.jsx(oe,{variant:"destructive",className:"mb-4",children:e.jsxs(ie,{children:["Failed to load papers. ",e.jsx("button",{type:"button",onClick:()=>void b.refetch(),children:"Try again"})]})}),O.isError&&O.variables&&e.jsx(oe,{variant:"destructive",className:"mb-4",children:e.jsxs(ie,{children:["Could not follow “",O.variables,"”. ",e.jsx("button",{type:"button",onClick:()=>z(O.variables),children:"Try again"})]})}),n.isError&&n.variables&&e.jsx(oe,{variant:"destructive",className:"mb-4",children:e.jsxs(ie,{children:["Could not follow ",n.variables.map(s=>s.name).join(", "),". ",e.jsx("button",{type:"button",onClick:()=>p(n.variables),children:"Try again"})]})}),o&&!!t&&d.isSuccess&&!i.isPending&&!E&&(d.data?C?e.jsxs("div",{className:"following-topic-note",role:"status",children:["Showing the closest papers about “",A,"” now. A model is reading papers to refine these matches, which takes a few minutes."]}):null:e.jsxs("div",{className:"following-topic-note",role:"status",children:["Describe a topic in your own words, and a model adds matching new papers to this feed."," ",e.jsx("button",{type:"button",className:"link-button",onClick:()=>a(!0),children:"Follow a topic"})]})),o&&q&&e.jsx(us,{open:D,onOpenChange:a}),v&&d.data&&e.jsxs("div",{className:"following-topic-note following-topic-filter",role:"status",children:["Showing only papers about “",A,"”."," ",e.jsx(F,{to:S(!1),children:"Show everything you follow"})]}),R?e.jsx(ds,{onBuild:q?()=>a(!0):void 0}):e.jsx(Ze,{query:b,isLoading:b.isLoading||o&&!!(l!=null&&l.isLoading),cards:V,skeleton:"card",rootMargin:"400px",empty:x?null:v?e.jsxs(e.Fragment,{children:["No papers about your topic match these filters. Widen the date range or ",e.jsx("button",{type:"button",className:"link-button",onClick:()=>a(!0),children:"edit your topic"}),"."]}):o?e.jsxs(e.Fragment,{children:["No papers from your topic or follows match these filters. Widen the date range, or follow more from ",e.jsx(F,{to:"/tasks",children:"tasks"}),", ",e.jsx(F,{to:"/methods",children:"methods"}),", benchmark, author, or organization pages."]}):r==="x"?"No papers shared on X in this window.":"No papers in this window."})]})]})]})]})},Js=({xTrending:r=!1})=>e.jsx(Ns,{mode:r?"x":"trending"});export{bs as AskAssistant,Ns as HomeFeed,Js as default}; +import{j as e,L as F,a as _e,c as Ce,b as H,r as ne,d as h,h as Ee,C as Fe,T as Q,e as je,f as Le,g as Ae,p as se,i as De,k as Re,l as re,m as ve,n as Me,o as qe}from"./index-CjdUkE4w.js";import{S as Ie}from"./sparkles-CIfeDmV2.js";import{D as Oe,a as He,b as $e}from"./dialog-BzX9PD3v.js";import{c as J}from"./catalog-qXcKve0z.js";import{u as Ne,a as Se,b as ke,T as me,s as ze,c as Ke,r as ee,d as ge,e as fe,f as Be}from"./researchTopic-NmABF6tT.js";import{d as le,t as Ue}from"./transform-CRNzYLch.js";import{P as Ge}from"./plus-AztI1566.js";import{A as Qe}from"./arrow-right-BrRhWCQS.js";import{r as We,P as Xe,w as Ye,a as Ze}from"./PaperFeed-D3FZw29k.js";import{M as Ve}from"./McpShowcase-Bo79ATLK.js";import{u as Je,a as es,P as ss,i as ts,A as as,b as os,S as $,c as is,D as te,q as ns,d as rs}from"./chatSessions-9VEG8seW.js";import{c as ls}from"./chat-B1EBF720.js";import{u as cs}from"./usePapers-BZThqZCx.js";import{p as xe}from"./papers-DgZwjF3K.js";import{S as ae}from"./skeleton-DTWi7Ctg.js";import{A as oe,a as ie}from"./alert-BM9Xfuyy.js";import"./useMutation-BYtVrkc7.js";import"./PaperCard-dvXhr75r.js";import"./AuthorAvatar-D9249Frl.js";import"./SotaBadges-CyScuNCv.js";import"./colors-BkWRhvFI.js";import"./Icon-CGRs4BYD.js";import"./LatexTitle-DESKtS30.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-Df5_dywQ.js";import"./useIntersectionObserver-Ch6RpsSk.js";import"./AgentLogos-xoTIu0NB.js";import"./useInfiniteQuery-DeZTTVbI.js";import"./curation-CyyuHfv5.js";function ds({onBuild:r}){return e.jsxs("section",{className:"following-intro","aria-labelledby":"following-intro-title",children:[e.jsx("h2",{id:"following-intro-title",children:"Build your personal research feed"}),e.jsx("p",{className:"following-intro-lead",children:"Describe a topic in your own words, or follow the tasks, benchmarks, authors, and organizations you care about, and this page collects their latest papers and results in one place."}),r&&e.jsxs("button",{type:"button",className:"research-topic-save following-intro-topic",onClick:r,children:[e.jsx(Ie,{"aria-hidden":"true"}),"Build your feed"]}),e.jsxs("p",{className:"following-intro-note",children:["Matching papers also arrive as a weekly email, which you can turn off in"," ",e.jsx(F,{to:"/settings",children:"Settings"}),"."]})]})}const we=16;function us({open:r,onOpenChange:o}){return e.jsx(Oe,{open:r,onOpenChange:o,children:e.jsx(He,{className:"topic-dialog","aria-describedby":void 0,children:e.jsx(ps,{onDone:()=>o(!1)})})})}function ps({onDone:r}){var W,X,Y,Z,O,z,B;const{user:o}=_e(),m=Ce(),l=H({queryKey:ne.topic(o==null?void 0:o.hf_subject),queryFn:ee.topic,enabled:!!o}),t=Ne(),w=H({queryKey:["trending-tasks-follow"],queryFn:()=>J.trendingTasks({limit:we,level:0}),staleTime:Q}),y=H({queryKey:["trending-methods-follow"],queryFn:()=>J.trendingMethods({limit:we}),staleTime:Q}),c=H({queryKey:["research-follow-suggestions"],queryFn:ee.followSuggestions,staleTime:Q}),j=(n=[])=>n.map(p=>({id:String(p.entity_id),name:p.name,image:p.image_url})),[S,L]=h.useState(null),[P,v]=h.useState([]),_=Se(),M=ke(),b=((W=l.data)==null?void 0:W.text)??"",i=S??b,d=i.trim().replace(/\s+/g," "),C=((X=l.data)==null?void 0:X.status)==="failed"&&d===b,A=d.length>=3&&(d!==b||C),D=_.isPending||M.isPending,a=(n,p)=>{var N;return((N=t.data)==null?void 0:N.some(k=>k.kind===n&&String(k.entity_id)===p))??!1},g=(n,p)=>{var N;return((N=P.find(k=>k.kind===n&&k.id===p))==null?void 0:N.follow)??a(n,p)},f=P.filter(n=>n.follow!==a(n.kind,n.id)),E=!D&&(A||f.length>0),R=(n,p,N)=>v(k=>[...k.filter(U=>U.kind!==n||U.id!==p),{kind:n,id:p,name:N,follow:!g(n,p)}]),q=()=>{if(!E)return;if(!o){A&&ze(d),f.length&&Ke(f),window.location.href=Ee(`${m.pathname}${m.search}`);return}const n=[...f.length?[M.mutateAsync(f)]:[],...A?[_.mutateAsync(d)]:[]];Promise.allSettled(n).then(p=>{p.every(N=>N.status==="fulfilled")&&r()})},I=(n,p,N,k)=>{const V=[...(t.data??[]).filter(x=>x.kind===p).map(x=>({id:String(x.entity_id),name:x.name,slug:x.url.split("/").pop(),image:x.image_url})),...N.filter(x=>!a(p,x.id)).map(x=>({...x,suggested:!0}))];return V.length>0&&e.jsxs("div",{className:"topic-dialog-group",children:[e.jsx("h3",{children:n}),e.jsxs(hs,{children:[V.map(x=>{const G=g(p,x.id),K=p==="task"?le(x.name,x.slug??void 0):x.name;return e.jsxs("button",{type:"button",className:"topic-dialog-chip","aria-pressed":G,disabled:D,"data-suggested":"suggested"in x||void 0,onClick:()=>R(p,x.id,K),children:[G?e.jsx(Fe,{"aria-hidden":"true"}):e.jsx(Ge,{"aria-hidden":"true"}),(p==="author"||p==="organization")&&e.jsx(ms,{kind:p,name:K,src:x.image}),K]},x.id)}),k&&e.jsxs(F,{to:k.to,className:"topic-dialog-browse",children:[k.label,e.jsx(Qe,{"aria-hidden":"true"})]})]})]})};return e.jsxs("form",{className:"topic-dialog-form",onSubmit:n=>{n.preventDefault(),q()},children:[e.jsx($e,{className:"topic-dialog-title",children:b||(Y=t.data)!=null&&Y.length?"Edit your research feed":"Build your research feed"}),e.jsxs("div",{className:"topic-dialog-group",children:[e.jsx("h3",{children:e.jsx("label",{htmlFor:"topic-dialog-input",children:"Describe a topic in your own words"})}),e.jsx("p",{className:"topic-dialog-hint",children:"A model reads every new paper and adds the ones that match to your Following feed."}),e.jsx("textarea",{id:"topic-dialog-input",className:"research-topic-input",rows:4,maxLength:me,"aria-label":"Research topic",placeholder:"e.g. diffusion policies for robot manipulation, or speculative decoding for LLM inference",value:i,onChange:n=>L(n.target.value),onKeyDown:n=>{n.key==="Enter"&&!n.shiftKey&&!n.nativeEvent.isComposing&&(n.preventDefault(),q())}}),e.jsxs("span",{className:"research-topic-count",children:[i.length,"/",me]})]}),I("Trending tasks","task",((Z=w.data)==null?void 0:Z.results)??[],{to:"/tasks",label:"Browse tasks"}),I("Trending methods","method",((O=y.data)==null?void 0:O.results)??[],{to:"/methods",label:"Browse methods"}),I("Benchmarks","benchmark",[],{to:"/tasks",label:"Browse benchmarks"}),I("Popular authors","author",j((z=c.data)==null?void 0:z.authors)),I("Popular organizations","organization",j((B=c.data)==null?void 0:B.organizations),{to:"/organizations",label:"Browse organizations"}),(_.error||M.error)&&e.jsx("p",{className:"settings-token-error",role:"alert",children:"Could not save your feed. Please try again."}),e.jsxs("div",{className:"topic-dialog-actions",children:[b&&e.jsx("button",{type:"button",className:"research-follow-action topic-dialog-remove",disabled:D,onClick:()=>_.mutate(null,{onSuccess:r}),children:"Remove topic"}),e.jsx("button",{type:"button",className:"research-follow-action",disabled:D,onClick:r,children:"Cancel"}),e.jsx("button",{type:"submit",className:"research-topic-save",disabled:!E,children:f.some(n=>n.follow===!1)?"Save":f.length?"Follow":C?"Retry":b?"Update topic":"Follow"})]})]})}function hs({children:r}){const o=h.useRef(null);return h.useLayoutEffect(()=>{const m=o.current;if(!m)return;const l=()=>{const t=[...m.children],w=t.filter(c=>c.dataset.suggested);w.forEach(c=>{c.hidden=!1});const y=()=>new Set(t.filter(c=>!c.hidden).map(c=>c.offsetTop)).size;for(let c=w.length-1;c>=0&&y()>2;c--)w[c].hidden=!0};return l(),window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)}),e.jsx("div",{ref:o,className:"topic-dialog-chips",children:r})}function ms({kind:r,name:o,src:m}){const[l,t]=h.useState(!1);if(m&&!l)return e.jsx("img",{className:`topic-dialog-chip-image is-${r}`,src:m,alt:"",loading:"lazy",onError:()=>t(!0)});if(r!=="author")return null;const w=o.split(/\s+/).filter(Boolean).map(y=>y[0]).slice(0,2).join("").toUpperCase();return e.jsx("span",{className:"topic-dialog-chip-image is-author is-initials","aria-hidden":"true",children:w})}const be=45,gs=1800,fs=25,xs=350,ws=r=>{const[o,m]=h.useState($[0].slice(0,1)),[l,t]=h.useState(0);return h.useEffect(()=>{var L,P;if(!r)return;if((P=(L=window.matchMedia)==null?void 0:L.call(window,"(prefers-reduced-motion: reduce)"))!=null&&P.matches){m($[0]),t(0);return}let w=0,y=1,c=!1,j;m($[0].slice(0,y)),t(0);const S=()=>{const v=$[w];if(!c){if(y+=1,m(v.slice(0,y)),y===v.length){c=!0,j=window.setTimeout(S,gs);return}j=window.setTimeout(S,be);return}if(y-=1,m(v.slice(0,y)),y===0){c=!1,w=(w+1)%$.length,t(w),j=window.setTimeout(S,xs);return}j=window.setTimeout(S,fs)};return j=window.setTimeout(S,be),()=>window.clearTimeout(j)},[r]),{placeholder:o,prompt:$[l]}},bs=()=>{var D;const r=je(),o=ve(),[m,l]=h.useState({text:"",paperMentions:[]}),t=m.text,[w,y]=h.useState(0),[c,j]=h.useState(!1),[S,L]=h.useState(null),{placeholder:P,prompt:v}=ws(!t),_=h.useRef(null),M=H({queryKey:["chatAvailability"],queryFn:()=>ls.getAvailability(),retry:!1,enabled:re()}),b=re()&&((D=M.data)==null?void 0:D.paper_mentions_enabled)!==!1,i=Je({draft:m,onChange:l,enabled:b,textareaRef:_}),d=es(m,i.open),C=t?d.completion:v;h.useLayoutEffect(()=>{const a=_.current;if(!a)return;const g=()=>{if(a.style.height="auto",t){a.style.height=`${Math.min(is(a),160)}px`;return}const f=a.placeholder,E=$.reduce((R,q)=>(a.placeholder=q,Math.max(R,a.scrollHeight)),0);a.placeholder=f,a.style.height=`${Math.min(E,160)}px`};return g(),window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[t,C]);const A=async(a=m)=>{const g=a.text.trim();if(!(!g||c)){if(o){const f=new URLSearchParams({q:g,model:te}),E=`${Me}?${f}`,R=window.open(E,"_blank");if(!R){L(E);return}R.opener=null,L(null),l({text:"",paperMentions:[]});return}j(!0),ns(a,te);try{const f=await rs(te);r(`/chat/${f.id}`)}catch{r("/chat")}}};return e.jsxs(e.Fragment,{children:[!o&&e.jsx("div",{className:"ask-home-new",children:"Hint: type @ to bring papers into context, or press Tab to use a suggestion"}),e.jsxs("div",{className:"ask-home",children:[e.jsxs("div",{className:"ask-home-row",children:[e.jsxs("div",{className:"ask-home-textarea-wrap",children:[e.jsx(ss,{text:m.text,mentions:m.paperMentions,scrollTop:w,variant:"home",completion:t?C:""}),e.jsx("textarea",{ref:_,rows:1,value:t,placeholder:P,"aria-label":"Ask the assistant",disabled:c,onChange:a=>{i.updateText(a.target.value,a.target.selectionStart),d.trackCaret(a.target)},onSelect:a=>{i.refresh(a.currentTarget.selectionStart),d.trackCaret(a.currentTarget)},onClick:a=>{i.refresh(a.currentTarget.selectionStart),d.trackCaret(a.currentTarget)},onScroll:a=>y(a.currentTarget.scrollTop),onBlur:a=>{var g,f;(f=(g=a.relatedTarget)==null?void 0:g.closest)!=null&&f.call(g,".chat-paper-picker")||window.setTimeout(i.close,0)},onKeyDown:a=>{if(!i.keyDown(a)){if(ts(a)&&C){a.preventDefault();const g=t+C;i.updateText(g,g.length),window.requestAnimationFrame(()=>{var f;return(f=_.current)==null?void 0:f.setSelectionRange(g.length,g.length)});return}a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),A())}},role:b?"combobox":void 0,"aria-expanded":b?i.open:void 0,"aria-controls":i.open?i.pickerId:void 0,"aria-activedescendant":i.open&&i.results.length?`${i.optionIdPrefix}-${i.activeIndex}`:void 0,"aria-autocomplete":b?"list":void 0,"aria-describedby":i.message?"ask-home-paper-mention-message":void 0})]}),e.jsx("button",{type:"button",className:`chat-send${t.trim()?" chat-send-on":""}`,onClick:()=>void A(),disabled:!t.trim()||c,"aria-label":"Ask the assistant",children:e.jsx(as,{})})]}),S&&e.jsx("div",{className:"chat-paper-mention-message",role:"alert",children:e.jsx("a",{href:S,target:"_blank",rel:"noreferrer",children:"Open this question on paperswithcode.co"})}),i.message&&e.jsx("div",{id:"ask-home-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:i.message}),e.jsx(os,{open:i.open,query:i.query,results:i.results,activeIndex:i.activeIndex,loading:i.loading,error:i.error,onSelect:i.select,id:i.pickerId,optionIdPrefix:i.optionIdPrefix})]})]})},Te={task:"Tasks",method:"Methods",benchmark:"Benchmarks",author:"Authors",organization:"Orgs"},ys=Object.keys(Te),js=30,ye=40,vs=async r=>{const o=await r;return{results:o.results.map(m=>({paper:m})),next_page:o.next_page}},Ns=({mode:r})=>{var G,K,ce,de,ue,pe,he;const o=r==="following",m=je(),l=Le(),t=l==null?void 0:l.user,[w,y]=Ae(),c=We(w,void 0,o?"month":"week"),j=s=>{const u=new URLSearchParams(w);u.delete("order_by"),u.delete("only");const T=u.toString();m(T?`${s}?${T}`:s)},S=s=>{const u=new URLSearchParams(w);s?u.set("only","topic"):u.delete("only");const T=u.toString();return T?`/following?${T}`:"/following"},L=H({queryKey:qe.topTasksSidebar,queryFn:()=>J.topTasks(8),staleTime:Q}),P=H({queryKey:["trending-tasks-sidebar"],queryFn:()=>J.trendingTasks({limit:8,level:0}),staleTime:Q}),v=o&&w.get("only")==="topic",_={start_date:c.startDate,end_date:c.endDate},M={...c,topicOnly:v},b=cs(o?[...se.feeds.following,t==null?void 0:t.hf_subject,M]:[...r==="x"?se.feeds.xTrending:se.feeds.trending,_],async s=>{if(o){const T=await ee.following(s,M),Pe=T.length===ye?s+ye:null;return{results:T,next_page:Pe}}const u={..._,page:s,page_size:js,include_resources:!0};return vs(r==="x"?xe.xTrending(u):xe.list({...u,order_by:"trending",order_dir:"desc",latest_only:!0}))},{enabled:!o||!!t,initialPage:o?0:1}),i=Ne(o),d=H({queryKey:ne.topic(t==null?void 0:t.hf_subject),queryFn:ee.topic,enabled:o&&!!t,refetchInterval:s=>s.state.data&&["pending","running"].includes(s.state.data.status)?1e4:!1}),C=!!d.data&&["pending","running"].includes(d.data.status),A=d.data?d.data.label??d.data.text:"",[D,a]=h.useState(!1),g=De(),f=h.useRef(!1);h.useEffect(()=>{f.current&&!C&&g.invalidateQueries({queryKey:ne.feed(t==null?void 0:t.hf_subject)}),f.current=C},[C,g,t==null?void 0:t.hf_subject]);const E=o&&!!t&&((G=i.data)==null?void 0:G.length)===0&&d.isSuccess&&!d.data,R=o&&!(l!=null&&l.isLoading)&&!t||E,q=!!t||!Re(),[I,W]=h.useState(!1),[X]=h.useState(()=>!!ge()||fe().length>0),[Y,Z]=h.useState(!1);!I&&(d.data||(K=i.data)!=null&&K.length)&&W(!0),R&&!Y&&(Z(!0),q&&!I&&!X&&a(!0));const O=Se(),{mutate:z}=O,B=h.useRef(!1);h.useEffect(()=>{var u;const s=ge();!t||!d.isSuccess||!s||B.current||(B.current=!0,s===((u=d.data)==null?void 0:u.text)?Be():z(s))},[t,d.isSuccess,d.data,z]);const n=ke(),{mutate:p}=n,N=h.useRef(!1);h.useEffect(()=>{const s=fe();!t||!s.length||N.current||(N.current=!0,p(s))},[t,p]);const k=h.useMemo(()=>ys.map(s=>{var u;return{kind:s,follows:o?((u=i.data)==null?void 0:u.filter(T=>T.kind===s))??[]:[]}}).filter(s=>s.follows.length>0),[o,i.data]),U=o&&(!!(l!=null&&l.isLoading)||!!t&&!E),V=h.useMemo(()=>{var s;return((s=b.data)==null?void 0:s.pages.flatMap(u=>u.results.map(T=>({...Ue(T.paper),followReasons:T.reasons}))))??[]},[b.data]),x=b.error;return e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["Trending ",e.jsx("em",{children:"Research"})]}),e.jsx("div",{className:"feed-subtitle",children:r==="x"?"Papers people share most on X, picked daily":"Curated daily from arXiv and Hugging Face"})]})}),e.jsxs("div",{className:"layout-with-sidebar",children:[e.jsxs("aside",{className:"sidebar feed-sidebar",children:[U?e.jsxs("div",{className:"sidebar-section sidebar-section-follows",children:[e.jsx("div",{className:"sidebar-label",children:"You follow"}),((l==null?void 0:l.isLoading)||i.isLoading)&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:4}).map((s,u)=>e.jsx(ae,{className:"h-5 w-full"},u))}),i.isError&&e.jsx("div",{style:{fontSize:12,color:"var(--ink-faint)"},children:"Couldn't load your follows."}),e.jsxs("div",{className:"sidebar-links",children:[d.data&&e.jsxs("div",{className:`sidebar-follow-topic ${v?"active":""}`,children:[e.jsxs(F,{to:S(!v),className:"sidebar-link sidebar-follow-link",title:v?"Show papers from everything you follow":`Show only papers about “${d.data.text}”`,"aria-current":v?"true":void 0,children:[e.jsx("span",{className:"sidebar-follow-kind",children:"Topic"}),e.jsx("span",{className:"sidebar-follow-name",children:A})]}),e.jsx("button",{type:"button",className:"sidebar-follow-edit","aria-label":"Edit topic","aria-expanded":D,onClick:()=>a(!0),children:"edit"})]}),k.map(s=>e.jsxs("div",{className:"sidebar-follow-group",children:[e.jsx("span",{className:"sidebar-follow-kind",children:Te[s.kind]}),s.follows.map(u=>e.jsx(F,{to:u.url,className:"sidebar-link sidebar-follow-link",children:e.jsx("span",{className:"sidebar-follow-name",children:u.name})},u.entity_id))]},s.kind))]}),e.jsx(F,{to:"/settings",className:"sidebar-follow-manage",children:"Manage in Settings"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sidebar-section sidebar-section-top-domains",children:[e.jsx("div",{className:"sidebar-label",children:"Top Domains"}),L.isLoading&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:6}).map((s,u)=>e.jsx(ae,{className:"h-5 w-full"},u))}),e.jsxs("div",{className:"sidebar-links",children:[(ce=L.data)==null?void 0:ce.map(s=>e.jsxs(F,{to:`/tasks/${s.slug}`,className:"sidebar-link",children:[le(s.name,s.slug),s.paper_count!=null&&e.jsx("span",{className:"count",children:s.paper_count})]},s.id)),e.jsx(F,{to:"/tasks",className:"sidebar-link sidebar-link-more",children:"all domains →"})]})]}),e.jsxs("div",{className:"sidebar-section sidebar-section-trending-domains",children:[e.jsx("div",{className:"sidebar-label",children:"Trending Domains"}),P.isLoading&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:6}).map((s,u)=>e.jsx(ae,{className:"h-5 w-full"},u))}),((ue=(de=P.data)==null?void 0:de.results)==null?void 0:ue.length)===0&&!P.isLoading&&e.jsx("div",{style:{fontSize:12,color:"var(--ink-faint)"},children:"No domains gaining momentum right now."}),e.jsx("div",{className:"sidebar-links",children:(he=(pe=P.data)==null?void 0:pe.results)==null?void 0:he.map(s=>e.jsxs(F,{to:`/tasks/${s.slug}`,className:"sidebar-link",children:[le(s.name,s.slug),e.jsxs("span",{className:"count",children:[s.share_lift.toFixed(1),"x"]})]},s.id))})]})]}),e.jsx(Ve,{})]}),e.jsxs("div",{className:"feed-main",children:[(re()||ve())&&e.jsx("div",{className:"feed-chat",children:e.jsx(bs,{})}),e.jsxs("div",{className:"feed-content",children:[e.jsxs("div",{className:"sort-bar home-feed-sort-bar",children:[e.jsx("div",{className:"paper-feed-toolbar-controls",children:e.jsxs("div",{className:"sort-options",children:[e.jsx("button",{className:`sort-btn ${r==="trending"?"active":""}`,onClick:()=>j("/"),children:"trending"}),e.jsx("button",{className:`sort-btn ${r==="x"?"active":""}`,onClick:()=>j("/x-trending"),children:"trending (X)"}),e.jsx("button",{className:`sort-btn ${o?"active":""}`,onClick:()=>j("/following"),children:"following"})]})}),e.jsx(Xe,{startDate:c.startDate,endDate:c.endDate,onChange:s=>y(Ye(w,s))})]}),x&&e.jsx(oe,{variant:"destructive",className:"mb-4",children:e.jsxs(ie,{children:["Failed to load papers. ",e.jsx("button",{type:"button",onClick:()=>void b.refetch(),children:"Try again"})]})}),O.isError&&O.variables&&e.jsx(oe,{variant:"destructive",className:"mb-4",children:e.jsxs(ie,{children:["Could not follow “",O.variables,"”. ",e.jsx("button",{type:"button",onClick:()=>z(O.variables),children:"Try again"})]})}),n.isError&&n.variables&&e.jsx(oe,{variant:"destructive",className:"mb-4",children:e.jsxs(ie,{children:["Could not follow ",n.variables.map(s=>s.name).join(", "),". ",e.jsx("button",{type:"button",onClick:()=>p(n.variables),children:"Try again"})]})}),o&&!!t&&d.isSuccess&&!i.isPending&&!E&&(d.data?C?e.jsxs("div",{className:"following-topic-note",role:"status",children:["Showing the closest papers about “",A,"” now. A model is reading papers to refine these matches, which takes a few minutes."]}):null:e.jsxs("div",{className:"following-topic-note",role:"status",children:["Describe a topic in your own words, and a model adds matching new papers to this feed."," ",e.jsx("button",{type:"button",className:"link-button",onClick:()=>a(!0),children:"Follow a topic"})]})),o&&q&&e.jsx(us,{open:D,onOpenChange:a}),v&&d.data&&e.jsxs("div",{className:"following-topic-note following-topic-filter",role:"status",children:["Showing only papers about “",A,"”."," ",e.jsx(F,{to:S(!1),children:"Show everything you follow"})]}),R?e.jsx(ds,{onBuild:q?()=>a(!0):void 0}):e.jsx(Ze,{query:b,isLoading:b.isLoading||o&&!!(l!=null&&l.isLoading),cards:V,skeleton:"card",rootMargin:"400px",empty:x?null:v?e.jsxs(e.Fragment,{children:["No papers about your topic match these filters. Widen the date range or ",e.jsx("button",{type:"button",className:"link-button",onClick:()=>a(!0),children:"edit your topic"}),"."]}):o?e.jsxs(e.Fragment,{children:["No papers from your topic or follows match these filters. Widen the date range, or follow more from ",e.jsx(F,{to:"/tasks",children:"tasks"}),", ",e.jsx(F,{to:"/methods",children:"methods"}),", benchmark, author, or organization pages."]}):r==="x"?"No papers shared on X in this window.":"No papers in this window."})]})]})]})]})},Js=({xTrending:r=!1})=>e.jsx(Ns,{mode:r?"x":"trending"});export{bs as AskAssistant,Ns as HomeFeed,Js as default}; diff --git a/assets/FollowingView-C0KL9Wds.js b/assets/FollowingView-C0KL9Wds.js new file mode 100644 index 0000000000000000000000000000000000000000..80e0f034b9859d1af9bbf8d9dc884501f59ad6d6 --- /dev/null +++ b/assets/FollowingView-C0KL9Wds.js @@ -0,0 +1 @@ +import{j as o}from"./index-CjdUkE4w.js";import{HomeFeed as r}from"./FeedView-BZs7imUl.js";import"./sparkles-CIfeDmV2.js";import"./dialog-BzX9PD3v.js";import"./catalog-qXcKve0z.js";import"./researchTopic-NmABF6tT.js";import"./useMutation-BYtVrkc7.js";import"./transform-CRNzYLch.js";import"./plus-AztI1566.js";import"./arrow-right-BrRhWCQS.js";import"./PaperFeed-D3FZw29k.js";import"./PaperCard-dvXhr75r.js";import"./AuthorAvatar-D9249Frl.js";import"./SotaBadges-CyScuNCv.js";import"./colors-BkWRhvFI.js";import"./Icon-CGRs4BYD.js";import"./LatexTitle-DESKtS30.js";import"./papers-DgZwjF3K.js";import"./curation-CyyuHfv5.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-Df5_dywQ.js";import"./skeleton-DTWi7Ctg.js";import"./useIntersectionObserver-Ch6RpsSk.js";import"./McpShowcase-Bo79ATLK.js";import"./AgentLogos-xoTIu0NB.js";import"./chatSessions-9VEG8seW.js";import"./chat-B1EBF720.js";import"./usePapers-BZThqZCx.js";import"./useInfiniteQuery-DeZTTVbI.js";import"./alert-BM9Xfuyy.js";function B(){return o.jsx(r,{mode:"following"})}export{B as default}; diff --git a/assets/FollowingView-Ctbw54vk.js b/assets/FollowingView-Ctbw54vk.js deleted file mode 100644 index 4bbdf0ea07da86d8a8380855f8d6df4502ade61c..0000000000000000000000000000000000000000 --- a/assets/FollowingView-Ctbw54vk.js +++ /dev/null @@ -1 +0,0 @@ -import{j as o}from"./index-DyXq7-Tg.js";import{HomeFeed as r}from"./FeedView-tA68x8iy.js";import"./sparkles-CcIiUzzc.js";import"./dialog-CfM0Uql2.js";import"./catalog-CRar2olQ.js";import"./researchTopic-DbX0eko-.js";import"./useMutation-UWxBeqtn.js";import"./transform-D46m70Qr.js";import"./plus-Yh42pKZz.js";import"./arrow-right-BzPanrWZ.js";import"./PaperFeed-EBt97iOL.js";import"./PaperCard-57p1OSGy.js";import"./AuthorAvatar-B-9xS2Wo.js";import"./SotaBadges-vbLLOUtT.js";import"./colors-BkWRhvFI.js";import"./Icon-T4LYkEQj.js";import"./LatexTitle-Bkyz3jCs.js";import"./papers-Dh3ljlL0.js";import"./curation-YeS7FBYf.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-CTBEUp7Y.js";import"./skeleton-C3IIzpSL.js";import"./useIntersectionObserver-D6_Iig9a.js";import"./McpShowcase-CLO4HLon.js";import"./AgentLogos-j-Qekw7T.js";import"./chatSessions-Ck_dyM0d.js";import"./chat-Ix1IrIwq.js";import"./usePapers-B0s20UcU.js";import"./useInfiniteQuery-BYh2zN-T.js";import"./alert-gbJBhAVE.js";function B(){return o.jsx(r,{mode:"following"})}export{B as default}; diff --git a/assets/FrameworksIndexView-CZmHXkeL.js b/assets/FrameworksIndexView-BBgK14SQ.js similarity index 95% rename from assets/FrameworksIndexView-CZmHXkeL.js rename to assets/FrameworksIndexView-BBgK14SQ.js index f007a71abfef453e99f932bb488f4f9dbbca16e5..f6b9270fdc4306faabfc4fce5c02f4532e4b1bb7 100644 --- a/assets/FrameworksIndexView-CZmHXkeL.js +++ b/assets/FrameworksIndexView-BBgK14SQ.js @@ -1 +1 @@ -import{e as d,j as e,L as c,b as m,V as h}from"./index-DyXq7-Tg.js";import{I as p}from"./Icon-T4LYkEQj.js";import{c as u}from"./catalog-CRar2olQ.js";import{c as g,h as x}from"./colors-BkWRhvFI.js";import{P as f}from"./frameworks-DDA0P4Tf.js";const j={fontFamily:"var(--mono)",fontSize:13,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--ink)",marginBottom:6},k=({platform:s})=>{const n=g(x(s));return e.jsx("span",{className:"framework-platform-chip",style:{background:n.bg,color:n.text},children:f[s]})},_=({framework:s})=>{const n=d(),t=`/papers?framework=${encodeURIComponent(s.slug)}`;return e.jsxs("article",{id:`framework-${s.slug}`,className:"framework-card framework-card-clickable",role:"link",tabIndex:0,"aria-label":`View papers implemented by ${s.name}`,onClick:a=>{a.target.closest("a, button")||n(t)},onKeyDown:a=>{a.target===a.currentTarget&&(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),n(t))},children:[e.jsxs("div",{className:"framework-card-head",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"framework-card-name",children:s.name}),s.organization_name&&e.jsx("div",{className:"framework-card-org",children:s.organization_name})]}),s.platforms&&s.platforms.length>0&&e.jsx("div",{className:"framework-platform-row",children:s.platforms.map(a=>e.jsx(k,{platform:a},a))})]}),e.jsx("p",{className:"framework-card-desc",children:s.description}),s.when_to_use&&e.jsxs("div",{className:"framework-card-when",children:[e.jsx("span",{className:"framework-card-when-label",children:"When to use"}),s.when_to_use]}),(s.github_url||s.docs_url||s.introducing_paper_arxiv_id)&&e.jsxs("div",{className:"framework-card-links",children:[s.introducing_paper_arxiv_id&&e.jsx(c,{to:`/paper/${s.introducing_paper_arxiv_id}`,className:"framework-link",children:"Introducing paper"}),s.github_url&&s.paper_count>0&&e.jsxs(c,{to:t,className:"framework-link",children:["Implements ",s.paper_count," ",s.paper_count===1?"paper":"papers"]}),s.github_url&&s.paper_count===0&&e.jsx("span",{className:"framework-link framework-link-disabled","aria-disabled":"true",children:"Implements 0 papers"}),s.github_url&&e.jsxs("a",{href:s.github_url,target:"_blank",rel:"noopener noreferrer",className:"framework-link",children:[e.jsx(p,{name:"github",size:13}),"GitHub"]}),s.docs_url&&s.docs_url!==s.github_url&&e.jsx("a",{href:s.docs_url,target:"_blank",rel:"noopener noreferrer",className:"framework-link",children:"Docs"})]})]})},I=()=>{var a;const s=m({queryKey:["framework-catalog"],queryFn:()=>u.frameworkCatalog()}),n=((a=s.data)==null?void 0:a.domains)??[],t=n.reduce((i,r)=>i+r.categories.reduce((l,o)=>l+o.frameworks.length,0),0);return h.useEffect(()=>{var r;const i=window.location.hash.slice(1);i&&((r=document.getElementById(i))==null||r.scrollIntoView())},[s.data]),e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["AI ",e.jsx("em",{children:"Frameworks"})]}),e.jsx("div",{className:"feed-subtitle",children:"Curated libraries and tools to run, serve, and train models — pick the right stack for your hardware and workload."})]})}),s.isLoading&&e.jsx("div",{className:"empty",children:"Loading frameworks…"}),s.isError&&e.jsx("div",{className:"empty",children:"Could not load frameworks."}),n.map(i=>e.jsxs("section",{style:{marginBottom:56},children:[e.jsxs("div",{className:"area-section-head",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"area-section-title",children:i.name}),e.jsx("div",{className:"area-section-description",children:i.description})]}),e.jsxs("div",{className:"area-section-meta",children:[i.categories.length," ",i.categories.length===1?"category":"categories"," ·"," ",i.categories.reduce((r,l)=>r+l.frameworks.length,0)," frameworks"]})]}),i.categories.map(r=>e.jsxs("div",{className:"framework-category",children:[e.jsxs("div",{className:"framework-category-head",children:[e.jsxs("div",{children:[e.jsx("h3",{style:j,children:r.name}),r.description&&e.jsx("p",{className:"framework-category-blurb",children:r.description}),r.guide_url&&e.jsxs("a",{href:r.guide_url,target:"_blank",rel:"noopener noreferrer",className:"framework-guide-link",children:[r.guide_label??"Read guide"," →"]})]}),e.jsxs("div",{className:"framework-category-meta",children:[r.frameworks.length," ",r.frameworks.length===1?"framework":"frameworks"]})]}),e.jsx("div",{className:"framework-grid",children:r.frameworks.map(l=>e.jsx(_,{framework:l},l.slug))})]},r.slug))]},i.slug)),e.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink-faint)",marginTop:8},children:[t," frameworks across ",n.length," ",n.length===1?"domain":"domains",". More areas coming soon."]})]})};export{_ as FrameworkCard,I as default}; +import{e as d,j as e,L as c,b as m,V as h}from"./index-CjdUkE4w.js";import{I as p}from"./Icon-CGRs4BYD.js";import{c as u}from"./catalog-qXcKve0z.js";import{c as g,h as x}from"./colors-BkWRhvFI.js";import{P as f}from"./frameworks-DDA0P4Tf.js";const j={fontFamily:"var(--mono)",fontSize:13,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--ink)",marginBottom:6},k=({platform:s})=>{const n=g(x(s));return e.jsx("span",{className:"framework-platform-chip",style:{background:n.bg,color:n.text},children:f[s]})},_=({framework:s})=>{const n=d(),t=`/papers?framework=${encodeURIComponent(s.slug)}`;return e.jsxs("article",{id:`framework-${s.slug}`,className:"framework-card framework-card-clickable",role:"link",tabIndex:0,"aria-label":`View papers implemented by ${s.name}`,onClick:a=>{a.target.closest("a, button")||n(t)},onKeyDown:a=>{a.target===a.currentTarget&&(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),n(t))},children:[e.jsxs("div",{className:"framework-card-head",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"framework-card-name",children:s.name}),s.organization_name&&e.jsx("div",{className:"framework-card-org",children:s.organization_name})]}),s.platforms&&s.platforms.length>0&&e.jsx("div",{className:"framework-platform-row",children:s.platforms.map(a=>e.jsx(k,{platform:a},a))})]}),e.jsx("p",{className:"framework-card-desc",children:s.description}),s.when_to_use&&e.jsxs("div",{className:"framework-card-when",children:[e.jsx("span",{className:"framework-card-when-label",children:"When to use"}),s.when_to_use]}),(s.github_url||s.docs_url||s.introducing_paper_arxiv_id)&&e.jsxs("div",{className:"framework-card-links",children:[s.introducing_paper_arxiv_id&&e.jsx(c,{to:`/paper/${s.introducing_paper_arxiv_id}`,className:"framework-link",children:"Introducing paper"}),s.github_url&&s.paper_count>0&&e.jsxs(c,{to:t,className:"framework-link",children:["Implements ",s.paper_count," ",s.paper_count===1?"paper":"papers"]}),s.github_url&&s.paper_count===0&&e.jsx("span",{className:"framework-link framework-link-disabled","aria-disabled":"true",children:"Implements 0 papers"}),s.github_url&&e.jsxs("a",{href:s.github_url,target:"_blank",rel:"noopener noreferrer",className:"framework-link",children:[e.jsx(p,{name:"github",size:13}),"GitHub"]}),s.docs_url&&s.docs_url!==s.github_url&&e.jsx("a",{href:s.docs_url,target:"_blank",rel:"noopener noreferrer",className:"framework-link",children:"Docs"})]})]})},I=()=>{var a;const s=m({queryKey:["framework-catalog"],queryFn:()=>u.frameworkCatalog()}),n=((a=s.data)==null?void 0:a.domains)??[],t=n.reduce((i,r)=>i+r.categories.reduce((l,o)=>l+o.frameworks.length,0),0);return h.useEffect(()=>{var r;const i=window.location.hash.slice(1);i&&((r=document.getElementById(i))==null||r.scrollIntoView())},[s.data]),e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["AI ",e.jsx("em",{children:"Frameworks"})]}),e.jsx("div",{className:"feed-subtitle",children:"Curated libraries and tools to run, serve, and train models — pick the right stack for your hardware and workload."})]})}),s.isLoading&&e.jsx("div",{className:"empty",children:"Loading frameworks…"}),s.isError&&e.jsx("div",{className:"empty",children:"Could not load frameworks."}),n.map(i=>e.jsxs("section",{style:{marginBottom:56},children:[e.jsxs("div",{className:"area-section-head",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"area-section-title",children:i.name}),e.jsx("div",{className:"area-section-description",children:i.description})]}),e.jsxs("div",{className:"area-section-meta",children:[i.categories.length," ",i.categories.length===1?"category":"categories"," ·"," ",i.categories.reduce((r,l)=>r+l.frameworks.length,0)," frameworks"]})]}),i.categories.map(r=>e.jsxs("div",{className:"framework-category",children:[e.jsxs("div",{className:"framework-category-head",children:[e.jsxs("div",{children:[e.jsx("h3",{style:j,children:r.name}),r.description&&e.jsx("p",{className:"framework-category-blurb",children:r.description}),r.guide_url&&e.jsxs("a",{href:r.guide_url,target:"_blank",rel:"noopener noreferrer",className:"framework-guide-link",children:[r.guide_label??"Read guide"," →"]})]}),e.jsxs("div",{className:"framework-category-meta",children:[r.frameworks.length," ",r.frameworks.length===1?"framework":"frameworks"]})]}),e.jsx("div",{className:"framework-grid",children:r.frameworks.map(l=>e.jsx(_,{framework:l},l.slug))})]},r.slug))]},i.slug)),e.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink-faint)",marginTop:8},children:[t," frameworks across ",n.length," ",n.length===1?"domain":"domains",". More areas coming soon."]})]})};export{_ as FrameworkCard,I as default}; diff --git a/assets/Icon-T4LYkEQj.js b/assets/Icon-CGRs4BYD.js similarity index 97% rename from assets/Icon-T4LYkEQj.js rename to assets/Icon-CGRs4BYD.js index 1379ddcee5acfde08712ee82a0b37ccfd5ffeb29..4b1f3e89b980593fdbb3d5177d71ae690e1cb56e 100644 --- a/assets/Icon-T4LYkEQj.js +++ b/assets/Icon-CGRs4BYD.js @@ -1 +1 @@ -import{j as o}from"./index-DyXq7-Tg.js";const s=({name:t,size:r=14})=>{const e={search:o.jsx("path",{d:"M11 11l3 3M7 12.5a5.5 5.5 0 110-11 5.5 5.5 0 010 11z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round"}),arrowUp:o.jsx("path",{d:"M8 3l5 6H3l5-6z",fill:"currentColor"}),arrowLeft:o.jsx("path",{d:"M9 3l-4 5 4 5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}),arrowRight:o.jsx("path",{d:"M7 3l4 5-4 5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}),external:o.jsx("path",{d:"M5 3h-2v8h8v-2M9 3h3v3M7 9l5-5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}),github:o.jsx("path",{d:"M8 1a7 7 0 00-2.21 13.64c.35.06.48-.15.48-.34v-1.2c-1.95.42-2.36-.94-2.36-.94-.32-.81-.78-1.03-.78-1.03-.64-.43.05-.43.05-.43.7.05 1.07.72 1.07.72.62 1.07 1.64.76 2.04.58.06-.45.24-.76.44-.94-1.55-.18-3.18-.78-3.18-3.46 0-.76.27-1.39.72-1.88-.07-.18-.31-.89.07-1.86 0 0 .59-.19 1.92.72.56-.15 1.16-.23 1.75-.24.59 0 1.19.08 1.75.24 1.33-.9 1.92-.72 1.92-.72.38.97.14 1.68.07 1.86.45.49.72 1.12.72 1.88 0 2.69-1.64 3.28-3.19 3.45.25.22.48.65.48 1.32v1.95c0 .19.13.41.49.34A7 7 0 008 1z",fill:"currentColor"}),citation:o.jsx("path",{d:"M3 4h3v3H3zM4 7v1.5a1.5 1.5 0 01-1.5 1.5M9 4h3v3H9zM10 7v1.5a1.5 1.5 0 01-1.5 1.5",stroke:"currentColor",strokeWidth:"1.2",fill:"none"}),bookmark:o.jsx("path",{d:"M4 2h8v12l-4-3-4 3V2z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinejoin:"round"}),chart:o.jsx("path",{d:"M2 13h12M3 11l3-4 3 2 4-5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}),chat:o.jsx("path",{d:"M3 3h10v7H7l-3 3v-3H3V3z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinejoin:"round"}),pdf:o.jsx("path",{d:"M5 2h5l3 3v9H5V2z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinejoin:"round"}),copy:o.jsx("path",{d:"M5 5h7v8H5V5zM3 3h7v2M3 3v8h2",stroke:"currentColor",strokeWidth:"1.2",fill:"none",strokeLinejoin:"round"}),sparkle:o.jsx("path",{d:"M8 2l1.2 3.8L13 7l-3.8 1.2L8 12l-1.2-3.8L3 7l3.8-1.2L8 2z",fill:"currentColor"}),user:o.jsx("path",{d:"M8 8a3 3 0 100-6 3 3 0 000 6zM2 14c0-3 2.5-5 6-5s6 2 6 5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round"}),globe:o.jsx("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM1.5 8h13M8 1.5c1.7 1.9 2.6 4.2 2.6 6.5s-.9 4.6-2.6 6.5M8 1.5C6.3 3.4 5.4 5.7 5.4 8s.9 4.6 2.6 6.5",stroke:"currentColor",strokeWidth:"1.2",fill:"none",strokeLinecap:"round"}),menu:o.jsx("path",{d:"M2 4h12M2 8h12M2 12h12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),close:o.jsx("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),pencil:o.jsx("path",{d:"M10.5 2.5l3 3L6 13H3v-3l7.5-7.5zM9 4l3 3",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})};return o.jsx("svg",{className:r===11?"icon-sm":"icon",viewBox:"0 0 16 16",width:r,height:r,children:e[t]})};export{s as I}; +import{j as o}from"./index-CjdUkE4w.js";const s=({name:t,size:r=14})=>{const e={search:o.jsx("path",{d:"M11 11l3 3M7 12.5a5.5 5.5 0 110-11 5.5 5.5 0 010 11z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round"}),arrowUp:o.jsx("path",{d:"M8 3l5 6H3l5-6z",fill:"currentColor"}),arrowLeft:o.jsx("path",{d:"M9 3l-4 5 4 5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}),arrowRight:o.jsx("path",{d:"M7 3l4 5-4 5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}),external:o.jsx("path",{d:"M5 3h-2v8h8v-2M9 3h3v3M7 9l5-5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}),github:o.jsx("path",{d:"M8 1a7 7 0 00-2.21 13.64c.35.06.48-.15.48-.34v-1.2c-1.95.42-2.36-.94-2.36-.94-.32-.81-.78-1.03-.78-1.03-.64-.43.05-.43.05-.43.7.05 1.07.72 1.07.72.62 1.07 1.64.76 2.04.58.06-.45.24-.76.44-.94-1.55-.18-3.18-.78-3.18-3.46 0-.76.27-1.39.72-1.88-.07-.18-.31-.89.07-1.86 0 0 .59-.19 1.92.72.56-.15 1.16-.23 1.75-.24.59 0 1.19.08 1.75.24 1.33-.9 1.92-.72 1.92-.72.38.97.14 1.68.07 1.86.45.49.72 1.12.72 1.88 0 2.69-1.64 3.28-3.19 3.45.25.22.48.65.48 1.32v1.95c0 .19.13.41.49.34A7 7 0 008 1z",fill:"currentColor"}),citation:o.jsx("path",{d:"M3 4h3v3H3zM4 7v1.5a1.5 1.5 0 01-1.5 1.5M9 4h3v3H9zM10 7v1.5a1.5 1.5 0 01-1.5 1.5",stroke:"currentColor",strokeWidth:"1.2",fill:"none"}),bookmark:o.jsx("path",{d:"M4 2h8v12l-4-3-4 3V2z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinejoin:"round"}),chart:o.jsx("path",{d:"M2 13h12M3 11l3-4 3 2 4-5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}),chat:o.jsx("path",{d:"M3 3h10v7H7l-3 3v-3H3V3z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinejoin:"round"}),pdf:o.jsx("path",{d:"M5 2h5l3 3v9H5V2z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinejoin:"round"}),copy:o.jsx("path",{d:"M5 5h7v8H5V5zM3 3h7v2M3 3v8h2",stroke:"currentColor",strokeWidth:"1.2",fill:"none",strokeLinejoin:"round"}),sparkle:o.jsx("path",{d:"M8 2l1.2 3.8L13 7l-3.8 1.2L8 12l-1.2-3.8L3 7l3.8-1.2L8 2z",fill:"currentColor"}),user:o.jsx("path",{d:"M8 8a3 3 0 100-6 3 3 0 000 6zM2 14c0-3 2.5-5 6-5s6 2 6 5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round"}),globe:o.jsx("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM1.5 8h13M8 1.5c1.7 1.9 2.6 4.2 2.6 6.5s-.9 4.6-2.6 6.5M8 1.5C6.3 3.4 5.4 5.7 5.4 8s.9 4.6 2.6 6.5",stroke:"currentColor",strokeWidth:"1.2",fill:"none",strokeLinecap:"round"}),menu:o.jsx("path",{d:"M2 4h12M2 8h12M2 12h12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),close:o.jsx("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),pencil:o.jsx("path",{d:"M10.5 2.5l3 3L6 13H3v-3l7.5-7.5zM9 4l3 3",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})};return o.jsx("svg",{className:r===11?"icon-sm":"icon",viewBox:"0 0 16 16",width:r,height:r,children:e[t]})};export{s as I}; diff --git a/assets/LatexTitle-Bkyz3jCs.js b/assets/LatexTitle-DESKtS30.js similarity index 98% rename from assets/LatexTitle-Bkyz3jCs.js rename to assets/LatexTitle-DESKtS30.js index 88477725882c04b51cf553c54cf3c51c5b9afa50..9db029a06e5d634417c6de6744648a471a388dcb 100644 --- a/assets/LatexTitle-Bkyz3jCs.js +++ b/assets/LatexTitle-DESKtS30.js @@ -1,2 +1,2 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/katex-wklAmtGL.css"])))=>i.map(i=>d[i]); -import{j as u,d as A,a7 as L}from"./index-DyXq7-Tg.js";let g=null,$=null;function M(){return $??($=Promise.all([L(()=>import("./katex-DkKDou_j.js"),[]),L(()=>Promise.resolve({}),__vite__mapDeps([0]))]).then(([n])=>(g=n.default,g))),$}const O=new Set([",",";",":","!"," ","quad","qquad","enspace","thinspace"]),S={a:"á",e:"é",i:"í",o:"ó",u:"ú",y:"ý",A:"Á",E:"É",I:"Í",O:"Ó",U:"Ú",Y:"Ý"},b={a:"à",e:"è",i:"ì",o:"ò",u:"ù",A:"À",E:"È",I:"Ì",O:"Ò",U:"Ù"},w={a:"â",e:"ê",i:"î",o:"ô",u:"û",A:"Â",E:"Ê",I:"Î",O:"Ô",U:"Û"},k={a:"ä",e:"ë",i:"ï",o:"ö",u:"ü",y:"ÿ",A:"Ä",E:"Ë",I:"Ï",O:"Ö",U:"Ü",Y:"Ÿ"},N={"'":S,"`":b,"^":w,'"':k,"~":{n:"ñ",N:"Ñ"}},T={ss:"ß",ae:"æ",AE:"Æ",oe:"œ",OE:"Œ",o:"ø",O:"Ø",l:"ł",L:"Ł"};function I(n,i){var e;return((e=N[n])==null?void 0:e[i])??null}function v(n){const i=[];let e=0,t="";const r=()=>{t&&(i.push({type:"text",content:t}),t="")};for(;e=n.length)return{name:"",end:e};if(!/[a-zA-Z]/.test(n[e]))return{name:n[e],end:e+1};const t=e;for(;e=n.length)return null;if(n[i+1]==="{"){const t=d(n,i+1);return t?{end:t.end}:null}return/[A-Za-z0-9+\-=.]/.test(n[i+1])?{end:i+2}:null}function y(n,i){let e=i;if(n[e]==="\\"){const{name:o,end:s}=j(n,e);if(!o)return null;if(e=s,n[e]==="{"){const a=d(n,e);a&&(e=a.end)}}else if(/[A-Za-z0-9]/.test(n[e])){let o=e+1;for(;oe.length-i.length)}function X(n,i,e){const t=z(i);if(!t.length)return[n];const r=t.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),o=new RegExp(`(${r.join("|")})`,"gi");return n.split(o).filter(Boolean).map((s,a)=>t.some(p=>p.toLocaleLowerCase()===s.toLocaleLowerCase())?u.jsx("mark",{children:s},`${e}-mark-${a}`):s)}function m(n,i,e){const t=[];let r=0,o=0;const s=()=>`${i}-${o++}`,a=(p,f)=>p==="strong"?u.jsx("strong",{children:f},s()):u.jsx("em",{children:f},s());for(;rr&&t.push(...X(n.slice(r,f),e,s())),r=f}return t}function _({latex:n,display:i}){const[e,t]=A.useState(g);A.useEffect(()=>{if(e)return;let o=!0;return M().then(s=>{o&&t(()=>s)}),()=>{o=!1}},[e]);const r=A.useMemo(()=>{if(e)try{return e.renderToString(n.trim(),{displayMode:i,throwOnError:!1})}catch{return null}},[e,n,i]);return r===void 0?u.jsx(u.Fragment,{children:n}):r?u.jsx("span",{className:i?"katex-display":void 0,dangerouslySetInnerHTML:{__html:r}}):u.jsx(u.Fragment,{children:i?`$$${n}$$`:`$${n}$`})}function D(n,i){const e=v(n),t=[];return e.forEach((r,o)=>{const s=`latex-${o}`;if(r.type==="text"){const a=m(r.content,s,i);a.length===1?t.push(a[0]):a.length>1&&t.push(u.jsx(A.Fragment,{children:a},s));return}if(r.type==="display"){t.push(u.jsx(_,{latex:r.content,display:!0},s));return}t.push(u.jsx(_,{latex:r.content,display:!1},s))}),t.length===1?t[0]:u.jsx(u.Fragment,{children:t})}const P=({text:n,className:i="",highlight:e})=>{const t=A.useMemo(()=>D(n,e),[n,e]);return u.jsx("span",{className:i,children:t})},Z=({title:n,className:i="",highlight:e})=>u.jsx(P,{text:n,className:i,highlight:e});export{Z as L,P as a}; +import{j as u,d as A,a7 as L}from"./index-CjdUkE4w.js";let g=null,$=null;function M(){return $??($=Promise.all([L(()=>import("./katex-DkKDou_j.js"),[]),L(()=>Promise.resolve({}),__vite__mapDeps([0]))]).then(([n])=>(g=n.default,g))),$}const O=new Set([",",";",":","!"," ","quad","qquad","enspace","thinspace"]),S={a:"á",e:"é",i:"í",o:"ó",u:"ú",y:"ý",A:"Á",E:"É",I:"Í",O:"Ó",U:"Ú",Y:"Ý"},b={a:"à",e:"è",i:"ì",o:"ò",u:"ù",A:"À",E:"È",I:"Ì",O:"Ò",U:"Ù"},w={a:"â",e:"ê",i:"î",o:"ô",u:"û",A:"Â",E:"Ê",I:"Î",O:"Ô",U:"Û"},k={a:"ä",e:"ë",i:"ï",o:"ö",u:"ü",y:"ÿ",A:"Ä",E:"Ë",I:"Ï",O:"Ö",U:"Ü",Y:"Ÿ"},N={"'":S,"`":b,"^":w,'"':k,"~":{n:"ñ",N:"Ñ"}},T={ss:"ß",ae:"æ",AE:"Æ",oe:"œ",OE:"Œ",o:"ø",O:"Ø",l:"ł",L:"Ł"};function I(n,i){var e;return((e=N[n])==null?void 0:e[i])??null}function v(n){const i=[];let e=0,t="";const r=()=>{t&&(i.push({type:"text",content:t}),t="")};for(;e=n.length)return{name:"",end:e};if(!/[a-zA-Z]/.test(n[e]))return{name:n[e],end:e+1};const t=e;for(;e=n.length)return null;if(n[i+1]==="{"){const t=d(n,i+1);return t?{end:t.end}:null}return/[A-Za-z0-9+\-=.]/.test(n[i+1])?{end:i+2}:null}function y(n,i){let e=i;if(n[e]==="\\"){const{name:o,end:s}=j(n,e);if(!o)return null;if(e=s,n[e]==="{"){const a=d(n,e);a&&(e=a.end)}}else if(/[A-Za-z0-9]/.test(n[e])){let o=e+1;for(;oe.length-i.length)}function X(n,i,e){const t=z(i);if(!t.length)return[n];const r=t.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),o=new RegExp(`(${r.join("|")})`,"gi");return n.split(o).filter(Boolean).map((s,a)=>t.some(p=>p.toLocaleLowerCase()===s.toLocaleLowerCase())?u.jsx("mark",{children:s},`${e}-mark-${a}`):s)}function m(n,i,e){const t=[];let r=0,o=0;const s=()=>`${i}-${o++}`,a=(p,f)=>p==="strong"?u.jsx("strong",{children:f},s()):u.jsx("em",{children:f},s());for(;rr&&t.push(...X(n.slice(r,f),e,s())),r=f}return t}function _({latex:n,display:i}){const[e,t]=A.useState(g);A.useEffect(()=>{if(e)return;let o=!0;return M().then(s=>{o&&t(()=>s)}),()=>{o=!1}},[e]);const r=A.useMemo(()=>{if(e)try{return e.renderToString(n.trim(),{displayMode:i,throwOnError:!1})}catch{return null}},[e,n,i]);return r===void 0?u.jsx(u.Fragment,{children:n}):r?u.jsx("span",{className:i?"katex-display":void 0,dangerouslySetInnerHTML:{__html:r}}):u.jsx(u.Fragment,{children:i?`$$${n}$$`:`$${n}$`})}function D(n,i){const e=v(n),t=[];return e.forEach((r,o)=>{const s=`latex-${o}`;if(r.type==="text"){const a=m(r.content,s,i);a.length===1?t.push(a[0]):a.length>1&&t.push(u.jsx(A.Fragment,{children:a},s));return}if(r.type==="display"){t.push(u.jsx(_,{latex:r.content,display:!0},s));return}t.push(u.jsx(_,{latex:r.content,display:!1},s))}),t.length===1?t[0]:u.jsx(u.Fragment,{children:t})}const P=({text:n,className:i="",highlight:e})=>{const t=A.useMemo(()=>D(n,e),[n,e]);return u.jsx("span",{className:i,children:t})},Z=({title:n,className:i="",highlight:e})=>u.jsx(P,{text:n,className:i,highlight:e});export{Z as L,P as a}; diff --git a/assets/MarkdownText-CUzPoC9Y.js b/assets/MarkdownText-MrITlqRE.js similarity index 86% rename from assets/MarkdownText-CUzPoC9Y.js rename to assets/MarkdownText-MrITlqRE.js index 50dee1fb800601183df594c3b0afd49c9afd143b..3c1143a4930db7649dfbd1f22a96aca0611b202d 100644 --- a/assets/MarkdownText-CUzPoC9Y.js +++ b/assets/MarkdownText-MrITlqRE.js @@ -1 +1 @@ -import{w as c,j as o,L as u}from"./index-DyXq7-Tg.js";/* empty css */import{r as p,a as m,P as d}from"./PaperPreviewLink-CpCZSa8K.js";import{M as h}from"./index-mCi_y_l3.js";import{r as f}from"./index-2CvJmBVB.js";function w(e){return(e??"").split(",").map(a=>a.trim().toLowerCase()).filter(Boolean)}const x=new Set(["paperswithcode.co","www.paperswithcode.co","localhost","127.0.0.1",...w(void 0)]),P=["/methods","/paper","/papers","/tasks","/benchmark","/conferences"];function k(e,a=window.location.origin){if(!e)return null;let t;if(e.startsWith("/"))t=e;else try{const n=new URL(e,a);if(!x.has(n.hostname))return null;t=`${n.pathname}${n.search}${n.hash}`}catch{return null}const r=t.split(/[?#]/,1)[0];return P.some(n=>r===n||r.startsWith(`${n}/`))?t:null}function I(e){const t=e.split(/[?#]/,1)[0].match(/^\/papers?\/([^/]+)$/);if(!t||t[1].includes("%"))return null;const r=t[1],n=/^\d{4}[.-]\d{4,5}(?:v\d+)?$/.test(r),s=/^[1-9]\d*$/.test(r);return!n&&!s?null:c(r)}const M=({text:e,className:a=""})=>o.jsx("div",{className:a,children:o.jsx(h,{remarkPlugins:[f,m],rehypePlugins:[p],components:{a:({href:t,children:r,node:n,...s})=>{const i=k(t);if(i){const l=I(i);return l?o.jsx(d,{routeId:l,to:i,...s,children:r}):o.jsx(u,{to:i,...s,children:r})}return o.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",...s,children:r})}},children:e})});export{M,k as r}; +import{w as c,j as o,L as u}from"./index-CjdUkE4w.js";/* empty css */import{r as p,a as m,P as d}from"./PaperPreviewLink-zGfFNaz6.js";import{M as h}from"./index-tLcwYp0U.js";import{r as f}from"./index-Dj6aE-6E.js";function w(e){return(e??"").split(",").map(a=>a.trim().toLowerCase()).filter(Boolean)}const x=new Set(["paperswithcode.co","www.paperswithcode.co","localhost","127.0.0.1",...w(void 0)]),P=["/methods","/paper","/papers","/tasks","/benchmark","/conferences"];function k(e,a=window.location.origin){if(!e)return null;let t;if(e.startsWith("/"))t=e;else try{const n=new URL(e,a);if(!x.has(n.hostname))return null;t=`${n.pathname}${n.search}${n.hash}`}catch{return null}const r=t.split(/[?#]/,1)[0];return P.some(n=>r===n||r.startsWith(`${n}/`))?t:null}function I(e){const t=e.split(/[?#]/,1)[0].match(/^\/papers?\/([^/]+)$/);if(!t||t[1].includes("%"))return null;const r=t[1],n=/^\d{4}[.-]\d{4,5}(?:v\d+)?$/.test(r),s=/^[1-9]\d*$/.test(r);return!n&&!s?null:c(r)}const M=({text:e,className:a=""})=>o.jsx("div",{className:a,children:o.jsx(h,{remarkPlugins:[f,m],rehypePlugins:[p],components:{a:({href:t,children:r,node:n,...s})=>{const i=k(t);if(i){const l=I(i);return l?o.jsx(d,{routeId:l,to:i,...s,children:r}):o.jsx(u,{to:i,...s,children:r})}return o.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",...s,children:r})}},children:e})});export{M,k as r}; diff --git a/assets/McpShowcase-CLO4HLon.js b/assets/McpShowcase-Bo79ATLK.js similarity index 84% rename from assets/McpShowcase-CLO4HLon.js rename to assets/McpShowcase-Bo79ATLK.js index a6087b02db81df73ae3a4809b84cd8f749dcf175..ec16b65d21fffb532d53a5e501cf1b80ebc7abce 100644 --- a/assets/McpShowcase-CLO4HLon.js +++ b/assets/McpShowcase-Bo79ATLK.js @@ -1 +1 @@ -import{j as e,L as t}from"./index-DyXq7-Tg.js";import{A as a}from"./AgentLogos-j-Qekw7T.js";function n({className:s="",canNavigate:r}){return e.jsxs("div",{className:`sidebar-section sidebar-section-tools ${s}`.trim(),children:[e.jsx("div",{className:"sidebar-label",children:"Use PwC with your agent"}),e.jsxs(t,{to:"/mcp",className:"action-btn sidebar-tools-mcp",title:"Connect Claude, Codex, Cursor, or OpenCode to the PwC MCP server",onClick:o=>{r&&!r()&&o.preventDefault()},children:["MCP server",e.jsx(a,{})]}),e.jsxs("p",{className:"sidebar-tools-copy",children:["Search papers, benchmarks, and leaderboards from any MCP client, or from the terminal with the"," ",e.jsxs("a",{href:"https://github.com/huggingface/pwc-cli",target:"_blank",rel:"noreferrer",children:[e.jsx("code",{children:"pwc"})," CLI"]}),"."]})]})}export{n as M}; +import{j as e,L as t}from"./index-CjdUkE4w.js";import{A as a}from"./AgentLogos-xoTIu0NB.js";function n({className:s="",canNavigate:r}){return e.jsxs("div",{className:`sidebar-section sidebar-section-tools ${s}`.trim(),children:[e.jsx("div",{className:"sidebar-label",children:"Use PwC with your agent"}),e.jsxs(t,{to:"/mcp",className:"action-btn sidebar-tools-mcp",title:"Connect Claude, Codex, Cursor, or OpenCode to the PwC MCP server",onClick:o=>{r&&!r()&&o.preventDefault()},children:["MCP server",e.jsx(a,{})]}),e.jsxs("p",{className:"sidebar-tools-copy",children:["Search papers, benchmarks, and leaderboards from any MCP client, or from the terminal with the"," ",e.jsxs("a",{href:"https://github.com/huggingface/pwc-cli",target:"_blank",rel:"noreferrer",children:[e.jsx("code",{children:"pwc"})," CLI"]}),"."]})]})}export{n as M}; diff --git a/assets/McpView-DYa6GKrp.js b/assets/McpView-A6zV6cTb.js similarity index 97% rename from assets/McpView-DYa6GKrp.js rename to assets/McpView-A6zV6cTb.js index 37c6fa2c1f9b0aeae0f216b5ded9f1eb9c87a749..e1286f389e2834fa25f005502ce9d1b14ba8c647 100644 --- a/assets/McpView-DYa6GKrp.js +++ b/assets/McpView-A6zV6cTb.js @@ -1,4 +1,4 @@ -import{s as b,b as x,V as m,j as e,C as j}from"./index-DyXq7-Tg.js";import{u as g,f as y}from"./useDocumentTitle-DcxM2Zv_.js";import{q as f}from"./queryOptions-C9woPjwX.js";import{G as v}from"./github-RNrgGHRT.js";import{E as o}from"./external-link-orY1Xz1I.js";import{C as w}from"./copy-CxR0OKx2.js";/** +import{s as b,b as x,V as m,j as e,C as j}from"./index-CjdUkE4w.js";import{u as g,f as y}from"./useDocumentTitle-2Ho8_KfW.js";import{q as f}from"./queryOptions-C9woPjwX.js";import{G as v}from"./github-4bW4WI_e.js";import{E as o}from"./external-link-CTLWFJ8S.js";import{C as w}from"./copy-SoF5zg-g.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/MethodDetailView-5wFkSBs8.js b/assets/MethodDetailView-DVIskZnq.js similarity index 92% rename from assets/MethodDetailView-5wFkSBs8.js rename to assets/MethodDetailView-DVIskZnq.js index bdef4b2d2df54ea7a4ecdd9e981d42ed8ad65700..7472d27125b8c8e465823a36759bae01d43723e2 100644 --- a/assets/MethodDetailView-5wFkSBs8.js +++ b/assets/MethodDetailView-DVIskZnq.js @@ -1 +1 @@ -import{j as e,d as I,u as P,b as k,p as V,L as _,o as A,T as v}from"./index-DyXq7-Tg.js";import{R as H}from"./ResearchFollowButton-Dv316ClR.js";import{M as Q}from"./SotaBadges-vbLLOUtT.js";import{u as q,b as K,a as R}from"./PaperFeed-EBt97iOL.js";import{r as G,M as L}from"./MarkdownText-CUzPoC9Y.js";import{c as b}from"./catalog-CRar2olQ.js";import{p as U}from"./papers-Dh3ljlL0.js";import{i as O}from"./apiErrors-BSvbQBb0.js";import{s as W}from"./slug-BpH-Nkvz.js";import{t as Z}from"./transform-D46m70Qr.js";import{u as X}from"./usePapers-B0s20UcU.js";import{S as N}from"./skeleton-C3IIzpSL.js";import{A as Y,a as J}from"./alert-gbJBhAVE.js";import{s as ee}from"./safeExternalHref-CkBrsh84.js";import te from"./NotFound-DV_nwcxG.js";import"./researchTopic-DbX0eko-.js";import"./useMutation-UWxBeqtn.js";import"./plus-Yh42pKZz.js";import"./colors-BkWRhvFI.js";import"./PaperCard-57p1OSGy.js";import"./AuthorAvatar-B-9xS2Wo.js";import"./Icon-T4LYkEQj.js";import"./LatexTitle-Bkyz3jCs.js";import"./popover-CTBEUp7Y.js";import"./useIntersectionObserver-D6_Iig9a.js";/* empty css */import"./PaperPreviewLink-CpCZSa8K.js";import"./index-mCi_y_l3.js";import"./index-2CvJmBVB.js";import"./katex-DkKDou_j.js";import"./hover-card-B45EJIn_.js";import"./curation-YeS7FBYf.js";import"./useInfiniteQuery-BYh2zN-T.js";const t={pink:"#F8D7D9",pinkS:"#D9B0B3",yellow:"#FBEFC2",yellowS:"#C9B97D",orange:"#F8D7B3",orangeS:"#C99466",blue:"#CDE2EE",blueS:"#7FA4BA",purple:"#D4D2EA",purpleS:"#8E8AC0",green:"#CCE2C5",greenS:"#7DA475",ink:"#1A1814",faint:"#8E8678"},n=({x:s,y:r,w:l,h:d,fill:o,stroke:p,label:h,fontSize:c=10})=>e.jsxs("g",{children:[e.jsx("rect",{x:s,y:r,width:l,height:d,rx:"3",ry:"3",fill:o,stroke:p,strokeWidth:"1"}),e.jsx("text",{x:s+l/2,y:r+d/2,fontSize:c,fontFamily:"var(--sans)",fill:t.ink,textAnchor:"middle",dominantBaseline:"middle",children:h})]}),se=()=>e.jsxs("svg",{viewBox:"0 0 360 420",width:"100%",height:"100%",style:{display:"block"},children:[e.jsx("text",{x:"180",y:"20",fontSize:"11",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.faint,textAnchor:"middle",children:"Scaled Dot-Product Attention"}),e.jsx(n,{x:140,y:40,w:80,h:26,fill:t.yellow,stroke:t.yellowS,label:"MatMul",fontSize:11}),e.jsx("path",{d:"M180 66 L180 80",stroke:t.ink}),e.jsx(n,{x:140,y:80,w:80,h:26,fill:t.green,stroke:t.greenS,label:"SoftMax",fontSize:11}),e.jsx("path",{d:"M180 106 L180 120",stroke:t.ink}),e.jsx(n,{x:140,y:120,w:80,h:26,fill:t.purple,stroke:t.purpleS,label:"Mask (opt.)",fontSize:11}),e.jsx("path",{d:"M180 146 L180 160",stroke:t.ink}),e.jsx(n,{x:140,y:160,w:80,h:26,fill:t.blue,stroke:t.blueS,label:"Scale ÷√dₖ",fontSize:11}),e.jsx("path",{d:"M180 186 L180 200",stroke:t.ink}),e.jsx(n,{x:140,y:200,w:80,h:26,fill:t.yellow,stroke:t.yellowS,label:"MatMul",fontSize:11}),e.jsx("path",{d:"M156 226 L120 270",stroke:t.ink}),e.jsx("path",{d:"M180 226 L180 270",stroke:t.ink}),e.jsx("path",{d:"M204 226 L240 270",stroke:t.ink}),e.jsx(n,{x:100,y:270,w:40,h:24,fill:t.pink,stroke:t.pinkS,label:"Q",fontSize:13}),e.jsx(n,{x:160,y:270,w:40,h:24,fill:t.pink,stroke:t.pinkS,label:"K",fontSize:13}),e.jsx(n,{x:220,y:270,w:40,h:24,fill:t.pink,stroke:t.pinkS,label:"V",fontSize:13}),e.jsxs("text",{x:"180",y:"330",fontSize:"14",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.ink,textAnchor:"middle",children:["softmax(QK",e.jsx("tspan",{fontSize:"9",baselineShift:"super",children:"⊤"})," / √d) V"]})]}),ae=()=>e.jsxs("svg",{viewBox:"0 0 360 420",width:"100%",height:"100%",style:{display:"block"},children:[e.jsx("text",{x:"180",y:"20",fontSize:"11",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.faint,textAnchor:"middle",children:"Contrastive learning"}),e.jsx(n,{x:120,y:40,w:120,h:26,fill:t.blue,stroke:t.blueS,label:"Input x",fontSize:11}),e.jsx("path",{d:"M180 66 V76 M90 76 H270 M90 76 V88 M270 76 V88",stroke:t.ink}),e.jsx(n,{x:35,y:88,w:110,h:26,fill:t.yellow,stroke:t.yellowS,label:"Augment t₁",fontSize:11}),e.jsx(n,{x:215,y:88,w:110,h:26,fill:t.yellow,stroke:t.yellowS,label:"Augment t₂",fontSize:11}),e.jsx("path",{d:"M90 114 V138 M270 114 V138",stroke:t.ink}),e.jsx(n,{x:35,y:138,w:110,h:26,fill:t.orange,stroke:t.orangeS,label:"Encoder f",fontSize:11}),e.jsx(n,{x:215,y:138,w:110,h:26,fill:t.orange,stroke:t.orangeS,label:"Encoder f",fontSize:11}),e.jsx("text",{x:"180",y:"155",fontSize:"9",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.faint,textAnchor:"middle",children:"shared weights"}),e.jsx("path",{d:"M90 164 V188 M270 164 V188",stroke:t.ink}),e.jsx(n,{x:35,y:188,w:110,h:26,fill:t.purple,stroke:t.purpleS,label:"Projection g",fontSize:11}),e.jsx(n,{x:215,y:188,w:110,h:26,fill:t.purple,stroke:t.purpleS,label:"Projection g",fontSize:11}),e.jsx("path",{d:"M90 214 V238 M270 214 V238",stroke:t.ink}),e.jsx(n,{x:35,y:238,w:110,h:26,fill:t.pink,stroke:t.pinkS,label:"z₁",fontSize:13}),e.jsx(n,{x:215,y:238,w:110,h:26,fill:t.pink,stroke:t.pinkS,label:"z₂",fontSize:13}),e.jsx("path",{d:"M145 251 H215",stroke:t.greenS,strokeWidth:"1.5",strokeDasharray:"4 3"}),e.jsx("text",{x:"180",y:"244",fontSize:"9",fontFamily:"var(--sans)",fill:t.greenS,textAnchor:"middle",children:"attract"}),e.jsx("text",{x:"180",y:"318",fontSize:"12",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.ink,textAnchor:"middle",children:"Positive pair: pull together"}),e.jsx("text",{x:"180",y:"336",fontSize:"12",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.ink,textAnchor:"middle",children:"Other samples: push apart"}),e.jsx("text",{x:"180",y:"370",fontSize:"11",fontFamily:"var(--serif)",fill:t.faint,textAnchor:"middle",children:"InfoNCE: maximize sim(z₁, z₂) / τ"})]}),re=[["my-skill/",""],["├── SKILL.md","# Required: metadata + instructions"],["├── scripts/","# Optional: executable code"],["├── references/","# Optional: documentation"],["├── assets/","# Optional: templates, resources"],["└── ...","# Any additional files or directories"]],le=()=>e.jsxs("svg",{viewBox:"0 0 360 420",width:"100%",height:"100%",style:{display:"block"},children:[e.jsx("text",{x:"180",y:"20",fontSize:"11",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.faint,textAnchor:"middle",children:"Skill package layout"}),e.jsx("rect",{x:"28",y:"48",width:"304",height:"318",rx:"8",fill:"#FFFDF8",stroke:t.faint,strokeWidth:"1"}),re.map(([s,r],l)=>{const d=92+l*44;return e.jsxs("g",{children:[e.jsx("text",{x:"44",y:d,fontSize:"11",fontFamily:"var(--mono)",fill:t.ink,dominantBaseline:"middle",children:s}),r?e.jsx("text",{x:"138",y:d,fontSize:"8.5",fontFamily:"var(--mono)",fill:t.faint,dominantBaseline:"middle",children:r}):null]},s)})]}),ie={attention:se,"contrastive-learning":ae,"agent-skills":le},ne=({method:s})=>e.jsxs("svg",{viewBox:"0 0 360 420",width:"100%",height:"100%",children:[e.jsx("text",{x:"180",y:"20",fontSize:"11",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.faint,textAnchor:"middle",children:s.name||"method"}),e.jsx(n,{x:80,y:70,w:200,h:50,fill:t.blue,stroke:t.blueS,label:"Input",fontSize:12}),e.jsx("path",{d:"M180 120 L180 150",stroke:t.ink}),e.jsx(n,{x:80,y:150,w:200,h:70,fill:t.orange,stroke:t.orangeS,label:s.name||"transform",fontSize:13}),e.jsx("path",{d:"M180 220 L180 250",stroke:t.ink}),e.jsx(n,{x:80,y:250,w:200,h:50,fill:t.purple,stroke:t.purpleS,label:"Output",fontSize:12})]}),oe=({method:s})=>{const r=(s.slug||"").toLowerCase(),l=ie[r];if(l)return e.jsx("div",{className:"method-figure-svg method-figure-svg--schematic",children:e.jsx(l,{})});if(s.image_url){const d=r==="transformer"||r==="gpt-4"||r==="gpt-4o"||r==="multi-head-attention"?" method-figure-svg--compact":r==="rpn"?" method-figure-svg--scaled-80":"";return e.jsx("div",{className:`method-figure-svg method-figure-svg--image${d}`,children:e.jsx("img",{className:"method-figure-img",src:s.image_url,alt:`${s.name} figure`})})}return e.jsx("div",{className:"method-figure-svg method-figure-svg--schematic",children:e.jsx(ne,{method:s})})},w=720,M=138,x={top:8,right:10,bottom:25,left:36},E=56,ce=new Intl.DateTimeFormat("en",{month:"short",year:"2-digit",timeZone:"UTC"}),de=new Intl.DateTimeFormat("en",{year:"numeric",timeZone:"UTC"}),F=s=>ce.format(new Date(`${s}T00:00:00Z`)),me=(s,r)=>{if(s===0)return new Set;const l=s>48?12:s>36?6:s>18?3:2,d=Math.max(1,Math.ceil(E/r)),o=Math.max(l,d),p=s-1,h=new Set([0,p]);for(let c=o;c=E&&h.add(c);return h},T=s=>{if(s.coverage_status===void 0||["complete","not_applicable"].includes(s.coverage_status))return null;const r=s.processed_paper_count!==void 0&&s.eligible_paper_count!==void 0?`; ${s.processed_paper_count.toLocaleString()} of ${s.eligible_paper_count.toLocaleString()} eligible papers processed`:"";return`Historical tagging ${s.coverage_status==="failed"?"needs retry":"in progress"}${r}`},he=({history:s,methodName:r})=>{const[l,d]=I.useState(null),o=Math.max(1,...s.map(i=>i.paper_count)),p=w-x.left-x.right,h=M-x.top-x.bottom,c=s.length?p/s.length:p,a=Math.max(2,c*.68),g=me(s.length,c),j=Array.from(new Set([0,Math.ceil(o/2),o])),f=l==null?null:s[l],y=f?T(f):null;return e.jsxs("div",{className:"method-usage-chart-wrap",children:[e.jsxs("svg",{className:"method-usage-chart",viewBox:`0 0 ${w} ${M}`,role:"group","aria-label":`${r}: papers mentioning this method by publication month`,children:[e.jsxs("title",{children:[r,": papers mentioning this method by publication month"]}),j.map(i=>{const m=x.top+h-i/o*h;return e.jsxs("g",{children:[e.jsx("line",{className:"method-usage-gridline",x1:x.left,x2:w-x.right,y1:m,y2:m}),e.jsx("text",{className:"method-usage-y-label",x:x.left-8,y:m+3,textAnchor:"end",children:i})]},i)}),s.map((i,m)=>{const u=i.paper_count/o*h,S=i.paper_count>0?Math.max(1,u):0,C=x.left+c*m+(c-a)/2,D=x.top+h-S,$=l===m,B=m===s.length-1,z=T(i);return e.jsxs("g",{className:`method-usage-bar${$?" is-active":""}${B?" is-current":""}`,tabIndex:0,role:"img","aria-label":`${F(i.start_date)}: ${i.paper_count} ${i.paper_count===1?"paper":"papers"}${z?`. ${z}`:""}`,onMouseEnter:()=>d(m),onMouseLeave:()=>d(null),onFocus:()=>d(m),onBlur:()=>d(null),children:[e.jsx("rect",{className:"method-usage-bar-hit",x:x.left+c*m,y:x.top,width:c,height:h}),e.jsx("rect",{className:"method-usage-bar-mark",x:C,y:D,width:a,height:S,rx:"1.5"})]},i.start_date)}),s.map((i,m)=>g.has(m)?e.jsx("text",{className:"method-usage-x-label",x:x.left+c*(m+.5),y:M-11,textAnchor:"middle",children:s.length>48?de.format(new Date(`${i.start_date}T00:00:00Z`)):F(i.start_date)},i.start_date):null)]}),f&&e.jsxs("div",{className:"method-usage-tooltip",role:"status",children:[e.jsx("strong",{children:F(f.start_date)}),e.jsxs("span",{children:[f.paper_count," ",f.paper_count===1?"paper":"papers",l===s.length-1?" · month to date":""]}),e.jsxs("span",{children:[(f.catalog_share??0).toFixed(2),"% of"," ",(f.catalog_paper_count??0).toLocaleString()," catalog papers"]}),y&&e.jsx("span",{children:y})]})]})},Ge=()=>{var y,i,m;const{methodSlug:s}=P(),r=q(),l=k({queryKey:A.method(s),queryFn:()=>b.getMethod(s),enabled:!!s,staleTime:v}),d=k({queryKey:A.areas,queryFn:()=>b.listAreas({page_size:50,ordering:"name"}),enabled:!!((y=l.data)!=null&&y.area_id),staleTime:v}),o=k({queryKey:["method-trend",s],queryFn:()=>b.methodTrend(s),enabled:!!s,staleTime:v}),p=X([...V.feeds.method,s,r.filters],u=>U.forMethod(s,{...r.filters,page:u,page_size:20,repository_limit:1}),{enabled:!!s}),h=k({queryKey:["related-methods",s],queryFn:()=>b.relatedMethods(s),enabled:!!s,staleTime:v}),c=I.useMemo(()=>{var u;return((u=p.data)==null?void 0:u.pages.flatMap(S=>S.results.map(Z)))??[]},[p.data]);if(l.isLoading)return e.jsxs("div",{className:"page",children:[e.jsx(N,{className:"h-12 w-1/2 mb-4"}),e.jsx(N,{className:"h-64 w-full"})]});if(O(l.error))return e.jsx(te,{});if(l.error||!l.data)return e.jsx("div",{className:"page",children:e.jsx(Y,{variant:"destructive",children:e.jsx(J,{children:"Method not found."})})});const a=l.data,g=(i=d.data)==null?void 0:i.results.find(u=>u.id===a.area_id),j=G(a.source_url),f=j?null:ee(a.source_url);return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"breadcrumb",children:[e.jsx(_,{to:"/methods",children:"Methods"}),g&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sep",children:"/"}),e.jsx(_,{to:`/methods#area-${W(g.name)}`,children:g.name})]}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("span",{style:{color:"var(--ink)"},children:a.name})]}),e.jsxs("div",{className:`tag-hero method-hero-grid${a.slug==="grokking"||a.slug==="latent-reasoning"||a.slug==="world-action-models"?" method-hero-grid--wide-figure":""}`,children:[e.jsxs("div",{children:[e.jsx("div",{className:"tag-hero-eyebrow",children:"METHOD"}),e.jsx("h1",{className:"tag-hero-title method-hero-title",children:a.name}),e.jsx(H,{kind:"method",entityId:a.id}),a.full_name&&!a.name.includes(a.full_name)&&e.jsx("div",{style:{fontFamily:"var(--serif)",fontSize:16,fontStyle:"italic",color:"var(--ink-soft)",marginTop:8},children:a.full_name}),a.description&&e.jsx(L,{className:"method-description",text:a.description}),a.source_url&&a.source_title&&e.jsxs("div",{className:"method-source",children:[e.jsx("span",{className:"method-source-label",children:"Source"}),j?e.jsxs(_,{className:"method-source-link",to:j,target:"_blank",rel:"noopener noreferrer",children:[e.jsx("span",{className:"method-source-title",children:a.source_title}),a.introduced_year&&e.jsx("span",{className:"method-source-meta",children:a.introduced_year})]}):f?e.jsxs("a",{className:"method-source-link",href:f,target:"_blank",rel:"noopener noreferrer",children:[e.jsx("span",{className:"method-source-title",children:a.source_title}),a.introduced_year&&e.jsx("span",{className:"method-source-meta",children:a.introduced_year})]}):e.jsxs("div",{className:"method-source-link is-static",children:[e.jsx("span",{className:"method-source-title",children:a.source_title}),a.introduced_year&&e.jsx("span",{className:"method-source-meta",children:a.introduced_year})]})]}),e.jsxs("div",{className:"tag-hero-meta",children:[e.jsxs("div",{className:"stat",children:[e.jsx("span",{className:"label",children:"Papers mentioning"}),e.jsx("span",{className:"value",children:(a.paper_count??0).toLocaleString()})]}),o.data&&e.jsxs("div",{className:"stat",children:[e.jsx("span",{className:"label",children:"Recent mentions"}),e.jsxs("span",{className:"value",children:[(o.data.recent_paper_count*30/o.data.recent_days).toFixed(1),e.jsx("small",{children:"/mo"})]}),!o.data.comparison_complete&&e.jsx("span",{title:"Tagging is still catching up. This rate reflects mentions found so far.",children:"Partial coverage"})]}),a.introduced_year!=null&&e.jsxs("div",{className:"stat",children:[e.jsx("span",{className:"label",children:"Introduced"}),e.jsx("span",{className:"value",children:a.introduced_year})]})]}),o.isLoading?e.jsx(N,{className:"h-36 w-full method-trend-skeleton"}):o.data?e.jsxs("section",{className:"method-trend-panel method-trend-panel--compact",children:[e.jsxs("div",{className:"method-trend-header",children:[e.jsx("div",{children:e.jsx("div",{className:"method-trend-eyebrow",children:"Usage trend"})}),e.jsxs("div",{className:"method-trend-summary",children:[e.jsx("strong",{children:o.data.recent_paper_count}),e.jsxs("span",{children:["papers / ",o.data.recent_days,"d"]})]})]}),e.jsx(he,{history:o.data.history,methodName:a.name})]}):null]}),e.jsxs("figure",{className:"method-figure-card",children:[e.jsx(oe,{method:a}),a.image_credit&&e.jsx("figcaption",{children:e.jsx(L,{className:"method-image-credit",text:a.image_credit})})]})]}),(((m=h.data)==null?void 0:m.results.length)??0)>0&&e.jsxs("div",{className:"filter-row",children:[e.jsx("span",{className:"label",children:"Related methods"}),h.data.results.map(u=>e.jsx(Q,{method:{slug:u.slug,name:u.name}},u.id))]}),e.jsx(K,{feed:r,children:e.jsxs("div",{className:"results-count",children:[c.length," papers mentioning ",a.name]})}),e.jsx(R,{query:p,cards:c,empty:"No papers tagged with this method yet."})]})};export{Ge as default}; +import{j as e,d as I,u as P,b as k,p as V,L as _,o as A,T as v}from"./index-CjdUkE4w.js";import{R as H}from"./ResearchFollowButton-DcTptDpW.js";import{M as Q}from"./SotaBadges-CyScuNCv.js";import{u as q,b as K,a as R}from"./PaperFeed-D3FZw29k.js";import{r as G,M as L}from"./MarkdownText-MrITlqRE.js";import{c as b}from"./catalog-qXcKve0z.js";import{p as U}from"./papers-DgZwjF3K.js";import{i as O}from"./apiErrors-D0w5By9R.js";import{s as W}from"./slug-BpH-Nkvz.js";import{t as Z}from"./transform-CRNzYLch.js";import{u as X}from"./usePapers-BZThqZCx.js";import{S as N}from"./skeleton-DTWi7Ctg.js";import{A as Y,a as J}from"./alert-BM9Xfuyy.js";import{s as ee}from"./safeExternalHref-CkBrsh84.js";import te from"./NotFound-BeWhm9El.js";import"./researchTopic-NmABF6tT.js";import"./useMutation-BYtVrkc7.js";import"./plus-AztI1566.js";import"./colors-BkWRhvFI.js";import"./PaperCard-dvXhr75r.js";import"./AuthorAvatar-D9249Frl.js";import"./Icon-CGRs4BYD.js";import"./LatexTitle-DESKtS30.js";import"./popover-Df5_dywQ.js";import"./useIntersectionObserver-Ch6RpsSk.js";/* empty css */import"./PaperPreviewLink-zGfFNaz6.js";import"./index-tLcwYp0U.js";import"./index-Dj6aE-6E.js";import"./katex-DkKDou_j.js";import"./hover-card-CIBIV2Hx.js";import"./curation-CyyuHfv5.js";import"./useInfiniteQuery-DeZTTVbI.js";const t={pink:"#F8D7D9",pinkS:"#D9B0B3",yellow:"#FBEFC2",yellowS:"#C9B97D",orange:"#F8D7B3",orangeS:"#C99466",blue:"#CDE2EE",blueS:"#7FA4BA",purple:"#D4D2EA",purpleS:"#8E8AC0",green:"#CCE2C5",greenS:"#7DA475",ink:"#1A1814",faint:"#8E8678"},n=({x:s,y:r,w:l,h:d,fill:o,stroke:p,label:h,fontSize:c=10})=>e.jsxs("g",{children:[e.jsx("rect",{x:s,y:r,width:l,height:d,rx:"3",ry:"3",fill:o,stroke:p,strokeWidth:"1"}),e.jsx("text",{x:s+l/2,y:r+d/2,fontSize:c,fontFamily:"var(--sans)",fill:t.ink,textAnchor:"middle",dominantBaseline:"middle",children:h})]}),se=()=>e.jsxs("svg",{viewBox:"0 0 360 420",width:"100%",height:"100%",style:{display:"block"},children:[e.jsx("text",{x:"180",y:"20",fontSize:"11",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.faint,textAnchor:"middle",children:"Scaled Dot-Product Attention"}),e.jsx(n,{x:140,y:40,w:80,h:26,fill:t.yellow,stroke:t.yellowS,label:"MatMul",fontSize:11}),e.jsx("path",{d:"M180 66 L180 80",stroke:t.ink}),e.jsx(n,{x:140,y:80,w:80,h:26,fill:t.green,stroke:t.greenS,label:"SoftMax",fontSize:11}),e.jsx("path",{d:"M180 106 L180 120",stroke:t.ink}),e.jsx(n,{x:140,y:120,w:80,h:26,fill:t.purple,stroke:t.purpleS,label:"Mask (opt.)",fontSize:11}),e.jsx("path",{d:"M180 146 L180 160",stroke:t.ink}),e.jsx(n,{x:140,y:160,w:80,h:26,fill:t.blue,stroke:t.blueS,label:"Scale ÷√dₖ",fontSize:11}),e.jsx("path",{d:"M180 186 L180 200",stroke:t.ink}),e.jsx(n,{x:140,y:200,w:80,h:26,fill:t.yellow,stroke:t.yellowS,label:"MatMul",fontSize:11}),e.jsx("path",{d:"M156 226 L120 270",stroke:t.ink}),e.jsx("path",{d:"M180 226 L180 270",stroke:t.ink}),e.jsx("path",{d:"M204 226 L240 270",stroke:t.ink}),e.jsx(n,{x:100,y:270,w:40,h:24,fill:t.pink,stroke:t.pinkS,label:"Q",fontSize:13}),e.jsx(n,{x:160,y:270,w:40,h:24,fill:t.pink,stroke:t.pinkS,label:"K",fontSize:13}),e.jsx(n,{x:220,y:270,w:40,h:24,fill:t.pink,stroke:t.pinkS,label:"V",fontSize:13}),e.jsxs("text",{x:"180",y:"330",fontSize:"14",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.ink,textAnchor:"middle",children:["softmax(QK",e.jsx("tspan",{fontSize:"9",baselineShift:"super",children:"⊤"})," / √d) V"]})]}),ae=()=>e.jsxs("svg",{viewBox:"0 0 360 420",width:"100%",height:"100%",style:{display:"block"},children:[e.jsx("text",{x:"180",y:"20",fontSize:"11",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.faint,textAnchor:"middle",children:"Contrastive learning"}),e.jsx(n,{x:120,y:40,w:120,h:26,fill:t.blue,stroke:t.blueS,label:"Input x",fontSize:11}),e.jsx("path",{d:"M180 66 V76 M90 76 H270 M90 76 V88 M270 76 V88",stroke:t.ink}),e.jsx(n,{x:35,y:88,w:110,h:26,fill:t.yellow,stroke:t.yellowS,label:"Augment t₁",fontSize:11}),e.jsx(n,{x:215,y:88,w:110,h:26,fill:t.yellow,stroke:t.yellowS,label:"Augment t₂",fontSize:11}),e.jsx("path",{d:"M90 114 V138 M270 114 V138",stroke:t.ink}),e.jsx(n,{x:35,y:138,w:110,h:26,fill:t.orange,stroke:t.orangeS,label:"Encoder f",fontSize:11}),e.jsx(n,{x:215,y:138,w:110,h:26,fill:t.orange,stroke:t.orangeS,label:"Encoder f",fontSize:11}),e.jsx("text",{x:"180",y:"155",fontSize:"9",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.faint,textAnchor:"middle",children:"shared weights"}),e.jsx("path",{d:"M90 164 V188 M270 164 V188",stroke:t.ink}),e.jsx(n,{x:35,y:188,w:110,h:26,fill:t.purple,stroke:t.purpleS,label:"Projection g",fontSize:11}),e.jsx(n,{x:215,y:188,w:110,h:26,fill:t.purple,stroke:t.purpleS,label:"Projection g",fontSize:11}),e.jsx("path",{d:"M90 214 V238 M270 214 V238",stroke:t.ink}),e.jsx(n,{x:35,y:238,w:110,h:26,fill:t.pink,stroke:t.pinkS,label:"z₁",fontSize:13}),e.jsx(n,{x:215,y:238,w:110,h:26,fill:t.pink,stroke:t.pinkS,label:"z₂",fontSize:13}),e.jsx("path",{d:"M145 251 H215",stroke:t.greenS,strokeWidth:"1.5",strokeDasharray:"4 3"}),e.jsx("text",{x:"180",y:"244",fontSize:"9",fontFamily:"var(--sans)",fill:t.greenS,textAnchor:"middle",children:"attract"}),e.jsx("text",{x:"180",y:"318",fontSize:"12",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.ink,textAnchor:"middle",children:"Positive pair: pull together"}),e.jsx("text",{x:"180",y:"336",fontSize:"12",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.ink,textAnchor:"middle",children:"Other samples: push apart"}),e.jsx("text",{x:"180",y:"370",fontSize:"11",fontFamily:"var(--serif)",fill:t.faint,textAnchor:"middle",children:"InfoNCE: maximize sim(z₁, z₂) / τ"})]}),re=[["my-skill/",""],["├── SKILL.md","# Required: metadata + instructions"],["├── scripts/","# Optional: executable code"],["├── references/","# Optional: documentation"],["├── assets/","# Optional: templates, resources"],["└── ...","# Any additional files or directories"]],le=()=>e.jsxs("svg",{viewBox:"0 0 360 420",width:"100%",height:"100%",style:{display:"block"},children:[e.jsx("text",{x:"180",y:"20",fontSize:"11",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.faint,textAnchor:"middle",children:"Skill package layout"}),e.jsx("rect",{x:"28",y:"48",width:"304",height:"318",rx:"8",fill:"#FFFDF8",stroke:t.faint,strokeWidth:"1"}),re.map(([s,r],l)=>{const d=92+l*44;return e.jsxs("g",{children:[e.jsx("text",{x:"44",y:d,fontSize:"11",fontFamily:"var(--mono)",fill:t.ink,dominantBaseline:"middle",children:s}),r?e.jsx("text",{x:"138",y:d,fontSize:"8.5",fontFamily:"var(--mono)",fill:t.faint,dominantBaseline:"middle",children:r}):null]},s)})]}),ie={attention:se,"contrastive-learning":ae,"agent-skills":le},ne=({method:s})=>e.jsxs("svg",{viewBox:"0 0 360 420",width:"100%",height:"100%",children:[e.jsx("text",{x:"180",y:"20",fontSize:"11",fontFamily:"var(--serif)",fontStyle:"italic",fill:t.faint,textAnchor:"middle",children:s.name||"method"}),e.jsx(n,{x:80,y:70,w:200,h:50,fill:t.blue,stroke:t.blueS,label:"Input",fontSize:12}),e.jsx("path",{d:"M180 120 L180 150",stroke:t.ink}),e.jsx(n,{x:80,y:150,w:200,h:70,fill:t.orange,stroke:t.orangeS,label:s.name||"transform",fontSize:13}),e.jsx("path",{d:"M180 220 L180 250",stroke:t.ink}),e.jsx(n,{x:80,y:250,w:200,h:50,fill:t.purple,stroke:t.purpleS,label:"Output",fontSize:12})]}),oe=({method:s})=>{const r=(s.slug||"").toLowerCase(),l=ie[r];if(l)return e.jsx("div",{className:"method-figure-svg method-figure-svg--schematic",children:e.jsx(l,{})});if(s.image_url){const d=r==="transformer"||r==="gpt-4"||r==="gpt-4o"||r==="multi-head-attention"?" method-figure-svg--compact":r==="rpn"?" method-figure-svg--scaled-80":"";return e.jsx("div",{className:`method-figure-svg method-figure-svg--image${d}`,children:e.jsx("img",{className:"method-figure-img",src:s.image_url,alt:`${s.name} figure`})})}return e.jsx("div",{className:"method-figure-svg method-figure-svg--schematic",children:e.jsx(ne,{method:s})})},w=720,M=138,x={top:8,right:10,bottom:25,left:36},E=56,ce=new Intl.DateTimeFormat("en",{month:"short",year:"2-digit",timeZone:"UTC"}),de=new Intl.DateTimeFormat("en",{year:"numeric",timeZone:"UTC"}),F=s=>ce.format(new Date(`${s}T00:00:00Z`)),me=(s,r)=>{if(s===0)return new Set;const l=s>48?12:s>36?6:s>18?3:2,d=Math.max(1,Math.ceil(E/r)),o=Math.max(l,d),p=s-1,h=new Set([0,p]);for(let c=o;c=E&&h.add(c);return h},T=s=>{if(s.coverage_status===void 0||["complete","not_applicable"].includes(s.coverage_status))return null;const r=s.processed_paper_count!==void 0&&s.eligible_paper_count!==void 0?`; ${s.processed_paper_count.toLocaleString()} of ${s.eligible_paper_count.toLocaleString()} eligible papers processed`:"";return`Historical tagging ${s.coverage_status==="failed"?"needs retry":"in progress"}${r}`},he=({history:s,methodName:r})=>{const[l,d]=I.useState(null),o=Math.max(1,...s.map(i=>i.paper_count)),p=w-x.left-x.right,h=M-x.top-x.bottom,c=s.length?p/s.length:p,a=Math.max(2,c*.68),g=me(s.length,c),j=Array.from(new Set([0,Math.ceil(o/2),o])),f=l==null?null:s[l],y=f?T(f):null;return e.jsxs("div",{className:"method-usage-chart-wrap",children:[e.jsxs("svg",{className:"method-usage-chart",viewBox:`0 0 ${w} ${M}`,role:"group","aria-label":`${r}: papers mentioning this method by publication month`,children:[e.jsxs("title",{children:[r,": papers mentioning this method by publication month"]}),j.map(i=>{const m=x.top+h-i/o*h;return e.jsxs("g",{children:[e.jsx("line",{className:"method-usage-gridline",x1:x.left,x2:w-x.right,y1:m,y2:m}),e.jsx("text",{className:"method-usage-y-label",x:x.left-8,y:m+3,textAnchor:"end",children:i})]},i)}),s.map((i,m)=>{const u=i.paper_count/o*h,S=i.paper_count>0?Math.max(1,u):0,C=x.left+c*m+(c-a)/2,D=x.top+h-S,$=l===m,B=m===s.length-1,z=T(i);return e.jsxs("g",{className:`method-usage-bar${$?" is-active":""}${B?" is-current":""}`,tabIndex:0,role:"img","aria-label":`${F(i.start_date)}: ${i.paper_count} ${i.paper_count===1?"paper":"papers"}${z?`. ${z}`:""}`,onMouseEnter:()=>d(m),onMouseLeave:()=>d(null),onFocus:()=>d(m),onBlur:()=>d(null),children:[e.jsx("rect",{className:"method-usage-bar-hit",x:x.left+c*m,y:x.top,width:c,height:h}),e.jsx("rect",{className:"method-usage-bar-mark",x:C,y:D,width:a,height:S,rx:"1.5"})]},i.start_date)}),s.map((i,m)=>g.has(m)?e.jsx("text",{className:"method-usage-x-label",x:x.left+c*(m+.5),y:M-11,textAnchor:"middle",children:s.length>48?de.format(new Date(`${i.start_date}T00:00:00Z`)):F(i.start_date)},i.start_date):null)]}),f&&e.jsxs("div",{className:"method-usage-tooltip",role:"status",children:[e.jsx("strong",{children:F(f.start_date)}),e.jsxs("span",{children:[f.paper_count," ",f.paper_count===1?"paper":"papers",l===s.length-1?" · month to date":""]}),e.jsxs("span",{children:[(f.catalog_share??0).toFixed(2),"% of"," ",(f.catalog_paper_count??0).toLocaleString()," catalog papers"]}),y&&e.jsx("span",{children:y})]})]})},Ge=()=>{var y,i,m;const{methodSlug:s}=P(),r=q(),l=k({queryKey:A.method(s),queryFn:()=>b.getMethod(s),enabled:!!s,staleTime:v}),d=k({queryKey:A.areas,queryFn:()=>b.listAreas({page_size:50,ordering:"name"}),enabled:!!((y=l.data)!=null&&y.area_id),staleTime:v}),o=k({queryKey:["method-trend",s],queryFn:()=>b.methodTrend(s),enabled:!!s,staleTime:v}),p=X([...V.feeds.method,s,r.filters],u=>U.forMethod(s,{...r.filters,page:u,page_size:20,repository_limit:1}),{enabled:!!s}),h=k({queryKey:["related-methods",s],queryFn:()=>b.relatedMethods(s),enabled:!!s,staleTime:v}),c=I.useMemo(()=>{var u;return((u=p.data)==null?void 0:u.pages.flatMap(S=>S.results.map(Z)))??[]},[p.data]);if(l.isLoading)return e.jsxs("div",{className:"page",children:[e.jsx(N,{className:"h-12 w-1/2 mb-4"}),e.jsx(N,{className:"h-64 w-full"})]});if(O(l.error))return e.jsx(te,{});if(l.error||!l.data)return e.jsx("div",{className:"page",children:e.jsx(Y,{variant:"destructive",children:e.jsx(J,{children:"Method not found."})})});const a=l.data,g=(i=d.data)==null?void 0:i.results.find(u=>u.id===a.area_id),j=G(a.source_url),f=j?null:ee(a.source_url);return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"breadcrumb",children:[e.jsx(_,{to:"/methods",children:"Methods"}),g&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sep",children:"/"}),e.jsx(_,{to:`/methods#area-${W(g.name)}`,children:g.name})]}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("span",{style:{color:"var(--ink)"},children:a.name})]}),e.jsxs("div",{className:`tag-hero method-hero-grid${a.slug==="grokking"||a.slug==="latent-reasoning"||a.slug==="world-action-models"?" method-hero-grid--wide-figure":""}`,children:[e.jsxs("div",{children:[e.jsx("div",{className:"tag-hero-eyebrow",children:"METHOD"}),e.jsx("h1",{className:"tag-hero-title method-hero-title",children:a.name}),e.jsx(H,{kind:"method",entityId:a.id}),a.full_name&&!a.name.includes(a.full_name)&&e.jsx("div",{style:{fontFamily:"var(--serif)",fontSize:16,fontStyle:"italic",color:"var(--ink-soft)",marginTop:8},children:a.full_name}),a.description&&e.jsx(L,{className:"method-description",text:a.description}),a.source_url&&a.source_title&&e.jsxs("div",{className:"method-source",children:[e.jsx("span",{className:"method-source-label",children:"Source"}),j?e.jsxs(_,{className:"method-source-link",to:j,target:"_blank",rel:"noopener noreferrer",children:[e.jsx("span",{className:"method-source-title",children:a.source_title}),a.introduced_year&&e.jsx("span",{className:"method-source-meta",children:a.introduced_year})]}):f?e.jsxs("a",{className:"method-source-link",href:f,target:"_blank",rel:"noopener noreferrer",children:[e.jsx("span",{className:"method-source-title",children:a.source_title}),a.introduced_year&&e.jsx("span",{className:"method-source-meta",children:a.introduced_year})]}):e.jsxs("div",{className:"method-source-link is-static",children:[e.jsx("span",{className:"method-source-title",children:a.source_title}),a.introduced_year&&e.jsx("span",{className:"method-source-meta",children:a.introduced_year})]})]}),e.jsxs("div",{className:"tag-hero-meta",children:[e.jsxs("div",{className:"stat",children:[e.jsx("span",{className:"label",children:"Papers mentioning"}),e.jsx("span",{className:"value",children:(a.paper_count??0).toLocaleString()})]}),o.data&&e.jsxs("div",{className:"stat",children:[e.jsx("span",{className:"label",children:"Recent mentions"}),e.jsxs("span",{className:"value",children:[(o.data.recent_paper_count*30/o.data.recent_days).toFixed(1),e.jsx("small",{children:"/mo"})]}),!o.data.comparison_complete&&e.jsx("span",{title:"Tagging is still catching up. This rate reflects mentions found so far.",children:"Partial coverage"})]}),a.introduced_year!=null&&e.jsxs("div",{className:"stat",children:[e.jsx("span",{className:"label",children:"Introduced"}),e.jsx("span",{className:"value",children:a.introduced_year})]})]}),o.isLoading?e.jsx(N,{className:"h-36 w-full method-trend-skeleton"}):o.data?e.jsxs("section",{className:"method-trend-panel method-trend-panel--compact",children:[e.jsxs("div",{className:"method-trend-header",children:[e.jsx("div",{children:e.jsx("div",{className:"method-trend-eyebrow",children:"Usage trend"})}),e.jsxs("div",{className:"method-trend-summary",children:[e.jsx("strong",{children:o.data.recent_paper_count}),e.jsxs("span",{children:["papers / ",o.data.recent_days,"d"]})]})]}),e.jsx(he,{history:o.data.history,methodName:a.name})]}):null]}),e.jsxs("figure",{className:"method-figure-card",children:[e.jsx(oe,{method:a}),a.image_credit&&e.jsx("figcaption",{children:e.jsx(L,{className:"method-image-credit",text:a.image_credit})})]})]}),(((m=h.data)==null?void 0:m.results.length)??0)>0&&e.jsxs("div",{className:"filter-row",children:[e.jsx("span",{className:"label",children:"Related methods"}),h.data.results.map(u=>e.jsx(Q,{method:{slug:u.slug,name:u.name}},u.id))]}),e.jsx(K,{feed:r,children:e.jsxs("div",{className:"results-count",children:[c.length," papers mentioning ",a.name]})}),e.jsx(R,{query:p,cards:c,empty:"No papers tagged with this method yet."})]})};export{Ge as default}; diff --git a/assets/MethodsIndexView-D_aKGLyJ.js b/assets/MethodsIndexView-BlMbRRsu.js similarity index 82% rename from assets/MethodsIndexView-D_aKGLyJ.js rename to assets/MethodsIndexView-BlMbRRsu.js index 3aac10389922d100e08442f233e6835c25532502..170a75277c216866ad3f5df437a32543debdcdf8 100644 --- a/assets/MethodsIndexView-D_aKGLyJ.js +++ b/assets/MethodsIndexView-BlMbRRsu.js @@ -1,4 +1,4 @@ -import{s as f,b as c,d as l,j as s,L as _,o as N,T as m}from"./index-DyXq7-Tg.js";import{c as p}from"./catalog-CRar2olQ.js";import{s as T}from"./areas-Dvi8w2dp.js";import{s as v}from"./slug-BpH-Nkvz.js";import{A as L,a as M}from"./alert-gbJBhAVE.js";import{A,a as F}from"./AreaSection-BxnKzNK0.js";import{T as q}from"./TaxonomySuggestionTile-jIiLMp4q.js";import{u as S,T as I}from"./useHashScrollOnReady-D5UCCQuT.js";import"./skeleton-C3IIzpSL.js";import"./SignInToEditDialog-B-oWVno5.js";import"./button-DZeAbOf2.js";import"./input-DJqCAbs7.js";import"./textarea-DPixlM5U.js";import"./searchable-select-DiDLwvbI.js";import"./popover-CTBEUp7Y.js";import"./dialog-CfM0Uql2.js";import"./search-8ssWDP68.js";import"./loader-circle-C75KLEgx.js";import"./useMutation-UWxBeqtn.js";import"./submissions-Cz_J-Ha2.js";import"./plus-Yh42pKZz.js";import"./trending-up-OM6wBVvQ.js";/** +import{s as f,b as c,d as l,j as s,L as _,o as N,T as m}from"./index-CjdUkE4w.js";import{c as p}from"./catalog-qXcKve0z.js";import{s as T}from"./areas-Dvi8w2dp.js";import{s as v}from"./slug-BpH-Nkvz.js";import{A as L,a as M}from"./alert-BM9Xfuyy.js";import{A,a as F}from"./AreaSection-iYSRoy6-.js";import{T as q}from"./TaxonomySuggestionTile-ByzqhBFs.js";import{u as S,T as I}from"./useHashScrollOnReady-mScSLUem.js";import"./skeleton-DTWi7Ctg.js";import"./SignInToEditDialog-rWxdYNRK.js";import"./button-DetZl_ch.js";import"./input-7i-rZ7fA.js";import"./textarea-biscLKBK.js";import"./searchable-select-EPf13F1I.js";import"./popover-Df5_dywQ.js";import"./dialog-BzX9PD3v.js";import"./search-DxMn7VKI.js";import"./loader-circle-xTdSzHv_.js";import"./useMutation-BYtVrkc7.js";import"./submissions-CQ6M0giV.js";import"./plus-AztI1566.js";import"./trending-up-BMb-8Pi8.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/NotFound-DV_nwcxG.js b/assets/NotFound-BeWhm9El.js similarity index 89% rename from assets/NotFound-DV_nwcxG.js rename to assets/NotFound-BeWhm9El.js index ffac31d78dffb6b56f77b18c451d9964a3e2b47b..77e5e4fb73b0cb04a5975e83c3093bf6baf130f0 100644 --- a/assets/NotFound-DV_nwcxG.js +++ b/assets/NotFound-BeWhm9El.js @@ -1 +1 @@ -import{c as o,d as s,j as t,L as a}from"./index-DyXq7-Tg.js";const r=()=>{const e=o();return s.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",e.pathname)},[e.pathname]),t.jsxs("div",{className:"page",style:{textAlign:"center",paddingTop:96},children:[t.jsx("h1",{className:"detail-title",style:{fontSize:96,marginBottom:8},children:"404"}),t.jsx("p",{style:{fontFamily:"var(--serif)",fontStyle:"italic",color:"var(--ink-soft)",marginBottom:24},children:"That route isn't on the map."}),t.jsx(a,{to:"/",className:"action-btn",children:"Return home"})]})};export{r as default}; +import{c as o,d as s,j as t,L as a}from"./index-CjdUkE4w.js";const r=()=>{const e=o();return s.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",e.pathname)},[e.pathname]),t.jsxs("div",{className:"page",style:{textAlign:"center",paddingTop:96},children:[t.jsx("h1",{className:"detail-title",style:{fontSize:96,marginBottom:8},children:"404"}),t.jsx("p",{style:{fontFamily:"var(--serif)",fontStyle:"italic",color:"var(--ink-soft)",marginBottom:24},children:"That route isn't on the map."}),t.jsx(a,{to:"/",className:"action-btn",children:"Return home"})]})};export{r as default}; diff --git a/assets/OrganizationContributionGraph-DsoZR4EG.js b/assets/OrganizationContributionGraph-JI11b4D1.js similarity index 94% rename from assets/OrganizationContributionGraph-DsoZR4EG.js rename to assets/OrganizationContributionGraph-JI11b4D1.js index 94950ecd7ba4bc043b01d270d7850427f2accf61..9c8392a5459fa7a5a8b8e285aacf06b47acf6abd 100644 --- a/assets/OrganizationContributionGraph-DsoZR4EG.js +++ b/assets/OrganizationContributionGraph-JI11b4D1.js @@ -1 +1 @@ -import{d as b,j as o,b as $,T as z}from"./index-DyXq7-Tg.js";import{S as w}from"./skeleton-C3IIzpSL.js";import{c as y}from"./catalog-CRar2olQ.js";const x=24*60*60*1e3,f=12,N=3,v=new Map([[1,"Mon"],[3,"Wed"],[5,"Fri"]]),T=n=>new Date(`${n}T00:00:00Z`),_=n=>n.toISOString().slice(0,10),M=(n,a)=>{if(n===0)return 0;const i=a.findIndex(s=>n<=s);return i===-1?4:i+1},S=n=>{const a=T(n.start_date),i=T(n.end_date),s=new Date(a.getTime()-a.getUTCDay()*x),h=new Date(i.getTime()+(6-i.getUTCDay())*x),p=new Map(n.results.map(e=>[e.date,e.paper_count])),u=n.results.map(e=>e.paper_count).sort((e,g)=>e-g),c=[.25,.5,.75].map(e=>u[Math.min(u.length-1,Math.floor(u.length*e))]??1),l=[];for(let e=s.getTime();e<=h.getTime();e+=x){const g=new Date(e),d=_(g),m=e>=a.getTime()&&e<=i.getTime(),C=m?p.get(d)??0:0;l.push({key:d,date:g,count:C,inRange:m,level:M(C,c)})}const t=l.length/7,r=[];let j=-1;for(let e=0;em.inRange&&(e===0||m.date.getUTCDate()<=7));d&&d.date.getUTCMonth()!==j&&(j=d.date.getUTCMonth(),r.length>0&&e-r[r.length-1].column<3&&r.pop(),r.push({label:d.date.toLocaleString("en",{month:"short",timeZone:"UTC"}),column:e}))}return{days:l,months:r,weekCount:t}},D=({data:n,organizationName:a,title:i="Paper contributions",noun:s="paper"})=>{const h=b.useRef(null),{days:p,months:u,weekCount:c}=b.useMemo(()=>S(n),[n]),l=c*f+(c-1)*N;return b.useEffect(()=>{const t=h.current;t&&(t.scrollLeft=t.scrollWidth)},[c]),o.jsxs("section",{className:"organization-contributions","aria-labelledby":"organization-contributions-title",children:[o.jsxs("div",{className:"organization-contributions-header",children:[o.jsx("h2",{id:"organization-contributions-title",className:"organization-contributions-title",children:i}),o.jsxs("p",{className:"organization-contributions-summary",children:[n.total_count.toLocaleString()," ",n.total_count===1?s:`${s}s`," recorded in the last year"]})]}),o.jsx("div",{className:"organization-contributions-scroll",ref:h,children:o.jsxs("div",{className:"organization-contributions-plot",style:{width:l+34},role:"img","aria-label":`${a} recorded ${n.total_count} ${n.total_count===1?s:`${s}s`} in the last year`,children:[o.jsx("div",{className:"organization-contributions-weekdays","aria-hidden":"true",children:Array.from({length:7}).map((t,r)=>o.jsx("span",{children:v.get(r)??""},r))}),o.jsxs("div",{children:[o.jsx("div",{className:"organization-contributions-months",style:{width:l,gridTemplateColumns:`repeat(${c}, ${f}px)`},"aria-hidden":"true",children:u.map(t=>o.jsx("span",{style:{gridColumnStart:t.column+1},children:t.label},`${t.label}-${t.column}`))}),o.jsx("div",{className:"organization-contributions-grid",style:{width:l,gridTemplateColumns:`repeat(${c}, ${f}px)`},"aria-hidden":"true",children:p.map(t=>o.jsx("span",{className:`organization-contribution-cell ${t.inRange?`level-${t.level}`:"is-outside"}`,title:t.inRange?`${t.count} ${t.count===1?s:`${s}s`} on ${t.date.toLocaleDateString("en",{dateStyle:"long",timeZone:"UTC"})}`:void 0},t.key))})]})]})}),o.jsxs("div",{className:"organization-contributions-legend","aria-hidden":"true",children:[o.jsx("span",{children:"Fewer"}),[0,1,2,3,4].map(t=>o.jsx("span",{className:`organization-contribution-cell level-${t}`},t)),o.jsx("span",{children:"More"})]})]})},U=({organizationSlug:n,organizationName:a})=>{const i=$({queryKey:["organization-contributions",n],queryFn:()=>y.organizationContributions(n),staleTime:z});return i.isLoading?o.jsx(w,{className:"organization-contributions-skeleton"}):i.data?o.jsx(D,{data:i.data,organizationName:a}):null};export{D as C,U as O}; +import{d as b,j as o,b as $,T as z}from"./index-CjdUkE4w.js";import{S as w}from"./skeleton-DTWi7Ctg.js";import{c as y}from"./catalog-qXcKve0z.js";const x=24*60*60*1e3,f=12,N=3,v=new Map([[1,"Mon"],[3,"Wed"],[5,"Fri"]]),T=n=>new Date(`${n}T00:00:00Z`),_=n=>n.toISOString().slice(0,10),M=(n,a)=>{if(n===0)return 0;const i=a.findIndex(s=>n<=s);return i===-1?4:i+1},S=n=>{const a=T(n.start_date),i=T(n.end_date),s=new Date(a.getTime()-a.getUTCDay()*x),h=new Date(i.getTime()+(6-i.getUTCDay())*x),p=new Map(n.results.map(e=>[e.date,e.paper_count])),u=n.results.map(e=>e.paper_count).sort((e,g)=>e-g),c=[.25,.5,.75].map(e=>u[Math.min(u.length-1,Math.floor(u.length*e))]??1),l=[];for(let e=s.getTime();e<=h.getTime();e+=x){const g=new Date(e),d=_(g),m=e>=a.getTime()&&e<=i.getTime(),C=m?p.get(d)??0:0;l.push({key:d,date:g,count:C,inRange:m,level:M(C,c)})}const t=l.length/7,r=[];let j=-1;for(let e=0;em.inRange&&(e===0||m.date.getUTCDate()<=7));d&&d.date.getUTCMonth()!==j&&(j=d.date.getUTCMonth(),r.length>0&&e-r[r.length-1].column<3&&r.pop(),r.push({label:d.date.toLocaleString("en",{month:"short",timeZone:"UTC"}),column:e}))}return{days:l,months:r,weekCount:t}},D=({data:n,organizationName:a,title:i="Paper contributions",noun:s="paper"})=>{const h=b.useRef(null),{days:p,months:u,weekCount:c}=b.useMemo(()=>S(n),[n]),l=c*f+(c-1)*N;return b.useEffect(()=>{const t=h.current;t&&(t.scrollLeft=t.scrollWidth)},[c]),o.jsxs("section",{className:"organization-contributions","aria-labelledby":"organization-contributions-title",children:[o.jsxs("div",{className:"organization-contributions-header",children:[o.jsx("h2",{id:"organization-contributions-title",className:"organization-contributions-title",children:i}),o.jsxs("p",{className:"organization-contributions-summary",children:[n.total_count.toLocaleString()," ",n.total_count===1?s:`${s}s`," recorded in the last year"]})]}),o.jsx("div",{className:"organization-contributions-scroll",ref:h,children:o.jsxs("div",{className:"organization-contributions-plot",style:{width:l+34},role:"img","aria-label":`${a} recorded ${n.total_count} ${n.total_count===1?s:`${s}s`} in the last year`,children:[o.jsx("div",{className:"organization-contributions-weekdays","aria-hidden":"true",children:Array.from({length:7}).map((t,r)=>o.jsx("span",{children:v.get(r)??""},r))}),o.jsxs("div",{children:[o.jsx("div",{className:"organization-contributions-months",style:{width:l,gridTemplateColumns:`repeat(${c}, ${f}px)`},"aria-hidden":"true",children:u.map(t=>o.jsx("span",{style:{gridColumnStart:t.column+1},children:t.label},`${t.label}-${t.column}`))}),o.jsx("div",{className:"organization-contributions-grid",style:{width:l,gridTemplateColumns:`repeat(${c}, ${f}px)`},"aria-hidden":"true",children:p.map(t=>o.jsx("span",{className:`organization-contribution-cell ${t.inRange?`level-${t.level}`:"is-outside"}`,title:t.inRange?`${t.count} ${t.count===1?s:`${s}s`} on ${t.date.toLocaleDateString("en",{dateStyle:"long",timeZone:"UTC"})}`:void 0},t.key))})]})]})}),o.jsxs("div",{className:"organization-contributions-legend","aria-hidden":"true",children:[o.jsx("span",{children:"Fewer"}),[0,1,2,3,4].map(t=>o.jsx("span",{className:`organization-contribution-cell level-${t}`},t)),o.jsx("span",{children:"More"})]})]})},U=({organizationSlug:n,organizationName:a})=>{const i=$({queryKey:["organization-contributions",n],queryFn:()=>y.organizationContributions(n),staleTime:z});return i.isLoading?o.jsx(w,{className:"organization-contributions-skeleton"}):i.data?o.jsx(D,{data:i.data,organizationName:a}):null};export{D as C,U as O}; diff --git a/assets/OrganizationDetailView-DYOQ1Mwd.js b/assets/OrganizationDetailView-ysggtQzi.js similarity index 75% rename from assets/OrganizationDetailView-DYOQ1Mwd.js rename to assets/OrganizationDetailView-ysggtQzi.js index 51dc6d4c3569ce824f6e72d13a6ca7240e21e6a7..213b2c19d2156cbfb460990980e3d42bfdb888c7 100644 --- a/assets/OrganizationDetailView-DYOQ1Mwd.js +++ b/assets/OrganizationDetailView-ysggtQzi.js @@ -1 +1 @@ -import{e as q,d,b as N,p as C,j as r,L as y,o as Q,T as F,u as z}from"./index-DyXq7-Tg.js";import{R as E}from"./ResearchFollowButton-Dv316ClR.js";import{M as I}from"./MarkdownText-CUzPoC9Y.js";import{O as K}from"./OrganizationContributionGraph-DsoZR4EG.js";import{u as R,b as G,a as H}from"./PaperFeed-EBt97iOL.js";import{A as W,a as B}from"./alert-gbJBhAVE.js";import{S as D}from"./searchable-select-DiDLwvbI.js";import{S}from"./skeleton-C3IIzpSL.js";import{u as U}from"./usePapers-B0s20UcU.js";import{c as v}from"./catalog-CRar2olQ.js";import{p as V}from"./papers-Dh3ljlL0.js";import{i as Z}from"./apiErrors-BSvbQBb0.js";import{d as L,t as J}from"./transform-D46m70Qr.js";import{o as X,i as Y}from"./organizationNames-BVKzYEBp.js";import k from"./NotFound-DV_nwcxG.js";import"./researchTopic-DbX0eko-.js";import"./useMutation-UWxBeqtn.js";import"./plus-Yh42pKZz.js";/* empty css */import"./PaperPreviewLink-CpCZSa8K.js";import"./index-mCi_y_l3.js";import"./index-2CvJmBVB.js";import"./katex-DkKDou_j.js";import"./hover-card-B45EJIn_.js";import"./PaperCard-57p1OSGy.js";import"./AuthorAvatar-B-9xS2Wo.js";import"./SotaBadges-vbLLOUtT.js";import"./colors-BkWRhvFI.js";import"./Icon-T4LYkEQj.js";import"./LatexTitle-Bkyz3jCs.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-CTBEUp7Y.js";import"./useIntersectionObserver-D6_Iig9a.js";import"./button-DZeAbOf2.js";import"./dialog-CfM0Uql2.js";import"./search-8ssWDP68.js";import"./loader-circle-C75KLEgx.js";import"./useInfiniteQuery-BYh2zN-T.js";import"./curation-YeS7FBYf.js";const ee=({organizationSlug:a,taskSlug:n})=>{var f,x,j,_,b;const $=q(),c=R(),{searchParams:w}=c,[O,h]=d.useState(!1),u=N({queryKey:Q.organization(a),queryFn:()=>v.getOrganization(a),staleTime:F}),l=N({queryKey:["organization-areas-with-tasks",a],queryFn:()=>v.organizationAreasWithTasks(a),staleTime:F}),p=U([...C.feeds.organization,a,n,c.filters],t=>V.forOrganization(a,{...c.filters,task:n,page:t,page_size:12}),{enabled:!!a});d.useEffect(()=>{h(!1)},[a,n]);const g=d.useMemo(()=>{var t;return(((t=l.data)==null?void 0:t.results)??[]).flatMap(o=>o.tasks.filter(s=>!!s.slug).map(s=>({...s,slug:s.slug,label:L(s.name,s.slug)})))},[l.data]),i=g.find(t=>t.slug===n),T=d.useMemo(()=>{var t;return(((t=p.data)==null?void 0:t.pages)??[]).flatMap(o=>o.results.map(J))},[p.data]),e=u.data??((f=l.data)==null?void 0:f.organization),m=e?X(e):null,A=((j=(x=p.data)==null?void 0:x.pages[0])==null?void 0:j.count)??0;if([u.error,l.error,p.error].some(Z))return r.jsx(k,{});if(l.error||p.error)return r.jsx("div",{className:"page",children:r.jsx(W,{variant:"destructive",children:r.jsx(B,{children:"Failed to load organization papers. Please try again."})})});const P=t=>{const o=t.trim().toLocaleLowerCase();return g.filter(s=>`${s.label} ${s.slug}`.toLocaleLowerCase().includes(o)).map(s=>({value:s.slug,label:s.label,description:`${s.paper_count.toLocaleString()} ${s.paper_count===1?"paper":"papers"}`}))},M=t=>{const o=t==="__all__"?`/orgs/${a}`:`/orgs/${a}/${t}`,s=w.toString();$({pathname:o,search:s?`?${s}`:""})};return r.jsxs("div",{className:"page",children:[r.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[r.jsx(y,{to:"/",children:"Home"}),r.jsx("span",{children:" / "}),r.jsx(y,{to:"/organizations",children:"Organizations"}),r.jsx("span",{children:" / "}),r.jsx("span",{children:(e==null?void 0:e.name)??a}),i&&r.jsxs(r.Fragment,{children:[r.jsx("span",{children:" / "}),r.jsx("span",{children:L(i.name,i.slug)})]})]}),r.jsxs("header",{className:"organization-hero",children:[r.jsxs("div",{className:"organization-hero-profile",children:[r.jsx("div",{className:"organizations-eyebrow",children:"ORGANIZATION"}),r.jsxs("h1",{className:`feed-title organization-hero-title${e&&!m&&Y(e.name)?" organization-hero-title--long":""}`,children:[e!=null&&e.logo_url&&!O?r.jsx("img",{src:e.logo_url,alt:"",width:58,height:58,onError:()=>h(!0)}):e?r.jsx("span",{className:"organization-hero-monogram","aria-hidden":"true",children:(m??e.name).slice(0,1).toUpperCase()}):null,e?r.jsxs("span",{className:"organization-hero-name",children:[m??e.name,m&&r.jsx("span",{className:"organization-hero-full-name",children:e.name})]}):r.jsx(S,{className:"h-12 w-64"})]}),e&&r.jsx(E,{kind:"organization",entityId:e.id}),e&&r.jsxs("div",{className:"feed-subtitle",children:[((_=e.paper_count)==null?void 0:_.toLocaleString())??0," papers",(e.organization_trending_score??0)>0&&e.trending_rank&&r.jsxs(r.Fragment,{children:[" · #",e.trending_rank," trending this month"]})]}),(e==null?void 0:e.description)&&r.jsx(I,{className:"method-description",text:e.description}),e&&r.jsxs("div",{className:"organization-hero-links",children:[e.website_url&&r.jsx("a",{href:e.website_url,target:"_blank",rel:"noreferrer",children:"Website ↗"}),e.hf_url&&r.jsx("a",{href:e.hf_url,target:"_blank",rel:"noreferrer",children:"Hugging Face ↗"}),e.github_url&&r.jsx("a",{href:e.github_url,target:"_blank",rel:"noreferrer",children:"GitHub ↗"})]})]}),r.jsx(K,{organizationSlug:a,organizationName:(e==null?void 0:e.name)??a})]}),r.jsx(G,{feed:c,style:{alignItems:"center",gap:16},leading:r.jsx("div",{style:{minWidth:260},children:r.jsx(D,{value:n??"__all__",onChange:M,placeholder:"All tasks",searchPlaceholder:"Search organization tasks...",emptyMessage:"No matching tasks.",ariaLabel:"Filter papers by task",selectedOption:i?{value:i.slug,label:i.label,description:`${i.paper_count.toLocaleString()} ${i.paper_count===1?"paper":"papers"}`}:{value:"__all__",label:"All tasks",description:`${((b=e==null?void 0:e.paper_count)==null?void 0:b.toLocaleString())??0} papers`},queryKey:["organization-task-options",a],queryFn:async t=>{var o;return[{value:"__all__",label:"All tasks",description:`${((o=e==null?void 0:e.paper_count)==null?void 0:o.toLocaleString())??0} papers`},...P(t)]},enabled:!l.isLoading,className:"h-[38px]"})}),children:r.jsxs("div",{className:"results-count",children:[A.toLocaleString()," papers"]})}),r.jsx(H,{query:p,cards:T,showInstitution:!1,empty:(e==null?void 0:e.paper_count)===0?"No papers indexed yet":"No papers found for this selection."})]})},Ke=()=>{const{orgSlug:a,taskSlug:n}=z();return a?r.jsx(ee,{organizationSlug:a,taskSlug:n}):r.jsx(k,{})};export{Ke as default}; +import{e as q,d,b as N,p as C,j as r,L as y,o as Q,T as F,u as z}from"./index-CjdUkE4w.js";import{R as E}from"./ResearchFollowButton-DcTptDpW.js";import{M as I}from"./MarkdownText-MrITlqRE.js";import{O as K}from"./OrganizationContributionGraph-JI11b4D1.js";import{u as R,b as G,a as H}from"./PaperFeed-D3FZw29k.js";import{A as W,a as B}from"./alert-BM9Xfuyy.js";import{S as D}from"./searchable-select-EPf13F1I.js";import{S}from"./skeleton-DTWi7Ctg.js";import{u as U}from"./usePapers-BZThqZCx.js";import{c as v}from"./catalog-qXcKve0z.js";import{p as V}from"./papers-DgZwjF3K.js";import{i as Z}from"./apiErrors-D0w5By9R.js";import{d as L,t as J}from"./transform-CRNzYLch.js";import{o as X,i as Y}from"./organizationNames-BVKzYEBp.js";import k from"./NotFound-BeWhm9El.js";import"./researchTopic-NmABF6tT.js";import"./useMutation-BYtVrkc7.js";import"./plus-AztI1566.js";/* empty css */import"./PaperPreviewLink-zGfFNaz6.js";import"./index-tLcwYp0U.js";import"./index-Dj6aE-6E.js";import"./katex-DkKDou_j.js";import"./hover-card-CIBIV2Hx.js";import"./PaperCard-dvXhr75r.js";import"./AuthorAvatar-D9249Frl.js";import"./SotaBadges-CyScuNCv.js";import"./colors-BkWRhvFI.js";import"./Icon-CGRs4BYD.js";import"./LatexTitle-DESKtS30.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-Df5_dywQ.js";import"./useIntersectionObserver-Ch6RpsSk.js";import"./button-DetZl_ch.js";import"./dialog-BzX9PD3v.js";import"./search-DxMn7VKI.js";import"./loader-circle-xTdSzHv_.js";import"./useInfiniteQuery-DeZTTVbI.js";import"./curation-CyyuHfv5.js";const ee=({organizationSlug:a,taskSlug:n})=>{var f,x,j,_,b;const $=q(),c=R(),{searchParams:w}=c,[O,h]=d.useState(!1),u=N({queryKey:Q.organization(a),queryFn:()=>v.getOrganization(a),staleTime:F}),l=N({queryKey:["organization-areas-with-tasks",a],queryFn:()=>v.organizationAreasWithTasks(a),staleTime:F}),p=U([...C.feeds.organization,a,n,c.filters],t=>V.forOrganization(a,{...c.filters,task:n,page:t,page_size:12}),{enabled:!!a});d.useEffect(()=>{h(!1)},[a,n]);const g=d.useMemo(()=>{var t;return(((t=l.data)==null?void 0:t.results)??[]).flatMap(o=>o.tasks.filter(s=>!!s.slug).map(s=>({...s,slug:s.slug,label:L(s.name,s.slug)})))},[l.data]),i=g.find(t=>t.slug===n),T=d.useMemo(()=>{var t;return(((t=p.data)==null?void 0:t.pages)??[]).flatMap(o=>o.results.map(J))},[p.data]),e=u.data??((f=l.data)==null?void 0:f.organization),m=e?X(e):null,A=((j=(x=p.data)==null?void 0:x.pages[0])==null?void 0:j.count)??0;if([u.error,l.error,p.error].some(Z))return r.jsx(k,{});if(l.error||p.error)return r.jsx("div",{className:"page",children:r.jsx(W,{variant:"destructive",children:r.jsx(B,{children:"Failed to load organization papers. Please try again."})})});const P=t=>{const o=t.trim().toLocaleLowerCase();return g.filter(s=>`${s.label} ${s.slug}`.toLocaleLowerCase().includes(o)).map(s=>({value:s.slug,label:s.label,description:`${s.paper_count.toLocaleString()} ${s.paper_count===1?"paper":"papers"}`}))},M=t=>{const o=t==="__all__"?`/orgs/${a}`:`/orgs/${a}/${t}`,s=w.toString();$({pathname:o,search:s?`?${s}`:""})};return r.jsxs("div",{className:"page",children:[r.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[r.jsx(y,{to:"/",children:"Home"}),r.jsx("span",{children:" / "}),r.jsx(y,{to:"/organizations",children:"Organizations"}),r.jsx("span",{children:" / "}),r.jsx("span",{children:(e==null?void 0:e.name)??a}),i&&r.jsxs(r.Fragment,{children:[r.jsx("span",{children:" / "}),r.jsx("span",{children:L(i.name,i.slug)})]})]}),r.jsxs("header",{className:"organization-hero",children:[r.jsxs("div",{className:"organization-hero-profile",children:[r.jsx("div",{className:"organizations-eyebrow",children:"ORGANIZATION"}),r.jsxs("h1",{className:`feed-title organization-hero-title${e&&!m&&Y(e.name)?" organization-hero-title--long":""}`,children:[e!=null&&e.logo_url&&!O?r.jsx("img",{src:e.logo_url,alt:"",width:58,height:58,onError:()=>h(!0)}):e?r.jsx("span",{className:"organization-hero-monogram","aria-hidden":"true",children:(m??e.name).slice(0,1).toUpperCase()}):null,e?r.jsxs("span",{className:"organization-hero-name",children:[m??e.name,m&&r.jsx("span",{className:"organization-hero-full-name",children:e.name})]}):r.jsx(S,{className:"h-12 w-64"})]}),e&&r.jsx(E,{kind:"organization",entityId:e.id}),e&&r.jsxs("div",{className:"feed-subtitle",children:[((_=e.paper_count)==null?void 0:_.toLocaleString())??0," papers",(e.organization_trending_score??0)>0&&e.trending_rank&&r.jsxs(r.Fragment,{children:[" · #",e.trending_rank," trending this month"]})]}),(e==null?void 0:e.description)&&r.jsx(I,{className:"method-description",text:e.description}),e&&r.jsxs("div",{className:"organization-hero-links",children:[e.website_url&&r.jsx("a",{href:e.website_url,target:"_blank",rel:"noreferrer",children:"Website ↗"}),e.hf_url&&r.jsx("a",{href:e.hf_url,target:"_blank",rel:"noreferrer",children:"Hugging Face ↗"}),e.github_url&&r.jsx("a",{href:e.github_url,target:"_blank",rel:"noreferrer",children:"GitHub ↗"})]})]}),r.jsx(K,{organizationSlug:a,organizationName:(e==null?void 0:e.name)??a})]}),r.jsx(G,{feed:c,style:{alignItems:"center",gap:16},leading:r.jsx("div",{style:{minWidth:260},children:r.jsx(D,{value:n??"__all__",onChange:M,placeholder:"All tasks",searchPlaceholder:"Search organization tasks...",emptyMessage:"No matching tasks.",ariaLabel:"Filter papers by task",selectedOption:i?{value:i.slug,label:i.label,description:`${i.paper_count.toLocaleString()} ${i.paper_count===1?"paper":"papers"}`}:{value:"__all__",label:"All tasks",description:`${((b=e==null?void 0:e.paper_count)==null?void 0:b.toLocaleString())??0} papers`},queryKey:["organization-task-options",a],queryFn:async t=>{var o;return[{value:"__all__",label:"All tasks",description:`${((o=e==null?void 0:e.paper_count)==null?void 0:o.toLocaleString())??0} papers`},...P(t)]},enabled:!l.isLoading,className:"h-[38px]"})}),children:r.jsxs("div",{className:"results-count",children:[A.toLocaleString()," papers"]})}),r.jsx(H,{query:p,cards:T,showInstitution:!1,empty:(e==null?void 0:e.paper_count)===0?"No papers indexed yet":"No papers found for this selection."})]})},Ke=()=>{const{orgSlug:a,taskSlug:n}=z();return a?r.jsx(ee,{organizationSlug:a,taskSlug:n}):r.jsx(k,{})};export{Ke as default}; diff --git a/assets/OrganizationsIndexView-DpJistoL.js b/assets/OrganizationsIndexView-ec7nj_SS.js similarity index 97% rename from assets/OrganizationsIndexView-DpJistoL.js rename to assets/OrganizationsIndexView-ec7nj_SS.js index 99bbdd60fef500d57932241395de73487f25d74a..a3d5b2b822000a33e9271c7736f6412c068b6ab4 100644 --- a/assets/OrganizationsIndexView-DpJistoL.js +++ b/assets/OrganizationsIndexView-ec7nj_SS.js @@ -1 +1 @@ -import{g as m,b as x,d as h,j as e,L as u,o as j,T as y}from"./index-DyXq7-Tg.js";import{A as N,a as f}from"./alert-gbJBhAVE.js";import{c as _}from"./catalog-CRar2olQ.js";const v=n=>n==="papers"||n==="name"?n:"trending",z=({organization:n})=>{const[d,i]=h.useState(!1);return!n.logo_url||d?e.jsx("span",{className:"organization-logo organization-logo--fallback","aria-hidden":"true",children:n.name.slice(0,1).toUpperCase()}):e.jsx("span",{className:"organization-logo",children:e.jsx("img",{src:n.logo_url,alt:"",width:48,height:48,onError:()=>i(!0)})})},L=()=>{const[n,d]=m(),i=v(n.get("sort")),c=n.get("q")??"",o=x({queryKey:[...j.organizations,"featured"],queryFn:()=>_.organizationIndex(),staleTime:y}),p=s=>{const a=new URLSearchParams(n),t=s.sort??i,r=s.query??c;t==="trending"?a.delete("sort"):a.set("sort",t),r.trim()?a.set("q",r):a.delete("q"),d(a)},g=h.useMemo(()=>{var t;const s=c.trim().toLocaleLowerCase(),a=(((t=o.data)==null?void 0:t.results)??[]).filter(r=>[r.name,r.slug,r.hf_slug??""].join(" ").toLocaleLowerCase().includes(s));return i==="papers"?[...a].sort((r,l)=>(l.paper_count??0)-(r.paper_count??0)||r.name.localeCompare(l.name)||r.slug.localeCompare(l.slug)):i==="name"?[...a].sort((r,l)=>r.name.localeCompare(l.name)||r.slug.localeCompare(l.slug)):a},[o.data,c,i]);return e.jsxs("div",{className:"page organizations-page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["AI ",e.jsx("em",{children:"Organizations"})]}),e.jsx("div",{className:"feed-subtitle",children:"Explore papers from leading AI organizations, ranked by sustained community momentum over the past 30 days."})]})}),e.jsxs("section",{"aria-labelledby":"organizations-heading",children:[e.jsxs("div",{className:"organizations-section-heading",children:[e.jsx("h2",{id:"organizations-heading",children:o.data?`${o.data.count.toLocaleString()} organizations`:"Organizations"}),e.jsx("span",{children:i==="trending"?"Ranked by 30-day momentum":i==="papers"?"Sorted by linked papers":"Sorted A–Z"})]}),e.jsxs("div",{className:"organizations-controls",children:[e.jsxs("label",{children:[e.jsx("span",{className:"sr-only",children:"Search organizations"}),e.jsx("input",{type:"search",value:c,onChange:s=>p({query:s.target.value}),placeholder:"Search organizations"})]}),e.jsx("div",{className:"organizations-sort","aria-label":"Sort organizations",children:[["trending","Trending"],["papers","Most papers"],["name","A–Z"]].map(([s,a])=>e.jsx("button",{type:"button",className:i===s?"active":"","aria-pressed":i===s,onClick:()=>p({sort:s}),children:a},s))})]}),o.isLoading?e.jsx("div",{className:"organizations-grid","aria-busy":"true","aria-label":"Loading organizations",children:Array.from({length:12}).map((s,a)=>e.jsxs("div",{className:"organization-card organization-card-skeleton",children:[e.jsxs("div",{className:"organization-card-header",children:[e.jsx("span",{className:"organization-logo"}),e.jsxs("div",{children:[e.jsx("span",{className:"organization-skeleton-line"}),e.jsx("span",{className:"organization-skeleton-line short"})]})]}),e.jsx("div",{className:"organization-card-metrics",children:e.jsx("span",{className:"organization-skeleton-line short"})}),e.jsxs("div",{className:"organization-highlight",children:[e.jsx("span",{className:"organization-skeleton-line"}),e.jsx("span",{className:"organization-skeleton-line"})]})]},a))}):o.error?e.jsx(N,{variant:"destructive",children:e.jsxs(f,{children:["Failed to load organizations."," ",e.jsx("button",{type:"button",onClick:()=>o.refetch(),children:"Try again"})]})}):g.length===0?e.jsxs("div",{className:"organizations-empty",children:["No organizations match “",c,"”."]}):e.jsx("div",{className:"organizations-grid",children:g.map(s=>{var r;const a=s.paper_count??0,t=s.first_paper_year&&s.latest_paper_year?s.first_paper_year===s.latest_paper_year?String(s.first_paper_year):`${s.first_paper_year}–${s.latest_paper_year}`:null;return e.jsxs(u,{to:`/orgs/${s.slug}`,className:"organization-card","aria-label":a?`Browse ${a.toLocaleString()} ${s.name} papers`:`Browse ${s.name} papers`,children:[e.jsxs("div",{className:"organization-card-header",children:[e.jsx(z,{organization:s}),e.jsxs("div",{children:[e.jsx("h3",{children:s.name}),e.jsxs("span",{children:["@",s.hf_slug??s.slug]})]})]}),e.jsxs("div",{className:"organization-card-metrics",children:[e.jsx("strong",{children:a.toLocaleString()}),e.jsx("span",{children:a===1?"paper":"papers"}),i==="trending"&&s.trending_rank&&e.jsxs("span",{className:"organization-rank",children:["#",s.trending_rank]})]}),e.jsxs("div",{className:"organization-highlight",children:[e.jsx("span",{children:"Trending paper"}),e.jsx("strong",{children:((r=s.top_trending_paper)==null?void 0:r.title)??"No papers indexed yet"})]}),e.jsxs("div",{className:"organization-card-footer",children:[t?`Publishing ${t}`:"Research archive ready",e.jsx("span",{"aria-hidden":"true",children:"↗"})]})]},s.id)})})]})]})};export{L as default}; +import{g as m,b as x,d as h,j as e,L as u,o as j,T as y}from"./index-CjdUkE4w.js";import{A as N,a as f}from"./alert-BM9Xfuyy.js";import{c as _}from"./catalog-qXcKve0z.js";const v=n=>n==="papers"||n==="name"?n:"trending",z=({organization:n})=>{const[d,i]=h.useState(!1);return!n.logo_url||d?e.jsx("span",{className:"organization-logo organization-logo--fallback","aria-hidden":"true",children:n.name.slice(0,1).toUpperCase()}):e.jsx("span",{className:"organization-logo",children:e.jsx("img",{src:n.logo_url,alt:"",width:48,height:48,onError:()=>i(!0)})})},L=()=>{const[n,d]=m(),i=v(n.get("sort")),c=n.get("q")??"",o=x({queryKey:[...j.organizations,"featured"],queryFn:()=>_.organizationIndex(),staleTime:y}),p=s=>{const a=new URLSearchParams(n),t=s.sort??i,r=s.query??c;t==="trending"?a.delete("sort"):a.set("sort",t),r.trim()?a.set("q",r):a.delete("q"),d(a)},g=h.useMemo(()=>{var t;const s=c.trim().toLocaleLowerCase(),a=(((t=o.data)==null?void 0:t.results)??[]).filter(r=>[r.name,r.slug,r.hf_slug??""].join(" ").toLocaleLowerCase().includes(s));return i==="papers"?[...a].sort((r,l)=>(l.paper_count??0)-(r.paper_count??0)||r.name.localeCompare(l.name)||r.slug.localeCompare(l.slug)):i==="name"?[...a].sort((r,l)=>r.name.localeCompare(l.name)||r.slug.localeCompare(l.slug)):a},[o.data,c,i]);return e.jsxs("div",{className:"page organizations-page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["AI ",e.jsx("em",{children:"Organizations"})]}),e.jsx("div",{className:"feed-subtitle",children:"Explore papers from leading AI organizations, ranked by sustained community momentum over the past 30 days."})]})}),e.jsxs("section",{"aria-labelledby":"organizations-heading",children:[e.jsxs("div",{className:"organizations-section-heading",children:[e.jsx("h2",{id:"organizations-heading",children:o.data?`${o.data.count.toLocaleString()} organizations`:"Organizations"}),e.jsx("span",{children:i==="trending"?"Ranked by 30-day momentum":i==="papers"?"Sorted by linked papers":"Sorted A–Z"})]}),e.jsxs("div",{className:"organizations-controls",children:[e.jsxs("label",{children:[e.jsx("span",{className:"sr-only",children:"Search organizations"}),e.jsx("input",{type:"search",value:c,onChange:s=>p({query:s.target.value}),placeholder:"Search organizations"})]}),e.jsx("div",{className:"organizations-sort","aria-label":"Sort organizations",children:[["trending","Trending"],["papers","Most papers"],["name","A–Z"]].map(([s,a])=>e.jsx("button",{type:"button",className:i===s?"active":"","aria-pressed":i===s,onClick:()=>p({sort:s}),children:a},s))})]}),o.isLoading?e.jsx("div",{className:"organizations-grid","aria-busy":"true","aria-label":"Loading organizations",children:Array.from({length:12}).map((s,a)=>e.jsxs("div",{className:"organization-card organization-card-skeleton",children:[e.jsxs("div",{className:"organization-card-header",children:[e.jsx("span",{className:"organization-logo"}),e.jsxs("div",{children:[e.jsx("span",{className:"organization-skeleton-line"}),e.jsx("span",{className:"organization-skeleton-line short"})]})]}),e.jsx("div",{className:"organization-card-metrics",children:e.jsx("span",{className:"organization-skeleton-line short"})}),e.jsxs("div",{className:"organization-highlight",children:[e.jsx("span",{className:"organization-skeleton-line"}),e.jsx("span",{className:"organization-skeleton-line"})]})]},a))}):o.error?e.jsx(N,{variant:"destructive",children:e.jsxs(f,{children:["Failed to load organizations."," ",e.jsx("button",{type:"button",onClick:()=>o.refetch(),children:"Try again"})]})}):g.length===0?e.jsxs("div",{className:"organizations-empty",children:["No organizations match “",c,"”."]}):e.jsx("div",{className:"organizations-grid",children:g.map(s=>{var r;const a=s.paper_count??0,t=s.first_paper_year&&s.latest_paper_year?s.first_paper_year===s.latest_paper_year?String(s.first_paper_year):`${s.first_paper_year}–${s.latest_paper_year}`:null;return e.jsxs(u,{to:`/orgs/${s.slug}`,className:"organization-card","aria-label":a?`Browse ${a.toLocaleString()} ${s.name} papers`:`Browse ${s.name} papers`,children:[e.jsxs("div",{className:"organization-card-header",children:[e.jsx(z,{organization:s}),e.jsxs("div",{children:[e.jsx("h3",{children:s.name}),e.jsxs("span",{children:["@",s.hf_slug??s.slug]})]})]}),e.jsxs("div",{className:"organization-card-metrics",children:[e.jsx("strong",{children:a.toLocaleString()}),e.jsx("span",{children:a===1?"paper":"papers"}),i==="trending"&&s.trending_rank&&e.jsxs("span",{className:"organization-rank",children:["#",s.trending_rank]})]}),e.jsxs("div",{className:"organization-highlight",children:[e.jsx("span",{children:"Trending paper"}),e.jsx("strong",{children:((r=s.top_trending_paper)==null?void 0:r.title)??"No papers indexed yet"})]}),e.jsxs("div",{className:"organization-card-footer",children:[t?`Publishing ${t}`:"Research archive ready",e.jsx("span",{"aria-hidden":"true",children:"↗"})]})]},s.id)})})]})]})};export{L as default}; diff --git a/assets/PaperCard-57p1OSGy.js b/assets/PaperCard-dvXhr75r.js similarity index 96% rename from assets/PaperCard-57p1OSGy.js rename to assets/PaperCard-dvXhr75r.js index d9d2b77dc79229b10779773234b4dce42acbf46e..d5e8633752872cfcb56198b7f953c87582c882f9 100644 --- a/assets/PaperCard-57p1OSGy.js +++ b/assets/PaperCard-dvXhr75r.js @@ -1 +1 @@ -import{i as v,V as g,T as M,p as y,j as a,L as d}from"./index-DyXq7-Tg.js";import{A as L}from"./AuthorAvatar-B-9xS2Wo.js";import{P as Z,S as A,T as k,M as E}from"./SotaBadges-vbLLOUtT.js";import{I as P}from"./Icon-T4LYkEQj.js";import{L as U,a as w}from"./LatexTitle-Bkyz3jCs.js";import{p as C}from"./papers-Dh3ljlL0.js";import{s as h}from"./safeExternalHref-CkBrsh84.js";const $=({size:s=16})=>a.jsxs("svg",{className:"hf-logo",width:s,height:s,viewBox:"0 0 95 88",fill:"none","aria-hidden":"true",focusable:"false",children:[a.jsx("path",{fill:"#FFD21E",d:"M47.21 76.5a34.75 34.75 0 1 0 0-69.5 34.75 34.75 0 0 0 0 69.5Z"}),a.jsx("path",{fill:"#FF9D0B",d:"M81.96 41.75a34.75 34.75 0 1 0-69.5 0 34.75 34.75 0 0 0 69.5 0Zm-73.5 0a38.75 38.75 0 1 1 77.5 0 38.75 38.75 0 0 1-77.5 0Z"}),a.jsx("path",{fill:"#3A3B45",d:"M58.5 32.3c1.28.44 1.78 3.06 3.07 2.38a5 5 0 1 0-6.76-2.07c.61 1.15 2.55-.72 3.7-.32ZM34.95 32.3c-1.28.44-1.79 3.06-3.07 2.38a5 5 0 1 1 6.76-2.07c-.61 1.15-2.56-.72-3.7-.32Z"}),a.jsx("path",{fill:"#FF323D",d:"M46.96 56.29c9.83 0 13-8.76 13-13.26 0-2.34-1.57-1.6-4.09-.36-2.33 1.15-5.46 2.74-8.9 2.74-7.19 0-13-6.88-13-2.38s3.16 13.26 13 13.26Z"}),a.jsx("path",{fill:"#3A3B45",fillRule:"evenodd",clipRule:"evenodd",d:"M39.43 54a8.7 8.7 0 0 1 5.3-4.49c.4-.12.81.57 1.24 1.28.4.68.82 1.37 1.24 1.37.45 0 .9-.68 1.33-1.35.45-.7.89-1.38 1.32-1.25a8.61 8.61 0 0 1 5 4.17c3.73-2.94 5.1-7.74 5.1-10.7 0-2.34-1.57-1.6-4.09-.36l-.14.07c-2.31 1.15-5.39 2.67-8.77 2.67s-6.45-1.52-8.77-2.67c-2.6-1.29-4.23-2.1-4.23.29 0 3.05 1.46 8.06 5.47 10.97Z"}),a.jsx("path",{fill:"#FF9D0B",d:"M70.71 37a3.25 3.25 0 1 0 0-6.5 3.25 3.25 0 0 0 0 6.5ZM24.21 37a3.25 3.25 0 1 0 0-6.5 3.25 3.25 0 0 0 0 6.5ZM17.52 48c-1.62 0-3.06.66-4.07 1.87a5.97 5.97 0 0 0-1.33 3.76 7.1 7.1 0 0 0-1.94-.3c-1.55 0-2.95.59-3.94 1.66a5.8 5.8 0 0 0-.8 7 5.3 5.3 0 0 0-1.79 2.82c-.24.9-.48 2.8.8 4.74a5.22 5.22 0 0 0-.37 5.02c1.02 2.32 3.57 4.14 8.52 6.1 3.07 1.22 5.89 2 5.91 2.01a44.33 44.33 0 0 0 10.93 1.6c5.86 0 10.05-1.8 12.46-5.34 3.88-5.69 3.33-10.9-1.7-15.92-2.77-2.78-4.62-6.87-5-7.77-.78-2.66-2.84-5.62-6.25-5.62a5.7 5.7 0 0 0-4.6 2.46c-1-1.26-1.98-2.25-2.86-2.82A7.4 7.4 0 0 0 17.52 48Zm0 4c.51 0 1.14.22 1.82.65 2.14 1.36 6.25 8.43 7.76 11.18.5.92 1.37 1.31 2.14 1.31 1.55 0 2.75-1.53.15-3.48-3.92-2.93-2.55-7.72-.68-8.01.08-.02.17-.02.24-.02 1.7 0 2.45 2.93 2.45 2.93s2.2 5.52 5.98 9.3c3.77 3.77 3.97 6.8 1.22 10.83-1.88 2.75-5.47 3.58-9.16 3.58-3.81 0-7.73-.9-9.92-1.46-.11-.03-13.45-3.8-11.76-7 .28-.54.75-.76 1.34-.76 2.38 0 6.7 3.54 8.57 3.54.41 0 .7-.17.83-.6.79-2.85-12.06-4.05-10.98-8.17.2-.73.71-1.02 1.44-1.02 3.14 0 10.2 5.53 11.68 5.53.11 0 .2-.03.24-.1.74-1.2.33-2.04-4.9-5.2-5.21-3.16-8.88-5.06-6.8-7.33.24-.26.58-.38 1-.38 3.17 0 10.66 6.82 10.66 6.82s2.02 2.1 3.25 2.1c.28 0 .52-.1.68-.38.86-1.46-8.06-8.22-8.56-11.01-.34-1.9.24-2.85 1.31-2.85Z"}),a.jsx("path",{fill:"#FFD21E",d:"M38.6 76.69c2.75-4.04 2.55-7.07-1.22-10.84-3.78-3.77-5.98-9.3-5.98-9.3s-.82-3.2-2.69-2.9c-1.87.3-3.24 5.08.68 8.01 3.91 2.93-.78 4.92-2.29 2.17-1.5-2.75-5.62-9.82-7.76-11.18-2.13-1.35-3.63-.6-3.13 2.2.5 2.79 9.43 9.55 8.56 11-.87 1.47-3.93-1.71-3.93-1.71s-9.57-8.71-11.66-6.44c-2.08 2.27 1.59 4.17 6.8 7.33 5.23 3.16 5.64 4 4.9 5.2-.75 1.2-12.28-8.53-13.36-4.4-1.08 4.11 11.77 5.3 10.98 8.15-.8 2.85-9.06-5.38-10.74-2.18-1.7 3.21 11.65 6.98 11.76 7.01 4.3 1.12 15.25 3.49 19.08-2.12Z"}),a.jsx("path",{fill:"#FF9D0B",d:"M77.4 48c1.62 0 3.07.66 4.07 1.87a5.97 5.97 0 0 1 1.33 3.76 7.1 7.1 0 0 1 1.95-.3c1.55 0 2.95.59 3.94 1.66a5.8 5.8 0 0 1 .8 7 5.3 5.3 0 0 1 1.78 2.82c.24.9.48 2.8-.8 4.74a5.22 5.22 0 0 1 .37 5.02c-1.02 2.32-3.57 4.14-8.51 6.1-3.08 1.22-5.9 2-5.92 2.01a44.33 44.33 0 0 1-10.93 1.6c-5.86 0-10.05-1.8-12.46-5.34-3.88-5.69-3.33-10.9 1.7-15.92 2.78-2.78 4.63-6.87 5.01-7.77.78-2.66 2.83-5.62 6.24-5.62a5.7 5.7 0 0 1 4.6 2.46c1-1.26 1.98-2.25 2.87-2.82A7.4 7.4 0 0 1 77.4 48Zm0 4c-.51 0-1.13.22-1.82.65-2.13 1.36-6.25 8.43-7.76 11.18a2.43 2.43 0 0 1-2.14 1.31c-1.54 0-2.75-1.53-.14-3.48 3.91-2.93 2.54-7.72.67-8.01a1.54 1.54 0 0 0-.24-.02c-1.7 0-2.45 2.93-2.45 2.93s-2.2 5.52-5.97 9.3c-3.78 3.77-3.98 6.8-1.22 10.83 1.87 2.75 5.47 3.58 9.15 3.58 3.82 0 7.73-.9 9.93-1.46.1-.03 13.45-3.8 11.76-7-.29-.54-.75-.76-1.34-.76-2.38 0-6.71 3.54-8.57 3.54-.42 0-.71-.17-.83-.6-.8-2.85 12.05-4.05 10.97-8.17-.19-.73-.7-1.02-1.44-1.02-3.14 0-10.2 5.53-11.68 5.53-.1 0-.19-.03-.23-.1-.74-1.2-.34-2.04 4.88-5.2 5.23-3.16 8.9-5.06 6.8-7.33-.23-.26-.57-.38-.98-.38-3.18 0-10.67 6.82-10.67 6.82s-2.02 2.1-3.24 2.1a.74.74 0 0 1-.68-.38c-.87-1.46 8.05-8.22 8.55-11.01.34-1.9-.24-2.85-1.31-2.85Z"}),a.jsx("path",{fill:"#FFD21E",d:"M56.33 76.69c-2.75-4.04-2.56-7.07 1.22-10.84 3.77-3.77 5.97-9.3 5.97-9.3s.82-3.2 2.7-2.9c1.86.3 3.23 5.08-.68 8.01-3.92 2.93.78 4.92 2.28 2.17 1.51-2.75 5.63-9.82 7.76-11.18 2.13-1.35 3.64-.6 3.13 2.2-.5 2.79-9.42 9.55-8.55 11 .86 1.47 3.92-1.71 3.92-1.71s9.58-8.71 11.66-6.44c2.08 2.27-1.58 4.17-6.8 7.33-5.23 3.16-5.63 4-4.9 5.2.75 1.2 12.28-8.53 13.36-4.4 1.08 4.11-11.76 5.3-10.97 8.15.8 2.85 9.05-5.38 10.74-2.18 1.69 3.21-11.65 6.98-11.76 7.01-4.31 1.12-15.26 3.49-19.08-2.12Z"})]});function T(s){const t=[...new Set(s.map(r=>r.replace(/ \(subtask\)$/,"")))],l=t.length>3?[...t.slice(0,2),`${t.length-2} more`]:t;return l.length>1?`${l.slice(0,-1).join(", ")} and ${l[l.length-1]}`:l[0]}const z="language-modeling";function p(s){return s?s.toLowerCase().replace(/\(.*?\)/g," ").replace(/[^a-z]+/g," ").replace(/\bllm\b/g," ").replace(/\s+/g," ").trim().replace(/s$/,""):""}function B(s){return p(s.slug)==="large language model"||p(s.name)==="large language model"}function D(s){return s.tags.includes(z)?s.methods.filter(t=>!B(t)):s.methods}const S=({name:s,slug:t,logoUrl:l})=>{const[r,i]=g.useState(!1);return!l||r?null:a.jsx(d,{to:`/orgs/${t}`,className:"paper-organization-logo","aria-label":`View ${s} organization`,title:s,children:a.jsx("img",{src:l,alt:"",onError:()=>i(!0)})})},q=({paper:s,priority:t=!1,showInstitution:l=!0,highlightQuery:r,followReasons:i})=>{const m=v(),u=`/paper/${s.id}`,n=g.useCallback(()=>{m.prefetchQuery({queryKey:y.detail(s.id),queryFn:()=>C.get(s.id,!0),staleTime:M})},[s.id,m]),F=s.authors.slice(0,3).map((e,o)=>{var b,N;const f=(b=s.authorIds)==null?void 0:b[o],j=(N=s.authorHfProfiles)==null?void 0:N[o];return a.jsxs(g.Fragment,{children:[o>0&&", ",j&&a.jsx(L,{className:"paper-card-author-avatar",url:j.avatarUrl}),f?a.jsx(d,{to:`/authors/${f}`,children:e}):e]},o)}),c=s.authors.length,x=D(s);return a.jsxs("article",{className:"paper-card",children:[a.jsx(d,{to:u,className:"paper-thumb-wrap",onFocus:n,onMouseEnter:n,children:a.jsx(Z,{paperId:s.id,title:s.title,thumbnailUrl:s.thumbnailUrl,priority:t})}),a.jsxs("div",{className:"paper-body",children:[a.jsxs("div",{className:"paper-body-main",children:[i&&i.length>0&&a.jsxs("div",{className:"paper-follow-reason",children:["Because you follow ",T(i)]}),a.jsxs("h3",{className:"paper-title",children:[a.jsx(d,{to:u,onFocus:n,onMouseEnter:n,children:a.jsx(U,{title:s.title,highlight:r})}),l&&s.organizations.length>0&&a.jsx("span",{className:"paper-organization-logos",children:s.organizations.map(e=>a.jsx(S,{...e},e.slug))})]}),a.jsxs("div",{className:"paper-authors",children:[F,c>3&&a.jsxs("span",{children:[", ","+",c-3," authors"]}),s.date&&a.jsxs(a.Fragment,{children:[c>0?" · ":"",a.jsx("span",{children:s.date})]}),s.citations>0&&a.jsxs(a.Fragment,{children:[c>0||s.date?" · ":"",a.jsxs("span",{children:[s.citations.toLocaleString()," citations"]})]})]}),s.abstract&&a.jsx("p",{className:"paper-abstract",children:a.jsx(w,{text:s.abstract,highlight:r})}),s.sotaRanks.length>0&&a.jsx(A,{ranks:s.sotaRanks,paperHref:u}),(s.tags.length>0||x.length>0)&&a.jsxs("div",{className:"paper-tags paper-tags--clamped",children:[s.tags.map(e=>a.jsx(k,{slug:e},e)),x.map(e=>a.jsx(E,{method:e},e.id||e.slug||e.name))]})]}),(s.githubUrl||s.hfUrl)&&a.jsxs("div",{className:"paper-resources",children:[h(s.githubUrl)&&a.jsxs("a",{className:"paper-resource is-link",href:h(s.githubUrl)??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":"Open GitHub repository",onClick:e=>e.stopPropagation(),children:[a.jsx(P,{name:"github",size:20}),s.velocity24h!=null&&s.velocity24h>0&&a.jsxs("span",{className:"resource-stat",children:[a.jsxs("span",{className:"resource-value",children:[a.jsx("span",{className:"gh-rate-arrow",children:"↑"}),s.velocity24h.toFixed(1)]}),a.jsx("span",{className:"resource-label",children:"stars / hr"})]})]}),h(s.hfUrl)&&s.hfKind&&a.jsxs("a",{className:"paper-resource is-link",href:h(s.hfUrl)??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":`Open Hugging Face ${s.hfKind}`,onClick:e=>e.stopPropagation(),children:[a.jsx($,{size:20}),a.jsxs("span",{className:"resource-stat",children:[a.jsx("span",{className:"resource-value",children:s.hfCount}),a.jsx("span",{className:"resource-label",children:s.hfKind})]})]})]})]})]})};export{q as P}; +import{i as v,V as g,T as M,p as y,j as a,L as d}from"./index-CjdUkE4w.js";import{A as L}from"./AuthorAvatar-D9249Frl.js";import{P as Z,S as A,T as k,M as E}from"./SotaBadges-CyScuNCv.js";import{I as P}from"./Icon-CGRs4BYD.js";import{L as U,a as w}from"./LatexTitle-DESKtS30.js";import{p as C}from"./papers-DgZwjF3K.js";import{s as h}from"./safeExternalHref-CkBrsh84.js";const $=({size:s=16})=>a.jsxs("svg",{className:"hf-logo",width:s,height:s,viewBox:"0 0 95 88",fill:"none","aria-hidden":"true",focusable:"false",children:[a.jsx("path",{fill:"#FFD21E",d:"M47.21 76.5a34.75 34.75 0 1 0 0-69.5 34.75 34.75 0 0 0 0 69.5Z"}),a.jsx("path",{fill:"#FF9D0B",d:"M81.96 41.75a34.75 34.75 0 1 0-69.5 0 34.75 34.75 0 0 0 69.5 0Zm-73.5 0a38.75 38.75 0 1 1 77.5 0 38.75 38.75 0 0 1-77.5 0Z"}),a.jsx("path",{fill:"#3A3B45",d:"M58.5 32.3c1.28.44 1.78 3.06 3.07 2.38a5 5 0 1 0-6.76-2.07c.61 1.15 2.55-.72 3.7-.32ZM34.95 32.3c-1.28.44-1.79 3.06-3.07 2.38a5 5 0 1 1 6.76-2.07c-.61 1.15-2.56-.72-3.7-.32Z"}),a.jsx("path",{fill:"#FF323D",d:"M46.96 56.29c9.83 0 13-8.76 13-13.26 0-2.34-1.57-1.6-4.09-.36-2.33 1.15-5.46 2.74-8.9 2.74-7.19 0-13-6.88-13-2.38s3.16 13.26 13 13.26Z"}),a.jsx("path",{fill:"#3A3B45",fillRule:"evenodd",clipRule:"evenodd",d:"M39.43 54a8.7 8.7 0 0 1 5.3-4.49c.4-.12.81.57 1.24 1.28.4.68.82 1.37 1.24 1.37.45 0 .9-.68 1.33-1.35.45-.7.89-1.38 1.32-1.25a8.61 8.61 0 0 1 5 4.17c3.73-2.94 5.1-7.74 5.1-10.7 0-2.34-1.57-1.6-4.09-.36l-.14.07c-2.31 1.15-5.39 2.67-8.77 2.67s-6.45-1.52-8.77-2.67c-2.6-1.29-4.23-2.1-4.23.29 0 3.05 1.46 8.06 5.47 10.97Z"}),a.jsx("path",{fill:"#FF9D0B",d:"M70.71 37a3.25 3.25 0 1 0 0-6.5 3.25 3.25 0 0 0 0 6.5ZM24.21 37a3.25 3.25 0 1 0 0-6.5 3.25 3.25 0 0 0 0 6.5ZM17.52 48c-1.62 0-3.06.66-4.07 1.87a5.97 5.97 0 0 0-1.33 3.76 7.1 7.1 0 0 0-1.94-.3c-1.55 0-2.95.59-3.94 1.66a5.8 5.8 0 0 0-.8 7 5.3 5.3 0 0 0-1.79 2.82c-.24.9-.48 2.8.8 4.74a5.22 5.22 0 0 0-.37 5.02c1.02 2.32 3.57 4.14 8.52 6.1 3.07 1.22 5.89 2 5.91 2.01a44.33 44.33 0 0 0 10.93 1.6c5.86 0 10.05-1.8 12.46-5.34 3.88-5.69 3.33-10.9-1.7-15.92-2.77-2.78-4.62-6.87-5-7.77-.78-2.66-2.84-5.62-6.25-5.62a5.7 5.7 0 0 0-4.6 2.46c-1-1.26-1.98-2.25-2.86-2.82A7.4 7.4 0 0 0 17.52 48Zm0 4c.51 0 1.14.22 1.82.65 2.14 1.36 6.25 8.43 7.76 11.18.5.92 1.37 1.31 2.14 1.31 1.55 0 2.75-1.53.15-3.48-3.92-2.93-2.55-7.72-.68-8.01.08-.02.17-.02.24-.02 1.7 0 2.45 2.93 2.45 2.93s2.2 5.52 5.98 9.3c3.77 3.77 3.97 6.8 1.22 10.83-1.88 2.75-5.47 3.58-9.16 3.58-3.81 0-7.73-.9-9.92-1.46-.11-.03-13.45-3.8-11.76-7 .28-.54.75-.76 1.34-.76 2.38 0 6.7 3.54 8.57 3.54.41 0 .7-.17.83-.6.79-2.85-12.06-4.05-10.98-8.17.2-.73.71-1.02 1.44-1.02 3.14 0 10.2 5.53 11.68 5.53.11 0 .2-.03.24-.1.74-1.2.33-2.04-4.9-5.2-5.21-3.16-8.88-5.06-6.8-7.33.24-.26.58-.38 1-.38 3.17 0 10.66 6.82 10.66 6.82s2.02 2.1 3.25 2.1c.28 0 .52-.1.68-.38.86-1.46-8.06-8.22-8.56-11.01-.34-1.9.24-2.85 1.31-2.85Z"}),a.jsx("path",{fill:"#FFD21E",d:"M38.6 76.69c2.75-4.04 2.55-7.07-1.22-10.84-3.78-3.77-5.98-9.3-5.98-9.3s-.82-3.2-2.69-2.9c-1.87.3-3.24 5.08.68 8.01 3.91 2.93-.78 4.92-2.29 2.17-1.5-2.75-5.62-9.82-7.76-11.18-2.13-1.35-3.63-.6-3.13 2.2.5 2.79 9.43 9.55 8.56 11-.87 1.47-3.93-1.71-3.93-1.71s-9.57-8.71-11.66-6.44c-2.08 2.27 1.59 4.17 6.8 7.33 5.23 3.16 5.64 4 4.9 5.2-.75 1.2-12.28-8.53-13.36-4.4-1.08 4.11 11.77 5.3 10.98 8.15-.8 2.85-9.06-5.38-10.74-2.18-1.7 3.21 11.65 6.98 11.76 7.01 4.3 1.12 15.25 3.49 19.08-2.12Z"}),a.jsx("path",{fill:"#FF9D0B",d:"M77.4 48c1.62 0 3.07.66 4.07 1.87a5.97 5.97 0 0 1 1.33 3.76 7.1 7.1 0 0 1 1.95-.3c1.55 0 2.95.59 3.94 1.66a5.8 5.8 0 0 1 .8 7 5.3 5.3 0 0 1 1.78 2.82c.24.9.48 2.8-.8 4.74a5.22 5.22 0 0 1 .37 5.02c-1.02 2.32-3.57 4.14-8.51 6.1-3.08 1.22-5.9 2-5.92 2.01a44.33 44.33 0 0 1-10.93 1.6c-5.86 0-10.05-1.8-12.46-5.34-3.88-5.69-3.33-10.9 1.7-15.92 2.78-2.78 4.63-6.87 5.01-7.77.78-2.66 2.83-5.62 6.24-5.62a5.7 5.7 0 0 1 4.6 2.46c1-1.26 1.98-2.25 2.87-2.82A7.4 7.4 0 0 1 77.4 48Zm0 4c-.51 0-1.13.22-1.82.65-2.13 1.36-6.25 8.43-7.76 11.18a2.43 2.43 0 0 1-2.14 1.31c-1.54 0-2.75-1.53-.14-3.48 3.91-2.93 2.54-7.72.67-8.01a1.54 1.54 0 0 0-.24-.02c-1.7 0-2.45 2.93-2.45 2.93s-2.2 5.52-5.97 9.3c-3.78 3.77-3.98 6.8-1.22 10.83 1.87 2.75 5.47 3.58 9.15 3.58 3.82 0 7.73-.9 9.93-1.46.1-.03 13.45-3.8 11.76-7-.29-.54-.75-.76-1.34-.76-2.38 0-6.71 3.54-8.57 3.54-.42 0-.71-.17-.83-.6-.8-2.85 12.05-4.05 10.97-8.17-.19-.73-.7-1.02-1.44-1.02-3.14 0-10.2 5.53-11.68 5.53-.1 0-.19-.03-.23-.1-.74-1.2-.34-2.04 4.88-5.2 5.23-3.16 8.9-5.06 6.8-7.33-.23-.26-.57-.38-.98-.38-3.18 0-10.67 6.82-10.67 6.82s-2.02 2.1-3.24 2.1a.74.74 0 0 1-.68-.38c-.87-1.46 8.05-8.22 8.55-11.01.34-1.9-.24-2.85-1.31-2.85Z"}),a.jsx("path",{fill:"#FFD21E",d:"M56.33 76.69c-2.75-4.04-2.56-7.07 1.22-10.84 3.77-3.77 5.97-9.3 5.97-9.3s.82-3.2 2.7-2.9c1.86.3 3.23 5.08-.68 8.01-3.92 2.93.78 4.92 2.28 2.17 1.51-2.75 5.63-9.82 7.76-11.18 2.13-1.35 3.64-.6 3.13 2.2-.5 2.79-9.42 9.55-8.55 11 .86 1.47 3.92-1.71 3.92-1.71s9.58-8.71 11.66-6.44c2.08 2.27-1.58 4.17-6.8 7.33-5.23 3.16-5.63 4-4.9 5.2.75 1.2 12.28-8.53 13.36-4.4 1.08 4.11-11.76 5.3-10.97 8.15.8 2.85 9.05-5.38 10.74-2.18 1.69 3.21-11.65 6.98-11.76 7.01-4.31 1.12-15.26 3.49-19.08-2.12Z"})]});function T(s){const t=[...new Set(s.map(r=>r.replace(/ \(subtask\)$/,"")))],l=t.length>3?[...t.slice(0,2),`${t.length-2} more`]:t;return l.length>1?`${l.slice(0,-1).join(", ")} and ${l[l.length-1]}`:l[0]}const z="language-modeling";function p(s){return s?s.toLowerCase().replace(/\(.*?\)/g," ").replace(/[^a-z]+/g," ").replace(/\bllm\b/g," ").replace(/\s+/g," ").trim().replace(/s$/,""):""}function B(s){return p(s.slug)==="large language model"||p(s.name)==="large language model"}function D(s){return s.tags.includes(z)?s.methods.filter(t=>!B(t)):s.methods}const S=({name:s,slug:t,logoUrl:l})=>{const[r,i]=g.useState(!1);return!l||r?null:a.jsx(d,{to:`/orgs/${t}`,className:"paper-organization-logo","aria-label":`View ${s} organization`,title:s,children:a.jsx("img",{src:l,alt:"",onError:()=>i(!0)})})},q=({paper:s,priority:t=!1,showInstitution:l=!0,highlightQuery:r,followReasons:i})=>{const m=v(),u=`/paper/${s.id}`,n=g.useCallback(()=>{m.prefetchQuery({queryKey:y.detail(s.id),queryFn:()=>C.get(s.id,!0),staleTime:M})},[s.id,m]),F=s.authors.slice(0,3).map((e,o)=>{var b,N;const f=(b=s.authorIds)==null?void 0:b[o],j=(N=s.authorHfProfiles)==null?void 0:N[o];return a.jsxs(g.Fragment,{children:[o>0&&", ",j&&a.jsx(L,{className:"paper-card-author-avatar",url:j.avatarUrl}),f?a.jsx(d,{to:`/authors/${f}`,children:e}):e]},o)}),c=s.authors.length,x=D(s);return a.jsxs("article",{className:"paper-card",children:[a.jsx(d,{to:u,className:"paper-thumb-wrap",onFocus:n,onMouseEnter:n,children:a.jsx(Z,{paperId:s.id,title:s.title,thumbnailUrl:s.thumbnailUrl,priority:t})}),a.jsxs("div",{className:"paper-body",children:[a.jsxs("div",{className:"paper-body-main",children:[i&&i.length>0&&a.jsxs("div",{className:"paper-follow-reason",children:["Because you follow ",T(i)]}),a.jsxs("h3",{className:"paper-title",children:[a.jsx(d,{to:u,onFocus:n,onMouseEnter:n,children:a.jsx(U,{title:s.title,highlight:r})}),l&&s.organizations.length>0&&a.jsx("span",{className:"paper-organization-logos",children:s.organizations.map(e=>a.jsx(S,{...e},e.slug))})]}),a.jsxs("div",{className:"paper-authors",children:[F,c>3&&a.jsxs("span",{children:[", ","+",c-3," authors"]}),s.date&&a.jsxs(a.Fragment,{children:[c>0?" · ":"",a.jsx("span",{children:s.date})]}),s.citations>0&&a.jsxs(a.Fragment,{children:[c>0||s.date?" · ":"",a.jsxs("span",{children:[s.citations.toLocaleString()," citations"]})]})]}),s.abstract&&a.jsx("p",{className:"paper-abstract",children:a.jsx(w,{text:s.abstract,highlight:r})}),s.sotaRanks.length>0&&a.jsx(A,{ranks:s.sotaRanks,paperHref:u}),(s.tags.length>0||x.length>0)&&a.jsxs("div",{className:"paper-tags paper-tags--clamped",children:[s.tags.map(e=>a.jsx(k,{slug:e},e)),x.map(e=>a.jsx(E,{method:e},e.id||e.slug||e.name))]})]}),(s.githubUrl||s.hfUrl)&&a.jsxs("div",{className:"paper-resources",children:[h(s.githubUrl)&&a.jsxs("a",{className:"paper-resource is-link",href:h(s.githubUrl)??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":"Open GitHub repository",onClick:e=>e.stopPropagation(),children:[a.jsx(P,{name:"github",size:20}),s.velocity24h!=null&&s.velocity24h>0&&a.jsxs("span",{className:"resource-stat",children:[a.jsxs("span",{className:"resource-value",children:[a.jsx("span",{className:"gh-rate-arrow",children:"↑"}),s.velocity24h.toFixed(1)]}),a.jsx("span",{className:"resource-label",children:"stars / hr"})]})]}),h(s.hfUrl)&&s.hfKind&&a.jsxs("a",{className:"paper-resource is-link",href:h(s.hfUrl)??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":`Open Hugging Face ${s.hfKind}`,onClick:e=>e.stopPropagation(),children:[a.jsx($,{size:20}),a.jsxs("span",{className:"resource-stat",children:[a.jsx("span",{className:"resource-value",children:s.hfCount}),a.jsx("span",{className:"resource-label",children:s.hfKind})]})]})]})]})]})};export{q as P}; diff --git a/assets/PaperDetailView-BlSDULsI.js b/assets/PaperDetailView-DSf05yVz.js similarity index 97% rename from assets/PaperDetailView-BlSDULsI.js rename to assets/PaperDetailView-DSf05yVz.js index 15e3bfe2753637707ea696f626a1a35a0111d75a..9070c1e04ecfa8608ee71431cf6d020defecd81b 100644 --- a/assets/PaperDetailView-BlSDULsI.js +++ b/assets/PaperDetailView-DSf05yVz.js @@ -1,4 +1,4 @@ -import{s as ft,b as Q,t as ea,T as it,v as re,w as ta,e as rs,x as J,d as b,p as me,j as e,C as gt,i as Z,y as xt,X as ns,o as Lt,P as is,z as ee,A as os,B as pe,D as he,E as ls,F as bt,G as Ce,I as Tt,J as sa,L as K,K as aa,M as ra,R as na,N as ia,O as cs,Q as oa,h as la,S as ca,U as Se,l as da,a as Pe,V as Ee,W as se,k as ds,u as ua,Y as Dt,Z as ma,q as Ft,_ as ha,$ as pa,a0 as fa,a1 as ga,a2 as xa,a3 as ba}from"./index-DyXq7-Tg.js";import{u as ae}from"./useMutation-UWxBeqtn.js";import{I as F}from"./Icon-T4LYkEQj.js";import{T as ja,M as va,S as ya,P as _a}from"./SotaBadges-vbLLOUtT.js";import{L as Ne,a as ot}from"./LatexTitle-Bkyz3jCs.js";import{e as $e,C as ka,E as Na}from"./ExternalSourceEvalBadge-K3r45EmO.js";import{p as U}from"./papers-Dh3ljlL0.js";import{s as wa,a as Ca}from"./transform-D46m70Qr.js";import{r as us,p as Sa}from"./paperReader-BIpQD5HO.js";import{a as Ea}from"./usePapers-B0s20UcU.js";import{u as Pa,f as $a}from"./useDocumentTitle-DcxM2Zv_.js";import{u as Ia}from"./preferences-COzeOLyS.js";import{s as Y}from"./safeExternalHref-CkBrsh84.js";import{F as Ut,i as Ra,P as Aa}from"./curation-YeS7FBYf.js";import{S as ue}from"./skeleton-C3IIzpSL.js";import{A as La,a as Ta}from"./alert-gbJBhAVE.js";import{B as A}from"./button-DZeAbOf2.js";import{D as Ie,a as Re,c as Ae,b as Le,d as Te,e as jt}from"./dialog-CfM0Uql2.js";import{A as Da,a as Fa}from"./AgentLogos-j-Qekw7T.js";import{C as Ua}from"./copy-CxR0OKx2.js";import{u as ye,r as Ba,e as za}from"./evaluationQueryInvalidation-Cm3s7Pfm.js";import{I as z}from"./input-DJqCAbs7.js";import{S as Bt}from"./searchable-select-DiDLwvbI.js";import{L as vt}from"./loader-circle-C75KLEgx.js";import{T as fe,n as He,g as zt,C as Ma}from"./CatalogEntityPreviewLink-BktpwL3_.js";import{S as ms,L as O,a as Ha}from"./SignInToEditDialog-B-oWVno5.js";import{c as G}from"./catalog-CRar2olQ.js";import{s as hs,p as ps}from"./submissions-Cz_J-Ha2.js";import{i as fs,a as gs,r as Oa}from"./queryInvalidation-CfHeNeUY.js";import{D as qa}from"./database-DflzbaZ5.js";import{P as ge}from"./plus-Yh42pKZz.js";import{S as lt}from"./search-8ssWDP68.js";import{B as xs}from"./badge-e6t3GCyf.js";import{G as Mt}from"./globe-BMJtRs4F.js";import{G as Ht}from"./github-RNrgGHRT.js";import{u as bs}from"./index-C041TDos.js";import{c as Oe,A as Ka}from"./codex-DFj4KHqP.js";import{M as Ga}from"./index-mCi_y_l3.js";import{r as Qa}from"./index-2CvJmBVB.js";import{u as Xa}from"./useIntersectionObserver-D6_Iig9a.js";import{a as ct}from"./account-cbblajck.js";import{S as Ot,s as Va}from"./savedPapersAuth-TV7AiXOw.js";import{o as Wa}from"./organizationNames-BVKzYEBp.js";import{A as Ya}from"./AuthorAvatar-B-9xS2Wo.js";import"./colors-BkWRhvFI.js";import"./hover-card-B45EJIn_.js";import"./useInfiniteQuery-BYh2zN-T.js";import"./popover-CTBEUp7Y.js";import"./textarea-DPixlM5U.js";/** +import{s as ft,b as Q,t as ea,T as it,v as re,w as ta,e as rs,x as J,d as b,p as me,j as e,C as gt,i as Z,y as xt,X as ns,o as Lt,P as is,z as ee,B as os,D as pe,E as he,F as ls,G as bt,I as Ce,J as Tt,K as sa,L as K,M as aa,N as ra,R as na,O as ia,Q as cs,S as oa,h as la,U as ca,A as Se,l as da,a as Pe,V as Ee,W as se,k as ds,u as ua,Y as Dt,Z as ma,q as Ft,_ as ha,$ as pa,a0 as fa,a1 as ga,a2 as xa,a3 as ba}from"./index-CjdUkE4w.js";import{u as ae}from"./useMutation-BYtVrkc7.js";import{I as F}from"./Icon-CGRs4BYD.js";import{T as ja,M as va,S as ya,P as _a}from"./SotaBadges-CyScuNCv.js";import{L as Ne,a as ot}from"./LatexTitle-DESKtS30.js";import{e as $e,C as ka,E as Na}from"./ExternalSourceEvalBadge-B3fyun97.js";import{p as U}from"./papers-DgZwjF3K.js";import{s as wa,a as Ca}from"./transform-CRNzYLch.js";import{r as us,p as Sa}from"./paperReader-h6jqpWHI.js";import{a as Ea}from"./usePapers-BZThqZCx.js";import{u as Pa,f as $a}from"./useDocumentTitle-2Ho8_KfW.js";import{u as Ia}from"./preferences-DMhkYrri.js";import{s as Y}from"./safeExternalHref-CkBrsh84.js";import{F as Ut,i as Ra,P as Aa}from"./curation-CyyuHfv5.js";import{S as ue}from"./skeleton-DTWi7Ctg.js";import{A as La,a as Ta}from"./alert-BM9Xfuyy.js";import{B as A}from"./button-DetZl_ch.js";import{D as Ie,a as Re,c as Ae,b as Le,d as Te,e as jt}from"./dialog-BzX9PD3v.js";import{A as Da,a as Fa}from"./AgentLogos-xoTIu0NB.js";import{C as Ua}from"./copy-SoF5zg-g.js";import{u as ye,r as Ba,e as za}from"./evaluationQueryInvalidation-BAyi4YoG.js";import{I as z}from"./input-7i-rZ7fA.js";import{S as Bt}from"./searchable-select-EPf13F1I.js";import{L as vt}from"./loader-circle-xTdSzHv_.js";import{T as fe,n as He,g as zt,C as Ma}from"./CatalogEntityPreviewLink-DY_jhXy9.js";import{S as ms,L as O,a as Ha}from"./SignInToEditDialog-rWxdYNRK.js";import{c as G}from"./catalog-qXcKve0z.js";import{s as hs,p as ps}from"./submissions-CQ6M0giV.js";import{i as fs,a as gs,r as Oa}from"./queryInvalidation-LiTu0GxY.js";import{D as qa}from"./database-b_ekt_5x.js";import{P as ge}from"./plus-AztI1566.js";import{S as lt}from"./search-DxMn7VKI.js";import{B as xs}from"./badge-C8r6F6JD.js";import{G as Mt}from"./globe-mBp0l-nC.js";import{G as Ht}from"./github-4bW4WI_e.js";import{u as bs}from"./index-BxR27SAB.js";import{c as Oe,A as Ka}from"./codex-CgFzL2AI.js";import{M as Ga}from"./index-tLcwYp0U.js";import{r as Qa}from"./index-Dj6aE-6E.js";import{u as Xa}from"./useIntersectionObserver-Ch6RpsSk.js";import{a as ct}from"./account-DoluPGSd.js";import{S as Ot,s as Va}from"./savedPapersAuth-DT83MLdi.js";import{o as Wa}from"./organizationNames-BVKzYEBp.js";import{A as Ya}from"./AuthorAvatar-D9249Frl.js";import"./colors-BkWRhvFI.js";import"./hover-card-CIBIV2Hx.js";import"./useInfiniteQuery-DeZTTVbI.js";import"./popover-Df5_dywQ.js";import"./textarea-biscLKBK.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/PaperFeed-EBt97iOL.js b/assets/PaperFeed-D3FZw29k.js similarity index 97% rename from assets/PaperFeed-EBt97iOL.js rename to assets/PaperFeed-D3FZw29k.js index 6d265c5e2597cd4f4d8355246c570dab867e2407..265fe2c60d93a71263af5a95ee74475af5de3624 100644 --- a/assets/PaperFeed-EBt97iOL.js +++ b/assets/PaperFeed-D3FZw29k.js @@ -1 +1 @@ -import{d as u,j as t,g as J,V as K}from"./index-DyXq7-Tg.js";import{P as X}from"./PaperCard-57p1OSGy.js";import{P as ee,a as te,b as ae}from"./popover-CTBEUp7Y.js";import{I as se}from"./Icon-T4LYkEQj.js";import{S as j}from"./skeleton-C3IIzpSL.js";import{u as ne}from"./useIntersectionObserver-D6_Iig9a.js";const Y=(e,a)=>{const s=new Date(a),n=new Date(s);return n.setUTCDate(s.getUTCDate()-(e==="week"?6:29)),{startDate:n.toISOString().slice(0,10),endDate:s.toISOString().slice(0,10)}},V=e=>({startDate:e.get("start_date")||void 0,endDate:e.get("end_date")||void 0}),Ne=(e,a=new Date,s="week")=>{const n=V(e);if(n.startDate||n.endDate||e.get("time")==="all_time")return n;const o=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()));return Y(s,o)},Z=(e,a)=>{const s=new URLSearchParams(e);return a.startDate?s.set("start_date",a.startDate):s.delete("start_date"),a.endDate?s.set("end_date",a.endDate):s.delete("end_date"),s.delete("time"),s},Se=(e,a)=>{const s=Z(e,a);return!a.startDate&&!a.endDate&&s.set("time","all_time"),s},re=new Intl.DateTimeFormat("en",{month:"long",year:"numeric",timeZone:"UTC"}),H=new Intl.DateTimeFormat("en",{month:"short",timeZone:"UTC"}),O="(max-width: 640px)",oe=()=>{const[e,a]=u.useState(()=>typeof window<"u"&&window.matchMedia(O).matches);return u.useEffect(()=>{const s=window.matchMedia(O),n=o=>a(o.matches);return a(s.matches),s.addEventListener("change",n),()=>s.removeEventListener("change",n)},[]),e},W=e=>e.toISOString().slice(0,10),b=e=>new Date(`${e}T00:00:00Z`),ie=()=>{const e=new Date;return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))},F=(e,a)=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+a,1)),v=e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)),ce=(e,a)=>new Date(Date.UTC(a,e.getUTCMonth(),1)),w=(e,a)=>e.startDate===a.startDate&&e.endDate===a.endDate,le=(e,a)=>{const s=b(e),n=b(a),o=H.format(s),i=H.format(n),d=s.getUTCDate(),l=n.getUTCDate(),r=s.getUTCFullYear(),p=n.getUTCFullYear();return e===a?`${o} ${d}, ${r}`:r===p&&s.getUTCMonth()===n.getUTCMonth()?`${o} ${d}–${l}, ${r}`:r===p?`${o} ${d}–${i} ${l}, ${r}`:`${o} ${d}, ${r}–${i} ${l}, ${p}`},de=e=>{const a=e.getUTCFullYear(),s=e.getUTCMonth(),n=new Date(Date.UTC(a,s,1)),o=(n.getUTCDay()+6)%7,i=new Date(n);return i.setUTCDate(n.getUTCDate()-o),Array.from({length:42},(d,l)=>{const r=new Date(i);return r.setUTCDate(i.getUTCDate()+l),{iso:W(r),day:r.getUTCDate(),outsideMonth:r.getUTCMonth()!==s}})},L=({month:e,today:a,startDate:s,endDate:n,onSelect:o,yearLabel:i,yearValue:d,onYearChange:l,secondary:r=!1})=>{const p=u.useMemo(()=>de(e),[e]);return t.jsxs("section",{className:`paper-date-calendar${r?" paper-date-calendar-secondary":""}`,children:[t.jsxs("label",{className:"paper-date-year",children:[t.jsx("span",{children:i}),t.jsx("input",{type:"number",inputMode:"numeric",min:"1900",max:a.slice(0,4),step:"1",value:d,onChange:c=>l(c.target.value)})]}),t.jsx("h3",{children:re.format(e)}),t.jsx("div",{className:"paper-date-weekdays","aria-hidden":"true",children:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(c=>t.jsx("span",{children:c},c))}),t.jsx("div",{className:"paper-date-days",children:p.map(c=>{const g=c.iso===s||c.iso===n,m=!!(s&&n&&c.iso>s&&c.isoa;return t.jsx("button",{type:"button","aria-label":c.iso,"aria-selected":g,disabled:f,className:["paper-date-day",c.outsideMonth?"outside":"",g?"selected":"",m?"in-range":"",c.iso===a?"today":""].filter(Boolean).join(" "),onClick:()=>o(c.iso),children:c.day},c.iso)})})]})},I=({calendar:e,onPrevious:a,onNext:s,secondary:n=!1})=>t.jsxs("div",{className:`paper-date-navigation-group${n?" paper-date-navigation-group-secondary":""}`,children:[t.jsx("button",{type:"button","aria-label":`Previous ${e} month`,onClick:a,children:"←"}),t.jsx("button",{type:"button","aria-label":`Next ${e} month`,onClick:s,children:"→"})]}),he=({startDate:e,endDate:a,onChange:s,currentDate:n})=>{const o=oe(),i=n?b(n):ie(),[d,l]=u.useState(!1),[r,p]=u.useState(),[c,g]=u.useState(),[m,f]=u.useState(()=>v(i)),[_,T]=u.useState(()=>F(v(i),1)),[z,D]=u.useState(()=>String(i.getUTCFullYear())),[G,y]=u.useState(()=>String(i.getUTCFullYear())),N={startDate:e,endDate:a},M=Y("week",i),P=Y("month",i),k=W(i),R=!!(e&&a&&!w(N,M)&&!w(N,P)),Q=()=>{p(e),g(a);const h=v(e?b(e):i),x=v(a?b(a):F(h,1));f(h),T(x),D(String(h.getUTCFullYear())),y(String(x.getUTCFullYear())),l(!0)},E=(h,x,$)=>{if(x(h),!/^\d{4}$/.test(h))return;const C=Number(h);C>=1900&&C<=i.getUTCFullYear()&&$(U=>ce(U,C))},S=(h,x,$,C)=>{const U=F(h,x);$(U),C(String(U.getUTCFullYear()))},A=h=>{!r||c?(p(h),g(void 0)):h{s({}),l(!1)};return t.jsxs("div",{className:`paper-date-filter${o?" paper-date-filter-single-calendar":""}`,role:"group","aria-label":"Publication date",children:[t.jsx("button",{type:"button",className:`sort-btn sort-btn-time${w(N,M)?" active":""}`,onClick:()=>s(M),children:"Last Week"}),t.jsx("button",{type:"button",className:`sort-btn sort-btn-time${w(N,P)?" active":""}`,onClick:()=>s(P),children:"Last Month"}),t.jsx("button",{type:"button",className:`sort-btn sort-btn-time${!e&&!a?" active":""}`,onClick:()=>s({}),children:"All Time"}),t.jsxs(ee,{open:d,onOpenChange:h=>{h?Q():l(!1)},children:[t.jsx(te,{asChild:!0,children:t.jsx("button",{type:"button",className:`sort-btn sort-btn-time${R?" active":""}`,"aria-label":R?"Change date range":"Select a range",children:R&&e&&a?le(e,a):"Select a range"})}),t.jsxs(ae,{align:"end",className:`paper-date-popover${o?" paper-date-popover-single-calendar":""}`,role:"dialog","aria-label":"Select a date range",children:[t.jsxs("div",{className:"paper-date-popover-header",children:[t.jsx("h2",{children:"Select a date range"}),t.jsx("p",{children:"Choose an inclusive start and end publication date."})]}),t.jsxs("div",{className:"paper-date-navigation",children:[t.jsx(I,{calendar:"start",onPrevious:()=>S(m,-1,f,D),onNext:()=>S(m,1,f,D)}),!o&&t.jsx(I,{calendar:"end",onPrevious:()=>S(_,-1,T,y),onNext:()=>S(_,1,T,y),secondary:!0})]}),t.jsxs("div",{className:"paper-date-calendars",children:[t.jsx(L,{month:m,today:k,startDate:r,endDate:c,onSelect:A,yearLabel:o?"Year":"Start year",yearValue:z,onYearChange:h=>E(h,D,f)}),!o&&t.jsx(L,{month:_,today:k,startDate:r,endDate:c,onSelect:A,yearLabel:"End year",yearValue:G,onYearChange:h=>E(h,y,T),secondary:!0})]}),t.jsxs("div",{className:"paper-date-actions",children:[t.jsx("button",{type:"button",className:"paper-date-clear",onClick:q,children:"Clear range"}),t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>l(!1),children:"Cancel"}),t.jsx("button",{type:"button",className:"paper-date-apply",disabled:!r||!c,onClick:()=>{r&&c&&s({startDate:r,endDate:c}),l(!1)},children:"Apply"})]})]})]})]})]})},pe=()=>t.jsxs("span",{className:"hf-resource-logo",children:[t.jsx("img",{className:"hf-resource-logo-black",src:"/hf-logo-monochrome-black.svg?v=20260729",alt:""}),t.jsx("img",{className:"hf-resource-logo-white",src:"/hf-logo-monochrome-white.svg?v=20260729",alt:""})]}),B=({checked:e,icon:a,label:s,onChange:n})=>t.jsxs("button",{type:"button",className:`paper-feed-filter ${e?"active":""}`,"aria-pressed":e,onClick:()=>n(!e),children:[t.jsxs("span",{className:"paper-feed-filter-content",children:[t.jsx("span",{className:"paper-feed-filter-icon","aria-hidden":"true",children:a}),s]}),e&&t.jsx("span",{className:"paper-feed-filter-check","aria-hidden":"true",children:"✓"})]}),ge=({hasCode:e,hasHfArtifacts:a,onHasCodeChange:s,onHasHfArtifactsChange:n,showDivider:o=!0,showHasCode:i=!0})=>t.jsxs("div",{className:"paper-feed-resource-controls",role:"group","aria-label":"Resource filters",children:[o&&t.jsx("span",{className:"paper-feed-resource-divider","aria-hidden":"true"}),t.jsxs("div",{className:"paper-feed-filter-options",children:[i&&t.jsx(B,{checked:e,icon:t.jsx(se,{name:"github",size:14}),label:"Has code",onChange:s}),t.jsx(B,{checked:a,icon:t.jsx(pe,{}),label:"Has artifacts",onChange:n})]})]});function ue(e,a="200px"){const{targetRef:s,isIntersecting:n}=ne({rootMargin:a}),{data:o,hasNextPage:i,isFetchingNextPage:d,fetchNextPage:l}=e;return u.useEffect(()=>{n&&i&&!d&&l()},[n,i,d,l,o]),s}const me=[["trending","trending"],["date_published","newest"],["citation_count","most cited"]];function Ue(){const[e,a]=J(),s=e.get("order_by"),n=s==="date_published"||s==="citation_count"?s:"trending",o=e.get("has_code")==="true",i=e.get("has_hf_artifacts")==="true",d=V(e),l=(r,p)=>{const c=new URLSearchParams(e);p?c.set(r,p):c.delete(r),a(c)};return{searchParams:e,setSearchParams:a,orderBy:n,hasCode:o,hasHfArtifacts:i,dateRange:d,setOrderBy:r=>l("order_by",r==="trending"?null:r),setHasCode:r=>l("has_code",r?"true":null),setHasHfArtifacts:r=>l("has_hf_artifacts",r?"true":null),setDateRange:r=>a(Z(e,r)),filters:{order_by:n,order_dir:"desc",latest_only:!0,include_resources:!0,has_code:o,has_hf_artifacts:i,start_date:d.startDate,end_date:d.endDate}}}const ve=({feed:e,sorts:a=me,activeSort:s=e.orderBy,showDateFilter:n=!0,showHasCode:o,style:i,leading:d,children:l})=>t.jsxs("div",{className:"sort-bar",style:i,children:[d,t.jsxs("div",{className:"paper-feed-toolbar-controls",children:[a&&t.jsx("div",{className:"sort-options",children:a.map(([r,p])=>t.jsx("button",{type:"button",className:`sort-btn ${s===r?"active":""}`,onClick:()=>e.setOrderBy(r),children:p},r))}),t.jsx(ge,{hasCode:e.hasCode,hasHfArtifacts:e.hasHfArtifacts,onHasCodeChange:e.setHasCode,onHasHfArtifactsChange:e.setHasHfArtifacts,showDivider:!!a,showHasCode:o})]}),n&&t.jsx(he,{startDate:e.dateRange.startDate,endDate:e.dateRange.endDate,onChange:e.setDateRange}),l]}),fe=()=>t.jsx(j,{className:"h-40 w-full"}),xe=()=>t.jsxs("div",{className:"paper-card",children:[t.jsx("div",{className:"paper-thumb-wrap",children:t.jsx(j,{className:"paper-thumb-skeleton"})}),t.jsxs("div",{className:"paper-body",style:{flex:1,gap:12},children:[t.jsx(j,{className:"h-6 w-3/4"}),t.jsx(j,{className:"h-4 w-1/2"}),t.jsx(j,{className:"h-12 w-full"})]})]}),we=({query:e,isLoading:a=e.isLoading,cards:s,empty:n,skeleton:o="block",showInstitution:i,highlightQuery:d,cardHeader:l,rootMargin:r,children:p})=>{const c=ue(e,r);if(a){const g=o==="card"?xe:fe;return t.jsx("div",{className:"paper-list",children:Array.from({length:o==="card"?6:4}).map((m,f)=>t.jsx(g,{},f))})}return s.length===0?n===null?null:t.jsx("div",{className:"no-results",children:n}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"paper-list",children:s.map((g,m)=>t.jsxs(K.Fragment,{children:[l==null?void 0:l(m),t.jsx(X,{paper:g,priority:m<3,showInstitution:i,highlightQuery:d,followReasons:g.followReasons})]},g.id))}),t.jsx("div",{ref:c,style:{height:1}}),e.isFetchingNextPage&&t.jsx("div",{style:{padding:"20px 0",textAlign:"center",color:"var(--ink-faint)"},children:"Loading more…"}),p]})};export{he as P,we as a,ve as b,me as c,Ne as r,Ue as u,Se as w}; +import{d as u,j as t,g as J,V as K}from"./index-CjdUkE4w.js";import{P as X}from"./PaperCard-dvXhr75r.js";import{P as ee,a as te,b as ae}from"./popover-Df5_dywQ.js";import{I as se}from"./Icon-CGRs4BYD.js";import{S as j}from"./skeleton-DTWi7Ctg.js";import{u as ne}from"./useIntersectionObserver-Ch6RpsSk.js";const Y=(e,a)=>{const s=new Date(a),n=new Date(s);return n.setUTCDate(s.getUTCDate()-(e==="week"?6:29)),{startDate:n.toISOString().slice(0,10),endDate:s.toISOString().slice(0,10)}},V=e=>({startDate:e.get("start_date")||void 0,endDate:e.get("end_date")||void 0}),Ne=(e,a=new Date,s="week")=>{const n=V(e);if(n.startDate||n.endDate||e.get("time")==="all_time")return n;const o=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()));return Y(s,o)},Z=(e,a)=>{const s=new URLSearchParams(e);return a.startDate?s.set("start_date",a.startDate):s.delete("start_date"),a.endDate?s.set("end_date",a.endDate):s.delete("end_date"),s.delete("time"),s},Se=(e,a)=>{const s=Z(e,a);return!a.startDate&&!a.endDate&&s.set("time","all_time"),s},re=new Intl.DateTimeFormat("en",{month:"long",year:"numeric",timeZone:"UTC"}),H=new Intl.DateTimeFormat("en",{month:"short",timeZone:"UTC"}),O="(max-width: 640px)",oe=()=>{const[e,a]=u.useState(()=>typeof window<"u"&&window.matchMedia(O).matches);return u.useEffect(()=>{const s=window.matchMedia(O),n=o=>a(o.matches);return a(s.matches),s.addEventListener("change",n),()=>s.removeEventListener("change",n)},[]),e},W=e=>e.toISOString().slice(0,10),b=e=>new Date(`${e}T00:00:00Z`),ie=()=>{const e=new Date;return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))},F=(e,a)=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+a,1)),v=e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)),ce=(e,a)=>new Date(Date.UTC(a,e.getUTCMonth(),1)),w=(e,a)=>e.startDate===a.startDate&&e.endDate===a.endDate,le=(e,a)=>{const s=b(e),n=b(a),o=H.format(s),i=H.format(n),d=s.getUTCDate(),l=n.getUTCDate(),r=s.getUTCFullYear(),p=n.getUTCFullYear();return e===a?`${o} ${d}, ${r}`:r===p&&s.getUTCMonth()===n.getUTCMonth()?`${o} ${d}–${l}, ${r}`:r===p?`${o} ${d}–${i} ${l}, ${r}`:`${o} ${d}, ${r}–${i} ${l}, ${p}`},de=e=>{const a=e.getUTCFullYear(),s=e.getUTCMonth(),n=new Date(Date.UTC(a,s,1)),o=(n.getUTCDay()+6)%7,i=new Date(n);return i.setUTCDate(n.getUTCDate()-o),Array.from({length:42},(d,l)=>{const r=new Date(i);return r.setUTCDate(i.getUTCDate()+l),{iso:W(r),day:r.getUTCDate(),outsideMonth:r.getUTCMonth()!==s}})},L=({month:e,today:a,startDate:s,endDate:n,onSelect:o,yearLabel:i,yearValue:d,onYearChange:l,secondary:r=!1})=>{const p=u.useMemo(()=>de(e),[e]);return t.jsxs("section",{className:`paper-date-calendar${r?" paper-date-calendar-secondary":""}`,children:[t.jsxs("label",{className:"paper-date-year",children:[t.jsx("span",{children:i}),t.jsx("input",{type:"number",inputMode:"numeric",min:"1900",max:a.slice(0,4),step:"1",value:d,onChange:c=>l(c.target.value)})]}),t.jsx("h3",{children:re.format(e)}),t.jsx("div",{className:"paper-date-weekdays","aria-hidden":"true",children:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(c=>t.jsx("span",{children:c},c))}),t.jsx("div",{className:"paper-date-days",children:p.map(c=>{const g=c.iso===s||c.iso===n,m=!!(s&&n&&c.iso>s&&c.isoa;return t.jsx("button",{type:"button","aria-label":c.iso,"aria-selected":g,disabled:f,className:["paper-date-day",c.outsideMonth?"outside":"",g?"selected":"",m?"in-range":"",c.iso===a?"today":""].filter(Boolean).join(" "),onClick:()=>o(c.iso),children:c.day},c.iso)})})]})},I=({calendar:e,onPrevious:a,onNext:s,secondary:n=!1})=>t.jsxs("div",{className:`paper-date-navigation-group${n?" paper-date-navigation-group-secondary":""}`,children:[t.jsx("button",{type:"button","aria-label":`Previous ${e} month`,onClick:a,children:"←"}),t.jsx("button",{type:"button","aria-label":`Next ${e} month`,onClick:s,children:"→"})]}),he=({startDate:e,endDate:a,onChange:s,currentDate:n})=>{const o=oe(),i=n?b(n):ie(),[d,l]=u.useState(!1),[r,p]=u.useState(),[c,g]=u.useState(),[m,f]=u.useState(()=>v(i)),[_,T]=u.useState(()=>F(v(i),1)),[z,D]=u.useState(()=>String(i.getUTCFullYear())),[G,y]=u.useState(()=>String(i.getUTCFullYear())),N={startDate:e,endDate:a},M=Y("week",i),P=Y("month",i),k=W(i),R=!!(e&&a&&!w(N,M)&&!w(N,P)),Q=()=>{p(e),g(a);const h=v(e?b(e):i),x=v(a?b(a):F(h,1));f(h),T(x),D(String(h.getUTCFullYear())),y(String(x.getUTCFullYear())),l(!0)},E=(h,x,$)=>{if(x(h),!/^\d{4}$/.test(h))return;const C=Number(h);C>=1900&&C<=i.getUTCFullYear()&&$(U=>ce(U,C))},S=(h,x,$,C)=>{const U=F(h,x);$(U),C(String(U.getUTCFullYear()))},A=h=>{!r||c?(p(h),g(void 0)):h{s({}),l(!1)};return t.jsxs("div",{className:`paper-date-filter${o?" paper-date-filter-single-calendar":""}`,role:"group","aria-label":"Publication date",children:[t.jsx("button",{type:"button",className:`sort-btn sort-btn-time${w(N,M)?" active":""}`,onClick:()=>s(M),children:"Last Week"}),t.jsx("button",{type:"button",className:`sort-btn sort-btn-time${w(N,P)?" active":""}`,onClick:()=>s(P),children:"Last Month"}),t.jsx("button",{type:"button",className:`sort-btn sort-btn-time${!e&&!a?" active":""}`,onClick:()=>s({}),children:"All Time"}),t.jsxs(ee,{open:d,onOpenChange:h=>{h?Q():l(!1)},children:[t.jsx(te,{asChild:!0,children:t.jsx("button",{type:"button",className:`sort-btn sort-btn-time${R?" active":""}`,"aria-label":R?"Change date range":"Select a range",children:R&&e&&a?le(e,a):"Select a range"})}),t.jsxs(ae,{align:"end",className:`paper-date-popover${o?" paper-date-popover-single-calendar":""}`,role:"dialog","aria-label":"Select a date range",children:[t.jsxs("div",{className:"paper-date-popover-header",children:[t.jsx("h2",{children:"Select a date range"}),t.jsx("p",{children:"Choose an inclusive start and end publication date."})]}),t.jsxs("div",{className:"paper-date-navigation",children:[t.jsx(I,{calendar:"start",onPrevious:()=>S(m,-1,f,D),onNext:()=>S(m,1,f,D)}),!o&&t.jsx(I,{calendar:"end",onPrevious:()=>S(_,-1,T,y),onNext:()=>S(_,1,T,y),secondary:!0})]}),t.jsxs("div",{className:"paper-date-calendars",children:[t.jsx(L,{month:m,today:k,startDate:r,endDate:c,onSelect:A,yearLabel:o?"Year":"Start year",yearValue:z,onYearChange:h=>E(h,D,f)}),!o&&t.jsx(L,{month:_,today:k,startDate:r,endDate:c,onSelect:A,yearLabel:"End year",yearValue:G,onYearChange:h=>E(h,y,T),secondary:!0})]}),t.jsxs("div",{className:"paper-date-actions",children:[t.jsx("button",{type:"button",className:"paper-date-clear",onClick:q,children:"Clear range"}),t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>l(!1),children:"Cancel"}),t.jsx("button",{type:"button",className:"paper-date-apply",disabled:!r||!c,onClick:()=>{r&&c&&s({startDate:r,endDate:c}),l(!1)},children:"Apply"})]})]})]})]})]})},pe=()=>t.jsxs("span",{className:"hf-resource-logo",children:[t.jsx("img",{className:"hf-resource-logo-black",src:"/hf-logo-monochrome-black.svg?v=20260729",alt:""}),t.jsx("img",{className:"hf-resource-logo-white",src:"/hf-logo-monochrome-white.svg?v=20260729",alt:""})]}),B=({checked:e,icon:a,label:s,onChange:n})=>t.jsxs("button",{type:"button",className:`paper-feed-filter ${e?"active":""}`,"aria-pressed":e,onClick:()=>n(!e),children:[t.jsxs("span",{className:"paper-feed-filter-content",children:[t.jsx("span",{className:"paper-feed-filter-icon","aria-hidden":"true",children:a}),s]}),e&&t.jsx("span",{className:"paper-feed-filter-check","aria-hidden":"true",children:"✓"})]}),ge=({hasCode:e,hasHfArtifacts:a,onHasCodeChange:s,onHasHfArtifactsChange:n,showDivider:o=!0,showHasCode:i=!0})=>t.jsxs("div",{className:"paper-feed-resource-controls",role:"group","aria-label":"Resource filters",children:[o&&t.jsx("span",{className:"paper-feed-resource-divider","aria-hidden":"true"}),t.jsxs("div",{className:"paper-feed-filter-options",children:[i&&t.jsx(B,{checked:e,icon:t.jsx(se,{name:"github",size:14}),label:"Has code",onChange:s}),t.jsx(B,{checked:a,icon:t.jsx(pe,{}),label:"Has artifacts",onChange:n})]})]});function ue(e,a="200px"){const{targetRef:s,isIntersecting:n}=ne({rootMargin:a}),{data:o,hasNextPage:i,isFetchingNextPage:d,fetchNextPage:l}=e;return u.useEffect(()=>{n&&i&&!d&&l()},[n,i,d,l,o]),s}const me=[["trending","trending"],["date_published","newest"],["citation_count","most cited"]];function Ue(){const[e,a]=J(),s=e.get("order_by"),n=s==="date_published"||s==="citation_count"?s:"trending",o=e.get("has_code")==="true",i=e.get("has_hf_artifacts")==="true",d=V(e),l=(r,p)=>{const c=new URLSearchParams(e);p?c.set(r,p):c.delete(r),a(c)};return{searchParams:e,setSearchParams:a,orderBy:n,hasCode:o,hasHfArtifacts:i,dateRange:d,setOrderBy:r=>l("order_by",r==="trending"?null:r),setHasCode:r=>l("has_code",r?"true":null),setHasHfArtifacts:r=>l("has_hf_artifacts",r?"true":null),setDateRange:r=>a(Z(e,r)),filters:{order_by:n,order_dir:"desc",latest_only:!0,include_resources:!0,has_code:o,has_hf_artifacts:i,start_date:d.startDate,end_date:d.endDate}}}const ve=({feed:e,sorts:a=me,activeSort:s=e.orderBy,showDateFilter:n=!0,showHasCode:o,style:i,leading:d,children:l})=>t.jsxs("div",{className:"sort-bar",style:i,children:[d,t.jsxs("div",{className:"paper-feed-toolbar-controls",children:[a&&t.jsx("div",{className:"sort-options",children:a.map(([r,p])=>t.jsx("button",{type:"button",className:`sort-btn ${s===r?"active":""}`,onClick:()=>e.setOrderBy(r),children:p},r))}),t.jsx(ge,{hasCode:e.hasCode,hasHfArtifacts:e.hasHfArtifacts,onHasCodeChange:e.setHasCode,onHasHfArtifactsChange:e.setHasHfArtifacts,showDivider:!!a,showHasCode:o})]}),n&&t.jsx(he,{startDate:e.dateRange.startDate,endDate:e.dateRange.endDate,onChange:e.setDateRange}),l]}),fe=()=>t.jsx(j,{className:"h-40 w-full"}),xe=()=>t.jsxs("div",{className:"paper-card",children:[t.jsx("div",{className:"paper-thumb-wrap",children:t.jsx(j,{className:"paper-thumb-skeleton"})}),t.jsxs("div",{className:"paper-body",style:{flex:1,gap:12},children:[t.jsx(j,{className:"h-6 w-3/4"}),t.jsx(j,{className:"h-4 w-1/2"}),t.jsx(j,{className:"h-12 w-full"})]})]}),we=({query:e,isLoading:a=e.isLoading,cards:s,empty:n,skeleton:o="block",showInstitution:i,highlightQuery:d,cardHeader:l,rootMargin:r,children:p})=>{const c=ue(e,r);if(a){const g=o==="card"?xe:fe;return t.jsx("div",{className:"paper-list",children:Array.from({length:o==="card"?6:4}).map((m,f)=>t.jsx(g,{},f))})}return s.length===0?n===null?null:t.jsx("div",{className:"no-results",children:n}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"paper-list",children:s.map((g,m)=>t.jsxs(K.Fragment,{children:[l==null?void 0:l(m),t.jsx(X,{paper:g,priority:m<3,showInstitution:i,highlightQuery:d,followReasons:g.followReasons})]},g.id))}),t.jsx("div",{ref:c,style:{height:1}}),e.isFetchingNextPage&&t.jsx("div",{style:{padding:"20px 0",textAlign:"center",color:"var(--ink-faint)"},children:"Loading more…"}),p]})};export{he as P,we as a,ve as b,me as c,Ne as r,Ue as u,Se as w}; diff --git a/assets/PaperPreviewLink-CpCZSa8K.js b/assets/PaperPreviewLink-zGfFNaz6.js similarity index 97% rename from assets/PaperPreviewLink-CpCZSa8K.js rename to assets/PaperPreviewLink-zGfFNaz6.js index 263ec86273708819e6e3e0687def06451b1f2b03..47efa127c2de2b73abff9ddab54f0880ffe60891 100644 --- a/assets/PaperPreviewLink-CpCZSa8K.js +++ b/assets/PaperPreviewLink-zGfFNaz6.js @@ -1,4 +1,4 @@ -import{o as F,f as j,m as b,a as le,p as O,b as z,n as D,h as ce,s as ue,c as he,v as pe,S as me}from"./index-mCi_y_l3.js";import{l as fe}from"./index-2CvJmBVB.js";import R from"./katex-DkKDou_j.js";import{j as p,V as A,a3 as de,w as C,p as xe,f as ge,i as ye,L as T,b as we,U as be}from"./index-DyXq7-Tg.js";import{H as Ne,a as ve,b as ke}from"./hover-card-B45EJIn_.js";import{p as I}from"./papers-Dh3ljlL0.js";import{u as Fe}from"./useMutation-UWxBeqtn.js";function je(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:s},exit:{mathFlow:i,mathFlowFence:n,mathFlowFenceMeta:r,mathFlowValue:l,mathText:o,mathTextData:l}};function e(a){const c={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[c]}},a)}function t(){this.buffer()}function r(){const a=this.resume(),c=this.stack[this.stack.length-1];F(c.type==="math"),c.meta=a}function n(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(a){const c=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),m=this.stack[this.stack.length-1];F(m.type==="math"),this.exit(a),m.value=c;const f=m.data.hChildren[0];F(f.type==="element"),F(f.tagName==="code"),f.children.push({type:"text",value:c}),this.data.mathFlowInside=void 0}function s(a){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},a),this.buffer()}function o(a){const c=this.resume(),m=this.stack[this.stack.length-1];F(m.type==="inlineMath"),this.exit(a),m.value=c,m.data.hChildren.push({type:"text",value:c})}function l(a){this.config.enter.data.call(this,a),this.config.exit.data.call(this,a)}}function Ce(e){let t=(e||{}).singleDollarTextMath;return t==null&&(t=!0),n.peek=i,{unsafe:[{character:"\r",inConstruct:"mathFlowMeta"},{character:` +import{o as F,f as j,m as b,a as le,p as O,b as z,n as D,h as ce,s as ue,c as he,v as pe,S as me}from"./index-tLcwYp0U.js";import{l as fe}from"./index-Dj6aE-6E.js";import R from"./katex-DkKDou_j.js";import{j as p,V as A,a3 as de,p as xe,w as C,f as ge,i as ye,L as T,b as we,A as be}from"./index-CjdUkE4w.js";import{H as Ne,a as ve,b as ke}from"./hover-card-CIBIV2Hx.js";import{p as I}from"./papers-DgZwjF3K.js";import{u as Fe}from"./useMutation-BYtVrkc7.js";function je(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:s},exit:{mathFlow:i,mathFlowFence:n,mathFlowFenceMeta:r,mathFlowValue:l,mathText:o,mathTextData:l}};function e(a){const c={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[c]}},a)}function t(){this.buffer()}function r(){const a=this.resume(),c=this.stack[this.stack.length-1];F(c.type==="math"),c.meta=a}function n(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(a){const c=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),m=this.stack[this.stack.length-1];F(m.type==="math"),this.exit(a),m.value=c;const f=m.data.hChildren[0];F(f.type==="element"),F(f.tagName==="code"),f.children.push({type:"text",value:c}),this.data.mathFlowInside=void 0}function s(a){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},a),this.buffer()}function o(a){const c=this.resume(),m=this.stack[this.stack.length-1];F(m.type==="inlineMath"),this.exit(a),m.value=c,m.data.hChildren.push({type:"text",value:c})}function l(a){this.config.enter.data.call(this,a),this.config.exit.data.call(this,a)}}function Ce(e){let t=(e||{}).singleDollarTextMath;return t==null&&(t=!0),n.peek=i,{unsafe:[{character:"\r",inConstruct:"mathFlowMeta"},{character:` `,inConstruct:"mathFlowMeta"},{character:"$",after:t?void 0:"\\$",inConstruct:"phrasing"},{character:"$",inConstruct:"mathFlowMeta"},{atBreak:!0,character:"$",after:"\\$"}],handlers:{math:r,inlineMath:n}};function r(s,o,l,a){const c=s.value||"",m=l.createTracker(a),f="$".repeat(Math.max(fe(c,"$")+1,2)),g=l.enter("mathFlow");let d=m.move(f);if(s.meta){const x=l.enter("mathFlowMeta");d+=m.move(l.safe(s.meta,{after:` `,before:d,encode:["$"],...m.current()})),x()}return d+=m.move(` `),c&&(d+=m.move(c+` diff --git a/assets/PaperReaderView-C7GrMxPx.js b/assets/PaperReaderView-C7GrMxPx.js deleted file mode 100644 index 903716df4634d39e61c0e5cb1cbb2c16635de67c..0000000000000000000000000000000000000000 --- a/assets/PaperReaderView-C7GrMxPx.js +++ /dev/null @@ -1 +0,0 @@ -import{d as s,b as J,j as a,U as ee,u as Se,e as Ke,w as De,a3 as je,Z as Oe,L as Z}from"./index-DyXq7-Tg.js";import{u as Ve,R as Qe,A as Xe,c as Ze,d as Ye,a as Ge,P as Je,e as et}from"./ArtifactWorkspace-Ya79_F5k.js";import{M as tt}from"./MarkdownText-CUzPoC9Y.js";import{g as rt,a as at}from"./papers-Dh3ljlL0.js";import{w as st,e as nt}from"./paperReader-BIpQD5HO.js";import{a as ot}from"./usePapers-B0s20UcU.js";import{c as it}from"./chat-Ix1IrIwq.js";import{s as te}from"./safeExternalHref-CkBrsh84.js";import{ChatExperience as ct}from"./ChatView-D06zYumh.js";import"./chatSessions-Ck_dyM0d.js";/* empty css */import"./hover-card-B45EJIn_.js";import"./CatalogEntityPreviewLink-BktpwL3_.js";import"./catalog-CRar2olQ.js";import"./github-RNrgGHRT.js";import"./file-text-dvKtHbmD.js";import"./PaperPreviewLink-CpCZSa8K.js";import"./index-mCi_y_l3.js";import"./index-2CvJmBVB.js";import"./katex-DkKDou_j.js";import"./useMutation-UWxBeqtn.js";import"./copy-CxR0OKx2.js";import"./thumbs-up-CPLlGli7.js";import"./arrow-left-PA_b6law.js";import"./external-link-orY1Xz1I.js";import"./plus-Yh42pKZz.js";import"./search-8ssWDP68.js";import"./chevron-up-DYSYRyvz.js";import"./AuthorAvatar-B-9xS2Wo.js";import"./curation-YeS7FBYf.js";import"./useInfiniteQuery-BYh2zN-T.js";import"./McpShowcase-CLO4HLon.js";import"./AgentLogos-j-Qekw7T.js";import"./share-2-fiavn5SS.js";import"./openrouter-o51Eagw8.js";import"./queryOptions-C9woPjwX.js";function lt(r){return r instanceof ee&&r.status===422?"This page could not be turned into a readable paper.":r instanceof ee&&r.status===503?"Paper content is still being prepared. Please try again later.":"The paper could not be loaded."}function dt({paperId:r,paperKey:i,paperTitle:o,paperHref:b,sourceUrl:d,resources:t,paperVersion:f="",selectionEnabled:v=!1,onReady:h,onPaperSelection:I,onPaperSelectionError:B}){const c=s.useRef(null),g=J({queryKey:["paperWebMarkdown",r],queryFn:()=>rt(r),staleTime:5*6e4,retry:(P,j)=>P<2&&!(j instanceof ee&&j.status<500),retryDelay:3e3}),x=g.isSuccess;s.useEffect(()=>{x&&(h==null||h())},[h,x]),Ve({enabled:v&&!!f&&x,pagesRoot:c,routeId:i,paperVersion:f,numPages:1,onSelect:I,onError:B});const S=g.data?st(g.data):"";return a.jsxs("div",{className:"pdf-viewer",children:[a.jsx(Qe,{paperTitle:o,paperHref:b,resources:t,label:"Paper controls",children:a.jsx("div",{className:"pdf-toolbar-controls",children:a.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",children:"Open original"})})}),a.jsx("div",{className:"pdf-scroll-frame",children:a.jsx("div",{className:"pdf-scroll",role:"region","aria-label":"Paper web page",children:g.isPending?a.jsx("div",{className:"pdf-loading",role:"status",children:"Preparing a readable version of this page…"}):g.isError?a.jsxs("div",{className:"pdf-error",role:"alert",children:[a.jsx("p",{children:lt(g.error)}),a.jsxs("div",{children:[a.jsx("button",{type:"button",onClick:()=>void g.refetch(),children:"Retry"})," ",a.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",children:"Open original"})]})]}):a.jsxs("article",{ref:c,className:"reader-web-document","data-page":"1",children:[!S.startsWith("# ")&&a.jsx("h1",{children:o}),a.jsx(tt,{text:S})]})})})]})}const _e=66,ut=240,re="pwc:reader:split-ratio",L=r=>`pwc:reader:session:${r}`,Y=r=>`pwc:reader:assistant-collapsed:${r}`,Ce=r=>`pwc:reader:page:${r}`;function G(r){const i=Number(sessionStorage.getItem(Ce(r)));return Number.isInteger(i)&&i>0?i:1}function pt(){const r=Number(localStorage.getItem(re));return Number.isFinite(r)&&r>=45&&r<=75?r:_e}function ft(r){const i=te(r);if(!i)return null;const o=new URL(i);return(o.hostname==="arxiv.org"||o.hostname==="www.arxiv.org")&&o.pathname.startsWith("/pdf/")&&o.pathname.endsWith(".pdf")&&(o.pathname=o.pathname.slice(0,-4)),o.href}const mt=/^\/pdf\/(\d{4}\.\d{4,5}(?:v\d{1,3})?|[a-z]+(?:-[a-z]+)*(?:\.[A-Z]{2})?\/\d{7}(?:v\d{1,3})?)$/;function ht(r){const i=new URL(r),o=i.pathname.match(mt);return(i.hostname==="arxiv.org"||i.hostname==="www.arxiv.org")&&o&&!i.search?je(`/paper-assets/arxiv-pdf/${o[1]}`)??r:r}function gt(r){return new URL(r).hostname.replace(/^www\./,"")}function bt(r){if(!r)return{};const i={};for(const d of r.repositories??[]){if(!d.is_official)continue;const t=te(d.url);if(!t)continue;const f=new URL(t),v=f.pathname.split("/").filter(Boolean);if((f.hostname==="github.com"||f.hostname==="www.github.com")&&v.length>=2){i.repository={href:t,stars:d.num_stars||0};break}}const o=[...r.project_pages??[]].sort((d,t)=>Number(t.is_official)-Number(d.is_official));for(const d of o){const t=te(d.url);if(t){i.projectPage={href:t,label:gt(t)};break}}const b=r.hf_artifact_summary?r.hf_artifact_summary.model_count+r.hf_artifact_summary.dataset_count+r.hf_artifact_summary.space_count:new Set([...r.hf_models??[],...r.hf_datasets??[],...r.hf_spaces??[]]).size;return b>0&&r.arxiv_id&&(i.huggingFace={href:`https://huggingface.co/papers/${r.arxiv_id.replace(/v\d+$/i,"")}`,count:b}),i}function vt(){var xe,we,Pe,ye,Re;const r=Ke(),{paperId:i}=Se(),o=De(i??"").replace(/v\d+$/i,""),b=ot(o,!!o),d=J({queryKey:["chatAvailability"],queryFn:()=>it.getAvailability(),refetchInterval:3e4,retry:!1}),t=b.data,f=t?nt(t):null,v=f?null:(t==null?void 0:t.source)==="external"?je(`/paper-assets/external/${t.id}/paper.pdf`):ft(t==null?void 0:t.url_pdf),h=v&&(t==null?void 0:t.source)!=="external"?ht(v):v,I=bt(t),B=s.useMemo(()=>{var e;return(e=t==null?void 0:t.author_links)==null?void 0:e.flatMap(n=>n.id?[{id:n.id,name:n.name,avatarUrl:n.hf_avatar_url}]:[])},[t==null?void 0:t.author_links]),c=((xe=t==null?void 0:t.arxiv_id)==null?void 0:xe.replace(/v\d+$/i,""))||o,g=s.useCallback(()=>r(`/paper/${c}`),[c,r]),[x,S]=s.useState(()=>sessionStorage.getItem(L(o))||void 0),[P,j]=s.useState(pt),[u,ae]=s.useState(()=>sessionStorage.getItem(Y(o))==="1"),[w,_]=s.useState("paper"),[H,C]=s.useState(),[ke,se]=s.useState(),[Ae,ne]=s.useState(!1),Ie=s.useCallback(()=>ne(!0),[]),[$e,y]=s.useState(""),[Ne,Ee]=s.useState(()=>G(o)),[k,Te]=s.useState(0),[oe,ie]=s.useState(!1),[Me,F]=s.useState(!1),$=s.useRef(null),U=s.useRef(null),N=s.useRef(null),ce=s.useRef(null),le=s.useRef(null),q=s.useRef(!1),E=s.useRef(!1),T=s.useRef(0),R=s.useRef(0),K=s.useRef(0),A=s.useRef(P),D=s.useRef(G(o)),O=s.useRef(t==null?void 0:t.version),de=Ze().reset,ue=s.useRef(`${o}:${x??"new"}`),p=k>=840;s.useEffect(()=>{const e=`${o}:${x??"new"}`;ue.current!==e&&(ue.current=e,de())},[x,de,o]),s.useEffect(()=>{t!=null&&t.version&&O.current&&t.version!==O.current&&(C(void 0),y("")),O.current=t==null?void 0:t.version},[t==null?void 0:t.version]),s.useEffect(()=>{window.clearTimeout(T.current),F(!1);const e=sessionStorage.getItem(L(o));S(e||void 0),ae(sessionStorage.getItem(Y(o))==="1"),_("paper"),ne(!1),C(void 0),se(void 0),y("");const n=G(o);D.current=n,Ee(n)},[o]),s.useEffect(()=>()=>{window.clearTimeout(T.current),cancelAnimationFrame(R.current)},[]),s.useLayoutEffect(()=>{const e=$.current;if(!e)return;const n=()=>Te(e.clientWidth);n();const l=new ResizeObserver(n);return l.observe(e),()=>l.disconnect()},[t]),s.useEffect(()=>{if(!t)return;document.title=`${t.title} — Papers With Code reader`;let e=document.querySelector('meta[name="robots"]');const n=!e;e||(e=document.createElement("meta"),e.name="robots",document.head.appendChild(e));const l=e.content;e.content="noindex, nofollow";let m=document.querySelector('link[rel="canonical"]');const Ue=!m;m||(m=document.createElement("link"),m.rel="canonical",document.head.appendChild(m));const qe=m.href;return m.href=`${window.location.origin}/paper/${c}`,()=>{document.title="Papers With Code",n?e==null||e.remove():e&&(e.content=l),Ue?m==null||m.remove():m&&(m.href=qe)}},[c,t]);const M=s.useCallback(e=>{if(!k)return Math.max(45,Math.min(75,e));const n=480/k*100,l=100-360/k*100;return Math.max(n,Math.min(l,e))},[k]);s.useEffect(()=>j(e=>{const n=M(e);return A.current=n,n}),[M]);const W=e=>{const n=M(e);A.current=n,j(n),localStorage.setItem(re,String(n))},pe=e=>{var l;const n=M(e);A.current=n,U.current&&(U.current.style.width=`${n}%`),N.current&&(N.current.style.width=`${100-n}%`),(l=ce.current)==null||l.setAttribute("aria-valuenow",String(Math.round(n)))},fe=e=>{K.current=e,!R.current&&(R.current=requestAnimationFrame(()=>{var l;R.current=0;const n=(l=$.current)==null?void 0:l.getBoundingClientRect();n!=null&&n.width&&pe((K.current-n.left)/n.width*100)}))},We=e=>{E.current=!0,ie(!0),e.currentTarget.setPointerCapture(e.pointerId),fe(e.clientX)},V=()=>{var e;if(E.current){if(R.current){cancelAnimationFrame(R.current),R.current=0;const n=(e=$.current)==null?void 0:e.getBoundingClientRect();n!=null&&n.width&&pe((K.current-n.left)/n.width*100)}E.current=!1,j(A.current),localStorage.setItem(re,String(A.current)),ie(!1)}},me=e=>{window.clearTimeout(T.current),F(!0),ae(e),sessionStorage.setItem(Y(o),e?"1":"0"),T.current=window.setTimeout(()=>F(!1),ut+40)},he=e=>{q.current=!0,me(e)};s.useEffect(()=>{var e;q.current&&(q.current=!1,(e=u?le.current:N.current)==null||e.focus())},[u]);const ze=e=>{S(e),sessionStorage.setItem(L(o),e)},Le=()=>{S(void 0),sessionStorage.removeItem(L(o)),C(void 0),y("")},ge=((we=d.data)==null?void 0:we.paper_reader_selection_enabled)===!0,be=e=>{C(e),y(`Selection from page ${e.page} added to chat`),p&&u&&me(!1)},Be=s.useCallback(e=>{C(e),e||y("")},[]),Q=((Pe=d.data)==null?void 0:Pe.paper_reader_citations_enabled)===!0&&!!h,z=J({queryKey:["paper-layout",c],queryFn:()=>at(c),enabled:Q&&!!c,staleTime:5*6e4}).data,He=s.useMemo(()=>Q?{layout:z,open:e=>{const n=z?Ye(z,e):[];n.length&&(se(l=>({boxes:n,nonce:((l==null?void 0:l.nonce)??0)+1})),_("paper"))}}:null,[Q,z]),ve=Oe()&&((ye=d.data)==null?void 0:ye.paper_reader_chat_enabled)!==!1,X=!!(t&&ve&&!(f&&!Ae)),Fe=t&&ve&&!X?a.jsx("div",{className:"reader-chat-unavailable",role:"status",children:"Chat opens once the paper is ready."}):t&&X?a.jsx(ct,{mode:"paper",routeSessionId:x,primaryPaper:{id:t.id,routeId:c,title:t.title},currentPage:()=>D.current,paperSelection:H,onPaperSelectionChange:Be,onSessionId:ze,onReaderSubmit:()=>_("assistant"),onReaderNewChat:Le,onReaderClose:p?()=>he(!0):void 0}):a.jsx("div",{className:"reader-chat-unavailable",children:"Chat is not enabled for this preview."});return b.isLoading?a.jsx("div",{className:"reader-status",role:"status",children:"Loading paper…"}):b.error||!t?a.jsxs("div",{className:"reader-status",role:"alert",children:[a.jsx("p",{children:"Paper not found."}),a.jsx(Z,{to:"/papers",children:"Browse papers"})]}):((Re=d.data)==null?void 0:Re.native_pdf_reader_enabled)===!1?a.jsxs("div",{className:"reader-status",role:"alert",children:[a.jsx("p",{children:"The native reader is currently unavailable."}),a.jsx(Z,{to:`/paper/${c}`,children:"Back to paper"})]}):!h&&!f?a.jsxs("div",{className:"reader-status",role:"alert",children:[a.jsx("p",{children:"Native reading is unavailable for this resource."}),a.jsx(Z,{to:`/paper/${c}`,children:"Back to paper"})]}):a.jsxs("div",{className:"paper-reader-shell",children:[!p&&a.jsxs("div",{className:"reader-tabs",role:"tablist","aria-label":"Reader panels",children:[a.jsx("button",{type:"button",role:"tab","aria-selected":w==="paper",onClick:()=>_("paper"),children:"Paper"}),a.jsxs("button",{type:"button",role:"tab","aria-selected":w==="assistant","aria-label":H&&w!=="assistant"?"Chat, selection attached":"Chat",onClick:()=>_("assistant"),children:["Chat",H&&w!=="assistant"&&a.jsx("span",{className:"reader-tab-pending","aria-hidden":"true"})]})]}),a.jsx(Ge,{variant:"reader",children:a.jsxs("div",{ref:$,className:`reader-workspace${p?" is-desktop":" is-tabs"}${u?" is-assistant-collapsed":""}${oe?" is-resizing":""}`,"data-testid":"paper-chat-workspace",children:[a.jsx("section",{ref:U,className:`reader-paper-pane${!p&&w!=="paper"?" is-hidden":""}`,style:p?{width:u?"100%":`${P}%`}:void 0,role:"tabpanel","aria-label":"Paper","aria-hidden":!p&&w!=="paper",children:f?a.jsx(dt,{paperId:t.id,paperKey:c,paperTitle:t.title,paperHref:`/paper/${c}`,sourceUrl:f,resources:I,paperVersion:t.version,selectionEnabled:ge,onReady:Ie,onPaperSelection:be,onPaperSelectionError:y}):h&&a.jsx(Je,{url:h,downloadUrl:v??h,paperKey:c,paperTitle:t.title,paperHref:`/paper/${c}`,onClose:g,resources:I,initialPage:Ne,resizeActive:oe||Me,selectionEnabled:ge,paperVersion:t.version,authors:B,loadErrorMessage:t.source==="external"?"Paper content is still being prepared. Please try again later.":void 0,onPaperSelection:be,onPaperSelectionError:y,highlight:ke,onPageChange:e=>{D.current=e,sessionStorage.setItem(Ce(o),String(e))}})}),p&&!u&&a.jsx("div",{ref:ce,className:"reader-resize-handle",role:"separator","aria-label":"Resize paper and Chat panels","aria-orientation":"vertical","aria-valuemin":45,"aria-valuemax":75,"aria-valuenow":Math.round(P),tabIndex:0,onPointerDown:We,onPointerMove:e=>{E.current&&fe(e.clientX)},onPointerUp:V,onPointerCancel:V,onLostPointerCapture:V,onDoubleClick:()=>W(_e),onKeyDown:e=>{(e.key==="ArrowLeft"||e.key==="ArrowRight")&&(e.preventDefault(),W(P+(e.key==="ArrowRight"?2:-2))),e.key==="Home"&&W(45),e.key==="End"&&W(75)}}),a.jsx("aside",{ref:N,id:"reader-chat-panel",className:`reader-assistant-pane${!p&&w!=="assistant"?" is-hidden":""}${p&&u?" is-collapsed":""}`,style:p?{width:u?0:`${100-P}%`}:void 0,role:"tabpanel","aria-label":"Chat","aria-hidden":!p&&w!=="assistant"||u,tabIndex:-1,children:a.jsx(et.Provider,{value:He,children:Fe})}),a.jsx("div",{className:"sr-only","aria-live":"polite",children:$e}),p&&(u||!X)&&a.jsx("button",{ref:le,type:"button",className:"reader-collapse-assistant","aria-controls":"reader-chat-panel","aria-expanded":!u,onClick:()=>he(!u),children:u?"Open chat":"Hide chat"})]})})]})}function ar(){const{paperId:r=""}=Se();return a.jsx(Xe,{workspaceKey:`reader:${r}`,children:a.jsx(vt,{})})}export{ar as default,bt as readerToolbarResources}; diff --git a/assets/PaperReaderView-CqbyUlPD.js b/assets/PaperReaderView-CqbyUlPD.js new file mode 100644 index 0000000000000000000000000000000000000000..3c74b88a4b3719b7284352271d28418f0ba77bc5 --- /dev/null +++ b/assets/PaperReaderView-CqbyUlPD.js @@ -0,0 +1 @@ +import{d as s,b as Q,j as a,A as X,u as He,w as Fe,e as qe,a3 as Pe,Z as Ke,L as O}from"./index-CjdUkE4w.js";import{u as Ue,R as De,A as Oe,c as Ve,d as Qe,a as Xe,P as Ze,e as Ye}from"./chatLifecycle-B6B3Dpfi.js";import{M as Ge}from"./MarkdownText-MrITlqRE.js";import{g as Je,a as et}from"./papers-DgZwjF3K.js";import{w as tt,e as rt,a as V,b as xe,c as we}from"./paperReader-h6jqpWHI.js";import{a as at}from"./usePapers-BZThqZCx.js";import{c as st}from"./chat-B1EBF720.js";import{s as Z}from"./safeExternalHref-CkBrsh84.js";import{ChatExperience as nt}from"./ChatView-DeilSeCH.js";import"./chatSessions-9VEG8seW.js";/* empty css */import"./hover-card-CIBIV2Hx.js";import"./CatalogEntityPreviewLink-DY_jhXy9.js";import"./catalog-qXcKve0z.js";import"./github-4bW4WI_e.js";import"./file-text-CHlxsNJC.js";import"./PaperPreviewLink-zGfFNaz6.js";import"./index-tLcwYp0U.js";import"./index-Dj6aE-6E.js";import"./katex-DkKDou_j.js";import"./useMutation-BYtVrkc7.js";import"./thumbs-up-Dn_5H93T.js";import"./copy-SoF5zg-g.js";import"./queryOptions-C9woPjwX.js";import"./arrow-left-CkQb0MI4.js";import"./external-link-CTLWFJ8S.js";import"./plus-AztI1566.js";import"./search-DxMn7VKI.js";import"./chevron-up-BwiJ46dh.js";import"./AuthorAvatar-D9249Frl.js";import"./curation-CyyuHfv5.js";import"./useInfiniteQuery-DeZTTVbI.js";import"./McpShowcase-Bo79ATLK.js";import"./AgentLogos-xoTIu0NB.js";import"./share-2-Nvga0TP8.js";import"./openrouter-B-ghWDkd.js";function ot(r){return r instanceof X&&r.status===422?"This page could not be turned into a readable paper.":r instanceof X&&r.status===503?"Paper content is still being prepared. Please try again later.":"The paper could not be loaded."}function it({paperId:r,paperKey:o,paperTitle:i,paperHref:g,sourceUrl:t,resources:c,paperVersion:h="",selectionEnabled:b=!1,onReady:P,onPaperSelection:W,onPaperSelectionError:l}){const C=s.useRef(null),f=Q({queryKey:["paperWebMarkdown",r],queryFn:()=>Je(r),staleTime:5*6e4,retry:(S,d)=>S<2&&!(d instanceof X&&d.status<500),retryDelay:3e3}),y=f.isSuccess;s.useEffect(()=>{y&&(P==null||P())},[P,y]),Ue({enabled:b&&!!h&&y,pagesRoot:C,routeId:o,paperVersion:h,numPages:1,onSelect:W,onError:l});const v=f.data?tt(f.data):"";return a.jsxs("div",{className:"pdf-viewer",children:[a.jsx(De,{paperTitle:i,paperHref:g,resources:c,label:"Paper controls",children:a.jsx("div",{className:"pdf-toolbar-controls",children:a.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:"Open original"})})}),a.jsx("div",{className:"pdf-scroll-frame",children:a.jsx("div",{className:"pdf-scroll",role:"region","aria-label":"Paper web page",children:f.isPending?a.jsx("div",{className:"pdf-loading",role:"status",children:"Preparing a readable version of this page…"}):f.isError?a.jsxs("div",{className:"pdf-error",role:"alert",children:[a.jsx("p",{children:ot(f.error)}),a.jsxs("div",{children:[a.jsx("button",{type:"button",onClick:()=>void f.refetch(),children:"Retry"})," ",a.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:"Open original"})]})]}):a.jsxs("article",{ref:C,className:"reader-web-document","data-page":"1",children:[!v.startsWith("# ")&&a.jsx("h1",{children:i}),a.jsx(Ge,{text:v})]})})})]})}const ye=66,ct=240,Y="pwc:reader:split-ratio";function lt(r){const o=Number(sessionStorage.getItem(we(r)));return Number.isInteger(o)&&o>0?o:1}function dt(){const r=Number(localStorage.getItem(Y));return Number.isFinite(r)&&r>=45&&r<=75?r:ye}function ut(r){const o=Z(r);if(!o)return null;const i=new URL(o);return(i.hostname==="arxiv.org"||i.hostname==="www.arxiv.org")&&i.pathname.startsWith("/pdf/")&&i.pathname.endsWith(".pdf")&&(i.pathname=i.pathname.slice(0,-4)),i.href}const ft=/^\/pdf\/(\d{4}\.\d{4,5}(?:v\d{1,3})?|[a-z]+(?:-[a-z]+)*(?:\.[A-Z]{2})?\/\d{7}(?:v\d{1,3})?)$/;function pt(r){const o=new URL(r),i=o.pathname.match(ft);return(o.hostname==="arxiv.org"||o.hostname==="www.arxiv.org")&&i&&!o.search?Pe(`/paper-assets/arxiv-pdf/${i[1]}`)??r:r}function mt(r){return new URL(r).hostname.replace(/^www\./,"")}function ht(r){if(!r)return{};const o={};for(const t of r.repositories??[]){if(!t.is_official)continue;const c=Z(t.url);if(!c)continue;const h=new URL(c),b=h.pathname.split("/").filter(Boolean);if((h.hostname==="github.com"||h.hostname==="www.github.com")&&b.length>=2){o.repository={href:c,stars:t.num_stars||0};break}}const i=[...r.project_pages??[]].sort((t,c)=>Number(c.is_official)-Number(t.is_official));for(const t of i){const c=Z(t.url);if(c){o.projectPage={href:c,label:mt(c)};break}}const g=r.hf_artifact_summary?r.hf_artifact_summary.model_count+r.hf_artifact_summary.dataset_count+r.hf_artifact_summary.space_count:new Set([...r.hf_models??[],...r.hf_datasets??[],...r.hf_spaces??[]]).size;return g>0&&r.arxiv_id&&(o.huggingFace={href:`https://huggingface.co/papers/${r.arxiv_id.replace(/v\d+$/i,"")}`,count:g}),o}function gt({routeId:r}){var me,he,ge,be,ve;const o=qe(),i=at(r,!!r),g=Q({queryKey:["chatAvailability"],queryFn:()=>st.getAvailability(),refetchInterval:3e4,retry:!1}),t=i.data,c=t?rt(t):null,h=c?null:(t==null?void 0:t.source)==="external"?Pe(`/paper-assets/external/${t.id}/paper.pdf`):ut(t==null?void 0:t.url_pdf),b=h&&(t==null?void 0:t.source)!=="external"?pt(h):h,P=ht(t),W=s.useMemo(()=>{var e;return(e=t==null?void 0:t.author_links)==null?void 0:e.flatMap(n=>n.id?[{id:n.id,name:n.name,avatarUrl:n.hf_avatar_url}]:[])},[t==null?void 0:t.author_links]),l=((me=t==null?void 0:t.arxiv_id)==null?void 0:me.replace(/v\d+$/i,""))||r,C=s.useCallback(()=>o(`/paper/${l}`),[l,o]),[f,y]=s.useState(()=>sessionStorage.getItem(V(r))||void 0),[v,S]=s.useState(dt),[d,Re]=s.useState(()=>sessionStorage.getItem(xe(r))==="1"),[x,k]=s.useState("paper"),[z,A]=s.useState(),[Se,je]=s.useState(),[_e,Ce]=s.useState(!1),ke=s.useCallback(()=>Ce(!0),[]),[Ae,R]=s.useState(""),[G]=s.useState(()=>lt(r)),[j,Ne]=s.useState(0),[J,ee]=s.useState(!1),[Ee,te]=s.useState(!1),N=s.useRef(null),L=s.useRef(null),E=s.useRef(null),re=s.useRef(null),ae=s.useRef(null),B=s.useRef(!1),T=s.useRef(!1),H=s.useRef(0),w=s.useRef(0),F=s.useRef(0),_=s.useRef(v),se=s.useRef(G),q=s.useRef(t==null?void 0:t.version),ne=Ve().reset,oe=s.useRef(f),p=j>=840;s.useEffect(()=>{oe.current!==f&&(oe.current=f,ne())},[f,ne]),s.useEffect(()=>{t!=null&&t.version&&q.current&&t.version!==q.current&&(A(void 0),R("")),q.current=t==null?void 0:t.version},[t==null?void 0:t.version]),s.useEffect(()=>()=>{window.clearTimeout(H.current),cancelAnimationFrame(w.current)},[]),s.useLayoutEffect(()=>{const e=N.current;if(!e)return;const n=()=>Ne(e.clientWidth);n();const u=new ResizeObserver(n);return u.observe(e),()=>u.disconnect()},[t]),s.useEffect(()=>{if(!t)return;document.title=`${t.title} — Papers With Code reader`;let e=document.querySelector('meta[name="robots"]');const n=!e;e||(e=document.createElement("meta"),e.name="robots",document.head.appendChild(e));const u=e.content;e.content="noindex, nofollow";let m=document.querySelector('link[rel="canonical"]');const Le=!m;m||(m=document.createElement("link"),m.rel="canonical",document.head.appendChild(m));const Be=m.href;return m.href=`${window.location.origin}/paper/${l}`,()=>{document.title="Papers With Code",n?e==null||e.remove():e&&(e.content=u),Le?m==null||m.remove():m&&(m.href=Be)}},[l,t]);const $=s.useCallback(e=>{if(!j)return Math.max(45,Math.min(75,e));const n=480/j*100,u=100-360/j*100;return Math.max(n,Math.min(u,e))},[j]);s.useEffect(()=>S(e=>{const n=$(e);return _.current=n,n}),[$]);const I=e=>{const n=$(e);_.current=n,S(n),localStorage.setItem(Y,String(n))},ie=e=>{var u;const n=$(e);_.current=n,L.current&&(L.current.style.width=`${n}%`),E.current&&(E.current.style.width=`${100-n}%`),(u=re.current)==null||u.setAttribute("aria-valuenow",String(Math.round(n)))},ce=e=>{F.current=e,!w.current&&(w.current=requestAnimationFrame(()=>{var u;w.current=0;const n=(u=N.current)==null?void 0:u.getBoundingClientRect();n!=null&&n.width&&ie((F.current-n.left)/n.width*100)}))},Te=e=>{T.current=!0,ee(!0),e.currentTarget.setPointerCapture(e.pointerId),ce(e.clientX)},K=()=>{var e;if(T.current){if(w.current){cancelAnimationFrame(w.current),w.current=0;const n=(e=N.current)==null?void 0:e.getBoundingClientRect();n!=null&&n.width&&ie((F.current-n.left)/n.width*100)}T.current=!1,S(_.current),localStorage.setItem(Y,String(_.current)),ee(!1)}},le=e=>{window.clearTimeout(H.current),te(!0),Re(e),sessionStorage.setItem(xe(r),e?"1":"0"),H.current=window.setTimeout(()=>te(!1),ct+40)},de=e=>{B.current=!0,le(e)};s.useEffect(()=>{var e;B.current&&(B.current=!1,(e=d?ae.current:E.current)==null||e.focus())},[d]);const $e=e=>{y(e),sessionStorage.setItem(V(r),e)},Ie=()=>{y(void 0),sessionStorage.removeItem(V(r)),A(void 0),R("")},ue=((he=g.data)==null?void 0:he.paper_reader_selection_enabled)===!0,fe=e=>{A(e),R(`Selection from page ${e.page} added to chat`),p&&d&&le(!1)},Me=s.useCallback(e=>{A(e),e||R("")},[]),U=((ge=g.data)==null?void 0:ge.paper_reader_citations_enabled)===!0&&!!b,M=Q({queryKey:["paper-layout",l],queryFn:()=>et(l),enabled:U&&!!l,staleTime:5*6e4}).data,We=s.useMemo(()=>U?{layout:M,open:e=>{const n=M?Qe(M,e):[];n.length&&(je(u=>({boxes:n,nonce:((u==null?void 0:u.nonce)??0)+1})),k("paper"))}}:null,[U,M]),pe=Ke()&&((be=g.data)==null?void 0:be.paper_reader_chat_enabled)!==!1,D=!!(t&&pe&&!(c&&!_e)),ze=t&&pe&&!D?a.jsx("div",{className:"reader-chat-unavailable",role:"status",children:"Chat opens once the paper is ready."}):t&&D?a.jsx(nt,{mode:"paper",routeSessionId:f,primaryPaper:{id:t.id,routeId:l,title:t.title},currentPage:()=>se.current,paperSelection:z,onPaperSelectionChange:Me,onSessionId:$e,onReaderSubmit:()=>k("assistant"),onReaderNewChat:Ie,onReaderClose:p?()=>de(!0):void 0}):a.jsx("div",{className:"reader-chat-unavailable",children:"Chat is not enabled for this preview."});return i.isLoading?a.jsx("div",{className:"reader-status",role:"status",children:"Loading paper…"}):i.error||!t?a.jsxs("div",{className:"reader-status",role:"alert",children:[a.jsx("p",{children:"Paper not found."}),a.jsx(O,{to:"/papers",children:"Browse papers"})]}):((ve=g.data)==null?void 0:ve.native_pdf_reader_enabled)===!1?a.jsxs("div",{className:"reader-status",role:"alert",children:[a.jsx("p",{children:"The native reader is currently unavailable."}),a.jsx(O,{to:`/paper/${l}`,children:"Back to paper"})]}):!b&&!c?a.jsxs("div",{className:"reader-status",role:"alert",children:[a.jsx("p",{children:"Native reading is unavailable for this resource."}),a.jsx(O,{to:`/paper/${l}`,children:"Back to paper"})]}):a.jsxs("div",{className:"paper-reader-shell",children:[!p&&a.jsxs("div",{className:"reader-tabs",role:"tablist","aria-label":"Reader panels",children:[a.jsx("button",{type:"button",role:"tab","aria-selected":x==="paper",onClick:()=>k("paper"),children:"Paper"}),a.jsxs("button",{type:"button",role:"tab","aria-selected":x==="assistant","aria-label":z&&x!=="assistant"?"Chat, selection attached":"Chat",onClick:()=>k("assistant"),children:["Chat",z&&x!=="assistant"&&a.jsx("span",{className:"reader-tab-pending","aria-hidden":"true"})]})]}),a.jsx(Xe,{variant:"reader",children:a.jsxs("div",{ref:N,className:`reader-workspace${p?" is-desktop":" is-tabs"}${d?" is-assistant-collapsed":""}${J?" is-resizing":""}`,"data-testid":"paper-chat-workspace",children:[a.jsx("section",{ref:L,className:`reader-paper-pane${!p&&x!=="paper"?" is-hidden":""}`,style:p?{width:d?"100%":`${v}%`}:void 0,role:"tabpanel","aria-label":"Paper","aria-hidden":!p&&x!=="paper",children:c?a.jsx(it,{paperId:t.id,paperKey:l,paperTitle:t.title,paperHref:`/paper/${l}`,sourceUrl:c,resources:P,paperVersion:t.version,selectionEnabled:ue,onReady:ke,onPaperSelection:fe,onPaperSelectionError:R}):b&&a.jsx(Ze,{url:b,downloadUrl:h??b,paperKey:l,paperTitle:t.title,paperHref:`/paper/${l}`,onClose:C,resources:P,initialPage:G,resizeActive:J||Ee,selectionEnabled:ue,paperVersion:t.version,authors:W,loadErrorMessage:t.source==="external"?"Paper content is still being prepared. Please try again later.":void 0,onPaperSelection:fe,onPaperSelectionError:R,highlight:Se,onPageChange:e=>{se.current=e,sessionStorage.setItem(we(r),String(e))}})}),p&&!d&&a.jsx("div",{ref:re,className:"reader-resize-handle",role:"separator","aria-label":"Resize paper and Chat panels","aria-orientation":"vertical","aria-valuemin":45,"aria-valuemax":75,"aria-valuenow":Math.round(v),tabIndex:0,onPointerDown:Te,onPointerMove:e=>{T.current&&ce(e.clientX)},onPointerUp:K,onPointerCancel:K,onLostPointerCapture:K,onDoubleClick:()=>I(ye),onKeyDown:e=>{(e.key==="ArrowLeft"||e.key==="ArrowRight")&&(e.preventDefault(),I(v+(e.key==="ArrowRight"?2:-2))),e.key==="Home"&&I(45),e.key==="End"&&I(75)}}),a.jsx("aside",{ref:E,id:"reader-chat-panel",className:`reader-assistant-pane${!p&&x!=="assistant"?" is-hidden":""}${p&&d?" is-collapsed":""}`,style:p?{width:d?0:`${100-v}%`}:void 0,role:"tabpanel","aria-label":"Chat","aria-hidden":!p&&x!=="assistant"||d,tabIndex:-1,children:a.jsx(Ye.Provider,{value:We,children:ze})}),a.jsx("div",{className:"sr-only","aria-live":"polite",children:Ae}),p&&(d||!D)&&a.jsx("button",{ref:ae,type:"button",className:"reader-collapse-assistant","aria-controls":"reader-chat-panel","aria-expanded":!d,onClick:()=>de(!d),children:d?"Open chat":"Hide chat"})]})})]})}function tr(){const{paperId:r=""}=He(),o=Fe(r).replace(/v\d+$/i,"");return a.jsx(Oe,{workspaceKey:`reader:${r}`,children:a.jsx(gt,{routeId:o},o)})}export{tr as default,ht as readerToolbarResources}; diff --git a/assets/PapersListView-BwwaBBb8.js b/assets/PapersListView-DL7UDvBC.js similarity index 88% rename from assets/PapersListView-BwwaBBb8.js rename to assets/PapersListView-DL7UDvBC.js index 357d44ccebf4f25e9566d60f8cdf1df4cf18ab8a..41739d090b3f257d64c56394aa64c9eb069cbee1 100644 --- a/assets/PapersListView-BwwaBBb8.js +++ b/assets/PapersListView-DL7UDvBC.js @@ -1 +1 @@ -import{d as f,p as M,b as K,j as e,L as x,l as V,o as X,T as J}from"./index-DyXq7-Tg.js";import{T as W}from"./SotaBadges-vbLLOUtT.js";import{I as H}from"./Icon-T4LYkEQj.js";import{u as Y,P as Z,b as ee,c as se,a as re}from"./PaperFeed-EBt97iOL.js";import{c as ae}from"./catalog-CRar2olQ.js";import{p as O}from"./papers-Dh3ljlL0.js";import{t as te,d as ne}from"./transform-D46m70Qr.js";import{u as Q}from"./usePapers-B0s20UcU.js";import{u as ie}from"./useDebounce-B9jkN7LV.js";import{S as oe}from"./skeleton-C3IIzpSL.js";import{A as le,a as ce}from"./alert-gbJBhAVE.js";import{i as de}from"./apiErrors-BSvbQBb0.js";import{f as me}from"./frameworks-DDA0P4Tf.js";import"./colors-BkWRhvFI.js";import"./PaperCard-57p1OSGy.js";import"./AuthorAvatar-B-9xS2Wo.js";import"./LatexTitle-Bkyz3jCs.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-CTBEUp7Y.js";import"./useIntersectionObserver-D6_Iig9a.js";import"./curation-YeS7FBYf.js";import"./useInfiniteQuery-BYh2zN-T.js";const g=360;function pe(r,t){const c=r.toLocaleLowerCase();return t.trim().split(/\s+/).filter(Boolean).reduce((i,l)=>{const o=c.indexOf(l.toLocaleLowerCase());return o>=0&&(i<0||o=0?l+1:t}function he(r,t){if(r.length<=g)return r;const c=pe(r,t);if(c<0||c0?"…":""}${r.slice(i,l).trim()}${l{var L,R,T,D,$,A,I,B,q;const r=Y(),{searchParams:t,setSearchParams:c}=r,i=t.get("framework")||void 0,l=t.get("repository")||void 0,o=!!(i||l),d=t.get("search")||"",[b,F]=f.useState(d),h=ie(b,300),n=!o&&d.trim().length>0;f.useEffect(()=>F(d),[d]),f.useEffect(()=>{if(h===d)return;const a=new URLSearchParams(t);h?a.set("search",h):a.delete("search"),c(a,{replace:!0})},[h]),f.useEffect(()=>{const a=t.get("order_by"),m=new URLSearchParams(t);n&&!["relevance","date_published","citation_count"].includes(a||"")?(m.set("order_by","relevance"),c(m,{replace:!0})):!n&&a==="relevance"&&(m.delete("order_by"),c(m,{replace:!0}))},[n,t,c]);const j=n&&r.orderBy==="trending"?"relevance":r.orderBy,S=!o&&r.hasCode,P={...r.filters,has_code:S,search:o&&h||void 0,conference:t.get("conference")||void 0,latest_only:t.get("latest_only")!=="false",framework:i,repository:l},k=Q([...M.feeds.infinite,P],a=>O.list({...P,page:a,page_size:20}),{enabled:!n}),_={q:h.trim(),order_by:j==="trending"?"relevance":j,start_date:r.dateRange.startDate,end_date:r.dateRange.endDate,has_code:S,has_hf_artifacts:r.hasHfArtifacts},E=Q([...M.feeds.search,_],a=>O.searchFeed({..._,page:a,page_size:20,mode:"hybrid"}),{enabled:n&&_.q.length>0}),p=n?E:k,C=K({queryKey:X.topTasksSidebar,queryFn:()=>ae.topTasks(8),enabled:!o&&!n,staleTime:J}),v=f.useMemo(()=>{var m;return(((m=p.data)==null?void 0:m.pages.flatMap(N=>N.results))||[]).map(N=>{const w=te(N);return n?{...w,abstract:he(w.abstract,d)}:w})},[p.data,n,d]),u=((T=(R=(L=k.data)==null?void 0:L.pages)==null?void 0:R[0])==null?void 0:T.count)??0,s=(A=($=(D=k.data)==null?void 0:D.pages)==null?void 0:$[0])==null?void 0:A.scope,y=(B=(I=E.data)==null?void 0:I.pages)==null?void 0:B.at(-1),G=i&&de(p.error),U=(s==null?void 0:s.kind)==="framework"?s.framework_name:s==null?void 0:s.repository;return e.jsxs("div",{className:"page",children:[(s==null?void 0:s.kind)==="framework"&&e.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[e.jsx(x,{to:"/",children:"Papers"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx(x,{to:"/frameworks",children:"Frameworks"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("span",{style:{color:"var(--ink)"},children:s.framework_name})]}),e.jsxs("div",{className:"feed-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"feed-title",children:o?e.jsxs(e.Fragment,{children:["Papers implemented by ",e.jsx("em",{children:U||i||l})]}):n?e.jsxs(e.Fragment,{children:["Search results for ",e.jsxs("em",{children:["“",d,"”"]})]}):e.jsxs(e.Fragment,{children:["All ",e.jsx("em",{children:"Papers"})]})}),e.jsx("div",{className:"feed-subtitle",children:o?(s==null?void 0:s.kind)==="framework"?u>0&&`${u.toLocaleString()} papers.`:s!=null&&s.repository?e.jsxs(e.Fragment,{children:["GitHub repository ",e.jsx("strong",{children:s.repository}),". ",u>0&&`${u.toLocaleString()} papers.`]}):"Repository-scoped paper feed.":n?`${v.length} loaded from the most relevant results.`:e.jsxs(e.Fragment,{children:["Search the full corpus. ",u>0&&`${u.toLocaleString()} papers indexed.`]})}),o&&s&&e.jsxs("div",{className:"paper-feed-scope-links",children:[e.jsxs("div",{className:"paper-feed-primary-links",children:[s.github_url&&e.jsxs("a",{href:s.github_url,target:"_blank",rel:"noopener noreferrer",className:s.kind==="framework"?"task-framework-link":"framework-link",children:[e.jsx(H,{name:"github",size:13}),s.kind==="framework"?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:s.repository||"GitHub"}),s.num_stars!=null&&e.jsxs("span",{className:"task-framework-link-stars",children:["★ ",me(s.num_stars)]})]}):"GitHub"]}),s.kind==="framework"&&s.introducing_paper_arxiv_id&&e.jsx(x,{to:`/paper/${s.introducing_paper_arxiv_id}`,className:"framework-link",children:"Introducing paper"})]}),s.kind==="framework"&&s.recommended_tasks&&s.recommended_tasks.length>0&&e.jsx("div",{className:"paper-feed-task-tags",children:s.recommended_tasks.map(a=>a.slug?e.jsx(W,{slug:a.slug,label:a.name},a.id):null)})]})]}),e.jsx(Z,{startDate:r.dateRange.startDate,endDate:r.dateRange.endDate,onChange:r.setDateRange})]}),e.jsx("div",{className:"papers-search-row",children:e.jsxs("div",{className:"papers-search-input-wrap",children:[e.jsx(H,{name:"search",size:14}),e.jsx("input",{className:"papers-search-input",placeholder:"Search title or abstract…",value:b,onChange:a=>F(a.target.value)})]})}),e.jsxs("div",{className:o||n?"papers-feed-layout-scoped":"layout-with-sidebar",children:[!o&&!n&&e.jsx("aside",{className:"sidebar",children:e.jsxs("div",{className:"sidebar-section",children:[e.jsx("div",{className:"sidebar-label",children:"Top Domains"}),C.isLoading&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:6}).map((a,m)=>e.jsx(oe,{className:"h-5 w-full"},m))}),e.jsx("div",{className:"sidebar-links",children:(q=C.data)==null?void 0:q.map(a=>e.jsxs(x,{to:`/tasks/${a.slug}`,className:"sidebar-link",children:[ne(a.name,a.slug),a.paper_count!=null&&e.jsx("span",{className:"count",children:a.paper_count})]},a.id))})]})}),e.jsxs("div",{children:[e.jsx(ee,{feed:r,sorts:n?ue:se,activeSort:j,showDateFilter:!1,showHasCode:!o,children:e.jsxs("div",{className:"results-count",children:[v.length," loaded"]})}),G?e.jsx("div",{className:"no-results",children:"Framework not found."}):e.jsxs(e.Fragment,{children:[p.error&&e.jsx(le,{variant:"destructive",className:"mb-4",children:e.jsx(ce,{children:"Failed to load papers. Please try again."})}),e.jsx(re,{query:p,cards:v,skeleton:"card",highlightQuery:n?d:void 0,empty:e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"No matching papers."}),n&&V()&&e.jsx(x,{to:`/chat?q=${encodeURIComponent(d.trim())}`,children:"Ask the assistant instead"})]}),children:!p.hasNextPage&&!p.isFetchingNextPage&&n&&e.jsx("div",{className:"search-results-end",children:y!=null&&y.cap_reached?"End of the top 100 results":"End of results"})})]})]})]})]})};export{Ie as default}; +import{d as f,p as M,b as K,j as e,L as x,l as V,o as X,T as J}from"./index-CjdUkE4w.js";import{T as W}from"./SotaBadges-CyScuNCv.js";import{I as H}from"./Icon-CGRs4BYD.js";import{u as Y,P as Z,b as ee,c as se,a as re}from"./PaperFeed-D3FZw29k.js";import{c as ae}from"./catalog-qXcKve0z.js";import{p as O}from"./papers-DgZwjF3K.js";import{t as te,d as ne}from"./transform-CRNzYLch.js";import{u as Q}from"./usePapers-BZThqZCx.js";import{u as ie}from"./useDebounce-wGQ3PIQd.js";import{S as oe}from"./skeleton-DTWi7Ctg.js";import{A as le,a as ce}from"./alert-BM9Xfuyy.js";import{i as de}from"./apiErrors-D0w5By9R.js";import{f as me}from"./frameworks-DDA0P4Tf.js";import"./colors-BkWRhvFI.js";import"./PaperCard-dvXhr75r.js";import"./AuthorAvatar-D9249Frl.js";import"./LatexTitle-DESKtS30.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-Df5_dywQ.js";import"./useIntersectionObserver-Ch6RpsSk.js";import"./curation-CyyuHfv5.js";import"./useInfiniteQuery-DeZTTVbI.js";const g=360;function pe(r,t){const c=r.toLocaleLowerCase();return t.trim().split(/\s+/).filter(Boolean).reduce((i,l)=>{const o=c.indexOf(l.toLocaleLowerCase());return o>=0&&(i<0||o=0?l+1:t}function he(r,t){if(r.length<=g)return r;const c=pe(r,t);if(c<0||c0?"…":""}${r.slice(i,l).trim()}${l{var L,R,T,D,$,A,I,B,q;const r=Y(),{searchParams:t,setSearchParams:c}=r,i=t.get("framework")||void 0,l=t.get("repository")||void 0,o=!!(i||l),d=t.get("search")||"",[b,F]=f.useState(d),h=ie(b,300),n=!o&&d.trim().length>0;f.useEffect(()=>F(d),[d]),f.useEffect(()=>{if(h===d)return;const a=new URLSearchParams(t);h?a.set("search",h):a.delete("search"),c(a,{replace:!0})},[h]),f.useEffect(()=>{const a=t.get("order_by"),m=new URLSearchParams(t);n&&!["relevance","date_published","citation_count"].includes(a||"")?(m.set("order_by","relevance"),c(m,{replace:!0})):!n&&a==="relevance"&&(m.delete("order_by"),c(m,{replace:!0}))},[n,t,c]);const j=n&&r.orderBy==="trending"?"relevance":r.orderBy,S=!o&&r.hasCode,P={...r.filters,has_code:S,search:o&&h||void 0,conference:t.get("conference")||void 0,latest_only:t.get("latest_only")!=="false",framework:i,repository:l},k=Q([...M.feeds.infinite,P],a=>O.list({...P,page:a,page_size:20}),{enabled:!n}),_={q:h.trim(),order_by:j==="trending"?"relevance":j,start_date:r.dateRange.startDate,end_date:r.dateRange.endDate,has_code:S,has_hf_artifacts:r.hasHfArtifacts},E=Q([...M.feeds.search,_],a=>O.searchFeed({..._,page:a,page_size:20,mode:"hybrid"}),{enabled:n&&_.q.length>0}),p=n?E:k,C=K({queryKey:X.topTasksSidebar,queryFn:()=>ae.topTasks(8),enabled:!o&&!n,staleTime:J}),v=f.useMemo(()=>{var m;return(((m=p.data)==null?void 0:m.pages.flatMap(N=>N.results))||[]).map(N=>{const w=te(N);return n?{...w,abstract:he(w.abstract,d)}:w})},[p.data,n,d]),u=((T=(R=(L=k.data)==null?void 0:L.pages)==null?void 0:R[0])==null?void 0:T.count)??0,s=(A=($=(D=k.data)==null?void 0:D.pages)==null?void 0:$[0])==null?void 0:A.scope,y=(B=(I=E.data)==null?void 0:I.pages)==null?void 0:B.at(-1),G=i&&de(p.error),U=(s==null?void 0:s.kind)==="framework"?s.framework_name:s==null?void 0:s.repository;return e.jsxs("div",{className:"page",children:[(s==null?void 0:s.kind)==="framework"&&e.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[e.jsx(x,{to:"/",children:"Papers"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx(x,{to:"/frameworks",children:"Frameworks"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("span",{style:{color:"var(--ink)"},children:s.framework_name})]}),e.jsxs("div",{className:"feed-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"feed-title",children:o?e.jsxs(e.Fragment,{children:["Papers implemented by ",e.jsx("em",{children:U||i||l})]}):n?e.jsxs(e.Fragment,{children:["Search results for ",e.jsxs("em",{children:["“",d,"”"]})]}):e.jsxs(e.Fragment,{children:["All ",e.jsx("em",{children:"Papers"})]})}),e.jsx("div",{className:"feed-subtitle",children:o?(s==null?void 0:s.kind)==="framework"?u>0&&`${u.toLocaleString()} papers.`:s!=null&&s.repository?e.jsxs(e.Fragment,{children:["GitHub repository ",e.jsx("strong",{children:s.repository}),". ",u>0&&`${u.toLocaleString()} papers.`]}):"Repository-scoped paper feed.":n?`${v.length} loaded from the most relevant results.`:e.jsxs(e.Fragment,{children:["Search the full corpus. ",u>0&&`${u.toLocaleString()} papers indexed.`]})}),o&&s&&e.jsxs("div",{className:"paper-feed-scope-links",children:[e.jsxs("div",{className:"paper-feed-primary-links",children:[s.github_url&&e.jsxs("a",{href:s.github_url,target:"_blank",rel:"noopener noreferrer",className:s.kind==="framework"?"task-framework-link":"framework-link",children:[e.jsx(H,{name:"github",size:13}),s.kind==="framework"?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:s.repository||"GitHub"}),s.num_stars!=null&&e.jsxs("span",{className:"task-framework-link-stars",children:["★ ",me(s.num_stars)]})]}):"GitHub"]}),s.kind==="framework"&&s.introducing_paper_arxiv_id&&e.jsx(x,{to:`/paper/${s.introducing_paper_arxiv_id}`,className:"framework-link",children:"Introducing paper"})]}),s.kind==="framework"&&s.recommended_tasks&&s.recommended_tasks.length>0&&e.jsx("div",{className:"paper-feed-task-tags",children:s.recommended_tasks.map(a=>a.slug?e.jsx(W,{slug:a.slug,label:a.name},a.id):null)})]})]}),e.jsx(Z,{startDate:r.dateRange.startDate,endDate:r.dateRange.endDate,onChange:r.setDateRange})]}),e.jsx("div",{className:"papers-search-row",children:e.jsxs("div",{className:"papers-search-input-wrap",children:[e.jsx(H,{name:"search",size:14}),e.jsx("input",{className:"papers-search-input",placeholder:"Search title or abstract…",value:b,onChange:a=>F(a.target.value)})]})}),e.jsxs("div",{className:o||n?"papers-feed-layout-scoped":"layout-with-sidebar",children:[!o&&!n&&e.jsx("aside",{className:"sidebar",children:e.jsxs("div",{className:"sidebar-section",children:[e.jsx("div",{className:"sidebar-label",children:"Top Domains"}),C.isLoading&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:6}).map((a,m)=>e.jsx(oe,{className:"h-5 w-full"},m))}),e.jsx("div",{className:"sidebar-links",children:(q=C.data)==null?void 0:q.map(a=>e.jsxs(x,{to:`/tasks/${a.slug}`,className:"sidebar-link",children:[ne(a.name,a.slug),a.paper_count!=null&&e.jsx("span",{className:"count",children:a.paper_count})]},a.id))})]})}),e.jsxs("div",{children:[e.jsx(ee,{feed:r,sorts:n?ue:se,activeSort:j,showDateFilter:!1,showHasCode:!o,children:e.jsxs("div",{className:"results-count",children:[v.length," loaded"]})}),G?e.jsx("div",{className:"no-results",children:"Framework not found."}):e.jsxs(e.Fragment,{children:[p.error&&e.jsx(le,{variant:"destructive",className:"mb-4",children:e.jsx(ce,{children:"Failed to load papers. Please try again."})}),e.jsx(re,{query:p,cards:v,skeleton:"card",highlightQuery:n?d:void 0,empty:e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"No matching papers."}),n&&V()&&e.jsx(x,{to:`/chat?q=${encodeURIComponent(d.trim())}`,children:"Ask the assistant instead"})]}),children:!p.hasNextPage&&!p.isFetchingNextPage&&n&&e.jsx("div",{className:"search-results-end",children:y!=null&&y.cap_reached?"End of the top 100 results":"End of results"})})]})]})]})]})};export{Ie as default}; diff --git a/assets/PrivacyView-BQ3x7IFA.js b/assets/PrivacyView-BHODG2cO.js similarity index 98% rename from assets/PrivacyView-BQ3x7IFA.js rename to assets/PrivacyView-BHODG2cO.js index 1c4a87e7ddaa05774286620162249554c109d48d..345d664d3356b2e00e324c4602e95faf33685593 100644 --- a/assets/PrivacyView-BQ3x7IFA.js +++ b/assets/PrivacyView-BHODG2cO.js @@ -1 +1 @@ -import{j as e}from"./index-DyXq7-Tg.js";import{u as s,f as i}from"./useDocumentTitle-DcxM2Zv_.js";const t=()=>(s(i("Privacy Policy")),e.jsxs("article",{className:"page legal-page",children:[e.jsxs("header",{className:"legal-header",children:[e.jsx("p",{className:"legal-kicker",children:"Legal"}),e.jsx("h1",{children:"Privacy Policy"}),e.jsx("p",{className:"legal-effective-date",children:"Effective August 11, 2026"})]}),e.jsx("p",{children:"This Privacy Policy explains how Hugging Face, Inc. (“Hugging Face,” “we,” or “us”) collects, uses, and shares information when you use Papers With Code, including its website, research assistant, APIs, and related services (the “Service”)."}),e.jsxs("section",{children:[e.jsx("h2",{children:"1. Information we collect"}),e.jsx("h3",{children:"Information you provide"}),e.jsxs("ul",{children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Account information."})," If you sign in with Hugging Face, we receive account identifiers and profile details needed to authenticate you, such as your user ID, username, and avatar. If you request contributor access, we also receive and retain the verified email address associated with your Hugging Face account so we can review and communicate about your request."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Contributions and preferences."})," We collect information you submit or save, such as paper submissions and edits, bookmarks, display preferences, feedback, and communications with us. Material you submit to a public research page may be publicly visible."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Research assistant content."})," We collect your questions, conversation history, generated answers, citations, tool calls and results, and feedback about answers. Chats are private to your account unless you choose to create a share link; anyone with that link may be able to view the shared chat."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Provider and billing information."})," If you enable a model provider, we process the authorization or API credentials needed to make requests on your behalf. Hugging Face or another provider processes its own billing information under its terms. Papers With Code does not collect your payment-card details."]})]}),e.jsx("h3",{children:"Information collected automatically"}),e.jsx("p",{children:"We collect technical and usage information such as IP address, browser and device type, operating system, pages or features used, dates and times, referring pages, request identifiers, cookies, logs, and diagnostic data. For research-assistant requests, this may include the selected model, token and cost details, latency, errors, and other operational metadata."}),e.jsx("h3",{children:"Research assistant tracing"}),e.jsxs("p",{children:["To evaluate, debug, secure, and improve the research assistant, we use Langfuse to record traces. A trace may contain the complete text of your question and the assistant's answer, as well as tool inputs, tool outputs, retrieved research material, model details, usage data, and related operational metadata.",e.jsx("strong",{children:" This trace content is not redacted before it is sent to Langfuse."})]}),e.jsx("p",{children:"Papers With Code is designed for questions about research literature. Do not put passwords, API keys, confidential information, health or financial data, or other sensitive personal information in research-assistant prompts."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"2. How we use information"}),e.jsx("p",{children:"We use information to:"}),e.jsxs("ul",{children:[e.jsx("li",{children:"provide, personalize, maintain, and operate the Service;"}),e.jsx("li",{children:"authenticate users and keep accounts and the Service secure;"}),e.jsx("li",{children:"run research-assistant requests and preserve conversation history;"}),e.jsx("li",{children:"measure performance, troubleshoot failures, and improve quality;"}),e.jsx("li",{children:"review contributions, prevent abuse, and enforce applicable terms;"}),e.jsx("li",{children:"communicate with you and respond to requests; and"}),e.jsx("li",{children:"comply with law and protect users, Hugging Face, and the public."})]})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"3. How we share information"}),e.jsx("p",{children:"We may share information in these circumstances:"}),e.jsxs("ul",{children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Service providers."})," Vendors process information for hosting, authentication, analytics, observability, security, and support. These include Hugging Face services, Langfuse for research-assistant tracing, Plausible for website analytics, and infrastructure providers."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Model providers."})," Research-assistant content is sent to the model provider you use, such as Hugging Face Inference Providers or OpenRouter, so it can generate a response. That provider's privacy terms also apply to its processing."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Public and shared content."})," Contributions intended for public pages are public. A chat is disclosed through the Service when you create and distribute a share link."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Legal, safety, and corporate events."})," We may disclose information when reasonably necessary to comply with law, protect rights and safety, investigate abuse, or complete a merger, acquisition, financing, or transfer of assets."]})]}),e.jsx("p",{children:"We do not sell your personal information."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"4. Cookies and analytics"}),e.jsx("p",{children:"We use cookies and similar storage when needed for sign-in, security, preferences, and operation of the Service. We also use Plausible to understand aggregate website usage. You can control cookies through your browser, but disabling necessary cookies may prevent account features from working."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"5. Legal bases"}),e.jsx("p",{children:"Where applicable law requires a legal basis, we process information as needed to perform our agreement with you, with your consent, to comply with legal obligations, and for legitimate interests such as operating, securing, and improving the Service. You may withdraw consent where consent is the basis for processing, without affecting earlier processing."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"6. Retention and deletion"}),e.jsx("p",{children:"Private chats are retained until you delete them, subject to limits of 500 active chats and 100 MB of chat data per user. Archiving hides a chat and frees active-chat quota but does not delete it. You may deliberately share an unlisted snapshot; deleting its private chat removes the durable transcript, workspace reference, and share link after deletion is verified. No dedicated private-chat export format is currently offered."}),e.jsx("p",{children:"We keep information for as long as reasonably needed for the purposes described here, including providing the Service, maintaining security and audit records, resolving disputes, and meeting legal obligations. Retention periods vary by data type and service provider. You can delete individual chats in the Service. Deletion may not immediately remove information from backups, security logs, or third-party systems where limited retention is required."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"7. Security and international transfers"}),e.jsx("p",{children:"We use reasonable administrative, technical, and organizational safeguards, but no internet service can guarantee absolute security. We and our service providers may process information in the United States and other countries, which may have different data-protection laws from your country. Where required, we use appropriate safeguards for international transfers."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"8. Your privacy rights"}),e.jsx("p",{children:"Depending on where you live, you may have rights to access, correct, delete, or receive a copy of your personal information; object to or restrict processing; withdraw consent; or appeal a decision about a request. You may also have the right to complain to a data-protection authority. We may need to verify your identity before fulfilling a request."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"9. Children"}),e.jsx("p",{children:"The Service is not directed to children under 13, and we do not knowingly collect personal information from children under 13. If you believe a child has provided personal information, please contact us."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"10. Changes to this policy"}),e.jsx("p",{children:"We may update this policy as the Service changes. We will post the revised policy here and update its effective date. If a change is material, we will provide additional notice when appropriate."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"11. Contact us"}),e.jsxs("p",{children:["For questions or privacy requests, contact"," ",e.jsx("a",{href:"mailto:privacy@huggingface.co",children:"privacy@huggingface.co"}),". Please do not include passwords, API keys, or other sensitive credentials in your message."]})]})]}));export{t as default}; +import{j as e}from"./index-CjdUkE4w.js";import{u as s,f as i}from"./useDocumentTitle-2Ho8_KfW.js";const t=()=>(s(i("Privacy Policy")),e.jsxs("article",{className:"page legal-page",children:[e.jsxs("header",{className:"legal-header",children:[e.jsx("p",{className:"legal-kicker",children:"Legal"}),e.jsx("h1",{children:"Privacy Policy"}),e.jsx("p",{className:"legal-effective-date",children:"Effective August 11, 2026"})]}),e.jsx("p",{children:"This Privacy Policy explains how Hugging Face, Inc. (“Hugging Face,” “we,” or “us”) collects, uses, and shares information when you use Papers With Code, including its website, research assistant, APIs, and related services (the “Service”)."}),e.jsxs("section",{children:[e.jsx("h2",{children:"1. Information we collect"}),e.jsx("h3",{children:"Information you provide"}),e.jsxs("ul",{children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Account information."})," If you sign in with Hugging Face, we receive account identifiers and profile details needed to authenticate you, such as your user ID, username, and avatar. If you request contributor access, we also receive and retain the verified email address associated with your Hugging Face account so we can review and communicate about your request."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Contributions and preferences."})," We collect information you submit or save, such as paper submissions and edits, bookmarks, display preferences, feedback, and communications with us. Material you submit to a public research page may be publicly visible."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Research assistant content."})," We collect your questions, conversation history, generated answers, citations, tool calls and results, and feedback about answers. Chats are private to your account unless you choose to create a share link; anyone with that link may be able to view the shared chat."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Provider and billing information."})," If you enable a model provider, we process the authorization or API credentials needed to make requests on your behalf. Hugging Face or another provider processes its own billing information under its terms. Papers With Code does not collect your payment-card details."]})]}),e.jsx("h3",{children:"Information collected automatically"}),e.jsx("p",{children:"We collect technical and usage information such as IP address, browser and device type, operating system, pages or features used, dates and times, referring pages, request identifiers, cookies, logs, and diagnostic data. For research-assistant requests, this may include the selected model, token and cost details, latency, errors, and other operational metadata."}),e.jsx("h3",{children:"Research assistant tracing"}),e.jsxs("p",{children:["To evaluate, debug, secure, and improve the research assistant, we use Langfuse to record traces. A trace may contain the complete text of your question and the assistant's answer, as well as tool inputs, tool outputs, retrieved research material, model details, usage data, and related operational metadata.",e.jsx("strong",{children:" This trace content is not redacted before it is sent to Langfuse."})]}),e.jsx("p",{children:"Papers With Code is designed for questions about research literature. Do not put passwords, API keys, confidential information, health or financial data, or other sensitive personal information in research-assistant prompts."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"2. How we use information"}),e.jsx("p",{children:"We use information to:"}),e.jsxs("ul",{children:[e.jsx("li",{children:"provide, personalize, maintain, and operate the Service;"}),e.jsx("li",{children:"authenticate users and keep accounts and the Service secure;"}),e.jsx("li",{children:"run research-assistant requests and preserve conversation history;"}),e.jsx("li",{children:"measure performance, troubleshoot failures, and improve quality;"}),e.jsx("li",{children:"review contributions, prevent abuse, and enforce applicable terms;"}),e.jsx("li",{children:"communicate with you and respond to requests; and"}),e.jsx("li",{children:"comply with law and protect users, Hugging Face, and the public."})]})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"3. How we share information"}),e.jsx("p",{children:"We may share information in these circumstances:"}),e.jsxs("ul",{children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Service providers."})," Vendors process information for hosting, authentication, analytics, observability, security, and support. These include Hugging Face services, Langfuse for research-assistant tracing, Plausible for website analytics, and infrastructure providers."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Model providers."})," Research-assistant content is sent to the model provider you use, such as Hugging Face Inference Providers or OpenRouter, so it can generate a response. That provider's privacy terms also apply to its processing."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Public and shared content."})," Contributions intended for public pages are public. A chat is disclosed through the Service when you create and distribute a share link."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Legal, safety, and corporate events."})," We may disclose information when reasonably necessary to comply with law, protect rights and safety, investigate abuse, or complete a merger, acquisition, financing, or transfer of assets."]})]}),e.jsx("p",{children:"We do not sell your personal information."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"4. Cookies and analytics"}),e.jsx("p",{children:"We use cookies and similar storage when needed for sign-in, security, preferences, and operation of the Service. We also use Plausible to understand aggregate website usage. You can control cookies through your browser, but disabling necessary cookies may prevent account features from working."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"5. Legal bases"}),e.jsx("p",{children:"Where applicable law requires a legal basis, we process information as needed to perform our agreement with you, with your consent, to comply with legal obligations, and for legitimate interests such as operating, securing, and improving the Service. You may withdraw consent where consent is the basis for processing, without affecting earlier processing."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"6. Retention and deletion"}),e.jsx("p",{children:"Private chats are retained until you delete them, subject to limits of 500 active chats and 100 MB of chat data per user. Archiving hides a chat and frees active-chat quota but does not delete it. You may deliberately share an unlisted snapshot; deleting its private chat removes the durable transcript, workspace reference, and share link after deletion is verified. No dedicated private-chat export format is currently offered."}),e.jsx("p",{children:"We keep information for as long as reasonably needed for the purposes described here, including providing the Service, maintaining security and audit records, resolving disputes, and meeting legal obligations. Retention periods vary by data type and service provider. You can delete individual chats in the Service. Deletion may not immediately remove information from backups, security logs, or third-party systems where limited retention is required."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"7. Security and international transfers"}),e.jsx("p",{children:"We use reasonable administrative, technical, and organizational safeguards, but no internet service can guarantee absolute security. We and our service providers may process information in the United States and other countries, which may have different data-protection laws from your country. Where required, we use appropriate safeguards for international transfers."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"8. Your privacy rights"}),e.jsx("p",{children:"Depending on where you live, you may have rights to access, correct, delete, or receive a copy of your personal information; object to or restrict processing; withdraw consent; or appeal a decision about a request. You may also have the right to complain to a data-protection authority. We may need to verify your identity before fulfilling a request."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"9. Children"}),e.jsx("p",{children:"The Service is not directed to children under 13, and we do not knowingly collect personal information from children under 13. If you believe a child has provided personal information, please contact us."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"10. Changes to this policy"}),e.jsx("p",{children:"We may update this policy as the Service changes. We will post the revised policy here and update its effective date. If a change is material, we will provide additional notice when appropriate."})]}),e.jsxs("section",{children:[e.jsx("h2",{children:"11. Contact us"}),e.jsxs("p",{children:["For questions or privacy requests, contact"," ",e.jsx("a",{href:"mailto:privacy@huggingface.co",children:"privacy@huggingface.co"}),". Please do not include passwords, API keys, or other sensitive credentials in your message."]})]})]}));export{t as default}; diff --git a/assets/RateLimitsView-phVSVOy1.js b/assets/RateLimitsView-CrvlGHnU.js similarity index 87% rename from assets/RateLimitsView-phVSVOy1.js rename to assets/RateLimitsView-CrvlGHnU.js index 841509f7bc3888b861d3e8be038073ecca7cd82c..49f4e3804e972b95e9bce5654ba1bda06451d9dd 100644 --- a/assets/RateLimitsView-phVSVOy1.js +++ b/assets/RateLimitsView-CrvlGHnU.js @@ -1 +1 @@ -import{b as t,j as e}from"./index-DyXq7-Tg.js";import{a as s}from"./account-cbblajck.js";const n=()=>{const i=t({queryKey:["submission-rate-limit-policy"],queryFn:()=>s.getRateLimitPolicy()}).data;return e.jsxs("div",{className:"page",style:{maxWidth:760},children:[e.jsx("h1",{children:"Submission and rate-limit policy"}),i?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Each account may have up to ",i.active_pending," active submissions."]}),e.jsxs("p",{children:["New submissions are limited to ",i.subject_per_hour," per account and ",i.ip_per_hour," per source network in a rolling hour."]})]}):e.jsx("p",{children:"Loading current limits…"}),e.jsx("p",{children:"Duplicate, no-op, and idempotently replayed requests do not consume creation quota."}),e.jsx("p",{children:"Rate-limited responses use HTTP 429 with Retry-After, RateLimit, and RateLimit-Policy headers."}),e.jsx("p",{children:"Good-faith contributors who are blocked should contact the Papers with Code maintainers with their Hugging Face username."})]})};export{n as default}; +import{b as t,j as e}from"./index-CjdUkE4w.js";import{a as s}from"./account-DoluPGSd.js";const n=()=>{const i=t({queryKey:["submission-rate-limit-policy"],queryFn:()=>s.getRateLimitPolicy()}).data;return e.jsxs("div",{className:"page",style:{maxWidth:760},children:[e.jsx("h1",{children:"Submission and rate-limit policy"}),i?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Each account may have up to ",i.active_pending," active submissions."]}),e.jsxs("p",{children:["New submissions are limited to ",i.subject_per_hour," per account and ",i.ip_per_hour," per source network in a rolling hour."]})]}):e.jsx("p",{children:"Loading current limits…"}),e.jsx("p",{children:"Duplicate, no-op, and idempotently replayed requests do not consume creation quota."}),e.jsx("p",{children:"Rate-limited responses use HTTP 429 with Retry-After, RateLimit, and RateLimit-Policy headers."}),e.jsx("p",{children:"Good-faith contributors who are blocked should contact the Papers with Code maintainers with their Hugging Face username."})]})};export{n as default}; diff --git a/assets/ResearchFollowButton-Dv316ClR.js b/assets/ResearchFollowButton-DcTptDpW.js similarity index 93% rename from assets/ResearchFollowButton-Dv316ClR.js rename to assets/ResearchFollowButton-DcTptDpW.js index 27fc00667a266b3c950f82f79eada46999606f11..e4191216b3908465d2597865aec6a16899e998ec 100644 --- a/assets/ResearchFollowButton-Dv316ClR.js +++ b/assets/ResearchFollowButton-DcTptDpW.js @@ -1 +1 @@ -import{f as x,c as j,d as b,k as F,j as e,h as N,C as S,L as i}from"./index-DyXq7-Tg.js";import{u as y,g as C}from"./researchTopic-DbX0eko-.js";import{P as w}from"./plus-Yh42pKZz.js";const f={task:"Get new papers on this task",method:"Get new papers using this method",benchmark:"Get new results on this benchmark",author:"Get new papers by this author",organization:"Get new papers from this organization"};function R({kind:o,entityId:n}){var u;const l=x(),c=l==null?void 0:l.user,h=j(),[m,p]=b.useState(null),d=`${o}:${n}`,a=y(),s=((u=a.data)==null?void 0:u.some(r=>r.kind===o&&String(r.entity_id)===String(n)))??!1,t=C({onChanged:({follow:r})=>p(r?d:null),awaitRefresh:!0});if(!l||!c&&F())return null;if(!c)return e.jsxs("div",{className:"research-follow",children:[e.jsxs("a",{className:"research-follow-btn",href:N(h.pathname+h.search),children:[e.jsx(w,{"aria-hidden":"true"}),"Follow"]}),e.jsxs("span",{className:"research-follow-hint",children:["Sign in to ",f[o].toLowerCase(),"."]})]});const g=t.error||a.error;return e.jsxs("div",{className:"research-follow",children:[e.jsx("button",{type:"button",className:s?"research-follow-btn is-following":"research-follow-btn",disabled:a.isLoading||!!a.error||t.isPending,"aria-pressed":s,"aria-label":s?"Unfollow":"Follow",onClick:()=>t.mutate({kind:o,entityId:n,follow:!s}),children:s?e.jsxs(e.Fragment,{children:[e.jsx(S,{"aria-hidden":"true"}),e.jsx("span",{className:"research-follow-label",children:"Following"}),e.jsx("span",{className:"research-follow-label-hover",children:"Unfollow"})]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{"aria-hidden":"true"}),"Follow"]})}),g?e.jsx("span",{className:"research-follow-hint is-error",role:"alert",children:"Could not update follows. Please try again."}):s?m===d&&e.jsxs("span",{className:"research-follow-hint",role:"status",children:["Added to ",e.jsx(i,{to:"/following",children:"your Following feed"})," · ",e.jsx(i,{to:"/settings",children:"Manage in Settings"})]}):e.jsxs("span",{className:"research-follow-hint",children:[f[o]," in ",e.jsx(i,{to:"/following",children:"your Following feed"}),"."]})]})}export{R}; +import{f as x,c as j,d as b,k as F,j as e,h as N,C as S,L as i}from"./index-CjdUkE4w.js";import{u as y,g as C}from"./researchTopic-NmABF6tT.js";import{P as w}from"./plus-AztI1566.js";const f={task:"Get new papers on this task",method:"Get new papers using this method",benchmark:"Get new results on this benchmark",author:"Get new papers by this author",organization:"Get new papers from this organization"};function R({kind:o,entityId:n}){var u;const l=x(),c=l==null?void 0:l.user,h=j(),[m,p]=b.useState(null),d=`${o}:${n}`,a=y(),s=((u=a.data)==null?void 0:u.some(r=>r.kind===o&&String(r.entity_id)===String(n)))??!1,t=C({onChanged:({follow:r})=>p(r?d:null),awaitRefresh:!0});if(!l||!c&&F())return null;if(!c)return e.jsxs("div",{className:"research-follow",children:[e.jsxs("a",{className:"research-follow-btn",href:N(h.pathname+h.search),children:[e.jsx(w,{"aria-hidden":"true"}),"Follow"]}),e.jsxs("span",{className:"research-follow-hint",children:["Sign in to ",f[o].toLowerCase(),"."]})]});const g=t.error||a.error;return e.jsxs("div",{className:"research-follow",children:[e.jsx("button",{type:"button",className:s?"research-follow-btn is-following":"research-follow-btn",disabled:a.isLoading||!!a.error||t.isPending,"aria-pressed":s,"aria-label":s?"Unfollow":"Follow",onClick:()=>t.mutate({kind:o,entityId:n,follow:!s}),children:s?e.jsxs(e.Fragment,{children:[e.jsx(S,{"aria-hidden":"true"}),e.jsx("span",{className:"research-follow-label",children:"Following"}),e.jsx("span",{className:"research-follow-label-hover",children:"Unfollow"})]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{"aria-hidden":"true"}),"Follow"]})}),g?e.jsx("span",{className:"research-follow-hint is-error",role:"alert",children:"Could not update follows. Please try again."}):s?m===d&&e.jsxs("span",{className:"research-follow-hint",role:"status",children:["Added to ",e.jsx(i,{to:"/following",children:"your Following feed"})," · ",e.jsx(i,{to:"/settings",children:"Manage in Settings"})]}):e.jsxs("span",{className:"research-follow-hint",children:[f[o]," in ",e.jsx(i,{to:"/following",children:"your Following feed"}),"."]})]})}export{R}; diff --git a/assets/SavedPapersView-B2fQDeYi.js b/assets/SavedPapersView-CCKo8hBZ.js similarity index 85% rename from assets/SavedPapersView-B2fQDeYi.js rename to assets/SavedPapersView-CCKo8hBZ.js index d11e5a8f08dd9366753600ef872e636d2014bb15..754a02f7e5d5b1e5dcb133859cf72f268dcef117 100644 --- a/assets/SavedPapersView-B2fQDeYi.js +++ b/assets/SavedPapersView-CCKo8hBZ.js @@ -1 +1 @@ -import{a as g,b as v,U as x,j as e,H as j,L as b,p as N}from"./index-DyXq7-Tg.js";import{P as f}from"./PaperCard-57p1OSGy.js";import{T as k}from"./SotaBadges-vbLLOUtT.js";import{S as r}from"./skeleton-C3IIzpSL.js";import{A as y,a as w}from"./alert-gbJBhAVE.js";import{a as A}from"./account-cbblajck.js";import{t as B}from"./transform-D46m70Qr.js";import{s as F}from"./savedPapersAuth-TV7AiXOw.js";import"./AuthorAvatar-B-9xS2Wo.js";import"./Icon-T4LYkEQj.js";import"./LatexTitle-Bkyz3jCs.js";import"./papers-Dh3ljlL0.js";import"./curation-YeS7FBYf.js";import"./safeExternalHref-CkBrsh84.js";import"./colors-BkWRhvFI.js";const Q=()=>{var d,l;const{user:i,isLoading:m}=g(),a=v({queryKey:[...N.feeds.saved],queryFn:()=>A.getBookmarks(),enabled:!!i,staleTime:30*1e3}),c=a.error instanceof x&&a.error.code==="saved_papers_bucket_authorization_required",o=!!a.data&&!a.data.bucket_connected,n=()=>{window.location.assign(F())};if(m)return e.jsxs("div",{className:"page",children:[e.jsx(r,{className:"h-10 w-1/3 mb-4"}),e.jsx(r,{className:"h-6 w-1/2 mb-8"})]});if(!i)return e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["Saved ",e.jsx("em",{children:"Papers"})]}),e.jsx("div",{className:"feed-subtitle",children:"Sign in with Hugging Face to save papers and revisit them later."})]})}),e.jsx("div",{className:"saved-signin-panel",children:e.jsx(j,{returnTo:"/saved"})})]});let h=0;return e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["Saved ",e.jsx("em",{children:"Papers"})]}),e.jsxs("div",{className:"feed-subtitle",children:[(d=a.data)!=null&&d.count?`${a.data.count.toLocaleString()} saved · grouped by domain`:"Your bookmarked papers, grouped by domain.",(l=a.data)!=null&&l.bucket_connected?e.jsxs(e.Fragment,{children:[" · ",e.jsx("a",{href:`https://huggingface.co/buckets/${i.username}/pwc-saved-papers`,target:"_blank",rel:"noopener noreferrer",children:"Open your Hugging Face Bucket"})]}):null]})]})}),c?e.jsxs("div",{className:"saved-bucket-migration",children:[e.jsx("p",{children:"Your saved papers are still safe in Papers With Code. Approve Bucket access to copy them into a private Hugging Face Bucket that belongs to you."}),e.jsx("button",{type:"button",className:"hf-signin-btn",onClick:n,children:"Approve and migrate saved papers"})]}):a.error?e.jsx(y,{variant:"destructive",className:"mb-4",children:e.jsx(w,{children:"Failed to load your saved papers. Please try again."})}):null,o&&a.data.bucket_migrated?e.jsxs("div",{className:"saved-bucket-migration",children:[e.jsx("p",{children:"Your saved papers are already in your private Hugging Face Bucket. Reconnect it in this browser to read from it and save new papers there."}),e.jsx("button",{type:"button",className:"hf-signin-btn",onClick:n,children:"Reconnect Hugging Face Bucket"})]}):o?e.jsxs("div",{className:"saved-bucket-migration",children:[e.jsxs("p",{children:[a.data.count?`Your ${a.data.count.toLocaleString()} saved ${a.data.count===1?"paper is":"papers are"} still available below. `:"When you save your first paper, ","Approve Bucket access to copy saved papers into a private Hugging Face Bucket that belongs to you. The existing data is kept until the copy is verified."]}),e.jsx("button",{type:"button",className:"hf-signin-btn",onClick:n,children:a.data.count?"Approve and migrate saved papers":"Use a Hugging Face Bucket"})]}):null,c||a.error?null:a.isLoading?e.jsx("div",{className:"paper-list",children:Array.from({length:4}).map((t,s)=>e.jsxs("div",{className:"paper-card",children:[e.jsx(r,{className:"h-[220px] w-[160px]"}),e.jsxs("div",{className:"paper-body",style:{flex:1,gap:12},children:[e.jsx(r,{className:"h-6 w-3/4"}),e.jsx(r,{className:"h-4 w-1/2"}),e.jsx(r,{className:"h-12 w-full"})]})]},s))}):!a.data||a.data.count===0?e.jsxs("div",{className:"no-results",children:["No saved papers yet."," ",e.jsx(b,{to:"/papers",className:"sidebar-link",style:{display:"inline"},children:"Browse papers →"})]}):a.data.areas.map(t=>e.jsxs("section",{className:"saved-area-section",children:[e.jsx("h2",{className:"saved-area-heading",children:t.name}),t.tasks.map(s=>{const p=s.papers.length;return e.jsxs("div",{className:"saved-task-block",children:[e.jsxs("div",{className:"saved-task-row",children:[s.slug?e.jsx(k,{slug:s.slug,label:s.name}):e.jsx("span",{className:"tag-chip",style:{background:"var(--surface)"},children:s.name}),e.jsxs("span",{className:"saved-task-count",children:[p," ",p===1?"paper":"papers"]})]}),e.jsx("div",{className:"paper-list",children:s.papers.map(u=>e.jsx(f,{paper:B(u),priority:h++<3},u.id))})]},`task-${t.id??"other"}-${s.id??"untagged"}`)})]},`area-${t.id??"other"}`))]})};export{Q as default}; +import{a as g,b as v,A as x,j as e,H as j,L as b,p as N}from"./index-CjdUkE4w.js";import{P as f}from"./PaperCard-dvXhr75r.js";import{T as k}from"./SotaBadges-CyScuNCv.js";import{S as r}from"./skeleton-DTWi7Ctg.js";import{A as y,a as w}from"./alert-BM9Xfuyy.js";import{a as A}from"./account-DoluPGSd.js";import{t as B}from"./transform-CRNzYLch.js";import{s as F}from"./savedPapersAuth-DT83MLdi.js";import"./AuthorAvatar-D9249Frl.js";import"./Icon-CGRs4BYD.js";import"./LatexTitle-DESKtS30.js";import"./papers-DgZwjF3K.js";import"./curation-CyyuHfv5.js";import"./safeExternalHref-CkBrsh84.js";import"./colors-BkWRhvFI.js";const U=()=>{var d,l;const{user:i,isLoading:m}=g(),a=v({queryKey:[...N.feeds.saved],queryFn:()=>A.getBookmarks(),enabled:!!i,staleTime:30*1e3}),c=a.error instanceof x&&a.error.code==="saved_papers_bucket_authorization_required",o=!!a.data&&!a.data.bucket_connected,n=()=>{window.location.assign(F())};if(m)return e.jsxs("div",{className:"page",children:[e.jsx(r,{className:"h-10 w-1/3 mb-4"}),e.jsx(r,{className:"h-6 w-1/2 mb-8"})]});if(!i)return e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["Saved ",e.jsx("em",{children:"Papers"})]}),e.jsx("div",{className:"feed-subtitle",children:"Sign in with Hugging Face to save papers and revisit them later."})]})}),e.jsx("div",{className:"saved-signin-panel",children:e.jsx(j,{returnTo:"/saved"})})]});let h=0;return e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["Saved ",e.jsx("em",{children:"Papers"})]}),e.jsxs("div",{className:"feed-subtitle",children:[(d=a.data)!=null&&d.count?`${a.data.count.toLocaleString()} saved · grouped by domain`:"Your bookmarked papers, grouped by domain.",(l=a.data)!=null&&l.bucket_connected?e.jsxs(e.Fragment,{children:[" · ",e.jsx("a",{href:`https://huggingface.co/buckets/${i.username}/pwc-saved-papers`,target:"_blank",rel:"noopener noreferrer",children:"Open your Hugging Face Bucket"})]}):null]})]})}),c?e.jsxs("div",{className:"saved-bucket-migration",children:[e.jsx("p",{children:"Your saved papers are still safe in Papers With Code. Approve Bucket access to copy them into a private Hugging Face Bucket that belongs to you."}),e.jsx("button",{type:"button",className:"hf-signin-btn",onClick:n,children:"Approve and migrate saved papers"})]}):a.error?e.jsx(y,{variant:"destructive",className:"mb-4",children:e.jsx(w,{children:"Failed to load your saved papers. Please try again."})}):null,o&&a.data.bucket_migrated?e.jsxs("div",{className:"saved-bucket-migration",children:[e.jsx("p",{children:"Your saved papers are already in your private Hugging Face Bucket. Reconnect it in this browser to read from it and save new papers there."}),e.jsx("button",{type:"button",className:"hf-signin-btn",onClick:n,children:"Reconnect Hugging Face Bucket"})]}):o?e.jsxs("div",{className:"saved-bucket-migration",children:[e.jsxs("p",{children:[a.data.count?`Your ${a.data.count.toLocaleString()} saved ${a.data.count===1?"paper is":"papers are"} still available below. `:"When you save your first paper, ","Approve Bucket access to copy saved papers into a private Hugging Face Bucket that belongs to you. The existing data is kept until the copy is verified."]}),e.jsx("button",{type:"button",className:"hf-signin-btn",onClick:n,children:a.data.count?"Approve and migrate saved papers":"Use a Hugging Face Bucket"})]}):null,c||a.error?null:a.isLoading?e.jsx("div",{className:"paper-list",children:Array.from({length:4}).map((t,s)=>e.jsxs("div",{className:"paper-card",children:[e.jsx(r,{className:"h-[220px] w-[160px]"}),e.jsxs("div",{className:"paper-body",style:{flex:1,gap:12},children:[e.jsx(r,{className:"h-6 w-3/4"}),e.jsx(r,{className:"h-4 w-1/2"}),e.jsx(r,{className:"h-12 w-full"})]})]},s))}):!a.data||a.data.count===0?e.jsxs("div",{className:"no-results",children:["No saved papers yet."," ",e.jsx(b,{to:"/papers",className:"sidebar-link",style:{display:"inline"},children:"Browse papers →"})]}):a.data.areas.map(t=>e.jsxs("section",{className:"saved-area-section",children:[e.jsx("h2",{className:"saved-area-heading",children:t.name}),t.tasks.map(s=>{const p=s.papers.length;return e.jsxs("div",{className:"saved-task-block",children:[e.jsxs("div",{className:"saved-task-row",children:[s.slug?e.jsx(k,{slug:s.slug,label:s.name}):e.jsx("span",{className:"tag-chip",style:{background:"var(--surface)"},children:s.name}),e.jsxs("span",{className:"saved-task-count",children:[p," ",p===1?"paper":"papers"]})]}),e.jsx("div",{className:"paper-list",children:s.papers.map(u=>e.jsx(f,{paper:B(u),priority:h++<3},u.id))})]},`task-${t.id??"other"}-${s.id??"untagged"}`)})]},`area-${t.id??"other"}`))]})};export{U as default}; diff --git a/assets/SearchOverlay-5zBt7fdP.js b/assets/SearchOverlay-Dvr0LreX.js similarity index 95% rename from assets/SearchOverlay-5zBt7fdP.js rename to assets/SearchOverlay-Dvr0LreX.js index e7ed99e94eccd346af0b8de314d11331751f8def..ed966f60e67f33ffe0ecd98ed166a51154db0c6c 100644 --- a/assets/SearchOverlay-5zBt7fdP.js +++ b/assets/SearchOverlay-Dvr0LreX.js @@ -1 +1 @@ -import{d as K,e as O,V as M,l as B,b as i,j as e,p as H}from"./index-DyXq7-Tg.js";import{L as U}from"./LatexTitle-Bkyz3jCs.js";import{c as x}from"./catalog-CRar2olQ.js";import{p as R}from"./papers-Dh3ljlL0.js";import{u as Y}from"./useDebounce-B9jkN7LV.js";import{c as G,h as V}from"./colors-BkWRhvFI.js";import{d as X}from"./transform-D46m70Qr.js";import"./curation-YeS7FBYf.js";const Z=10,S=6,W=350,v=3,ls=({open:t,onClose:h})=>{var A,C,w,P,Q,z;const f=K.useRef(null),$=O(),[c,D]=M.useState(""),a=Y(c,W),j=c.trim(),r=a.trim().length>=v,y=B();K.useEffect(()=>{var l;if(!t)return;(l=f.current)==null||l.focus();const s=N=>{N.key==="Escape"&&(N.preventDefault(),N.stopPropagation(),h())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[t,h]);const k=i({queryKey:[...H.feeds.searchOverlay,a],queryFn:()=>R.search(a,1,Z),enabled:t&&r,staleTime:6e4,retry:!1}),_=i({queryKey:["search-tasks",a],queryFn:()=>x.listTasks({q:a,page_size:6}),enabled:t&&r,staleTime:6e4,retry:!1}),b=i({queryKey:["search-methods",a],queryFn:()=>x.listMethods({q:a,page_size:6}),enabled:t&&r,staleTime:6e4,retry:!1}),E=i({queryKey:["search-benchmarks",a],queryFn:()=>x.listDatasets({q:a,page_size:6}),enabled:t&&r,staleTime:6e4,retry:!1}),F=i({queryKey:["search-authors",a],queryFn:()=>R.searchAuthors(a,S),enabled:t&&r,staleTime:6e4,retry:!1}),q=i({queryKey:["search-organizations",a],queryFn:()=>x.searchOrganizations(a,S),enabled:t&&r,staleTime:6e4,retry:!1});if(!t)return null;const o=((A=_.data)==null?void 0:A.results)||[],d=((C=b.data)==null?void 0:C.results)||[],u=((w=E.data)==null?void 0:w.results)||[],m=((P=F.data)==null?void 0:P.results)||[],p=((Q=q.data)==null?void 0:Q.results)||[],g=((z=k.data)==null?void 0:z.results)||[],I=k.isFetching||_.isFetching||b.isFetching||E.isFetching||F.isFetching||q.isFetching,L=o.length||g.length||d.length||u.length||m.length||p.length,n=s=>{h(),$(s)},T=()=>{const s=c.trim();s&&n(`/chat?q=${encodeURIComponent(s)}`)};return e.jsx("div",{className:"search-overlay",onClick:h,children:e.jsxs("div",{className:"search-modal",onClick:s=>s.stopPropagation(),children:[e.jsx("input",{ref:f,className:"search-modal-input",placeholder:"Search papers, tasks, methods, benchmarks, authors, or organizations…",value:c,onChange:s=>D(s.target.value),onKeyDown:s=>{y&&s.key==="Enter"&&(s.preventDefault(),T())}}),e.jsxs("div",{className:"search-results",children:[y&&c.trim()&&e.jsxs("button",{type:"button",className:"search-ask-row",onClick:T,children:[e.jsx("span",{className:"search-ask-chip",children:"assistant"}),e.jsxs("span",{className:"search-ask-text",children:["Ask: “",c.trim(),"”"]}),e.jsx("kbd",{children:"↵"})]}),!a&&e.jsxs("div",{className:"search-empty",children:["Try “diffusion”, “object detection”, or an arXiv id.",y&&e.jsx("span",{className:"search-empty-sub",children:"Press Enter to ask the assistant"})]}),a&&!r&&e.jsxs("div",{className:"search-empty",children:["Keep typing: results appear from ",v," characters."]}),r&&!I&&!L&&e.jsxs("div",{className:"search-empty",children:['No matches for "',c,'"']}),o.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-section-label",children:["Tasks · ",o.length]}),o.map(s=>{const l=G(V(s.slug||""));return e.jsxs("div",{className:"search-result-tag",onClick:()=>n(`/tasks/${s.slug}`),children:[e.jsx("span",{className:"dot",style:{width:6,height:6,borderRadius:"50%",background:l.dot}}),e.jsx("span",{className:"name",children:X(s.name,s.slug)}),s.paper_count!=null&&e.jsxs("span",{className:"count",children:[s.paper_count," papers"]})]},s.id)})]}),d.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-section-label",children:["Methods · ",d.length]}),d.map(s=>e.jsxs("div",{className:"search-result-tag",onClick:()=>n(`/methods/${s.slug||s.id}`),children:[e.jsx("span",{style:{fontFamily:"var(--mono)",fontWeight:600},children:s.name}),s.paper_count!=null&&e.jsxs("span",{className:"count",children:[s.paper_count," papers"]})]},s.id))]}),u.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-section-label",children:["Benchmarks · ",u.length]}),u.map(s=>e.jsxs("div",{className:"search-result-tag",onClick:()=>n(`/benchmark/${s.slug||s.id}`),children:[e.jsx("span",{className:"name",children:s.name}),s.paper_count!=null&&s.paper_count>0&&e.jsxs("span",{className:"count",children:[s.paper_count," entries"]})]},s.id))]}),m.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-section-label",children:["Authors · ",m.length]}),m.map(s=>e.jsxs("div",{className:"search-result-tag",onClick:()=>n(`/authors/${s.id}`),children:[e.jsx("span",{className:"name",children:s.full_name}),s.hf_username&&e.jsxs("span",{className:"handle",children:["@",s.hf_username]}),s.paper_count>0&&e.jsxs("span",{className:"count",children:[s.paper_count," papers"]})]},s.id))]}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-section-label",children:["Organizations · ",p.length]}),p.map(s=>e.jsxs("div",{className:"search-result-tag",onClick:()=>n(`/orgs/${s.slug}`),children:[s.logo_url&&e.jsx("img",{className:"logo",src:s.logo_url,alt:"",loading:"lazy"}),e.jsx("span",{className:"name",children:s.name}),s.paper_count!=null&&s.paper_count>0&&e.jsxs("span",{className:"count",children:[s.paper_count," papers"]})]},s.id))]}),g.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-section-label",children:["Papers · ",g.length]}),g.map(s=>{var l;return e.jsxs("div",{className:"search-result",onClick:()=>n(`/paper/${s.arxiv_id||s.id}`),children:[e.jsx("div",{className:"search-result-title",children:e.jsx(U,{title:s.title})}),e.jsxs("div",{className:"search-result-meta",children:[e.jsx("span",{children:s.arxiv_id?`arXiv:${s.arxiv_id}`:"External resource"}),((l=s.authors)==null?void 0:l[0])&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[s.authors[0],s.authors.length>1?" et al.":""]})]}),s.citation_count!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:["↑ ",s.citation_count.toLocaleString()]})]})]})]},s.id)})]}),j.length>=v&&e.jsxs("button",{type:"button",className:"search-view-all-row",onClick:()=>n(`/papers?search=${encodeURIComponent(j)}`),children:["View all paper results for “",j,"”"]})]})]})})};export{ls as default}; +import{d as K,e as O,V as M,l as B,b as i,j as e,p as H}from"./index-CjdUkE4w.js";import{L as U}from"./LatexTitle-DESKtS30.js";import{c as x}from"./catalog-qXcKve0z.js";import{p as R}from"./papers-DgZwjF3K.js";import{u as Y}from"./useDebounce-wGQ3PIQd.js";import{c as G,h as V}from"./colors-BkWRhvFI.js";import{d as X}from"./transform-CRNzYLch.js";import"./curation-CyyuHfv5.js";const Z=10,S=6,W=350,v=3,ls=({open:t,onClose:h})=>{var A,C,w,P,Q,z;const f=K.useRef(null),$=O(),[c,D]=M.useState(""),a=Y(c,W),j=c.trim(),r=a.trim().length>=v,y=B();K.useEffect(()=>{var l;if(!t)return;(l=f.current)==null||l.focus();const s=N=>{N.key==="Escape"&&(N.preventDefault(),N.stopPropagation(),h())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[t,h]);const k=i({queryKey:[...H.feeds.searchOverlay,a],queryFn:()=>R.search(a,1,Z),enabled:t&&r,staleTime:6e4,retry:!1}),_=i({queryKey:["search-tasks",a],queryFn:()=>x.listTasks({q:a,page_size:6}),enabled:t&&r,staleTime:6e4,retry:!1}),b=i({queryKey:["search-methods",a],queryFn:()=>x.listMethods({q:a,page_size:6}),enabled:t&&r,staleTime:6e4,retry:!1}),E=i({queryKey:["search-benchmarks",a],queryFn:()=>x.listDatasets({q:a,page_size:6}),enabled:t&&r,staleTime:6e4,retry:!1}),F=i({queryKey:["search-authors",a],queryFn:()=>R.searchAuthors(a,S),enabled:t&&r,staleTime:6e4,retry:!1}),q=i({queryKey:["search-organizations",a],queryFn:()=>x.searchOrganizations(a,S),enabled:t&&r,staleTime:6e4,retry:!1});if(!t)return null;const o=((A=_.data)==null?void 0:A.results)||[],d=((C=b.data)==null?void 0:C.results)||[],u=((w=E.data)==null?void 0:w.results)||[],m=((P=F.data)==null?void 0:P.results)||[],p=((Q=q.data)==null?void 0:Q.results)||[],g=((z=k.data)==null?void 0:z.results)||[],I=k.isFetching||_.isFetching||b.isFetching||E.isFetching||F.isFetching||q.isFetching,L=o.length||g.length||d.length||u.length||m.length||p.length,n=s=>{h(),$(s)},T=()=>{const s=c.trim();s&&n(`/chat?q=${encodeURIComponent(s)}`)};return e.jsx("div",{className:"search-overlay",onClick:h,children:e.jsxs("div",{className:"search-modal",onClick:s=>s.stopPropagation(),children:[e.jsx("input",{ref:f,className:"search-modal-input",placeholder:"Search papers, tasks, methods, benchmarks, authors, or organizations…",value:c,onChange:s=>D(s.target.value),onKeyDown:s=>{y&&s.key==="Enter"&&(s.preventDefault(),T())}}),e.jsxs("div",{className:"search-results",children:[y&&c.trim()&&e.jsxs("button",{type:"button",className:"search-ask-row",onClick:T,children:[e.jsx("span",{className:"search-ask-chip",children:"assistant"}),e.jsxs("span",{className:"search-ask-text",children:["Ask: “",c.trim(),"”"]}),e.jsx("kbd",{children:"↵"})]}),!a&&e.jsxs("div",{className:"search-empty",children:["Try “diffusion”, “object detection”, or an arXiv id.",y&&e.jsx("span",{className:"search-empty-sub",children:"Press Enter to ask the assistant"})]}),a&&!r&&e.jsxs("div",{className:"search-empty",children:["Keep typing: results appear from ",v," characters."]}),r&&!I&&!L&&e.jsxs("div",{className:"search-empty",children:['No matches for "',c,'"']}),o.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-section-label",children:["Tasks · ",o.length]}),o.map(s=>{const l=G(V(s.slug||""));return e.jsxs("div",{className:"search-result-tag",onClick:()=>n(`/tasks/${s.slug}`),children:[e.jsx("span",{className:"dot",style:{width:6,height:6,borderRadius:"50%",background:l.dot}}),e.jsx("span",{className:"name",children:X(s.name,s.slug)}),s.paper_count!=null&&e.jsxs("span",{className:"count",children:[s.paper_count," papers"]})]},s.id)})]}),d.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-section-label",children:["Methods · ",d.length]}),d.map(s=>e.jsxs("div",{className:"search-result-tag",onClick:()=>n(`/methods/${s.slug||s.id}`),children:[e.jsx("span",{style:{fontFamily:"var(--mono)",fontWeight:600},children:s.name}),s.paper_count!=null&&e.jsxs("span",{className:"count",children:[s.paper_count," papers"]})]},s.id))]}),u.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-section-label",children:["Benchmarks · ",u.length]}),u.map(s=>e.jsxs("div",{className:"search-result-tag",onClick:()=>n(`/benchmark/${s.slug||s.id}`),children:[e.jsx("span",{className:"name",children:s.name}),s.paper_count!=null&&s.paper_count>0&&e.jsxs("span",{className:"count",children:[s.paper_count," entries"]})]},s.id))]}),m.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-section-label",children:["Authors · ",m.length]}),m.map(s=>e.jsxs("div",{className:"search-result-tag",onClick:()=>n(`/authors/${s.id}`),children:[e.jsx("span",{className:"name",children:s.full_name}),s.hf_username&&e.jsxs("span",{className:"handle",children:["@",s.hf_username]}),s.paper_count>0&&e.jsxs("span",{className:"count",children:[s.paper_count," papers"]})]},s.id))]}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-section-label",children:["Organizations · ",p.length]}),p.map(s=>e.jsxs("div",{className:"search-result-tag",onClick:()=>n(`/orgs/${s.slug}`),children:[s.logo_url&&e.jsx("img",{className:"logo",src:s.logo_url,alt:"",loading:"lazy"}),e.jsx("span",{className:"name",children:s.name}),s.paper_count!=null&&s.paper_count>0&&e.jsxs("span",{className:"count",children:[s.paper_count," papers"]})]},s.id))]}),g.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-section-label",children:["Papers · ",g.length]}),g.map(s=>{var l;return e.jsxs("div",{className:"search-result",onClick:()=>n(`/paper/${s.arxiv_id||s.id}`),children:[e.jsx("div",{className:"search-result-title",children:e.jsx(U,{title:s.title})}),e.jsxs("div",{className:"search-result-meta",children:[e.jsx("span",{children:s.arxiv_id?`arXiv:${s.arxiv_id}`:"External resource"}),((l=s.authors)==null?void 0:l[0])&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[s.authors[0],s.authors.length>1?" et al.":""]})]}),s.citation_count!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:["↑ ",s.citation_count.toLocaleString()]})]})]})]},s.id)})]}),j.length>=v&&e.jsxs("button",{type:"button",className:"search-view-all-row",onClick:()=>n(`/papers?search=${encodeURIComponent(j)}`),children:["View all paper results for “",j,"”"]})]})]})})};export{ls as default}; diff --git a/assets/SettingsView-BuCdwlbq.js b/assets/SettingsView-DAkLrhMP.js similarity index 97% rename from assets/SettingsView-BuCdwlbq.js rename to assets/SettingsView-DAkLrhMP.js index 90cf86349540593064a12181c14204a8230175c0..f4702e2a32c4e5f691a48e7f12a1bf8317838ee4 100644 --- a/assets/SettingsView-BuCdwlbq.js +++ b/assets/SettingsView-DAkLrhMP.js @@ -1,4 +1,4 @@ -import{s as k,a as A,c as ce,d as L,b as I,r as Q,j as e,L as T,i as W,H as C,h as de,aw as he,l as ue,V as P,U as ae}from"./index-DyXq7-Tg.js";import{u as E}from"./useMutation-UWxBeqtn.js";import{a as ge,T as se,r as z,u as me,g as pe}from"./researchTopic-DbX0eko-.js";import{S as K}from"./switch-nfvTohnt.js";import{S as fe}from"./sparkles-CcIiUzzc.js";import{A as ye}from"./arrow-right-BzPanrWZ.js";import{T as xe}from"./trophy-BtgLmZ39.js";import{c as N}from"./chat-Ix1IrIwq.js";import{u as je,f as be}from"./useDocumentTitle-DcxM2Zv_.js";import{a as ve,u as we,r as ke,O as Y}from"./openrouter-o51Eagw8.js";import{u as Ne}from"./preferences-COzeOLyS.js";import{E as ne}from"./external-link-orY1Xz1I.js";import{M as Ce}from"./moon-DMVsctTM.js";import"./index-C041TDos.js";import"./account-cbblajck.js";/** +import{s as k,a as A,c as ce,d as L,b as I,r as Q,j as e,L as T,i as W,H as C,h as de,aw as he,l as ue,V as P,A as ae}from"./index-CjdUkE4w.js";import{u as E}from"./useMutation-BYtVrkc7.js";import{a as ge,T as se,r as z,u as me,g as pe}from"./researchTopic-NmABF6tT.js";import{S as K}from"./switch-hcLL2FH0.js";import{S as fe}from"./sparkles-CIfeDmV2.js";import{A as ye}from"./arrow-right-BrRhWCQS.js";import{T as xe}from"./trophy-BQy3NGXy.js";import{c as N}from"./chat-B1EBF720.js";import{u as je,f as be}from"./useDocumentTitle-2Ho8_KfW.js";import{a as ve,u as we,r as ke,O as Y}from"./openrouter-B-ghWDkd.js";import{u as Ne}from"./preferences-DMhkYrri.js";import{E as ne}from"./external-link-CTLWFJ8S.js";import{M as Ce}from"./moon-HVqBvdxs.js";import"./index-BxR27SAB.js";import"./account-DoluPGSd.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/SharedChatView-BS81XNKW.js b/assets/SharedChatView-BS81XNKW.js new file mode 100644 index 0000000000000000000000000000000000000000..b3c54f0e88e0ef910b018ffc7e90e25d2a4237b8 --- /dev/null +++ b/assets/SharedChatView-BS81XNKW.js @@ -0,0 +1 @@ +import{u as x,e as g,d as o,b as v,j as e,A as f,q as j}from"./index-CjdUkE4w.js";import{A as b,a as y,C as S,U as w,b as N,t as k}from"./chatLifecycle-B6B3Dpfi.js";import{e as C,p as q,f as A,q as P}from"./chatSessions-9VEG8seW.js";import{c as _}from"./chat-B1EBF720.js";/* empty css */import"./hover-card-CIBIV2Hx.js";import"./CatalogEntityPreviewLink-DY_jhXy9.js";import"./catalog-qXcKve0z.js";import"./github-4bW4WI_e.js";import"./file-text-CHlxsNJC.js";import"./PaperPreviewLink-zGfFNaz6.js";import"./index-tLcwYp0U.js";import"./index-Dj6aE-6E.js";import"./katex-DkKDou_j.js";import"./papers-DgZwjF3K.js";import"./curation-CyyuHfv5.js";import"./useMutation-BYtVrkc7.js";import"./thumbs-up-Dn_5H93T.js";import"./copy-SoF5zg-g.js";import"./queryOptions-C9woPjwX.js";import"./arrow-left-CkQb0MI4.js";import"./external-link-CTLWFJ8S.js";import"./plus-AztI1566.js";import"./search-DxMn7VKI.js";import"./chevron-up-BwiJ46dh.js";import"./AuthorAvatar-D9249Frl.js";const m=s=>s instanceof f&&s.status===404,E=({detail:s})=>{const[n,i]=o.useState(()=>q(s)),h=o.useMemo(()=>A(n),[n]),l=(t,p)=>{i(u=>k(u,t,p))};return e.jsx("div",{className:"shared-chat-transcript",children:n.map(t=>t.role==="user"?e.jsx(w,{id:t.id,text:t.text??"",paperMentions:t.paperMentions??[],paperSelection:t.paperSelection},t.id):e.jsx(N,{msg:t,papers:h,onToggleBlock:l},t.id))})},se=()=>{const{shareId:s=""}=x(),n=g(),i=j(),[h,l]=o.useState(60),t=v({queryKey:["shared-chat",s],queryFn:()=>_.getSharedChat(s),retry:(r,a)=>!m(a)&&r<1});o.useEffect(()=>{const r=document.title,a=document.head.querySelector('meta[name="robots"]'),c=a==null?void 0:a.content,d=a??document.createElement("meta");return d.name="robots",d.content="noindex,nofollow",a||document.head.appendChild(d),document.title="Shared conversation",()=>{document.title=r,a?a.content=c??"":d.remove()}},[]),o.useLayoutEffect(()=>{const r=document.querySelector(".app-header");if(!r)return;const a=()=>l(r.offsetHeight);a();const c=new ResizeObserver(a);return c.observe(r),()=>c.disconnect()},[]);const p=r=>{P(r,void 0,{autoSend:!1}),n("/chat")},u=m(t.error);return t.isLoading?e.jsxs("div",{className:"shared-chat-state",role:"status",children:[e.jsx(C,{})," Loading shared conversation…"]}):u?e.jsxs("div",{className:"shared-chat-state shared-chat-not-found",children:[e.jsx("h1",{children:"Shared conversation not found"}),e.jsx("p",{children:"This link is invalid or is no longer available."})]}):t.isError||!t.data?e.jsxs("div",{className:"shared-chat-state",role:"alert",children:[e.jsx("h1",{children:"Couldn’t load this conversation"}),e.jsx("p",{children:"Please check your connection and try again."}),e.jsx("button",{type:"button",onClick:()=>void t.refetch(),children:"Try again"})]}):e.jsx(b,{workspaceKey:`share:${s}:${t.data.updated_at}`,autoOpenOnMount:!0,children:e.jsxs("div",{className:"shared-chat-page",style:{height:`calc(100dvh - ${h}px)`},children:[e.jsxs("div",{className:"shared-chat-heading",children:[e.jsx("h1",{children:"Shared conversation"}),i&&e.jsx("span",{className:"chat-staging-badge",children:"Staging"})]}),e.jsx(y,{variant:"shared",children:e.jsxs("div",{className:"shared-chat-content","data-testid":"shared-conversation-pane",children:[e.jsx(E,{detail:t.data},t.data.updated_at),t.data.model_label&&e.jsxs("div",{className:"shared-chat-attribution",children:[e.jsxs("span",{children:["Generated with ",t.data.model_label]}),t.data.model_provider==="huggingface"&&e.jsxs("span",{children:["Powered by ",e.jsx("span",{"aria-hidden":"true",children:"🤗"})," ",e.jsx("a",{href:"https://huggingface.co/docs/inference-providers/en/index",target:"_blank",rel:"noreferrer",children:"Inference Providers"})]}),t.data.model_provider==="openrouter"&&e.jsxs("span",{children:["Powered by ",e.jsx("a",{href:"https://openrouter.ai",target:"_blank",rel:"noreferrer",children:"OpenRouter"})]}),t.data.model_provider==="openai"&&e.jsx("span",{children:"Powered by OpenAI"})]}),e.jsxs("section",{className:"shared-chat-fresh","aria-labelledby":"shared-chat-fresh-title",children:[e.jsx("h2",{id:"shared-chat-fresh-title",children:"Start a new conversation"}),e.jsx("p",{children:"Your new question starts with an empty context."}),i&&e.jsxs("div",{className:"shared-chat-access-note",role:"note",children:[e.jsx("strong",{children:"Limited staging preview."})," Starting a chat is available only to approved Hugging Face users."]}),e.jsx(S,{onSend:r=>p(r.text),placeholder:"Ask a new research question…"})]})]})})]})})};export{se as default}; diff --git a/assets/SharedChatView-Cd2cL7B4.js b/assets/SharedChatView-Cd2cL7B4.js deleted file mode 100644 index 6a2ea7c72f1ee18871820ace0b12b9a58c9cf56c..0000000000000000000000000000000000000000 --- a/assets/SharedChatView-Cd2cL7B4.js +++ /dev/null @@ -1 +0,0 @@ -import{u as f,e as x,d as h,b as g,j as e,q as v}from"./index-DyXq7-Tg.js";import{A as j,a as b,C as y,U as S,b as k}from"./ArtifactWorkspace-Ya79_F5k.js";import{C as m,e as w,p as N,q,g as C}from"./chatSessions-Ck_dyM0d.js";/* empty css */import"./hover-card-B45EJIn_.js";import"./CatalogEntityPreviewLink-BktpwL3_.js";import"./catalog-CRar2olQ.js";import"./github-RNrgGHRT.js";import"./file-text-dvKtHbmD.js";import"./PaperPreviewLink-CpCZSa8K.js";import"./index-mCi_y_l3.js";import"./index-2CvJmBVB.js";import"./katex-DkKDou_j.js";import"./papers-Dh3ljlL0.js";import"./curation-YeS7FBYf.js";import"./useMutation-UWxBeqtn.js";import"./chat-Ix1IrIwq.js";import"./copy-CxR0OKx2.js";import"./thumbs-up-CPLlGli7.js";import"./arrow-left-PA_b6law.js";import"./external-link-orY1Xz1I.js";import"./plus-Yh42pKZz.js";import"./search-8ssWDP68.js";import"./chevron-up-DYSYRyvz.js";import"./AuthorAvatar-B-9xS2Wo.js";const _=({detail:i})=>{const[d,l]=h.useState(()=>N(i)),p=h.useMemo(()=>{const t={};for(const c of d)for(const n of c.blocks??[])if(n.kind==="tool")for(const r of n.results??[])t[r.route_id]=r;return t},[d]),u=(t,c)=>{l(n=>n.map(r=>{var a;return r.id!==t?r:{...r,blocks:(a=r.blocks)==null?void 0:a.map((s,o)=>o===c&&(s.kind==="reasoning"||s.kind==="tool")?{...s,open:!s.open}:s)}}))};return e.jsx("div",{className:"shared-chat-transcript",children:d.map(t=>t.role==="user"?e.jsx(S,{id:t.id,text:t.text??"",paperMentions:t.paperMentions??[],paperSelection:t.paperSelection},t.id):e.jsx(k,{msg:t,papers:p,onToggleBlock:u},t.id))})},ee=()=>{const{shareId:i=""}=f(),d=x(),l=v(),[p,u]=h.useState(60),t=g({queryKey:["shared-chat",i],queryFn:()=>C(i),retry:(r,a)=>!(a instanceof m&&a.status===404)&&r<1});h.useEffect(()=>{const r=document.title,a=document.head.querySelector('meta[name="robots"]'),s=a==null?void 0:a.content,o=a??document.createElement("meta");return o.name="robots",o.content="noindex,nofollow",a||document.head.appendChild(o),document.title="Shared conversation",()=>{document.title=r,a?a.content=s??"":o.remove()}},[]),h.useLayoutEffect(()=>{const r=document.querySelector(".app-header");if(!r)return;const a=()=>u(r.offsetHeight);a();const s=new ResizeObserver(a);return s.observe(r),()=>s.disconnect()},[]);const c=r=>{q(r,void 0,{autoSend:!1}),d("/chat")},n=t.error instanceof m&&t.error.status===404;return t.isLoading?e.jsxs("div",{className:"shared-chat-state",role:"status",children:[e.jsx(w,{})," Loading shared conversation…"]}):n?e.jsxs("div",{className:"shared-chat-state shared-chat-not-found",children:[e.jsx("h1",{children:"Shared conversation not found"}),e.jsx("p",{children:"This link is invalid or is no longer available."})]}):t.isError||!t.data?e.jsxs("div",{className:"shared-chat-state",role:"alert",children:[e.jsx("h1",{children:"Couldn’t load this conversation"}),e.jsx("p",{children:"Please check your connection and try again."}),e.jsx("button",{type:"button",onClick:()=>void t.refetch(),children:"Try again"})]}):e.jsx(j,{workspaceKey:`share:${i}:${t.data.updated_at}`,autoOpenOnMount:!0,children:e.jsxs("div",{className:"shared-chat-page",style:{height:`calc(100dvh - ${p}px)`},children:[e.jsxs("div",{className:"shared-chat-heading",children:[e.jsx("h1",{children:"Shared conversation"}),l&&e.jsx("span",{className:"chat-staging-badge",children:"Staging"})]}),e.jsx(b,{variant:"shared",children:e.jsxs("div",{className:"shared-chat-content","data-testid":"shared-conversation-pane",children:[e.jsx(_,{detail:t.data},t.data.updated_at),t.data.model_label&&e.jsxs("div",{className:"shared-chat-attribution",children:[e.jsxs("span",{children:["Generated with ",t.data.model_label]}),t.data.model_provider==="huggingface"&&e.jsxs("span",{children:["Powered by ",e.jsx("span",{"aria-hidden":"true",children:"🤗"})," ",e.jsx("a",{href:"https://huggingface.co/docs/inference-providers/en/index",target:"_blank",rel:"noreferrer",children:"Inference Providers"})]}),t.data.model_provider==="openrouter"&&e.jsxs("span",{children:["Powered by ",e.jsx("a",{href:"https://openrouter.ai",target:"_blank",rel:"noreferrer",children:"OpenRouter"})]}),t.data.model_provider==="openai"&&e.jsx("span",{children:"Powered by OpenAI"})]}),e.jsxs("section",{className:"shared-chat-fresh","aria-labelledby":"shared-chat-fresh-title",children:[e.jsx("h2",{id:"shared-chat-fresh-title",children:"Start a new conversation"}),e.jsx("p",{children:"Your new question starts with an empty context."}),l&&e.jsxs("div",{className:"shared-chat-access-note",role:"note",children:[e.jsx("strong",{children:"Limited staging preview."})," Starting a chat is available only to approved Hugging Face users."]}),e.jsx(y,{onSend:r=>c(r.text),placeholder:"Ask a new research question…"})]})]})})]})})};export{ee as default}; diff --git a/assets/SignInToEditDialog-B-oWVno5.js b/assets/SignInToEditDialog-rWxdYNRK.js similarity index 95% rename from assets/SignInToEditDialog-B-oWVno5.js rename to assets/SignInToEditDialog-rWxdYNRK.js index 296f74a27de6380ebe94c8f5bb5cc008c29058d6..58ddde7f2a869bc6d0e2b2e894ace05256b084cd 100644 --- a/assets/SignInToEditDialog-B-oWVno5.js +++ b/assets/SignInToEditDialog-rWxdYNRK.js @@ -1,4 +1,4 @@ -import{s as be,d as a,j as e,ad as je,G as fe,ae as ye,x as Ne,y as we,X as Se,C as _e,H as ke}from"./index-DyXq7-Tg.js";import{B as P}from"./button-DZeAbOf2.js";import{I as u}from"./input-DJqCAbs7.js";import{T as Ce}from"./textarea-DPixlM5U.js";import{S as se}from"./searchable-select-DiDLwvbI.js";import{D as ie,a as oe,c as le,b as ce,d as de,e as De}from"./dialog-CfM0Uql2.js";import{u as Ie}from"./useMutation-UWxBeqtn.js";import{s as b,p as j}from"./submissions-Cz_J-Ha2.js";import{c as te}from"./catalog-CRar2olQ.js";import{L as Ee}from"./loader-circle-C75KLEgx.js";/** +import{s as be,d as a,j as e,ad as je,I as fe,ae as ye,x as Ne,y as we,X as Se,C as _e,H as ke}from"./index-CjdUkE4w.js";import{B as P}from"./button-DetZl_ch.js";import{I as u}from"./input-7i-rZ7fA.js";import{T as Ce}from"./textarea-biscLKBK.js";import{S as se}from"./searchable-select-EPf13F1I.js";import{D as ie,a as oe,c as le,b as ce,d as de,e as De}from"./dialog-BzX9PD3v.js";import{u as Ie}from"./useMutation-BYtVrkc7.js";import{s as b,p as j}from"./submissions-CQ6M0giV.js";import{c as te}from"./catalog-qXcKve0z.js";import{L as Ee}from"./loader-circle-xTdSzHv_.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/SotaBadges-vbLLOUtT.js b/assets/SotaBadges-CyScuNCv.js similarity index 97% rename from assets/SotaBadges-vbLLOUtT.js rename to assets/SotaBadges-CyScuNCv.js index 0b2a5d27c9a9ae7da16cd4685cb80fb4c362dd7e..9f712be7fed93d6b222b39043abb94386027ba4d 100644 --- a/assets/SotaBadges-vbLLOUtT.js +++ b/assets/SotaBadges-CyScuNCv.js @@ -1 +1 @@ -import{e as M,j as e,V as x,L as C}from"./index-DyXq7-Tg.js";import{h as F,c as E}from"./colors-BkWRhvFI.js";import{d as A,h as P}from"./transform-D46m70Qr.js";const D=({slug:t,label:s,onClick:r})=>{const a=M(),j=F(t),o=E(j),p=c=>{if(c.stopPropagation(),r){r(t);return}a(`/tasks/${t}`)};return e.jsxs("span",{className:"tag-chip",style:{background:o.bg,color:o.text},onClick:p,children:[e.jsx("span",{className:"dot",style:{background:o.dot}}),A(s||P(t),t)]})},I=({method:t,onClick:s})=>{const r=M(),a=t.slug||t.id||"";if(!a)return null;const j=o=>{if(o.stopPropagation(),s){s(a);return}r(`/methods/${a}`)};return e.jsx("span",{className:"method-chip",onClick:j,children:t.name})},W=t=>{let s=2166136261;for(let r=0;r(s=Math.imul(s^s>>>15,2246822507),s=Math.imul(s^s>>>13,3266489909),s^=s>>>16,(s>>>0)%1e4/1e4)},O=({paperId:t})=>{const s=W(t),r=160,a=220,j=[.85+s()*.1,.55+s()*.25],o=.45+s()*.3,p=[],c=9+Math.floor(s()*3);for(let y=0;y.3,l=Math.floor(s()*3),m=[],$=6+Math.floor(s()*3);for(let y=0;y<$;y++)m.push(.5+s()*.45);const d="#9A9588",u="#3A352D",i=5,h=(r-i*2-2)/2,k=i,f=i+h+2;let w=i+2;const R=w;w+=6;const T=w+1;w+=5;const L=w;w+=3;const g=w+1;return e.jsx("div",{style:{width:r,height:a,background:"#FDFCF9",border:"1px solid var(--hairline-strong)",borderRadius:2,boxShadow:"0 1px 0 rgba(0,0,0,0.04), 0 4px 8px -4px rgba(0,0,0,0.08)",flexShrink:0,overflow:"hidden",position:"relative"},children:e.jsxs("svg",{width:r,height:a,viewBox:`0 0 ${r} ${a}`,style:{display:"block"},children:[j.map((y,v)=>e.jsx("rect",{x:i+(r-i*2)*(1-y)/2,y:R+v*2.4,width:(r-i*2)*y,height:1.4,fill:u,rx:.3},`t${v}`)),e.jsx("rect",{x:i+(r-i*2)*(1-o)/2,y:T,width:(r-i*2)*o,height:.9,fill:d,opacity:.7,rx:.2}),e.jsx("rect",{x:i,y:L,width:6,height:1,fill:u,opacity:.6}),p.map((y,v)=>{const b=g+v*2.1;return b>a-i-1?null:e.jsx("rect",{x:k,y:b,width:h*y,height:.8,fill:d,opacity:.55,rx:.2},`l${v}`)}),n&&e.jsxs("g",{children:[e.jsx("rect",{x:f,y:g,width:h,height:14,fill:"#F0EBE0",stroke:d,strokeWidth:.3,opacity:.9}),l===0&&e.jsx("g",{stroke:u,strokeWidth:.4,fill:"none",opacity:.6,children:e.jsx("polyline",{points:`${f+2},${g+11} ${f+6},${g+8} ${f+10},${g+9} ${f+14},${g+5} ${f+18},${g+6} ${f+22},${g+3}`})}),l===1&&e.jsxs("g",{opacity:.55,children:[e.jsx("circle",{cx:f+h/2,cy:g+7,r:3.5,fill:u}),e.jsx("rect",{x:f+2,y:g+11,width:h-4,height:1.5,fill:d})]}),l===2&&e.jsxs("g",{opacity:.55,children:[e.jsx("rect",{x:f+3,y:g+5,width:h-6,height:1,fill:u}),e.jsx("rect",{x:f+6,y:g+8,width:h-12,height:.8,fill:u})]})]}),m.map((y,v)=>{const b=g+(n?16:0)+v*2.1;return b>a-i-1?null:e.jsx("rect",{x:f,y:b,width:h*y,height:.8,fill:d,opacity:.55,rx:.2},`r${v}`)})]})})},Y=({paperId:t,title:s,thumbnailUrl:r,priority:a=!1})=>{const[j,o]=x.useState(!1),[p,c]=x.useState(0),[n,l]=x.useState(a),m=x.useRef(null);x.useEffect(()=>{o(!1),c(0)},[r]);const $=x.useMemo(()=>{if(!r)return null;if(p===0)return r;const d=r.includes("?")?"&":"?";return`${r}${d}retry=${p}`},[r,p]);return x.useEffect(()=>{if(a||n)return;const d=m.current;if(!d)return;const u=new IntersectionObserver(([i])=>{i.isIntersecting&&(l(!0),u.disconnect())},{rootMargin:"250px"});return u.observe(d),()=>u.disconnect()},[a,n]),r&&!j?e.jsx("div",{ref:m,style:{width:160,height:220,background:"#FDFCF9",border:"1px solid var(--hairline-strong)",borderRadius:2,boxShadow:"0 1px 0 rgba(0,0,0,0.04), 0 4px 8px -4px rgba(0,0,0,0.08)",flexShrink:0,overflow:"hidden",position:"relative"},children:(a||n)&&$&&e.jsx("img",{src:$,alt:`Thumbnail for ${s}`,loading:a?"eager":"lazy",decoding:"async",fetchPriority:a?"high":"auto",style:{width:"100%",height:"100%",objectFit:"contain",display:"block"},onError:()=>{if(p<1){c(d=>d+1);return}o(!0)}},$)}):e.jsx(O,{paperId:t})},S={1:"SOTA 🏆",2:"#2",3:"#3"},N=({units:t,paperHref:s})=>{const r=x.useRef(null),a=x.useRef(null),[j,o]=x.useState(t.length);if(x.useLayoutEffect(()=>{const n=r.current,l=a.current;if(!n||!l||t.length===0)return;const m=u=>(l.textContent=u,l.scrollWidth),$=()=>{const u=n.clientWidth;if(u<=0)return;let i=0,h=0;for(const k of t){const f=m(k.measureText);if(i+f<=u)i+=f,h+=1;else break}if(h0&&i+m(` · +${t.length-h} more`)>u;)h-=1,i-=m(t[h].measureText);h===0&&(h=1)}o(h)};$();const d=new ResizeObserver($);return d.observe(n),()=>d.disconnect()},[t]),t.length===0)return null;const p=t.slice(0,Math.max(1,Math.min(j,t.length))),c=t.length-p.length;return e.jsxs("div",{className:"paper-sota",ref:r,children:[e.jsx("span",{ref:a,className:"paper-sota-measure","aria-hidden":"true"}),p.map((n,l)=>e.jsxs(x.Fragment,{children:[n.isGroupStart?e.jsxs(e.Fragment,{children:[l>0&&e.jsx("span",{className:"paper-sota-sep",children:" · "}),e.jsx("span",{className:`paper-sota-label${n.rank===1?" paper-sota-label--sota":""}`,children:S[n.rank]}),e.jsx("span",{className:"paper-sota-on",children:" on "})]}):e.jsx("span",{className:"paper-sota-sep",children:", "}),n.href?e.jsx(C,{to:n.href,className:"paper-sota-name",onClick:m=>m.stopPropagation(),children:n.name}):e.jsx("span",{className:"paper-sota-name",children:n.name})]},`${n.href||n.name}-${l}`)),c>0&&e.jsxs(C,{to:`${s}#results`,className:"paper-sota-more",onClick:n=>n.stopPropagation(),children:[" · +",c," more"]})]})},V=({ranks:t,paperHref:s,wrap:r=!1})=>{const a=x.useMemo(()=>{const o=[];let p=!0;for(const c of[1,2,3]){const n=t.filter(l=>l.rank===c);n.forEach((l,m)=>{const $=m===0,d=$?`${p?"":" · "}${S[c]} on `:", ";o.push({name:l.name,href:l.href,rank:c,isGroupStart:$,measureText:d+l.name})}),n.length>0&&(p=!1)}return o},[t]),j=x.useMemo(()=>[1,2,3].map(o=>t.filter(c=>c.rank===o).map((c,n)=>({name:c.name,href:c.href,rank:o,isGroupStart:n===0,measureText:(n===0?`${S[o]} on `:", ")+c.name}))).filter(o=>o.length>0),[t]);return r?j.length===0?null:e.jsx("div",{className:"paper-sota-stack",children:j.map(o=>e.jsx(N,{units:o,paperHref:s},o[0].rank))}):a.length===0?null:e.jsx(N,{units:a,paperHref:s})};export{I as M,Y as P,V as S,D as T}; +import{e as M,j as e,V as x,L as C}from"./index-CjdUkE4w.js";import{h as F,c as E}from"./colors-BkWRhvFI.js";import{d as A,h as P}from"./transform-CRNzYLch.js";const D=({slug:t,label:s,onClick:r})=>{const a=M(),j=F(t),o=E(j),p=c=>{if(c.stopPropagation(),r){r(t);return}a(`/tasks/${t}`)};return e.jsxs("span",{className:"tag-chip",style:{background:o.bg,color:o.text},onClick:p,children:[e.jsx("span",{className:"dot",style:{background:o.dot}}),A(s||P(t),t)]})},I=({method:t,onClick:s})=>{const r=M(),a=t.slug||t.id||"";if(!a)return null;const j=o=>{if(o.stopPropagation(),s){s(a);return}r(`/methods/${a}`)};return e.jsx("span",{className:"method-chip",onClick:j,children:t.name})},W=t=>{let s=2166136261;for(let r=0;r(s=Math.imul(s^s>>>15,2246822507),s=Math.imul(s^s>>>13,3266489909),s^=s>>>16,(s>>>0)%1e4/1e4)},O=({paperId:t})=>{const s=W(t),r=160,a=220,j=[.85+s()*.1,.55+s()*.25],o=.45+s()*.3,p=[],c=9+Math.floor(s()*3);for(let y=0;y.3,l=Math.floor(s()*3),m=[],$=6+Math.floor(s()*3);for(let y=0;y<$;y++)m.push(.5+s()*.45);const d="#9A9588",u="#3A352D",i=5,h=(r-i*2-2)/2,k=i,f=i+h+2;let w=i+2;const R=w;w+=6;const T=w+1;w+=5;const L=w;w+=3;const g=w+1;return e.jsx("div",{style:{width:r,height:a,background:"#FDFCF9",border:"1px solid var(--hairline-strong)",borderRadius:2,boxShadow:"0 1px 0 rgba(0,0,0,0.04), 0 4px 8px -4px rgba(0,0,0,0.08)",flexShrink:0,overflow:"hidden",position:"relative"},children:e.jsxs("svg",{width:r,height:a,viewBox:`0 0 ${r} ${a}`,style:{display:"block"},children:[j.map((y,v)=>e.jsx("rect",{x:i+(r-i*2)*(1-y)/2,y:R+v*2.4,width:(r-i*2)*y,height:1.4,fill:u,rx:.3},`t${v}`)),e.jsx("rect",{x:i+(r-i*2)*(1-o)/2,y:T,width:(r-i*2)*o,height:.9,fill:d,opacity:.7,rx:.2}),e.jsx("rect",{x:i,y:L,width:6,height:1,fill:u,opacity:.6}),p.map((y,v)=>{const b=g+v*2.1;return b>a-i-1?null:e.jsx("rect",{x:k,y:b,width:h*y,height:.8,fill:d,opacity:.55,rx:.2},`l${v}`)}),n&&e.jsxs("g",{children:[e.jsx("rect",{x:f,y:g,width:h,height:14,fill:"#F0EBE0",stroke:d,strokeWidth:.3,opacity:.9}),l===0&&e.jsx("g",{stroke:u,strokeWidth:.4,fill:"none",opacity:.6,children:e.jsx("polyline",{points:`${f+2},${g+11} ${f+6},${g+8} ${f+10},${g+9} ${f+14},${g+5} ${f+18},${g+6} ${f+22},${g+3}`})}),l===1&&e.jsxs("g",{opacity:.55,children:[e.jsx("circle",{cx:f+h/2,cy:g+7,r:3.5,fill:u}),e.jsx("rect",{x:f+2,y:g+11,width:h-4,height:1.5,fill:d})]}),l===2&&e.jsxs("g",{opacity:.55,children:[e.jsx("rect",{x:f+3,y:g+5,width:h-6,height:1,fill:u}),e.jsx("rect",{x:f+6,y:g+8,width:h-12,height:.8,fill:u})]})]}),m.map((y,v)=>{const b=g+(n?16:0)+v*2.1;return b>a-i-1?null:e.jsx("rect",{x:f,y:b,width:h*y,height:.8,fill:d,opacity:.55,rx:.2},`r${v}`)})]})})},Y=({paperId:t,title:s,thumbnailUrl:r,priority:a=!1})=>{const[j,o]=x.useState(!1),[p,c]=x.useState(0),[n,l]=x.useState(a),m=x.useRef(null);x.useEffect(()=>{o(!1),c(0)},[r]);const $=x.useMemo(()=>{if(!r)return null;if(p===0)return r;const d=r.includes("?")?"&":"?";return`${r}${d}retry=${p}`},[r,p]);return x.useEffect(()=>{if(a||n)return;const d=m.current;if(!d)return;const u=new IntersectionObserver(([i])=>{i.isIntersecting&&(l(!0),u.disconnect())},{rootMargin:"250px"});return u.observe(d),()=>u.disconnect()},[a,n]),r&&!j?e.jsx("div",{ref:m,style:{width:160,height:220,background:"#FDFCF9",border:"1px solid var(--hairline-strong)",borderRadius:2,boxShadow:"0 1px 0 rgba(0,0,0,0.04), 0 4px 8px -4px rgba(0,0,0,0.08)",flexShrink:0,overflow:"hidden",position:"relative"},children:(a||n)&&$&&e.jsx("img",{src:$,alt:`Thumbnail for ${s}`,loading:a?"eager":"lazy",decoding:"async",fetchPriority:a?"high":"auto",style:{width:"100%",height:"100%",objectFit:"contain",display:"block"},onError:()=>{if(p<1){c(d=>d+1);return}o(!0)}},$)}):e.jsx(O,{paperId:t})},S={1:"SOTA 🏆",2:"#2",3:"#3"},N=({units:t,paperHref:s})=>{const r=x.useRef(null),a=x.useRef(null),[j,o]=x.useState(t.length);if(x.useLayoutEffect(()=>{const n=r.current,l=a.current;if(!n||!l||t.length===0)return;const m=u=>(l.textContent=u,l.scrollWidth),$=()=>{const u=n.clientWidth;if(u<=0)return;let i=0,h=0;for(const k of t){const f=m(k.measureText);if(i+f<=u)i+=f,h+=1;else break}if(h0&&i+m(` · +${t.length-h} more`)>u;)h-=1,i-=m(t[h].measureText);h===0&&(h=1)}o(h)};$();const d=new ResizeObserver($);return d.observe(n),()=>d.disconnect()},[t]),t.length===0)return null;const p=t.slice(0,Math.max(1,Math.min(j,t.length))),c=t.length-p.length;return e.jsxs("div",{className:"paper-sota",ref:r,children:[e.jsx("span",{ref:a,className:"paper-sota-measure","aria-hidden":"true"}),p.map((n,l)=>e.jsxs(x.Fragment,{children:[n.isGroupStart?e.jsxs(e.Fragment,{children:[l>0&&e.jsx("span",{className:"paper-sota-sep",children:" · "}),e.jsx("span",{className:`paper-sota-label${n.rank===1?" paper-sota-label--sota":""}`,children:S[n.rank]}),e.jsx("span",{className:"paper-sota-on",children:" on "})]}):e.jsx("span",{className:"paper-sota-sep",children:", "}),n.href?e.jsx(C,{to:n.href,className:"paper-sota-name",onClick:m=>m.stopPropagation(),children:n.name}):e.jsx("span",{className:"paper-sota-name",children:n.name})]},`${n.href||n.name}-${l}`)),c>0&&e.jsxs(C,{to:`${s}#results`,className:"paper-sota-more",onClick:n=>n.stopPropagation(),children:[" · +",c," more"]})]})},V=({ranks:t,paperHref:s,wrap:r=!1})=>{const a=x.useMemo(()=>{const o=[];let p=!0;for(const c of[1,2,3]){const n=t.filter(l=>l.rank===c);n.forEach((l,m)=>{const $=m===0,d=$?`${p?"":" · "}${S[c]} on `:", ";o.push({name:l.name,href:l.href,rank:c,isGroupStart:$,measureText:d+l.name})}),n.length>0&&(p=!1)}return o},[t]),j=x.useMemo(()=>[1,2,3].map(o=>t.filter(c=>c.rank===o).map((c,n)=>({name:c.name,href:c.href,rank:o,isGroupStart:n===0,measureText:(n===0?`${S[o]} on `:", ")+c.name}))).filter(o=>o.length>0),[t]);return r?j.length===0?null:e.jsx("div",{className:"paper-sota-stack",children:j.map(o=>e.jsx(N,{units:o,paperHref:s},o[0].rank))}):a.length===0?null:e.jsx(N,{units:a,paperHref:s})};export{I as M,Y as P,V as S,D as T}; diff --git a/assets/StagingAccessRequestView-CZz80h2x.js b/assets/StagingAccessRequestView-D1t7icpG.js similarity index 95% rename from assets/StagingAccessRequestView-CZz80h2x.js rename to assets/StagingAccessRequestView-D1t7icpG.js index f9ca342fc18e0e4ef9e6f4f9ed2419b7a0db2e43..b1b05012a91b4c97b146500458b9b99937d2419f 100644 --- a/assets/StagingAccessRequestView-CZz80h2x.js +++ b/assets/StagingAccessRequestView-D1t7icpG.js @@ -1 +1 @@ -import{a as m,V as a,j as e,H as g,b3 as p}from"./index-DyXq7-Tg.js";import{C as j}from"./circle-check-GGlu5UCV.js";const f=()=>{const{user:s,isLoading:u}=m(),[l,d]=a.useState(!1),[r,t]=a.useState(!1),[c,i]=a.useState(null),o=async h=>{h.preventDefault(),t(!0),i(null);try{await p.requestStagingAccess(),d(!0)}catch(n){i(n instanceof Error?n.message:"Could not submit your request.")}finally{t(!1)}};return e.jsx("main",{className:"access-request-page",children:e.jsxs("section",{className:"access-request-card","aria-labelledby":"access-request-title",children:[e.jsxs("a",{className:"access-request-brand",href:"https://paperswithcode.co",children:[e.jsx("span",{className:"brand-mark","aria-hidden":"true"}),e.jsxs("span",{className:"brand-name",children:["Papers ",e.jsx("em",{children:"with"})," Code"]})]}),l?e.jsxs("div",{className:"access-request-success",role:"status",children:[e.jsx(j,{size:34,strokeWidth:1.6,"aria-hidden":"true"}),e.jsx("h1",{id:"access-request-title",children:"Request received"}),e.jsxs("p",{children:["Thanks, @",s==null?void 0:s.username,". We’ll review your contributor access request."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"access-request-heading",children:[e.jsx("p",{className:"access-request-eyebrow",children:"Staging preview"}),e.jsx("h1",{id:"access-request-title",children:"Request access"}),e.jsx("p",{children:"This preview is limited to project contributors. Send us your verified Hugging Face username and email address to request access."})]}),u?e.jsx("p",{className:"access-request-status",role:"status",children:"Checking your Hugging Face account…"}):s?e.jsxs("form",{className:"access-request-form",onSubmit:o,children:[e.jsx("label",{htmlFor:"hf-username",children:"Hugging Face username"}),e.jsxs("div",{className:"access-request-input-wrap",children:[e.jsx("span",{"aria-hidden":"true",children:"@"}),e.jsx("input",{id:"hf-username",name:"hf_username",value:s.username,readOnly:!0,autoComplete:"username"})]}),e.jsxs("p",{className:"access-request-verified",children:["Username and email verified through Hugging Face sign-in. See our"," ",e.jsx("a",{href:"https://paperswithcode.co/privacy",children:"Privacy Policy"}),"."]}),c&&e.jsx("p",{className:"access-request-error",role:"alert",children:c}),e.jsx("button",{className:"access-request-submit",type:"submit",disabled:r,children:r?"Sending…":"Request access"})]}):e.jsxs("div",{className:"access-request-signin",children:[e.jsx("p",{children:"Sign in first so we can verify the account you’re requesting access for."}),e.jsx(g,{returnTo:"/request-access",label:"Sign in with Hugging Face",collectEmail:!0})]})]})]})})};export{f as default}; +import{a as m,V as a,j as e,H as g,b3 as p}from"./index-CjdUkE4w.js";import{C as j}from"./circle-check-B2vTBhyc.js";const f=()=>{const{user:s,isLoading:u}=m(),[l,d]=a.useState(!1),[r,t]=a.useState(!1),[c,i]=a.useState(null),o=async h=>{h.preventDefault(),t(!0),i(null);try{await p.requestStagingAccess(),d(!0)}catch(n){i(n instanceof Error?n.message:"Could not submit your request.")}finally{t(!1)}};return e.jsx("main",{className:"access-request-page",children:e.jsxs("section",{className:"access-request-card","aria-labelledby":"access-request-title",children:[e.jsxs("a",{className:"access-request-brand",href:"https://paperswithcode.co",children:[e.jsx("span",{className:"brand-mark","aria-hidden":"true"}),e.jsxs("span",{className:"brand-name",children:["Papers ",e.jsx("em",{children:"with"})," Code"]})]}),l?e.jsxs("div",{className:"access-request-success",role:"status",children:[e.jsx(j,{size:34,strokeWidth:1.6,"aria-hidden":"true"}),e.jsx("h1",{id:"access-request-title",children:"Request received"}),e.jsxs("p",{children:["Thanks, @",s==null?void 0:s.username,". We’ll review your contributor access request."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"access-request-heading",children:[e.jsx("p",{className:"access-request-eyebrow",children:"Staging preview"}),e.jsx("h1",{id:"access-request-title",children:"Request access"}),e.jsx("p",{children:"This preview is limited to project contributors. Send us your verified Hugging Face username and email address to request access."})]}),u?e.jsx("p",{className:"access-request-status",role:"status",children:"Checking your Hugging Face account…"}):s?e.jsxs("form",{className:"access-request-form",onSubmit:o,children:[e.jsx("label",{htmlFor:"hf-username",children:"Hugging Face username"}),e.jsxs("div",{className:"access-request-input-wrap",children:[e.jsx("span",{"aria-hidden":"true",children:"@"}),e.jsx("input",{id:"hf-username",name:"hf_username",value:s.username,readOnly:!0,autoComplete:"username"})]}),e.jsxs("p",{className:"access-request-verified",children:["Username and email verified through Hugging Face sign-in. See our"," ",e.jsx("a",{href:"https://paperswithcode.co/privacy",children:"Privacy Policy"}),"."]}),c&&e.jsx("p",{className:"access-request-error",role:"alert",children:c}),e.jsx("button",{className:"access-request-submit",type:"submit",disabled:r,children:r?"Sending…":"Request access"})]}):e.jsxs("div",{className:"access-request-signin",children:[e.jsx("p",{children:"Sign in first so we can verify the account you’re requesting access for."}),e.jsx(g,{returnTo:"/request-access",label:"Sign in with Hugging Face",collectEmail:!0})]})]})]})})};export{f as default}; diff --git a/assets/SubmissionsDashboard-CZ6QfHso.js b/assets/SubmissionsDashboard-CkzOBcpM.js similarity index 95% rename from assets/SubmissionsDashboard-CZ6QfHso.js rename to assets/SubmissionsDashboard-CkzOBcpM.js index b8fc46ae617bbabbc0e8677b27f14cf0a57cf637..1f91856341f05fa67af7f177e8d885aace68b3d9 100644 --- a/assets/SubmissionsDashboard-CZ6QfHso.js +++ b/assets/SubmissionsDashboard-CkzOBcpM.js @@ -1,4 +1,4 @@ -import{s as ae,V as v,j as e,G as y,b as ne,o as H,a3 as re,x as oe,p as le,y as E,i as de,aA as T,aB as ce,aC as ue,aD as pe}from"./index-DyXq7-Tg.js";import{u as G,r as me,e as he}from"./evaluationQueryInvalidation-Cm3s7Pfm.js";import{i as X,a as K}from"./queryInvalidation-CfHeNeUY.js";import{u as D}from"./useMutation-UWxBeqtn.js";import{u as fe}from"./useInfiniteQuery-BYh2zN-T.js";import{c as C}from"./catalog-CRar2olQ.js";import{s as xe}from"./safeExternalHref-CkBrsh84.js";import{E as O,s as I}from"./submissions-Cz_J-Ha2.js";import{p as je}from"./papers-Dh3ljlL0.js";import{R as ge,C as ve}from"./refresh-cw-DYXzpRir.js";import{L as $}from"./loader-circle-C75KLEgx.js";import{C as be}from"./circle-check-GGlu5UCV.js";import"./curation-YeS7FBYf.js";/** +import{s as ae,V as v,j as e,I as y,b as ne,o as H,a3 as re,x as oe,p as le,y as E,i as de,aB as T,aC as ce,aD as ue,aE as pe}from"./index-CjdUkE4w.js";import{u as W,r as me,e as he}from"./evaluationQueryInvalidation-BAyi4YoG.js";import{i as X,a as K}from"./queryInvalidation-LiTu0GxY.js";import{u as D}from"./useMutation-BYtVrkc7.js";import{u as fe}from"./useInfiniteQuery-DeZTTVbI.js";import{c as C}from"./catalog-qXcKve0z.js";import{s as xe}from"./safeExternalHref-CkBrsh84.js";import{E as O,s as I}from"./submissions-CQ6M0giV.js";import{p as je}from"./papers-DgZwjF3K.js";import{R as ge,C as ve}from"./refresh-cw-BuRFYuxm.js";import{L as $}from"./loader-circle-xTdSzHv_.js";import{C as be}from"./circle-check-B2vTBhyc.js";import"./curation-CyyuHfv5.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. @@ -8,4 +8,4 @@ import{s as ae,V as v,j as e,G as y,b as ne,o as H,a3 as re,x as oe,p as le,y as * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ye=ae("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);function x({title:s,children:t}){return e.jsxs("div",{className:"submission-diff-column",children:[e.jsx("div",{className:"submission-diff-label",children:s}),e.jsx("div",{className:"submission-diff-pills",children:t})]})}function g({children:s}){return e.jsx("span",{className:"submission-muted",children:s})}function k({url:s,empty:t,className:i}){return s?e.jsx("a",{className:y("submission-url-link",i),href:xe(s)??void 0,target:"_blank",rel:"noopener noreferrer",children:s}):t?e.jsx(g,{children:t}):null}function N({label:s,value:t}){return e.jsxs("div",{children:[e.jsx("div",{className:"submission-diff-label",children:s}),e.jsx("div",{className:"submission-field-value",children:t??e.jsx("span",{className:"submission-muted",children:"Not set"})})]})}function Z({title:s,value:t}){return e.jsxs("div",{className:"submission-json-block",children:[e.jsx("div",{className:"submission-diff-label",children:s}),e.jsx("pre",{children:JSON.stringify(t,null,2)})]})}function _e({currentPayload:s,proposedPayload:t}){const[i,a]=v.useState(!1);return e.jsxs("div",{className:"submission-raw-toggle",children:[e.jsx("button",{type:"button",className:"raw-json-btn",onClick:()=>a(n=>!n),children:i?"Hide raw JSON":"Show raw JSON"}),i&&e.jsxs("div",{className:"submission-json-grid",children:[e.jsx(Z,{title:"Current payload",value:s??{}}),e.jsx(Z,{title:"Proposed payload",value:t})]})]})}function J({currentItems:s,proposedIds:t,queryPrefix:i,fetchEntity:a,knownNames:n}){const o=v.useMemo(()=>Array.from(new Set([...s.map(d=>d.id),...t])).sort((d,f)=>d-f),[s,t]),c=G({queries:a?o.map(d=>({queryKey:H[i](String(d)),queryFn:()=>a(String(d)),staleTime:5*60*1e3})):[]}),h=v.useMemo(()=>{const d=new Map;return s.forEach(f=>d.set(f.id,f.name)),n==null||n.forEach((f,j)=>d.set(j,f)),c.forEach(({data:f})=>{f&&d.set(Number(f.id),f.name)}),d},[s,c,n]),r=new Set(s.map(d=>d.id)),u=new Set(t),m=(d,f)=>e.jsx("span",{className:y("submission-diff-pill",f==="current"&&!u.has(d)&&"removed",f==="proposed"&&!r.has(d)&&"added"),children:h.get(d)??`#${d}`},d);return e.jsxs("div",{className:"submission-diff-columns",children:[e.jsx(x,{title:"Currently tagged",children:s.length>0?s.map(d=>m(d.id,"current")):e.jsx(g,{children:"No current tags"})}),e.jsx(x,{title:"Will be tagged",children:t.length>0?t.map(d=>m(d,"proposed")):e.jsx(g,{children:"No proposed tags"})})]})}function Ne({currentItems:s,proposedIds:t}){var n;const i=ne({queryKey:[...H.organizations,"submission-diff"],queryFn:()=>C.organizations(),staleTime:3e5}),a=new Map(s.map(o=>[o.id,o.name]));return(n=i.data)==null||n.results.forEach(o=>{a.set(Number(o.id),o.name)}),e.jsx(J,{currentItems:s,proposedIds:t,queryPrefix:"organization",knownNames:a})}function ee(s,t,i){return G({queries:t.map(a=>({queryKey:H[s](String(a)),queryFn:()=>i(String(a)),staleTime:5*60*1e3})),combine:a=>new Map(a.flatMap(({data:n})=>n?[[Number(n.id),n.name]]:[]))})}function ke({edit:s}){const t=v.useMemo(()=>{var r;return((r=s.current_payload)==null?void 0:r.evaluations)??[]},[s.current_payload]),i=s.proposed_payload.operations,{taskIds:a,datasetIds:n}=v.useMemo(()=>{const r=[...t,...i.flatMap(m=>m.op==="delete"?[]:[m.data])],u=m=>Array.from(new Set(r.flatMap(d=>d[m]?[d[m]]:[])));return{taskIds:u("task_id"),datasetIds:u("dataset_id")}},[t,i]),o=ee("task",a,r=>C.getTask(r)),c=ee("dataset",n,r=>C.getDataset(r)),h=new Map(t.filter(r=>r.id!=null).map(r=>[r.id,r]));return i.length===0?e.jsx(g,{children:"No evaluation operations in this payload."}):e.jsx("div",{className:"submission-eval-list",children:i.map((r,u)=>{const m=r.op==="create"?void 0:r.evaluation_id,d=m?h.get(m):void 0,f=r.op==="update"?{...d,...r.data}:r.op==="create"?r.data:d??{};return e.jsxs("div",{className:"submission-eval-op",children:[e.jsxs("div",{className:"submission-eval-op-header",children:[e.jsx("span",{className:y("submission-pill status",r.op==="create"&&"approved",r.op==="update"&&"changed",r.op==="delete"&&"rejected"),children:r.op}),m&&e.jsxs("span",{className:"submission-meta",children:["Evaluation #",m]})]}),e.jsx(we,{evaluation:f,taskNames:o,datasetNames:c})]},`${r.op}-${m??u}`)})})}function we({evaluation:s,taskNames:t,datasetNames:i}){const{task_id:a,dataset_id:n}=s,o=s.metrics??{};return e.jsxs("div",{className:"submission-eval-fields",children:[e.jsx(N,{label:"Task",value:a?t.get(a)??`#${a}`:null}),e.jsx(N,{label:"Dataset",value:n?i.get(n)??`#${n}`:null}),e.jsx(N,{label:"Model",value:s.model_name||null}),e.jsx(N,{label:"Harness",value:s.harness||null}),e.jsx(N,{label:"Best rank",value:s.best_rank??null}),e.jsx(N,{label:"Parameters",value:s.num_parameters??null}),e.jsx(N,{label:"HF model URL",value:s.hf_model_url||null}),e.jsx(N,{label:"Open source",value:s.is_open===void 0?null:s.is_open?"Yes":"No"}),e.jsxs("div",{className:"submission-eval-metrics",children:[e.jsx("div",{className:"submission-diff-label",children:"Metrics"}),Object.keys(o).length>0?e.jsx("div",{className:"submission-metric-list",children:Object.entries(o).map(([c,h])=>e.jsxs("span",{className:"submission-metric-pill",children:[c,": ",String(h)]},c))}):e.jsx(g,{children:"No metrics"})]})]})}function L({label:s,currentItems:t,proposedItems:i}){const a=new Map(t.map(c=>[c.url,c])),n=new Map(i.map(c=>[c.url,c])),o=Array.from(new Set([...a.keys(),...n.keys()])).sort();return o.length===0?e.jsxs(g,{children:["No ",s," in this submission."]}):e.jsx("div",{className:"submission-url-list",children:o.map(c=>{var f;const h=a.get(c),r=n.get(c),u=!h&&r,m=h&&!r,d=h&&r&&h.is_official!==r.is_official;return e.jsx("div",{className:y("submission-url-row",u&&"added",m&&"removed",d&&"changed"),children:e.jsxs("div",{className:"submission-url-content",children:[e.jsx(k,{url:c,className:y(m&&"removed")}),u&&e.jsx("span",{className:"submission-pill status approved",children:"Added"}),m&&e.jsx("span",{className:"submission-pill status rejected",children:"Removed"}),d&&e.jsxs("span",{className:"submission-pill changed",children:["Official: ",String(h.is_official)," ","->"," ",String(r.is_official)]}),((f=r??h)==null?void 0:f.is_official)&&e.jsx("span",{className:"submission-pill",children:"Official"})]})},c)})})}const z=s=>({url:s,is_official:!1});function Se({edit:s}){const t=[{key:"hf_models",label:"Models"},{key:"hf_datasets",label:"Datasets"},{key:"hf_spaces",label:"Spaces"}];return e.jsx("div",{className:"submission-hf-artifacts-diff",children:t.map(({key:i,label:a})=>{var n;return e.jsxs("div",{className:"submission-hf-artifacts-section",children:[e.jsx("div",{className:"submission-diff-label",children:a}),e.jsx(L,{label:a.toLowerCase(),currentItems:(((n=s.current_payload)==null?void 0:n[i])??[]).map(z),proposedItems:s.proposed_payload[i].map(z)})]},i)})})}function Ee({edit:s}){var t;return e.jsx(L,{label:"X threads",currentItems:(((t=s.current_payload)==null?void 0:t.x_threads)??[]).map(({url:i})=>z(i)),proposedItems:s.proposed_payload.x_threads.map(z)})}function Ce({edit:s}){var t;return e.jsxs("div",{className:"submission-diff-columns",children:[e.jsx(x,{title:"Current source URL",children:e.jsx(k,{url:(t=s.current_payload)==null?void 0:t.source_url,empty:"No current URL"})}),e.jsx(x,{title:"Proposed source URL",children:e.jsx(k,{url:s.proposed_payload.source_url,empty:"No proposed URL"})})]})}const Re={new_task:"task",new_method:"method",new_benchmark:"benchmark",new_metric:"metric",new_conference:"conference"};function q({text:s,empty:t}){return s?e.jsx("span",{className:"submission-field-value",children:s}):e.jsx(g,{children:t})}function se({edit:s}){var n;const{image:t,image_credit:i}=s.proposed_payload,a=(t==null?void 0:t.url)!==void 0?re(t.url)??"":(n=t==null?void 0:t.data_url)!=null&&n.startsWith("data:image/")?t.data_url:"";return e.jsxs(e.Fragment,{children:[e.jsx(x,{title:"Image",children:a?e.jsx("img",{src:a,alt:(t==null?void 0:t.file_name)??"Suggested image",className:"max-h-64 max-w-full rounded-md border border-border object-contain"}):e.jsx(g,{children:"No image provided"})}),e.jsx(x,{title:"Image source",children:i||e.jsx(g,{children:"No image source provided"})})]})}function Me({edit:s}){switch(s.edit_type){case"new_task":{const{parent_id:t,area_id:i,keywords:a}=s.proposed_payload;return e.jsxs(e.Fragment,{children:[e.jsx(se,{edit:s}),e.jsx(x,{title:"Placement and keywords",children:e.jsx("span",{className:"submission-field-value",children:JSON.stringify({parent_id:t??null,area_id:i??null,keywords:a??null})})})]})}case"new_method":{const t=s.proposed_payload.source_url??"";return e.jsxs(e.Fragment,{children:[e.jsx(se,{edit:s}),e.jsx(x,{title:"Source",children:/^https?:\/\//.test(t)?e.jsx(k,{url:t}):e.jsx(q,{text:t,empty:"No source provided"})})]})}case"new_benchmark":{const t=s.proposed_payload;return e.jsx(x,{title:"Task",children:e.jsx("span",{className:"submission-field-value",children:"task"in t?t.task:JSON.stringify(t.task_ids)})})}case"new_metric":{const{direction:t,scale:i,task_id:a,dataset_id:n}=s.proposed_payload;return e.jsx(x,{title:"Metric and leaderboard definition",children:e.jsx("span",{className:"submission-field-value",children:JSON.stringify({direction:t,scale:i,task_id:a,dataset_id:n})})})}case"new_conference":{const{year:t,start_date:i,end_date:a,venue:n,url:o}=s.proposed_payload;return e.jsxs(e.Fragment,{children:[e.jsx(x,{title:"Edition and dates",children:t?`${t}${i?` · ${i}${a?` – ${a}`:""}`:""}`:e.jsx(g,{children:"No edition provided"})}),e.jsx(x,{title:"Venue",children:n||e.jsx(g,{children:"No venue provided"})}),e.jsx(x,{title:"URL",children:e.jsx(k,{url:o,empty:"No URL provided"})})]})}}}function Pe({edit:s}){const t=s.proposed_payload,i="benchmark"in t?t.benchmark:t.name;return e.jsxs("div",{className:"submission-diff-columns",children:[e.jsx(x,{title:`Suggested ${Re[s.edit_type]} name`,children:i?e.jsx("span",{className:"submission-diff-pill added",children:i}):e.jsx(g,{children:"No name provided"})}),e.jsx(x,{title:"Description",children:e.jsx(q,{text:t.description,empty:"No description provided"})}),e.jsx(Me,{edit:s})]})}function Te({edit:s}){var c;const{name:t,hf_slug:i,website_url:a,image:n}=s.proposed_payload,o=n!=null&&n.url?re(n.url):(c=n==null?void 0:n.data_url)!=null&&c.startsWith("data:image/")?n.data_url:void 0;return e.jsxs("div",{className:"submission-diff-columns",children:[e.jsx(x,{title:"Suggested organization name",children:e.jsx("span",{className:"submission-diff-pill added",children:t})}),e.jsx(x,{title:"Hugging Face organization",children:e.jsx(k,{url:i?`https://huggingface.co/${i}`:void 0,empty:"No Hugging Face organization provided"})}),e.jsx(x,{title:"Website",children:e.jsx(k,{url:a,empty:"No website provided"})}),e.jsx(x,{title:"Logo",children:o?e.jsx("img",{src:o,alt:(n==null?void 0:n.file_name)??"Suggested logo",className:"max-h-32 max-w-full rounded-md border border-border object-contain"}):e.jsx(g,{children:"No logo provided"})})]})}function Ie({edit:s}){const{title:t,source_url:i,abstract:a,date_published:n,authors:o}=s.proposed_payload;return e.jsxs("div",{className:"submission-diff-columns",children:[e.jsx(x,{title:"Title",children:e.jsx(q,{text:t,empty:"No title provided"})}),e.jsx(x,{title:"Publication date",children:n||e.jsx(g,{children:"No publication date provided"})}),e.jsx(x,{title:"Authors",children:o.length>0?o.map((c,h)=>e.jsx("span",{className:"submission-diff-pill added",children:c},`${c}-${h}`)):e.jsx(g,{children:"No authors provided"})}),e.jsx(x,{title:"Source URL",children:e.jsx(k,{url:i,empty:"No source URL provided"})}),e.jsx(x,{title:"Abstract",children:e.jsx(q,{text:a,empty:"No abstract provided"})})]})}function $e(s){throw new Error(`Unhandled pending edit: ${JSON.stringify(s)}`)}function Fe({edit:s}){var t,i,a,n,o;switch(s.edit_type){case"tasks":return e.jsx(J,{currentItems:((t=s.current_payload)==null?void 0:t.tasks)??[],proposedIds:s.proposed_payload.task_ids,queryPrefix:"task",fetchEntity:c=>C.getTask(c)});case"methods":return e.jsx(J,{currentItems:((i=s.current_payload)==null?void 0:i.methods)??[],proposedIds:s.proposed_payload.method_ids,queryPrefix:"method",fetchEntity:c=>C.getMethod(c)});case"organizations":return e.jsx(Ne,{currentItems:((a=s.current_payload)==null?void 0:a.organizations)??[],proposedIds:s.proposed_payload.organization_ids});case"repositories":return e.jsx(L,{label:"repositories",currentItems:((n=s.current_payload)==null?void 0:n.repositories)??[],proposedItems:s.proposed_payload.repositories});case"project_pages":return e.jsx(L,{label:"project pages",currentItems:((o=s.current_payload)==null?void 0:o.project_pages)??[],proposedItems:s.proposed_payload.project_pages});case"evaluations":return e.jsx(ke,{edit:s});case"source_url":return e.jsx(Ce,{edit:s});case"hf_artifacts":return e.jsx(Se,{edit:s});case"x_threads":return e.jsx(Ee,{edit:s});case"new_task":case"new_method":case"new_benchmark":case"new_metric":case"new_conference":return e.jsx(Pe,{edit:s});case"new_organization":return e.jsx(Te,{edit:s});case"new_external_paper":return e.jsx(Ie,{edit:s});default:return $e(s)}}function Ae({edit:s}){return e.jsxs("div",{className:"submission-diff-body",children:[e.jsx(Fe,{edit:s}),e.jsx(_e,{currentPayload:s.current_payload,proposedPayload:s.proposed_payload})]})}const te=25,De=["pending","approved","rejected","all"],Ue=["all",...Object.keys(O)],B=["pending","approved","rejected"];function Oe(s){return s.slice(0,2).toUpperCase()}function U(s){return s.replace(/_/g," ")}function ie(s){if(!s)return"unknown time";const t=new Date(s);if(Number.isNaN(t.getTime()))return s;const i=Date.now()-t.getTime(),a=Math.floor(i/6e4),n=Math.floor(i/36e5),o=Math.floor(i/864e5);return a<1?"just now":a<60?`${a}m ago`:n<24?`${n}h ago`:o<14?`${o}d ago`:t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Le(s){return s==="approved"?"approved":s==="rejected"?"rejected":"pending"}function ze(s,t){return(s==null?void 0:s.arxiv_id)||(s==null?void 0:s.id)||String(t)}function qe(s){return[...s].sort((t,i)=>new Date(i.created_at).getTime()-new Date(t.created_at).getTime())}async function Qe(s,t,i,a){const n=await Promise.all(s.map(u=>I.list({status:u,edit_type:t==="all"?void 0:t,reviewed_by_kind:i?"auto":void 0,limit:te,offset:a[u]??0}))),o=qe(n.flatMap(u=>u.results)).slice(0,te),c={};s.forEach((u,m)=>{const d=o.filter(f=>n[m].results.includes(f)).length;c[u]=(a[u]??0)+d});const h=n.reduce((u,m)=>u+m.count,0),r=s.reduce((u,m)=>u+(c[m]??0),0);return{count:h,results:o,nextOffsets:o.length>0&&r{i.invalidateQueries({queryKey:T.pendingEdits}),p.paper_id!=null&&p.edit_type!=="evaluations"&&X(i,[String(p.paper_id),t==null?void 0:t.arxiv_id])},[t==null?void 0:t.arxiv_id,i]),F=D({mutationFn:()=>I.approve(s.id),onSuccess:p=>{var A;j(p),p.edit_type==="evaluations"&&p.paper_id!=null?me(i,he(String(p.paper_id),((A=p.current_payload)==null?void 0:A.evaluations)??[],p.proposed_payload.operations,(t==null?void 0:t.arxiv_id)??void 0)):p.paper_id!=null&&!c&&K(i),a({title:"Submission approved",description:c?`Marked ${U(s.edit_type)} suggestion as approved. No catalog changes were applied.`:`Applied ${U(s.edit_type)} changes for ${u}.`})},onError:p=>{a({title:"Could not approve submission",description:E(p,"Approval failed. Please try again."),variant:"destructive"})}}),R=D({mutationFn:()=>I.reject(s.id),onSuccess:p=>{j(p),a({title:"Submission rejected",description:`Rejected ${U(s.edit_type)} changes for ${u}.`})},onError:p=>{a({title:"Could not reject submission",description:E(p,"Rejection failed. Please try again."),variant:"destructive"})}}),S=D({mutationFn:()=>C.rollbackEvent(s.catalog_event_id),onSuccess:()=>{i.invalidateQueries({queryKey:T.pendingEdits}),s.paper_id!=null&&(X(i,[String(s.paper_id),t==null?void 0:t.arxiv_id]),K(i)),a({title:"Edit reverted",description:`Restored ${u} to its previous state.`})},onError:p=>{a({title:"Could not revert edit",description:E(p,"The paper changed after this edit, or it was already reverted."),variant:"destructive"})}}),M=D({mutationFn:p=>I.revertAutoApproved(s.hf_subject,{suspend:p}),onSuccess:p=>{i.invalidateQueries({queryKey:T.pendingEdits}),K(i),a({title:`Reverted ${p.reverted} edits by @${s.hf_username}`,description:p.skipped.length?`${p.skipped.length} were skipped because the paper changed since.`:void 0})},onError:p=>{a({title:"Could not revert edits",description:E(p,"Bulk revert failed. Please try again."),variant:"destructive"})}}),P=p=>{const A=`Revert every edit @${s.hf_username} had auto-applied in the last 7 days${p?" and suspend the account":""}?`;window.confirm(A)&&M.mutate(p)},l=s.reviewed_by_kind==="auto",_=l&&!!s.catalog_event_id,b=F.isPending,w=R.isPending,W=b||w,Q=S.isPending||M.isPending;return e.jsxs("article",{id:`submission-${s.id}`,className:"submission-card",children:[e.jsxs("header",{className:"submission-card-header",children:[e.jsxs("div",{className:"submission-card-top",children:[e.jsxs("div",{children:[r?e.jsx("a",{href:`/paper/${encodeURIComponent(r)}`,target:"_blank",rel:"noopener noreferrer",className:"submission-title",children:u}):e.jsx("div",{className:"submission-title",children:u}),e.jsxs("div",{className:"submission-meta",children:[e.jsxs("span",{children:["#",s.id]}),e.jsx("span",{children:o?h.subtitle:`Paper #${s.paper_id}`}),e.jsx("span",{children:ie(s.created_at)})]})]}),e.jsxs("div",{className:"submission-badges",children:[e.jsx("span",{className:"submission-pill",children:U(s.edit_type)}),l&&e.jsx("span",{className:"submission-pill",children:"Auto-applied"}),s.is_author&&e.jsx("span",{className:"submission-pill author",children:"Linked author"}),e.jsx("span",{className:y("submission-pill status",Le(s.status)),children:s.status})]})]}),e.jsxs("a",{href:`https://huggingface.co/${encodeURIComponent(s.hf_username)}`,target:"_blank",rel:"noopener noreferrer",className:"submission-user",children:[e.jsxs(ce,{className:"h-6 w-6",children:[e.jsx(ue,{src:m,alt:s.hf_username}),e.jsx(pe,{className:"text-[10px]",children:Oe(s.hf_username)})]}),e.jsxs("span",{children:["@",s.hf_username]})]})]}),e.jsx("div",{className:"submission-diff",children:e.jsx(Ae,{edit:s})}),s.conflict_payload&&e.jsxs("div",{className:"submission-empty submission-empty-warn",children:["Canonical state changed after this submission. Review the conflict before deciding.",e.jsx("pre",{children:JSON.stringify(s.conflict_payload,null,2)})]}),e.jsx("footer",{className:"submission-actions",children:d?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"submission-action-buttons",children:[e.jsxs("button",{type:"button",onClick:()=>R.mutate(),disabled:W,className:"submission-action-btn reject",children:[w?e.jsx($,{className:"spin",size:14}):e.jsx(ve,{size:14}),"Reject"]}),e.jsxs("button",{type:"button",onClick:()=>F.mutate(),disabled:W,className:"submission-action-btn approve",children:[b?e.jsx($,{className:"spin",size:14}):e.jsx(be,{size:14}),"Approve"]})]})}):e.jsxs("div",{className:"submission-reviewed",children:[e.jsxs("span",{children:["Reviewed by ",e.jsx("strong",{children:s.reviewed_by||"unknown"}),s.reviewed_at?` ${ie(s.reviewed_at)}`:""]}),s.admin_note&&e.jsxs("span",{children:["Admin note: ",e.jsx("strong",{children:s.admin_note})]}),f&&e.jsxs("span",{children:["Submitter-visible reason: ",e.jsx("strong",{children:s.user_review_reason})]}),_&&e.jsxs("div",{className:"submission-action-buttons",children:[e.jsxs("button",{type:"button",onClick:()=>S.mutate(),disabled:Q,className:"submission-action-btn reject",children:[S.isPending?e.jsx($,{className:"spin",size:14}):e.jsx(ye,{size:14}),"Revert this edit"]}),s.hf_subject&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>P(!1),disabled:Q,className:"submission-action-btn reject",children:["Revert all by @",s.hf_username]}),e.jsx("button",{type:"button",onClick:()=>P(!0),disabled:Q,className:"submission-action-btn reject",children:"Revert all and suspend"})]})]}),s.applied_payload&&e.jsxs("details",{children:[e.jsx("summary",{children:c?"Reviewed payload":"Applied payload"}),e.jsx("pre",{children:JSON.stringify(s.applied_payload,null,2)})]}),s.result_entity_type&&e.jsxs("span",{children:["Created/applied: ",e.jsxs("strong",{children:[s.result_entity_type," #",s.result_entity_id]})]})]})})]})}function as(){var M,P;const{toast:s}=oe(),[t,i]=v.useState("pending"),[a,n]=v.useState("all"),[o,c]=v.useState(!1),h=ne({queryKey:[...T.pendingEdits,"counts",a,o],queryFn:async()=>{const l=a==="all"?void 0:a,_=await Promise.all(B.map(b=>I.list({status:b,edit_type:l,reviewed_by_kind:o?"auto":void 0,limit:1,offset:0})));return Object.fromEntries(_.map((b,w)=>[B[w],b.count]))},staleTime:30*1e3}),r=fe({queryKey:[...T.pendingEdits,{status:t,editType:a,autoOnly:o}],queryFn:({pageParam:l})=>Qe(t==="all"?B:[t],a,o,l),initialPageParam:{},getNextPageParam:l=>l.nextOffsets??void 0,retry:!1}),u=v.useMemo(()=>{var l;return((l=r.data)==null?void 0:l.pages.flatMap(_=>_.results))??[]},[r.data]),m=v.useMemo(()=>Array.from(new Set(u.map(l=>l.paper_id).filter(l=>l!=null))).sort((l,_)=>l-_),[u]),d=G({queries:m.map(l=>({queryKey:le.summary(String(l)),queryFn:()=>je.get(String(l),!1),staleTime:5*60*1e3}))}),f=v.useMemo(()=>{const l=new Map;return d.forEach(_=>{const b=_.data;if(!b)return;const w=Number(b.id);Number.isFinite(w)&&l.set(w,b)}),l},[d]);v.useEffect(()=>{r.error&&s({title:"Could not load submissions",description:E(r.error,"Failed to load pending paper edits."),variant:"destructive"})},[r.error,s]);const j=h.data,F=j?j.pending+j.approved+j.rejected:void 0,R={pending:j==null?void 0:j.pending,approved:j==null?void 0:j.approved,rejected:j==null?void 0:j.rejected,all:F},S=((P=(M=r.data)==null?void 0:M.pages[0])==null?void 0:P.count)??0;return e.jsxs("div",{className:"page submissions-page",children:[e.jsxs("div",{className:"feed-header",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["Pending ",e.jsx("em",{children:"Edits"})]}),e.jsx("div",{className:"feed-subtitle",children:"Review submitted changes to paper metadata and benchmark results"})]}),e.jsxs("button",{type:"button",className:"feedback-link",onClick:()=>{h.refetch(),r.refetch()},disabled:r.isFetching||h.isFetching,children:[e.jsx(ge,{className:y((r.isFetching||h.isFetching)&&"spin"),size:14}),"Refresh"]})]}),e.jsxs("div",{className:"submissions-filter-panel",children:[e.jsxs("div",{className:"submission-filter-block",children:[e.jsx("div",{className:"sidebar-label",children:"Status"}),e.jsxs("div",{className:"period-switch",children:[De.map(l=>e.jsxs("button",{type:"button",className:y("period-btn",t===l&&"active"),onClick:()=>i(l),children:[l,R[l]!=null&&e.jsx("span",{className:"submission-count",children:R[l]})]},l)),e.jsx("button",{type:"button",className:y("period-btn",o&&"active"),onClick:()=>{c(l=>!l),o||i("approved")},children:"auto-applied only"})]})]}),e.jsxs("div",{className:"submission-filter-block",children:[e.jsx("div",{className:"sidebar-label",children:"Edit Type"}),e.jsx("div",{className:"sort-options submissions-type-options",children:Ue.map(l=>e.jsx("button",{type:"button",className:y("sort-btn",a===l&&"active"),onClick:()=>n(l),children:l==="all"?"all":O[l].label},l))})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"sort-bar submissions-sort-bar",children:e.jsx("div",{children:e.jsx("div",{className:"sort-options",children:e.jsx("span",{className:"results-count",children:r.isFetching?"refreshing":`${S} submissions`})})})}),r.isLoading?e.jsxs("div",{className:"submission-loading",children:[e.jsx($,{className:"spin",size:18}),e.jsx("span",{children:"Loading submissions..."})]}):r.isError?e.jsxs("div",{className:"submission-empty submission-empty-warn",role:"alert",children:[e.jsx(Y,{size:28}),e.jsx("h2",{children:"Could not display submissions."}),e.jsx("p",{children:E(r.error,"The submissions response was invalid.")})]}):u.length===0?e.jsxs("div",{className:"submission-empty",children:[e.jsx(Y,{size:28}),e.jsx("h2",{children:"No pending submissions."}),e.jsxs("p",{children:["The SQL and curl fallback is still documented in"," ",e.jsx("a",{href:"https://github.com/huggingface/paperswithcode/blob/main/docs/operations.md",target:"_blank",rel:"noopener noreferrer",children:"operations.md"}),"."]})]}):e.jsx("div",{className:"submission-list",children:u.map(l=>e.jsx(Ke,{submission:l,paper:l.paper_id==null?void 0:f.get(l.paper_id)},l.id))}),u.length>0&&e.jsxs("div",{className:"submission-pagination",children:[e.jsxs("p",{children:["Showing ",u.length," of ",S," submissions"]}),r.hasNextPage&&e.jsxs("button",{type:"button",className:"feedback-link",onClick:()=>r.fetchNextPage(),disabled:r.isFetching,children:[r.isFetchingNextPage&&e.jsx($,{className:"spin",size:14}),"Load more"]})]})]})]})}export{as as default}; + */const ye=ae("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);function x({title:s,children:t}){return e.jsxs("div",{className:"submission-diff-column",children:[e.jsx("div",{className:"submission-diff-label",children:s}),e.jsx("div",{className:"submission-diff-pills",children:t})]})}function g({children:s}){return e.jsx("span",{className:"submission-muted",children:s})}function k({url:s,empty:t,className:i}){return s?e.jsx("a",{className:y("submission-url-link",i),href:xe(s)??void 0,target:"_blank",rel:"noopener noreferrer",children:s}):t?e.jsx(g,{children:t}):null}function N({label:s,value:t}){return e.jsxs("div",{children:[e.jsx("div",{className:"submission-diff-label",children:s}),e.jsx("div",{className:"submission-field-value",children:t??e.jsx("span",{className:"submission-muted",children:"Not set"})})]})}function Z({title:s,value:t}){return e.jsxs("div",{className:"submission-json-block",children:[e.jsx("div",{className:"submission-diff-label",children:s}),e.jsx("pre",{children:JSON.stringify(t,null,2)})]})}function _e({currentPayload:s,proposedPayload:t}){const[i,a]=v.useState(!1);return e.jsxs("div",{className:"submission-raw-toggle",children:[e.jsx("button",{type:"button",className:"raw-json-btn",onClick:()=>a(n=>!n),children:i?"Hide raw JSON":"Show raw JSON"}),i&&e.jsxs("div",{className:"submission-json-grid",children:[e.jsx(Z,{title:"Current payload",value:s??{}}),e.jsx(Z,{title:"Proposed payload",value:t})]})]})}function J({currentItems:s,proposedIds:t,queryPrefix:i,fetchEntity:a,knownNames:n}){const o=v.useMemo(()=>Array.from(new Set([...s.map(d=>d.id),...t])).sort((d,f)=>d-f),[s,t]),c=W({queries:a?o.map(d=>({queryKey:H[i](String(d)),queryFn:()=>a(String(d)),staleTime:5*60*1e3})):[]}),h=v.useMemo(()=>{const d=new Map;return s.forEach(f=>d.set(f.id,f.name)),n==null||n.forEach((f,j)=>d.set(j,f)),c.forEach(({data:f})=>{f&&d.set(Number(f.id),f.name)}),d},[s,c,n]),r=new Set(s.map(d=>d.id)),u=new Set(t),m=(d,f)=>e.jsx("span",{className:y("submission-diff-pill",f==="current"&&!u.has(d)&&"removed",f==="proposed"&&!r.has(d)&&"added"),children:h.get(d)??`#${d}`},d);return e.jsxs("div",{className:"submission-diff-columns",children:[e.jsx(x,{title:"Currently tagged",children:s.length>0?s.map(d=>m(d.id,"current")):e.jsx(g,{children:"No current tags"})}),e.jsx(x,{title:"Will be tagged",children:t.length>0?t.map(d=>m(d,"proposed")):e.jsx(g,{children:"No proposed tags"})})]})}function Ne({currentItems:s,proposedIds:t}){var n;const i=ne({queryKey:[...H.organizations,"submission-diff"],queryFn:()=>C.organizations(),staleTime:3e5}),a=new Map(s.map(o=>[o.id,o.name]));return(n=i.data)==null||n.results.forEach(o=>{a.set(Number(o.id),o.name)}),e.jsx(J,{currentItems:s,proposedIds:t,queryPrefix:"organization",knownNames:a})}function ee(s,t,i){return W({queries:t.map(a=>({queryKey:H[s](String(a)),queryFn:()=>i(String(a)),staleTime:5*60*1e3})),combine:a=>new Map(a.flatMap(({data:n})=>n?[[Number(n.id),n.name]]:[]))})}function ke({edit:s}){const t=v.useMemo(()=>{var r;return((r=s.current_payload)==null?void 0:r.evaluations)??[]},[s.current_payload]),i=s.proposed_payload.operations,{taskIds:a,datasetIds:n}=v.useMemo(()=>{const r=[...t,...i.flatMap(m=>m.op==="delete"?[]:[m.data])],u=m=>Array.from(new Set(r.flatMap(d=>d[m]?[d[m]]:[])));return{taskIds:u("task_id"),datasetIds:u("dataset_id")}},[t,i]),o=ee("task",a,r=>C.getTask(r)),c=ee("dataset",n,r=>C.getDataset(r)),h=new Map(t.filter(r=>r.id!=null).map(r=>[r.id,r]));return i.length===0?e.jsx(g,{children:"No evaluation operations in this payload."}):e.jsx("div",{className:"submission-eval-list",children:i.map((r,u)=>{const m=r.op==="create"?void 0:r.evaluation_id,d=m?h.get(m):void 0,f=r.op==="update"?{...d,...r.data}:r.op==="create"?r.data:d??{};return e.jsxs("div",{className:"submission-eval-op",children:[e.jsxs("div",{className:"submission-eval-op-header",children:[e.jsx("span",{className:y("submission-pill status",r.op==="create"&&"approved",r.op==="update"&&"changed",r.op==="delete"&&"rejected"),children:r.op}),m&&e.jsxs("span",{className:"submission-meta",children:["Evaluation #",m]})]}),e.jsx(we,{evaluation:f,taskNames:o,datasetNames:c})]},`${r.op}-${m??u}`)})})}function we({evaluation:s,taskNames:t,datasetNames:i}){const{task_id:a,dataset_id:n}=s,o=s.metrics??{};return e.jsxs("div",{className:"submission-eval-fields",children:[e.jsx(N,{label:"Task",value:a?t.get(a)??`#${a}`:null}),e.jsx(N,{label:"Dataset",value:n?i.get(n)??`#${n}`:null}),e.jsx(N,{label:"Model",value:s.model_name||null}),e.jsx(N,{label:"Harness",value:s.harness||null}),e.jsx(N,{label:"Best rank",value:s.best_rank??null}),e.jsx(N,{label:"Parameters",value:s.num_parameters??null}),e.jsx(N,{label:"HF model URL",value:s.hf_model_url||null}),e.jsx(N,{label:"Open source",value:s.is_open===void 0?null:s.is_open?"Yes":"No"}),e.jsxs("div",{className:"submission-eval-metrics",children:[e.jsx("div",{className:"submission-diff-label",children:"Metrics"}),Object.keys(o).length>0?e.jsx("div",{className:"submission-metric-list",children:Object.entries(o).map(([c,h])=>e.jsxs("span",{className:"submission-metric-pill",children:[c,": ",String(h)]},c))}):e.jsx(g,{children:"No metrics"})]})]})}function L({label:s,currentItems:t,proposedItems:i}){const a=new Map(t.map(c=>[c.url,c])),n=new Map(i.map(c=>[c.url,c])),o=Array.from(new Set([...a.keys(),...n.keys()])).sort();return o.length===0?e.jsxs(g,{children:["No ",s," in this submission."]}):e.jsx("div",{className:"submission-url-list",children:o.map(c=>{var f;const h=a.get(c),r=n.get(c),u=!h&&r,m=h&&!r,d=h&&r&&h.is_official!==r.is_official;return e.jsx("div",{className:y("submission-url-row",u&&"added",m&&"removed",d&&"changed"),children:e.jsxs("div",{className:"submission-url-content",children:[e.jsx(k,{url:c,className:y(m&&"removed")}),u&&e.jsx("span",{className:"submission-pill status approved",children:"Added"}),m&&e.jsx("span",{className:"submission-pill status rejected",children:"Removed"}),d&&e.jsxs("span",{className:"submission-pill changed",children:["Official: ",String(h.is_official)," ","->"," ",String(r.is_official)]}),((f=r??h)==null?void 0:f.is_official)&&e.jsx("span",{className:"submission-pill",children:"Official"})]})},c)})})}const z=s=>({url:s,is_official:!1});function Se({edit:s}){const t=[{key:"hf_models",label:"Models"},{key:"hf_datasets",label:"Datasets"},{key:"hf_spaces",label:"Spaces"}];return e.jsx("div",{className:"submission-hf-artifacts-diff",children:t.map(({key:i,label:a})=>{var n;return e.jsxs("div",{className:"submission-hf-artifacts-section",children:[e.jsx("div",{className:"submission-diff-label",children:a}),e.jsx(L,{label:a.toLowerCase(),currentItems:(((n=s.current_payload)==null?void 0:n[i])??[]).map(z),proposedItems:s.proposed_payload[i].map(z)})]},i)})})}function Ee({edit:s}){var t;return e.jsx(L,{label:"X threads",currentItems:(((t=s.current_payload)==null?void 0:t.x_threads)??[]).map(({url:i})=>z(i)),proposedItems:s.proposed_payload.x_threads.map(z)})}function Ce({edit:s}){var t;return e.jsxs("div",{className:"submission-diff-columns",children:[e.jsx(x,{title:"Current source URL",children:e.jsx(k,{url:(t=s.current_payload)==null?void 0:t.source_url,empty:"No current URL"})}),e.jsx(x,{title:"Proposed source URL",children:e.jsx(k,{url:s.proposed_payload.source_url,empty:"No proposed URL"})})]})}const Re={new_task:"task",new_method:"method",new_benchmark:"benchmark",new_metric:"metric",new_conference:"conference"};function q({text:s,empty:t}){return s?e.jsx("span",{className:"submission-field-value",children:s}):e.jsx(g,{children:t})}function se({edit:s}){var n;const{image:t,image_credit:i}=s.proposed_payload,a=(t==null?void 0:t.url)!==void 0?re(t.url)??"":(n=t==null?void 0:t.data_url)!=null&&n.startsWith("data:image/")?t.data_url:"";return e.jsxs(e.Fragment,{children:[e.jsx(x,{title:"Image",children:a?e.jsx("img",{src:a,alt:(t==null?void 0:t.file_name)??"Suggested image",className:"max-h-64 max-w-full rounded-md border border-border object-contain"}):e.jsx(g,{children:"No image provided"})}),e.jsx(x,{title:"Image source",children:i||e.jsx(g,{children:"No image source provided"})})]})}function Me({edit:s}){switch(s.edit_type){case"new_task":{const{parent_id:t,area_id:i,keywords:a}=s.proposed_payload;return e.jsxs(e.Fragment,{children:[e.jsx(se,{edit:s}),e.jsx(x,{title:"Placement and keywords",children:e.jsx("span",{className:"submission-field-value",children:JSON.stringify({parent_id:t??null,area_id:i??null,keywords:a??null})})})]})}case"new_method":{const t=s.proposed_payload.source_url??"";return e.jsxs(e.Fragment,{children:[e.jsx(se,{edit:s}),e.jsx(x,{title:"Source",children:/^https?:\/\//.test(t)?e.jsx(k,{url:t}):e.jsx(q,{text:t,empty:"No source provided"})})]})}case"new_benchmark":{const t=s.proposed_payload;return e.jsx(x,{title:"Task",children:e.jsx("span",{className:"submission-field-value",children:"task"in t?t.task:JSON.stringify(t.task_ids)})})}case"new_metric":{const{direction:t,scale:i,task_id:a,dataset_id:n}=s.proposed_payload;return e.jsx(x,{title:"Metric and leaderboard definition",children:e.jsx("span",{className:"submission-field-value",children:JSON.stringify({direction:t,scale:i,task_id:a,dataset_id:n})})})}case"new_conference":{const{year:t,start_date:i,end_date:a,venue:n,url:o}=s.proposed_payload;return e.jsxs(e.Fragment,{children:[e.jsx(x,{title:"Edition and dates",children:t?`${t}${i?` · ${i}${a?` – ${a}`:""}`:""}`:e.jsx(g,{children:"No edition provided"})}),e.jsx(x,{title:"Venue",children:n||e.jsx(g,{children:"No venue provided"})}),e.jsx(x,{title:"URL",children:e.jsx(k,{url:o,empty:"No URL provided"})})]})}}}function Pe({edit:s}){const t=s.proposed_payload,i="benchmark"in t?t.benchmark:t.name;return e.jsxs("div",{className:"submission-diff-columns",children:[e.jsx(x,{title:`Suggested ${Re[s.edit_type]} name`,children:i?e.jsx("span",{className:"submission-diff-pill added",children:i}):e.jsx(g,{children:"No name provided"})}),e.jsx(x,{title:"Description",children:e.jsx(q,{text:t.description,empty:"No description provided"})}),e.jsx(Me,{edit:s})]})}function Te({edit:s}){var c;const{name:t,hf_slug:i,website_url:a,image:n}=s.proposed_payload,o=n!=null&&n.url?re(n.url):(c=n==null?void 0:n.data_url)!=null&&c.startsWith("data:image/")?n.data_url:void 0;return e.jsxs("div",{className:"submission-diff-columns",children:[e.jsx(x,{title:"Suggested organization name",children:e.jsx("span",{className:"submission-diff-pill added",children:t})}),e.jsx(x,{title:"Hugging Face organization",children:e.jsx(k,{url:i?`https://huggingface.co/${i}`:void 0,empty:"No Hugging Face organization provided"})}),e.jsx(x,{title:"Website",children:e.jsx(k,{url:a,empty:"No website provided"})}),e.jsx(x,{title:"Logo",children:o?e.jsx("img",{src:o,alt:(n==null?void 0:n.file_name)??"Suggested logo",className:"max-h-32 max-w-full rounded-md border border-border object-contain"}):e.jsx(g,{children:"No logo provided"})})]})}function Ie({edit:s}){const{title:t,source_url:i,abstract:a,date_published:n,authors:o}=s.proposed_payload;return e.jsxs("div",{className:"submission-diff-columns",children:[e.jsx(x,{title:"Title",children:e.jsx(q,{text:t,empty:"No title provided"})}),e.jsx(x,{title:"Publication date",children:n||e.jsx(g,{children:"No publication date provided"})}),e.jsx(x,{title:"Authors",children:o.length>0?o.map((c,h)=>e.jsx("span",{className:"submission-diff-pill added",children:c},`${c}-${h}`)):e.jsx(g,{children:"No authors provided"})}),e.jsx(x,{title:"Source URL",children:e.jsx(k,{url:i,empty:"No source URL provided"})}),e.jsx(x,{title:"Abstract",children:e.jsx(q,{text:a,empty:"No abstract provided"})})]})}function $e(s){throw new Error(`Unhandled pending edit: ${JSON.stringify(s)}`)}function Fe({edit:s}){var t,i,a,n,o;switch(s.edit_type){case"tasks":return e.jsx(J,{currentItems:((t=s.current_payload)==null?void 0:t.tasks)??[],proposedIds:s.proposed_payload.task_ids,queryPrefix:"task",fetchEntity:c=>C.getTask(c)});case"methods":return e.jsx(J,{currentItems:((i=s.current_payload)==null?void 0:i.methods)??[],proposedIds:s.proposed_payload.method_ids,queryPrefix:"method",fetchEntity:c=>C.getMethod(c)});case"organizations":return e.jsx(Ne,{currentItems:((a=s.current_payload)==null?void 0:a.organizations)??[],proposedIds:s.proposed_payload.organization_ids});case"repositories":return e.jsx(L,{label:"repositories",currentItems:((n=s.current_payload)==null?void 0:n.repositories)??[],proposedItems:s.proposed_payload.repositories});case"project_pages":return e.jsx(L,{label:"project pages",currentItems:((o=s.current_payload)==null?void 0:o.project_pages)??[],proposedItems:s.proposed_payload.project_pages});case"evaluations":return e.jsx(ke,{edit:s});case"source_url":return e.jsx(Ce,{edit:s});case"hf_artifacts":return e.jsx(Se,{edit:s});case"x_threads":return e.jsx(Ee,{edit:s});case"new_task":case"new_method":case"new_benchmark":case"new_metric":case"new_conference":return e.jsx(Pe,{edit:s});case"new_organization":return e.jsx(Te,{edit:s});case"new_external_paper":return e.jsx(Ie,{edit:s});default:return $e(s)}}function Ae({edit:s}){return e.jsxs("div",{className:"submission-diff-body",children:[e.jsx(Fe,{edit:s}),e.jsx(_e,{currentPayload:s.current_payload,proposedPayload:s.proposed_payload})]})}const te=25,De=["pending","approved","rejected","all"],Ue=["all",...Object.keys(O)],B=["pending","approved","rejected"];function Oe(s){return s.slice(0,2).toUpperCase()}function U(s){return s.replace(/_/g," ")}function ie(s){if(!s)return"unknown time";const t=new Date(s);if(Number.isNaN(t.getTime()))return s;const i=Date.now()-t.getTime(),a=Math.floor(i/6e4),n=Math.floor(i/36e5),o=Math.floor(i/864e5);return a<1?"just now":a<60?`${a}m ago`:n<24?`${n}h ago`:o<14?`${o}d ago`:t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Le(s){return s==="approved"?"approved":s==="rejected"?"rejected":"pending"}function ze(s,t){return(s==null?void 0:s.arxiv_id)||(s==null?void 0:s.id)||String(t)}function qe(s){return[...s].sort((t,i)=>new Date(i.created_at).getTime()-new Date(t.created_at).getTime())}async function Qe(s,t,i,a){const n=await Promise.all(s.map(u=>I.list({status:u,edit_type:t==="all"?void 0:t,reviewed_by_kind:i?"auto":void 0,limit:te,offset:a[u]??0}))),o=qe(n.flatMap(u=>u.results)).slice(0,te),c={};s.forEach((u,m)=>{const d=o.filter(f=>n[m].results.includes(f)).length;c[u]=(a[u]??0)+d});const h=n.reduce((u,m)=>u+m.count,0),r=s.reduce((u,m)=>u+(c[m]??0),0);return{count:h,results:o,nextOffsets:o.length>0&&r{i.invalidateQueries({queryKey:T.pendingEdits}),p.paper_id!=null&&p.edit_type!=="evaluations"&&X(i,[String(p.paper_id),t==null?void 0:t.arxiv_id])},[t==null?void 0:t.arxiv_id,i]),F=D({mutationFn:()=>I.approve(s.id),onSuccess:p=>{var A;j(p),p.edit_type==="evaluations"&&p.paper_id!=null?me(i,he(String(p.paper_id),((A=p.current_payload)==null?void 0:A.evaluations)??[],p.proposed_payload.operations,(t==null?void 0:t.arxiv_id)??void 0)):p.paper_id!=null&&!c&&K(i),a({title:"Submission approved",description:c?`Marked ${U(s.edit_type)} suggestion as approved. No catalog changes were applied.`:`Applied ${U(s.edit_type)} changes for ${u}.`})},onError:p=>{a({title:"Could not approve submission",description:E(p,"Approval failed. Please try again."),variant:"destructive"})}}),R=D({mutationFn:()=>I.reject(s.id),onSuccess:p=>{j(p),a({title:"Submission rejected",description:`Rejected ${U(s.edit_type)} changes for ${u}.`})},onError:p=>{a({title:"Could not reject submission",description:E(p,"Rejection failed. Please try again."),variant:"destructive"})}}),S=D({mutationFn:()=>C.rollbackEvent(s.catalog_event_id),onSuccess:()=>{i.invalidateQueries({queryKey:T.pendingEdits}),s.paper_id!=null&&(X(i,[String(s.paper_id),t==null?void 0:t.arxiv_id]),K(i)),a({title:"Edit reverted",description:`Restored ${u} to its previous state.`})},onError:p=>{a({title:"Could not revert edit",description:E(p,"The paper changed after this edit, or it was already reverted."),variant:"destructive"})}}),M=D({mutationFn:p=>I.revertAutoApproved(s.hf_subject,{suspend:p}),onSuccess:p=>{i.invalidateQueries({queryKey:T.pendingEdits}),K(i),a({title:`Reverted ${p.reverted} edits by @${s.hf_username}`,description:p.skipped.length?`${p.skipped.length} were skipped because the paper changed since.`:void 0})},onError:p=>{a({title:"Could not revert edits",description:E(p,"Bulk revert failed. Please try again."),variant:"destructive"})}}),P=p=>{const A=`Revert every edit @${s.hf_username} had auto-applied in the last 7 days${p?" and suspend the account":""}?`;window.confirm(A)&&M.mutate(p)},l=s.reviewed_by_kind==="auto",_=l&&!!s.catalog_event_id,b=F.isPending,w=R.isPending,G=b||w,Q=S.isPending||M.isPending;return e.jsxs("article",{id:`submission-${s.id}`,className:"submission-card",children:[e.jsxs("header",{className:"submission-card-header",children:[e.jsxs("div",{className:"submission-card-top",children:[e.jsxs("div",{children:[r?e.jsx("a",{href:`/paper/${encodeURIComponent(r)}`,target:"_blank",rel:"noopener noreferrer",className:"submission-title",children:u}):e.jsx("div",{className:"submission-title",children:u}),e.jsxs("div",{className:"submission-meta",children:[e.jsxs("span",{children:["#",s.id]}),e.jsx("span",{children:o?h.subtitle:`Paper #${s.paper_id}`}),e.jsx("span",{children:ie(s.created_at)})]})]}),e.jsxs("div",{className:"submission-badges",children:[e.jsx("span",{className:"submission-pill",children:U(s.edit_type)}),l&&e.jsx("span",{className:"submission-pill",children:"Auto-applied"}),s.is_author&&e.jsx("span",{className:"submission-pill author",children:"Linked author"}),e.jsx("span",{className:y("submission-pill status",Le(s.status)),children:s.status})]})]}),e.jsxs("a",{href:`https://huggingface.co/${encodeURIComponent(s.hf_username)}`,target:"_blank",rel:"noopener noreferrer",className:"submission-user",children:[e.jsxs(ce,{className:"h-6 w-6",children:[e.jsx(ue,{src:m,alt:s.hf_username}),e.jsx(pe,{className:"text-[10px]",children:Oe(s.hf_username)})]}),e.jsxs("span",{children:["@",s.hf_username]})]})]}),e.jsx("div",{className:"submission-diff",children:e.jsx(Ae,{edit:s})}),s.conflict_payload&&e.jsxs("div",{className:"submission-empty submission-empty-warn",children:["Canonical state changed after this submission. Review the conflict before deciding.",e.jsx("pre",{children:JSON.stringify(s.conflict_payload,null,2)})]}),e.jsx("footer",{className:"submission-actions",children:d?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"submission-action-buttons",children:[e.jsxs("button",{type:"button",onClick:()=>R.mutate(),disabled:G,className:"submission-action-btn reject",children:[w?e.jsx($,{className:"spin",size:14}):e.jsx(ve,{size:14}),"Reject"]}),e.jsxs("button",{type:"button",onClick:()=>F.mutate(),disabled:G,className:"submission-action-btn approve",children:[b?e.jsx($,{className:"spin",size:14}):e.jsx(be,{size:14}),"Approve"]})]})}):e.jsxs("div",{className:"submission-reviewed",children:[e.jsxs("span",{children:["Reviewed by ",e.jsx("strong",{children:s.reviewed_by||"unknown"}),s.reviewed_at?` ${ie(s.reviewed_at)}`:""]}),s.admin_note&&e.jsxs("span",{children:["Admin note: ",e.jsx("strong",{children:s.admin_note})]}),f&&e.jsxs("span",{children:["Submitter-visible reason: ",e.jsx("strong",{children:s.user_review_reason})]}),_&&e.jsxs("div",{className:"submission-action-buttons",children:[e.jsxs("button",{type:"button",onClick:()=>S.mutate(),disabled:Q,className:"submission-action-btn reject",children:[S.isPending?e.jsx($,{className:"spin",size:14}):e.jsx(ye,{size:14}),"Revert this edit"]}),s.hf_subject&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>P(!1),disabled:Q,className:"submission-action-btn reject",children:["Revert all by @",s.hf_username]}),e.jsx("button",{type:"button",onClick:()=>P(!0),disabled:Q,className:"submission-action-btn reject",children:"Revert all and suspend"})]})]}),s.applied_payload&&e.jsxs("details",{children:[e.jsx("summary",{children:c?"Reviewed payload":"Applied payload"}),e.jsx("pre",{children:JSON.stringify(s.applied_payload,null,2)})]}),s.result_entity_type&&e.jsxs("span",{children:["Created/applied: ",e.jsxs("strong",{children:[s.result_entity_type," #",s.result_entity_id]})]})]})})]})}function as(){var M,P;const{toast:s}=oe(),[t,i]=v.useState("pending"),[a,n]=v.useState("all"),[o,c]=v.useState(!1),h=ne({queryKey:[...T.pendingEdits,"counts",a,o],queryFn:async()=>{const l=a==="all"?void 0:a,_=await Promise.all(B.map(b=>I.list({status:b,edit_type:l,reviewed_by_kind:o?"auto":void 0,limit:1,offset:0})));return Object.fromEntries(_.map((b,w)=>[B[w],b.count]))},staleTime:30*1e3}),r=fe({queryKey:[...T.pendingEdits,{status:t,editType:a,autoOnly:o}],queryFn:({pageParam:l})=>Qe(t==="all"?B:[t],a,o,l),initialPageParam:{},getNextPageParam:l=>l.nextOffsets??void 0,retry:!1}),u=v.useMemo(()=>{var l;return((l=r.data)==null?void 0:l.pages.flatMap(_=>_.results))??[]},[r.data]),m=v.useMemo(()=>Array.from(new Set(u.map(l=>l.paper_id).filter(l=>l!=null))).sort((l,_)=>l-_),[u]),d=W({queries:m.map(l=>({queryKey:le.summary(String(l)),queryFn:()=>je.get(String(l),!1),staleTime:5*60*1e3}))}),f=v.useMemo(()=>{const l=new Map;return d.forEach(_=>{const b=_.data;if(!b)return;const w=Number(b.id);Number.isFinite(w)&&l.set(w,b)}),l},[d]);v.useEffect(()=>{r.error&&s({title:"Could not load submissions",description:E(r.error,"Failed to load pending paper edits."),variant:"destructive"})},[r.error,s]);const j=h.data,F=j?j.pending+j.approved+j.rejected:void 0,R={pending:j==null?void 0:j.pending,approved:j==null?void 0:j.approved,rejected:j==null?void 0:j.rejected,all:F},S=((P=(M=r.data)==null?void 0:M.pages[0])==null?void 0:P.count)??0;return e.jsxs("div",{className:"page submissions-page",children:[e.jsxs("div",{className:"feed-header",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["Pending ",e.jsx("em",{children:"Edits"})]}),e.jsx("div",{className:"feed-subtitle",children:"Review submitted changes to paper metadata and benchmark results"})]}),e.jsxs("button",{type:"button",className:"feedback-link",onClick:()=>{h.refetch(),r.refetch()},disabled:r.isFetching||h.isFetching,children:[e.jsx(ge,{className:y((r.isFetching||h.isFetching)&&"spin"),size:14}),"Refresh"]})]}),e.jsxs("div",{className:"submissions-filter-panel",children:[e.jsxs("div",{className:"submission-filter-block",children:[e.jsx("div",{className:"sidebar-label",children:"Status"}),e.jsxs("div",{className:"period-switch",children:[De.map(l=>e.jsxs("button",{type:"button",className:y("period-btn",t===l&&"active"),onClick:()=>i(l),children:[l,R[l]!=null&&e.jsx("span",{className:"submission-count",children:R[l]})]},l)),e.jsx("button",{type:"button",className:y("period-btn",o&&"active"),onClick:()=>{c(l=>!l),o||i("approved")},children:"auto-applied only"})]})]}),e.jsxs("div",{className:"submission-filter-block",children:[e.jsx("div",{className:"sidebar-label",children:"Edit Type"}),e.jsx("div",{className:"sort-options submissions-type-options",children:Ue.map(l=>e.jsx("button",{type:"button",className:y("sort-btn",a===l&&"active"),onClick:()=>n(l),children:l==="all"?"all":O[l].label},l))})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"sort-bar submissions-sort-bar",children:e.jsx("div",{children:e.jsx("div",{className:"sort-options",children:e.jsx("span",{className:"results-count",children:r.isFetching?"refreshing":`${S} submissions`})})})}),r.isLoading?e.jsxs("div",{className:"submission-loading",children:[e.jsx($,{className:"spin",size:18}),e.jsx("span",{children:"Loading submissions..."})]}):r.isError?e.jsxs("div",{className:"submission-empty submission-empty-warn",role:"alert",children:[e.jsx(Y,{size:28}),e.jsx("h2",{children:"Could not display submissions."}),e.jsx("p",{children:E(r.error,"The submissions response was invalid.")})]}):u.length===0?e.jsxs("div",{className:"submission-empty",children:[e.jsx(Y,{size:28}),e.jsx("h2",{children:"No pending submissions."}),e.jsxs("p",{children:["The SQL and curl fallback is still documented in"," ",e.jsx("a",{href:"https://github.com/huggingface/paperswithcode/blob/main/docs/operations.md",target:"_blank",rel:"noopener noreferrer",children:"operations.md"}),"."]})]}):e.jsx("div",{className:"submission-list",children:u.map(l=>e.jsx(Ke,{submission:l,paper:l.paper_id==null?void 0:f.get(l.paper_id)},l.id))}),u.length>0&&e.jsxs("div",{className:"submission-pagination",children:[e.jsxs("p",{children:["Showing ",u.length," of ",S," submissions"]}),r.hasNextPage&&e.jsxs("button",{type:"button",className:"feedback-link",onClick:()=>r.fetchNextPage(),disabled:r.isFetching,children:[r.isFetchingNextPage&&e.jsx($,{className:"spin",size:14}),"Load more"]})]})]})]})}export{as as default}; diff --git a/assets/SubmitView-CDuD6xEz.js b/assets/SubmitView-BCL1MLcF.js similarity index 93% rename from assets/SubmitView-CDuD6xEz.js rename to assets/SubmitView-BCL1MLcF.js index d7cedc9d53d3b1439b27bb48408f9e3c10aed2bb..251b559af3f4d93582ce17c6a77a81a412ec7b1c 100644 --- a/assets/SubmitView-CDuD6xEz.js +++ b/assets/SubmitView-BCL1MLcF.js @@ -1 +1 @@ -import{e as D,i as E,x as C,a as F,g as N,V as o,y as X,j as e,h as z}from"./index-DyXq7-Tg.js";import{u as U}from"./useMutation-UWxBeqtn.js";import{A as O,a as V}from"./alert-gbJBhAVE.js";import{B as P}from"./button-DZeAbOf2.js";import{I as h}from"./input-DJqCAbs7.js";import{T as q}from"./textarea-DPixlM5U.js";import{p as B}from"./papers-Dh3ljlL0.js";import{a as H}from"./queryInvalidation-CfHeNeUY.js";import"./curation-YeS7FBYf.js";const S="pwc:paper-submit-draft",R={color:"var(--accent-text)",fontWeight:600,textDecoration:"underline",textUnderlineOffset:2},M=/^\d{4}\.\d{4,5}(v\d+)?$/i,J=/^[a-z-]+(\.[A-Z]{2})?\/\d{7}$/,W=/^https?:\/\/(?:www\.)?arxiv\.org\//i;function k(l){const i=l.trim();return i?M.test(i)||J.test(i)||W.test(i)?"arxiv":/^https?:\/\//i.test(i)?"external":"arxiv":"empty"}function $(l,i){const r=l.trim();if(k(r)==="arxiv")return/^https?:\/\//i.test(r)?{source_url:r}:{arxiv_id:r};const s={source_url:r},p=i.title.trim();p&&(s.title=p);const d=i.abstract.trim();d&&(s.abstract=d);const n=i.authors.split(/[,\n]/).map(c=>c.trim()).filter(Boolean);return n.length>0&&(s.authors=n),i.datePublished&&(s.date_published=i.datePublished),s}const re=()=>{const l=D(),i=E(),{toast:r}=C(),{user:g,isLoading:s}=F(),[p]=N(),d=p.get("arxiv_id")??"",[n,c]=o.useState(d),[f,j]=o.useState(""),[x,w]=o.useState(""),[b,I]=o.useState(""),[v,_]=o.useState(""),[A,y]=o.useState(null);o.useEffect(()=>{if(d)return;const t=sessionStorage.getItem(S);if(t){sessionStorage.removeItem(S);try{const a=JSON.parse(t);c(a.input??""),j(a.title??""),w(a.abstract??""),I(a.authors??""),_(a.datePublished??"")}catch{}}},[d]);const m=k(n),L=m==="external",u=U({mutationFn:t=>B.submit(t),onSuccess:t=>{if(t.pending_review){r({title:"Submission queued for review",description:"No source page was fetched and no catalog row was changed."}),u.reset();return}H(i);const a=t.refreshed&&t.created&&t.latest_version;r({title:a?`Paper updated to ${t.latest_version}`:t.created?"Paper submitted":"Paper already indexed",description:a?"Opening the updated paper page…":t.created?"Opening the paper page…":"Opening the existing paper page…"}),t.route_identifier&&l(`/paper/${t.route_identifier}`)},onError:t=>{y(X(t,"Submission failed"))}}),T=t=>{if(t.preventDefault(),y(null),m==="empty"){y("Enter an arXiv ID or a paper URL to submit.");return}if(!g){sessionStorage.setItem(S,JSON.stringify({input:n,title:f,abstract:x,authors:b,datePublished:v})),window.location.assign(z(window.location.href));return}const a=$(n,{title:f,abstract:x,authors:b,datePublished:v});u.mutate(a)};return e.jsxs("div",{className:"page",style:{maxWidth:720},children:[e.jsx("h1",{className:"detail-title",children:"Submit a paper"}),e.jsxs("p",{style:{fontFamily:"var(--serif)",color:"var(--ink-soft)",marginTop:12,lineHeight:1.55},children:["If your paper is on arXiv, submit it on"," ",e.jsx("a",{href:"https://huggingface.co/papers/submit",target:"_blank",rel:"noopener noreferrer",style:R,children:"Hugging Face"}),", which will automatically index it on Papers with Code."]}),e.jsxs("p",{style:{fontFamily:"var(--serif)",color:"var(--ink-soft)",marginTop:12,lineHeight:1.55},children:["If your paper is not on arXiv, submit it here. Non-arXiv papers (blog posts, technical reports, model release pages) enter the submission queue and appear only after review."," ",e.jsx("a",{href:"/rate-limits",style:R,children:"Read the submission and rate-limit policy."})]}),e.jsxs("form",{onSubmit:T,style:{marginTop:28,display:"grid",gap:20},children:[e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{htmlFor:"submit-input",style:{fontWeight:600,fontSize:14},children:"arXiv ID or paper URL"}),e.jsx(h,{id:"submit-input",value:n,onChange:t=>c(t.target.value),placeholder:"2501.12345 · https://arxiv.org/abs/2501.12345 · https://blog.example.com/release",autoFocus:!0,required:!0}),e.jsx("div",{style:{fontSize:12,color:"var(--ink-soft)",minHeight:18},children:m==="arxiv"?"Detected: arXiv paper — metadata will be fetched automatically.":m==="external"?"Detected: external URL — we'll extract metadata and you can override below.":"Paste an arXiv ID like 2501.12345 or any paper/blog URL."})]}),L&&e.jsxs("fieldset",{style:{border:"1px solid var(--rule)",borderRadius:8,padding:"16px 20px 20px",display:"grid",gap:16},children:[e.jsx("legend",{style:{padding:"0 8px",fontSize:12,color:"var(--ink-soft)",textTransform:"uppercase",letterSpacing:.5},children:"External paper details (optional)"}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{htmlFor:"submit-title",style:{fontSize:13},children:"Title"}),e.jsx(h,{id:"submit-title",value:f,onChange:t=>j(t.target.value),placeholder:"Leave blank to extract automatically"})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{htmlFor:"submit-abstract",style:{fontSize:13},children:"Abstract or summary"}),e.jsx(q,{id:"submit-abstract",value:x,onChange:t=>w(t.target.value),rows:4,placeholder:"Leave blank to extract automatically"})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{htmlFor:"submit-authors",style:{fontSize:13},children:"Authors (comma-separated)"}),e.jsx(h,{id:"submit-authors",value:b,onChange:t=>I(t.target.value),placeholder:"Jane Smith, John Doe"})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{htmlFor:"submit-date",style:{fontSize:13},children:"Publication date"}),e.jsx(h,{id:"submit-date",type:"date",value:v,onChange:t=>_(t.target.value),style:{maxWidth:220}}),e.jsx("div",{style:{fontSize:12,color:"var(--ink-soft)"},children:"Required only if we cannot infer a date from the page."})]})]}),A&&e.jsx(O,{variant:"destructive",children:e.jsx(V,{children:A})}),e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center"},children:[e.jsx(P,{type:"submit",disabled:u.isPending||s,children:s?"Checking sign-in…":u.isPending?"Submitting…":g?"Submit paper":"Sign in to submit"}),e.jsx(P,{type:"button",variant:"outline",onClick:()=>l(-1),disabled:u.isPending,children:"Cancel"})]})]})]})};export{re as default}; +import{e as D,i as E,x as C,a as F,g as N,V as o,y as X,j as e,h as z}from"./index-CjdUkE4w.js";import{u as U}from"./useMutation-BYtVrkc7.js";import{A as O,a as V}from"./alert-BM9Xfuyy.js";import{B as P}from"./button-DetZl_ch.js";import{I as h}from"./input-7i-rZ7fA.js";import{T as q}from"./textarea-biscLKBK.js";import{p as B}from"./papers-DgZwjF3K.js";import{a as H}from"./queryInvalidation-LiTu0GxY.js";import"./curation-CyyuHfv5.js";const S="pwc:paper-submit-draft",R={color:"var(--accent-text)",fontWeight:600,textDecoration:"underline",textUnderlineOffset:2},M=/^\d{4}\.\d{4,5}(v\d+)?$/i,J=/^[a-z-]+(\.[A-Z]{2})?\/\d{7}$/,W=/^https?:\/\/(?:www\.)?arxiv\.org\//i;function k(l){const i=l.trim();return i?M.test(i)||J.test(i)||W.test(i)?"arxiv":/^https?:\/\//i.test(i)?"external":"arxiv":"empty"}function $(l,i){const r=l.trim();if(k(r)==="arxiv")return/^https?:\/\//i.test(r)?{source_url:r}:{arxiv_id:r};const s={source_url:r},p=i.title.trim();p&&(s.title=p);const d=i.abstract.trim();d&&(s.abstract=d);const n=i.authors.split(/[,\n]/).map(c=>c.trim()).filter(Boolean);return n.length>0&&(s.authors=n),i.datePublished&&(s.date_published=i.datePublished),s}const re=()=>{const l=D(),i=E(),{toast:r}=C(),{user:g,isLoading:s}=F(),[p]=N(),d=p.get("arxiv_id")??"",[n,c]=o.useState(d),[f,j]=o.useState(""),[x,w]=o.useState(""),[b,I]=o.useState(""),[v,_]=o.useState(""),[A,y]=o.useState(null);o.useEffect(()=>{if(d)return;const t=sessionStorage.getItem(S);if(t){sessionStorage.removeItem(S);try{const a=JSON.parse(t);c(a.input??""),j(a.title??""),w(a.abstract??""),I(a.authors??""),_(a.datePublished??"")}catch{}}},[d]);const m=k(n),L=m==="external",u=U({mutationFn:t=>B.submit(t),onSuccess:t=>{if(t.pending_review){r({title:"Submission queued for review",description:"No source page was fetched and no catalog row was changed."}),u.reset();return}H(i);const a=t.refreshed&&t.created&&t.latest_version;r({title:a?`Paper updated to ${t.latest_version}`:t.created?"Paper submitted":"Paper already indexed",description:a?"Opening the updated paper page…":t.created?"Opening the paper page…":"Opening the existing paper page…"}),t.route_identifier&&l(`/paper/${t.route_identifier}`)},onError:t=>{y(X(t,"Submission failed"))}}),T=t=>{if(t.preventDefault(),y(null),m==="empty"){y("Enter an arXiv ID or a paper URL to submit.");return}if(!g){sessionStorage.setItem(S,JSON.stringify({input:n,title:f,abstract:x,authors:b,datePublished:v})),window.location.assign(z(window.location.href));return}const a=$(n,{title:f,abstract:x,authors:b,datePublished:v});u.mutate(a)};return e.jsxs("div",{className:"page",style:{maxWidth:720},children:[e.jsx("h1",{className:"detail-title",children:"Submit a paper"}),e.jsxs("p",{style:{fontFamily:"var(--serif)",color:"var(--ink-soft)",marginTop:12,lineHeight:1.55},children:["If your paper is on arXiv, submit it on"," ",e.jsx("a",{href:"https://huggingface.co/papers/submit",target:"_blank",rel:"noopener noreferrer",style:R,children:"Hugging Face"}),", which will automatically index it on Papers with Code."]}),e.jsxs("p",{style:{fontFamily:"var(--serif)",color:"var(--ink-soft)",marginTop:12,lineHeight:1.55},children:["If your paper is not on arXiv, submit it here. Non-arXiv papers (blog posts, technical reports, model release pages) enter the submission queue and appear only after review."," ",e.jsx("a",{href:"/rate-limits",style:R,children:"Read the submission and rate-limit policy."})]}),e.jsxs("form",{onSubmit:T,style:{marginTop:28,display:"grid",gap:20},children:[e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{htmlFor:"submit-input",style:{fontWeight:600,fontSize:14},children:"arXiv ID or paper URL"}),e.jsx(h,{id:"submit-input",value:n,onChange:t=>c(t.target.value),placeholder:"2501.12345 · https://arxiv.org/abs/2501.12345 · https://blog.example.com/release",autoFocus:!0,required:!0}),e.jsx("div",{style:{fontSize:12,color:"var(--ink-soft)",minHeight:18},children:m==="arxiv"?"Detected: arXiv paper — metadata will be fetched automatically.":m==="external"?"Detected: external URL — we'll extract metadata and you can override below.":"Paste an arXiv ID like 2501.12345 or any paper/blog URL."})]}),L&&e.jsxs("fieldset",{style:{border:"1px solid var(--rule)",borderRadius:8,padding:"16px 20px 20px",display:"grid",gap:16},children:[e.jsx("legend",{style:{padding:"0 8px",fontSize:12,color:"var(--ink-soft)",textTransform:"uppercase",letterSpacing:.5},children:"External paper details (optional)"}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{htmlFor:"submit-title",style:{fontSize:13},children:"Title"}),e.jsx(h,{id:"submit-title",value:f,onChange:t=>j(t.target.value),placeholder:"Leave blank to extract automatically"})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{htmlFor:"submit-abstract",style:{fontSize:13},children:"Abstract or summary"}),e.jsx(q,{id:"submit-abstract",value:x,onChange:t=>w(t.target.value),rows:4,placeholder:"Leave blank to extract automatically"})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{htmlFor:"submit-authors",style:{fontSize:13},children:"Authors (comma-separated)"}),e.jsx(h,{id:"submit-authors",value:b,onChange:t=>I(t.target.value),placeholder:"Jane Smith, John Doe"})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{htmlFor:"submit-date",style:{fontSize:13},children:"Publication date"}),e.jsx(h,{id:"submit-date",type:"date",value:v,onChange:t=>_(t.target.value),style:{maxWidth:220}}),e.jsx("div",{style:{fontSize:12,color:"var(--ink-soft)"},children:"Required only if we cannot infer a date from the page."})]})]}),A&&e.jsx(O,{variant:"destructive",children:e.jsx(V,{children:A})}),e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center"},children:[e.jsx(P,{type:"submit",disabled:u.isPending||s,children:s?"Checking sign-in…":u.isPending?"Submitting…":g?"Submit paper":"Sign in to submit"}),e.jsx(P,{type:"button",variant:"outline",onClick:()=>l(-1),disabled:u.isPending,children:"Cancel"})]})]})]})};export{re as default}; diff --git a/assets/TagBrowseView-DKVo9Mlp.js b/assets/TagBrowseView-jVCzOB7D.js similarity index 91% rename from assets/TagBrowseView-DKVo9Mlp.js rename to assets/TagBrowseView-jVCzOB7D.js index 8b510a7a3e75d48345fe4e67216f1348e6ff9ee2..10399da4a1b35d8b5656d5d3325867aee3d52a8c 100644 --- a/assets/TagBrowseView-DKVo9Mlp.js +++ b/assets/TagBrowseView-jVCzOB7D.js @@ -1 +1 @@ -import{j as e,L as g,V as oe,u as de,e as me,d as j,b as G,p as he,a3 as pe,o as K,T as O}from"./index-DyXq7-Tg.js";import{R as ue}from"./ResearchFollowButton-Dv316ClR.js";import{M as ge}from"./SotaBadges-vbLLOUtT.js";import{u as be,b as xe,a as je}from"./PaperFeed-EBt97iOL.js";import{A as L}from"./arrow-right-BzPanrWZ.js";import{B as ke}from"./BenchmarkTrendSparkline-DhXxdQ2D.js";import{M as W}from"./MarkdownText-CUzPoC9Y.js";import{c as J}from"./catalog-CRar2olQ.js";import{p as _e}from"./papers-Dh3ljlL0.js";import{i as Ne}from"./apiErrors-BSvbQBb0.js";import{f as fe}from"./frameworks-DDA0P4Tf.js";import{u as we}from"./preferences-COzeOLyS.js";import{s as ve}from"./slug-BpH-Nkvz.js";import{d as f,t as ye}from"./transform-D46m70Qr.js";import{u as Se}from"./usePapers-B0s20UcU.js";import{S as P}from"./skeleton-C3IIzpSL.js";import{A as Te,a as Ee}from"./alert-gbJBhAVE.js";import Be from"./NotFound-DV_nwcxG.js";import{T as $e}from"./trophy-BtgLmZ39.js";import{G as Me}from"./github-RNrgGHRT.js";import"./researchTopic-DbX0eko-.js";import"./useMutation-UWxBeqtn.js";import"./plus-Yh42pKZz.js";import"./colors-BkWRhvFI.js";import"./PaperCard-57p1OSGy.js";import"./AuthorAvatar-B-9xS2Wo.js";import"./Icon-T4LYkEQj.js";import"./LatexTitle-Bkyz3jCs.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-CTBEUp7Y.js";import"./useIntersectionObserver-D6_Iig9a.js";/* empty css */import"./PaperPreviewLink-CpCZSa8K.js";import"./index-mCi_y_l3.js";import"./index-2CvJmBVB.js";import"./katex-DkKDou_j.js";import"./hover-card-B45EJIn_.js";import"./curation-YeS7FBYf.js";import"./account-cbblajck.js";import"./useInfiniteQuery-BYh2zN-T.js";const Ce=()=>e.jsxs(g,{to:"/astra-for-robotics",className:"task-featured-collection","aria-label":"Featured collection: GPT-6 Astra for Robotics",children:[e.jsx("span",{className:"task-featured-collection-eyebrow",children:"Featured collection"}),e.jsx("strong",{children:"GPT-6 Astra for Robotics"}),e.jsx("span",{className:"task-featured-collection-description",children:"Papers and demos that put GPT-6 Astra in control of real and simulated robots, as the policy itself or as an agent orchestrating the stack."}),e.jsxs("span",{className:"task-featured-collection-meta",children:["Explore the collection",e.jsx(L,{size:14,"aria-hidden":"true"})]})]}),X=n=>{const c=n.match(/\(([^()]*)\)\s*$/);return c?c[1].split(",").map(d=>d.trim()).filter(Boolean):[]};function Fe(n,c){const d=X(n);if(c===void 0)return"standard";const i=new Set(X(c).map(l=>l.toLowerCase())),m=d.filter(l=>!i.has(l.toLowerCase()));return m.length?m.join(", "):n}function Ae(n,c){const d=new Map(n.map(l=>[l.id,l])),i=l=>{const x=new Set([l.id]);let k=l;for(;;){const w=c(k),_=w?d.get(w):void 0;if(!_)return k.id;if(x.has(_.id))return l.id;x.add(_.id),k=_}},m=new Map;return n.forEach(l=>{const x=i(l);m.set(x,[...m.get(x)||[],l])}),[...m].map(([l,x])=>({key:l,members:[d.get(l),...x.filter(k=>k.id!==l)]}))}const R=3,Pe=[{slug:"healthcare",eyebrow:"Clinical systems",title:"Clinical AI & Healthcare",description:"Agents, clinical workflows, medical calculators, safety, and decision support.",href:"#benchmarks"},{slug:"medical-question-answering",eyebrow:"Language & reasoning",title:"Medical Question Answering",description:"Medical exams, biomedical evidence, clinical comprehension, and explanations.",href:"/tasks/medical-question-answering"},{slug:"medical-imaging",eyebrow:"Vision",title:"Medical Imaging",description:"Radiology, pathology, ophthalmology, ultrasound, and diagnostic imaging.",href:"/tasks/medical-imaging"},{slug:"medical-visual-question-answering",eyebrow:"Multimodal",title:"Medical Visual Question Answering",description:"Questions grounded in radiology, pathology, and other biomedical images.",href:"/tasks/medical-visual-question-answering"}],Re=({frameworks:n})=>n.length===0?null:e.jsxs("div",{className:"task-framework-links",children:[e.jsx("span",{className:"task-framework-links-label",children:"Recommended frameworks"}),n.map(c=>e.jsxs(g,{to:`/papers?framework=${encodeURIComponent(c.framework_slug)}`,className:"task-framework-link",children:[e.jsx("span",{children:c.framework_name}),e.jsxs("span",{className:"task-framework-link-stars",children:["★ ",fe(c.num_stars)]})]},c.framework_id))]}),Le=({task:n,area:c,parents:d})=>e.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[e.jsx(g,{to:"/tasks",children:"Tasks"}),c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sep",children:"/"}),e.jsx(g,{to:`/tasks#area-${ve(c.name)}`,children:c.name})]}),[...d].reverse().map(i=>e.jsxs(oe.Fragment,{children:[e.jsx("span",{className:"sep",children:"/"}),e.jsx(g,{to:`/tasks/${i.slug||i.id}`,children:f(i.name,i.slug)})]},i.id)),e.jsx("span",{className:"sep",children:"/"}),e.jsx("span",{style:{color:"var(--accent-text)"},children:f(n.name,n.slug)})]}),Ie=({task:n,relatedTasks:c})=>{const d=new Map([n,...c].map(i=>[i.slug,i]));return e.jsxs("section",{className:"medical-ai-hub","aria-labelledby":"medical-ai-hub-title",children:[e.jsxs("div",{className:"medical-ai-hub-heading",children:[e.jsx("span",{children:"Medical AI directory"}),e.jsx("h2",{id:"medical-ai-hub-title",children:"Explore Healthcare & Medical AI"}),e.jsx("p",{children:"Browse the field by clinical application, language, vision, or multimodal reasoning."})]}),e.jsx("div",{className:"medical-ai-hub-grid",children:Pe.map(i=>{const m=d.get(i.slug),l=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"medical-ai-hub-card-eyebrow",children:i.eyebrow}),e.jsx("strong",{children:i.title}),e.jsx("span",{className:"medical-ai-hub-card-description",children:i.description}),e.jsxs("span",{className:"medical-ai-hub-card-meta",children:[(m==null?void 0:m.paper_count)!=null?`${m.paper_count.toLocaleString()} papers`:"Explore task",e.jsx(L,{size:14,"aria-hidden":"true"})]})]});return i.slug==="healthcare"?e.jsx("a",{href:i.href,className:"medical-ai-hub-card",children:l},i.slug):e.jsx(g,{to:i.href,className:"medical-ai-hub-card",children:l},i.slug)})})]})},qe=n=>[...n].sort((c,d)=>{const i=c.slug==="classic-language-modeling",m=d.slug==="classic-language-modeling";return i!==m?i?1:-1:0}),Ss=()=>{var V,z,U;const{taskSlug:n}=de(),c=me(),d=be(),{searchParams:i}=d,[m,l]=j.useState(!1),[x,k]=j.useState({}),[w,_]=j.useState(()=>new Set),{preferences:Y}=we(),E=(s,a)=>{const t=s||"";return a?`/benchmark/${t}?task=${encodeURIComponent(a)}`:`/benchmark/${t}`},v=Y.hide_closed_source_evals?!0:void 0,h=G({queryKey:[...K.taskPage,n,v],queryFn:()=>J.taskPage(n,{is_open:v}),enabled:!!n,staleTime:O});j.useEffect(()=>{var t;const s=(t=h.data)==null?void 0:t.task.slug;if(!n||!s||s===n)return;const a=i.toString();c(`/tasks/${s}${a?`?${a}`:""}`,{replace:!0})},[c,(V=h.data)==null?void 0:V.task.slug,i,n]);const I=G({queryKey:[...K.taskBenchmarkTrends,n,v],queryFn:()=>J.trendingBenchmarks(n,{limit:100,min_recent_papers:0,is_open:v}),enabled:!!n,staleTime:O}),y=j.useMemo(()=>{var s;return qe(((s=h.data)==null?void 0:s.children)||[])},[h.data]),B=j.useMemo(()=>{var a;const s=new Map;return(((a=h.data)==null?void 0:a.subtask_benchmarks)||[]).forEach(t=>{s.set(t.subtask_id,t.benchmarks||[])}),s},[h.data]),N=Se([...he.feeds.task,n,d.filters],s=>_e.forTask(n,{...d.filters,page:s,page_size:20,repository_limit:1}),{enabled:!!n}),Z=j.useMemo(()=>{var s;return((s=N.data)==null?void 0:s.pages.flatMap(a=>a.results.map(ye)))??[]},[N.data]),$=j.useMemo(()=>{var a;const s={};return(a=N.data)==null||a.pages.forEach(t=>t.results.forEach(b=>(b.methods||[]).forEach(u=>{const r=u.slug||u.id;s[r]||(s[r]={id:u.id,name:u.name,slug:u.slug||"",count:0}),s[r].count++}))),Object.values(s).sort((t,b)=>b.count-t.count).slice(0,8)},[N.data]);if(h.isLoading)return e.jsxs("div",{className:"page",children:[e.jsx(P,{className:"h-12 w-1/2 mb-4"}),e.jsx(P,{className:"h-6 w-1/3 mb-8"}),e.jsx(P,{className:"h-64 w-full"})]});if(Ne(h.error))return e.jsx(Be,{});if(h.error||!h.data)return e.jsx("div",{className:"page",children:e.jsx(Te,{variant:"destructive",children:e.jsx(Ee,{children:"Task not found."})})});const o=h.data.task,ee=h.data.parents||[],M=f(o.name,o.slug),C=(h.data.sisters||[]).filter(s=>s.id!==o.id),se=h.data.recommended_frameworks||[],S=h.data.benchmarks||[],q=new Map(S.map(s=>[s.id,s])),ae=new Set(S.map(s=>s.id)),H=(((z=I.data)==null?void 0:z.results)||[]).filter(s=>ae.has(s.id)).map(s=>{const a=q.get(s.id);return{...s,best_model_name:(a==null?void 0:a.best_model_name)??s.best_model_name,best_paper_route:a==null?void 0:a.best_paper_route,best_paper_title:a==null?void 0:a.best_paper_title,best_code_url:a==null?void 0:a.best_code_url}}),F=H.length?H:S.map(s=>({id:s.id,name:s.name,slug:s.slug,full_name:s.full_name,recent_paper_count:0,baseline_paper_count:0,all_time_paper_count:s.paper_count||0,trend_score:0,support_weighted_score:0,rate_change:null,latest_reported_on:null,best_model_name:s.best_model_name,best_paper_route:s.best_paper_route,best_paper_title:s.best_paper_title,best_code_url:s.best_code_url,history:[]})),T=Ae(F,s=>{var a;return(a=q.get(s.id))==null?void 0:a.parent_dataset_id}),re=m?T:T.slice(0,5),ne=T.slice(5).reduce((s,a)=>s+a.members.length,0),Q=((U=I.data)==null?void 0:U.recent_days)||90,te=y.some(s=>(B.get(s.id)||[]).length>0),ie=y.length>0,D=F.length>0,ce=(()=>{const s=new Set;return S.forEach(a=>s.add(a.id)),B.forEach(a=>a.forEach(t=>s.add(t.id))),s.size})(),le=s=>{_(a=>{const t=new Set(a);return t.has(s)?t.delete(s):t.add(s),t})};return e.jsxs("div",{className:"page",children:[e.jsx(Le,{task:o,area:h.data.area,parents:ee}),e.jsxs("div",{className:o.image_url?`task-hero-grid${o.slug==="auto-research"?" task-hero-grid--wide":""}`:void 0,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--accent-text)",letterSpacing:"0.1em",marginBottom:8},children:"TASK"}),e.jsx("h1",{className:"domain-mega-title",children:M}),e.jsx(ue,{kind:"task",entityId:o.id}),o.description&&e.jsx(W,{className:"task-explainer",text:o.description}),e.jsxs("div",{className:"task-quickstats",children:[e.jsxs("span",{children:[e.jsx("span",{className:"num",children:(o.paper_count??0).toLocaleString()}),"PAPERS"]}),e.jsxs("span",{children:[e.jsx("span",{className:"num",children:ce}),"BENCHMARKS"]}),e.jsxs("span",{children:[e.jsxs("span",{className:"num",children:[$.length,"+"]}),"METHODS USED"]})]}),e.jsx(Re,{frameworks:se})]}),o.image_url&&e.jsxs("figure",{className:`task-figure-card${o.slug==="omni-models"?" task-figure-card--compact":""}`,children:[e.jsx("div",{className:"task-figure-img-wrap",children:e.jsx("img",{className:"task-figure-img",src:pe(o.image_url)??void 0,alt:`${M} schematic`,onError:s=>{var a,t;(t=(a=s.currentTarget.parentElement)==null?void 0:a.parentElement)==null||t.style.setProperty("display","none")}})}),e.jsxs("figcaption",{children:["Figure · ",M,o.image_credit&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx(W,{className:"task-image-credit",text:o.image_credit})]})]})]})]}),o.slug==="healthcare"&&e.jsx(Ie,{task:o,relatedTasks:C}),o.slug==="robotics"&&e.jsx(Ce,{}),e.jsxs("div",{className:"task-page-grid",style:{marginTop:28},children:[e.jsxs("div",{children:[D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"task-section-head",id:"benchmarks",children:[e.jsxs("div",{className:"task-section-eyebrow",children:[Q,"-day reporting activity · select a benchmark"]}),e.jsxs("div",{className:"task-section-title",children:["Benchmarks ",e.jsxs("span",{className:"meta",children:["[",F.length,"]"]})]})]}),e.jsxs("div",{className:"benchmark-trend-table",role:"table","aria-label":"Trending benchmarks",children:[e.jsxs("div",{className:"benchmark-trend-head",role:"row",children:[e.jsx("span",{role:"columnheader",children:"Trend"}),e.jsx("span",{role:"columnheader",children:"Benchmark"}),e.jsx("span",{role:"columnheader",children:"Best model"}),e.jsx("span",{role:"columnheader",children:"Paper title"}),e.jsx("span",{role:"columnheader",children:"Code"}),e.jsx("span",{role:"columnheader",children:"Compare"})]}),re.map(({key:s,members:a})=>{const t=a[0],b=p=>p===t?"standard":Fe(p.name,t.name),u=[t,...a.slice(1).sort((p,A)=>b(p).localeCompare(b(A),void 0,{sensitivity:"base"}))],r=u.find(p=>p.id===x[s])??t;return e.jsxs("div",{className:"benchmark-trend-row",role:"row",children:[e.jsxs("div",{className:"benchmark-trend-cell",role:"cell",children:[e.jsx(ke,{history:r.history,benchmarkName:r.name}),e.jsxs("div",{className:"benchmark-trend-meta",children:[e.jsxs("span",{children:[e.jsx("strong",{children:r.recent_paper_count})," ",r.recent_paper_count===1?"paper":"papers"," /"," ",Q,"d"]}),r.rate_change==null?r.recent_paper_count>0&&e.jsx("span",{className:"benchmark-trend-change is-new",children:"new"}):e.jsxs("span",{className:`benchmark-trend-change ${r.rate_change>=1?"is-up":"is-down"}`,children:[r.rate_change>=1?"↑":"↓"," ",r.rate_change.toFixed(1),"×"]})]})]}),e.jsxs("div",{className:"benchmark-trend-benchmark",role:"cell",children:[e.jsx(g,{className:"bench-row-name",to:E(r.slug||r.id,n),children:r.name}),u.length>1&&e.jsx("div",{className:"bench-row-variants",role:"group","aria-label":`Evaluation protocols for ${t.name}`,children:u.map(p=>e.jsx("button",{type:"button",className:"bench-row-variant","aria-pressed":p.id===r.id,title:p.name,onClick:()=>k(A=>({...A,[s]:p.id})),children:b(p)},p.id))}),e.jsx("div",{className:"bench-row-sub",children:e.jsxs("span",{children:[e.jsx("strong",{children:r.all_time_paper_count})," reporting papers"]})})]}),e.jsx("div",{className:"bench-row-best",role:"cell",children:r.best_model_name?e.jsxs(e.Fragment,{children:[e.jsx($e,{size:13,className:"bench-row-best-icon"}),e.jsx("span",{className:"bench-row-best-name",children:r.best_model_name})]}):e.jsx("span",{className:"bench-row-best-empty",children:"—"})}),e.jsx("div",{className:"bench-row-paper",role:"cell",children:r.best_paper_route&&r.best_paper_title?e.jsx(g,{to:`/paper/${encodeURIComponent(r.best_paper_route)}`,children:r.best_paper_title}):e.jsx("span",{className:"bench-row-best-empty",children:"—"})}),e.jsx("div",{className:"bench-row-code",role:"cell",children:r.best_code_url?e.jsx("a",{href:r.best_code_url,target:"_blank",rel:"noopener noreferrer","aria-label":`Code for ${r.best_paper_title||r.best_model_name}`,children:e.jsx(Me,{size:18,strokeWidth:1.8,"aria-hidden":"true"})}):e.jsx("span",{className:"bench-row-best-empty",children:"—"})}),e.jsx("div",{className:"bench-row-compare",role:"cell",children:e.jsxs(g,{to:E(r.slug||r.id,n),"aria-label":`Compare ${r.best_model_name||"the best model"} with all results on ${r.name}`,children:[e.jsx("span",{children:"See all"}),e.jsx(L,{size:11,strokeWidth:2,"aria-hidden":"true"})]})})]},s)})]}),T.length>5&&e.jsx("button",{type:"button",className:"bench-show-more",onClick:()=>l(s=>!s),children:m?"− show top 5":`+ show ${ne} more benchmarks`})]}),ie&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"task-section-head",style:D?{marginTop:36}:void 0,children:[e.jsx("div",{className:"task-section-eyebrow",children:te?"Benchmarks by capability":"Task hierarchy"}),e.jsxs("div",{className:"task-section-title",children:["Subtasks ",e.jsxs("span",{className:"meta",children:["[",y.length,"]"]})]})]}),e.jsx("div",{className:"subtask-grid",children:y.map(s=>{const a=B.get(s.id)||[],t=w.has(s.id),b=t?a:a.slice(0,R),u=a.length-R;return e.jsxs("div",{className:"subtask-section",children:[e.jsxs("div",{className:"subtask-head",children:[e.jsx(g,{to:`/tasks/${s.slug||s.id}`,className:"subtask-head-name",children:f(s.name,s.slug)}),e.jsx("span",{className:"subtask-head-meta",children:a.length>0?`[${a.length} benchmark${a.length===1?"":"s"}]`:`[${(s.paper_count??0).toLocaleString()} papers]`})]}),b.length>0?b.map((r,p)=>e.jsxs("div",{className:"bench-row",onClick:()=>c(E(r.slug||r.id,s.slug||s.id)),children:[e.jsx("div",{className:"bench-row-num",children:String(p+1).padStart(2,"0")}),e.jsxs("div",{className:"bench-row-main",children:[e.jsx("div",{className:"bench-row-name",children:r.name}),e.jsx("div",{className:"bench-row-sub",children:r.paper_count!=null&&e.jsxs("span",{children:[e.jsx("strong",{children:r.paper_count})," ENTRIES"]})})]}),e.jsx("div",{className:"bench-row-arrow",children:"→"})]},r.id)):e.jsxs(g,{to:`/tasks/${s.slug||s.id}`,className:"subtask-summary",children:[e.jsxs("span",{children:[(s.paper_count??0).toLocaleString()," papers"]}),s.description&&e.jsx("span",{className:"subtask-summary-desc",children:s.description})]}),u>0&&e.jsx("button",{type:"button",className:"bench-show-more",onClick:()=>le(s.id),children:t?`− show top ${R}`:`+ show ${u} more benchmark${u===1?"":"s"}`})]},s.id)})})]}),e.jsxs("div",{className:"task-section-head",style:{marginTop:36},children:[e.jsx("div",{className:"task-section-eyebrow",children:"Top trending · sort below"}),e.jsxs("div",{className:"task-section-title",children:["Papers ",e.jsxs("span",{className:"meta",children:["[",(o.paper_count??0).toLocaleString(),"]"]})]})]}),e.jsx(xe,{feed:d}),e.jsx(je,{query:N,cards:Z,empty:"No papers in this task yet."})]}),e.jsxs("aside",{className:"task-side",children:[C.length>0&&o.slug!=="healthcare"&&e.jsxs("div",{className:"side-block",children:[e.jsx("div",{className:"side-block-num",children:"01/"}),e.jsx("div",{className:"side-block-label",children:"Sister Tasks"}),C.slice(0,8).map(s=>e.jsxs(g,{to:`/tasks/${s.slug||s.id}`,className:"side-link-row",children:[e.jsx("span",{children:f(s.name,s.slug)}),s.paper_count!=null&&e.jsx("span",{className:"count",children:s.paper_count.toLocaleString()})]},s.id))]}),$.length>0&&e.jsxs("div",{className:"side-block",children:[e.jsx("div",{className:"side-block-num",children:"02/"}),e.jsx("div",{className:"side-block-label",children:"Common Methods"}),$.map(s=>e.jsxs("div",{className:"side-method-row",children:[e.jsx(ge,{method:{slug:s.slug,name:s.name}}),e.jsxs("span",{className:"num",children:["·",s.count]})]},s.id))]})]})]})]})};export{Ie as HealthcareMedicalAiHub,Re as RecommendedFrameworkLinks,Le as TaskBreadcrumb,Ss as default}; +import{j as e,L as g,V as oe,u as de,e as me,d as j,b as G,p as he,a3 as pe,o as K,T as O}from"./index-CjdUkE4w.js";import{R as ue}from"./ResearchFollowButton-DcTptDpW.js";import{M as ge}from"./SotaBadges-CyScuNCv.js";import{u as be,b as xe,a as je}from"./PaperFeed-D3FZw29k.js";import{A as L}from"./arrow-right-BrRhWCQS.js";import{B as ke}from"./BenchmarkTrendSparkline-Dfex1cLI.js";import{M as W}from"./MarkdownText-MrITlqRE.js";import{c as J}from"./catalog-qXcKve0z.js";import{p as _e}from"./papers-DgZwjF3K.js";import{i as Ne}from"./apiErrors-D0w5By9R.js";import{f as fe}from"./frameworks-DDA0P4Tf.js";import{u as we}from"./preferences-DMhkYrri.js";import{s as ve}from"./slug-BpH-Nkvz.js";import{d as f,t as ye}from"./transform-CRNzYLch.js";import{u as Se}from"./usePapers-BZThqZCx.js";import{S as P}from"./skeleton-DTWi7Ctg.js";import{A as Te,a as Ee}from"./alert-BM9Xfuyy.js";import Be from"./NotFound-BeWhm9El.js";import{T as $e}from"./trophy-BQy3NGXy.js";import{G as Me}from"./github-4bW4WI_e.js";import"./researchTopic-NmABF6tT.js";import"./useMutation-BYtVrkc7.js";import"./plus-AztI1566.js";import"./colors-BkWRhvFI.js";import"./PaperCard-dvXhr75r.js";import"./AuthorAvatar-D9249Frl.js";import"./Icon-CGRs4BYD.js";import"./LatexTitle-DESKtS30.js";import"./safeExternalHref-CkBrsh84.js";import"./popover-Df5_dywQ.js";import"./useIntersectionObserver-Ch6RpsSk.js";/* empty css */import"./PaperPreviewLink-zGfFNaz6.js";import"./index-tLcwYp0U.js";import"./index-Dj6aE-6E.js";import"./katex-DkKDou_j.js";import"./hover-card-CIBIV2Hx.js";import"./curation-CyyuHfv5.js";import"./account-DoluPGSd.js";import"./useInfiniteQuery-DeZTTVbI.js";const Ce=()=>e.jsxs(g,{to:"/astra-for-robotics",className:"task-featured-collection","aria-label":"Featured collection: GPT-6 Astra for Robotics",children:[e.jsx("span",{className:"task-featured-collection-eyebrow",children:"Featured collection"}),e.jsx("strong",{children:"GPT-6 Astra for Robotics"}),e.jsx("span",{className:"task-featured-collection-description",children:"Papers and demos that put GPT-6 Astra in control of real and simulated robots, as the policy itself or as an agent orchestrating the stack."}),e.jsxs("span",{className:"task-featured-collection-meta",children:["Explore the collection",e.jsx(L,{size:14,"aria-hidden":"true"})]})]}),X=n=>{const c=n.match(/\(([^()]*)\)\s*$/);return c?c[1].split(",").map(d=>d.trim()).filter(Boolean):[]};function Fe(n,c){const d=X(n);if(c===void 0)return"standard";const i=new Set(X(c).map(l=>l.toLowerCase())),m=d.filter(l=>!i.has(l.toLowerCase()));return m.length?m.join(", "):n}function Ae(n,c){const d=new Map(n.map(l=>[l.id,l])),i=l=>{const x=new Set([l.id]);let k=l;for(;;){const w=c(k),_=w?d.get(w):void 0;if(!_)return k.id;if(x.has(_.id))return l.id;x.add(_.id),k=_}},m=new Map;return n.forEach(l=>{const x=i(l);m.set(x,[...m.get(x)||[],l])}),[...m].map(([l,x])=>({key:l,members:[d.get(l),...x.filter(k=>k.id!==l)]}))}const R=3,Pe=[{slug:"healthcare",eyebrow:"Clinical systems",title:"Clinical AI & Healthcare",description:"Agents, clinical workflows, medical calculators, safety, and decision support.",href:"#benchmarks"},{slug:"medical-question-answering",eyebrow:"Language & reasoning",title:"Medical Question Answering",description:"Medical exams, biomedical evidence, clinical comprehension, and explanations.",href:"/tasks/medical-question-answering"},{slug:"medical-imaging",eyebrow:"Vision",title:"Medical Imaging",description:"Radiology, pathology, ophthalmology, ultrasound, and diagnostic imaging.",href:"/tasks/medical-imaging"},{slug:"medical-visual-question-answering",eyebrow:"Multimodal",title:"Medical Visual Question Answering",description:"Questions grounded in radiology, pathology, and other biomedical images.",href:"/tasks/medical-visual-question-answering"}],Re=({frameworks:n})=>n.length===0?null:e.jsxs("div",{className:"task-framework-links",children:[e.jsx("span",{className:"task-framework-links-label",children:"Recommended frameworks"}),n.map(c=>e.jsxs(g,{to:`/papers?framework=${encodeURIComponent(c.framework_slug)}`,className:"task-framework-link",children:[e.jsx("span",{children:c.framework_name}),e.jsxs("span",{className:"task-framework-link-stars",children:["★ ",fe(c.num_stars)]})]},c.framework_id))]}),Le=({task:n,area:c,parents:d})=>e.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[e.jsx(g,{to:"/tasks",children:"Tasks"}),c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sep",children:"/"}),e.jsx(g,{to:`/tasks#area-${ve(c.name)}`,children:c.name})]}),[...d].reverse().map(i=>e.jsxs(oe.Fragment,{children:[e.jsx("span",{className:"sep",children:"/"}),e.jsx(g,{to:`/tasks/${i.slug||i.id}`,children:f(i.name,i.slug)})]},i.id)),e.jsx("span",{className:"sep",children:"/"}),e.jsx("span",{style:{color:"var(--accent-text)"},children:f(n.name,n.slug)})]}),Ie=({task:n,relatedTasks:c})=>{const d=new Map([n,...c].map(i=>[i.slug,i]));return e.jsxs("section",{className:"medical-ai-hub","aria-labelledby":"medical-ai-hub-title",children:[e.jsxs("div",{className:"medical-ai-hub-heading",children:[e.jsx("span",{children:"Medical AI directory"}),e.jsx("h2",{id:"medical-ai-hub-title",children:"Explore Healthcare & Medical AI"}),e.jsx("p",{children:"Browse the field by clinical application, language, vision, or multimodal reasoning."})]}),e.jsx("div",{className:"medical-ai-hub-grid",children:Pe.map(i=>{const m=d.get(i.slug),l=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"medical-ai-hub-card-eyebrow",children:i.eyebrow}),e.jsx("strong",{children:i.title}),e.jsx("span",{className:"medical-ai-hub-card-description",children:i.description}),e.jsxs("span",{className:"medical-ai-hub-card-meta",children:[(m==null?void 0:m.paper_count)!=null?`${m.paper_count.toLocaleString()} papers`:"Explore task",e.jsx(L,{size:14,"aria-hidden":"true"})]})]});return i.slug==="healthcare"?e.jsx("a",{href:i.href,className:"medical-ai-hub-card",children:l},i.slug):e.jsx(g,{to:i.href,className:"medical-ai-hub-card",children:l},i.slug)})})]})},qe=n=>[...n].sort((c,d)=>{const i=c.slug==="classic-language-modeling",m=d.slug==="classic-language-modeling";return i!==m?i?1:-1:0}),Ss=()=>{var V,z,U;const{taskSlug:n}=de(),c=me(),d=be(),{searchParams:i}=d,[m,l]=j.useState(!1),[x,k]=j.useState({}),[w,_]=j.useState(()=>new Set),{preferences:Y}=we(),E=(s,a)=>{const t=s||"";return a?`/benchmark/${t}?task=${encodeURIComponent(a)}`:`/benchmark/${t}`},v=Y.hide_closed_source_evals?!0:void 0,h=G({queryKey:[...K.taskPage,n,v],queryFn:()=>J.taskPage(n,{is_open:v}),enabled:!!n,staleTime:O});j.useEffect(()=>{var t;const s=(t=h.data)==null?void 0:t.task.slug;if(!n||!s||s===n)return;const a=i.toString();c(`/tasks/${s}${a?`?${a}`:""}`,{replace:!0})},[c,(V=h.data)==null?void 0:V.task.slug,i,n]);const I=G({queryKey:[...K.taskBenchmarkTrends,n,v],queryFn:()=>J.trendingBenchmarks(n,{limit:100,min_recent_papers:0,is_open:v}),enabled:!!n,staleTime:O}),y=j.useMemo(()=>{var s;return qe(((s=h.data)==null?void 0:s.children)||[])},[h.data]),B=j.useMemo(()=>{var a;const s=new Map;return(((a=h.data)==null?void 0:a.subtask_benchmarks)||[]).forEach(t=>{s.set(t.subtask_id,t.benchmarks||[])}),s},[h.data]),N=Se([...he.feeds.task,n,d.filters],s=>_e.forTask(n,{...d.filters,page:s,page_size:20,repository_limit:1}),{enabled:!!n}),Z=j.useMemo(()=>{var s;return((s=N.data)==null?void 0:s.pages.flatMap(a=>a.results.map(ye)))??[]},[N.data]),$=j.useMemo(()=>{var a;const s={};return(a=N.data)==null||a.pages.forEach(t=>t.results.forEach(b=>(b.methods||[]).forEach(u=>{const r=u.slug||u.id;s[r]||(s[r]={id:u.id,name:u.name,slug:u.slug||"",count:0}),s[r].count++}))),Object.values(s).sort((t,b)=>b.count-t.count).slice(0,8)},[N.data]);if(h.isLoading)return e.jsxs("div",{className:"page",children:[e.jsx(P,{className:"h-12 w-1/2 mb-4"}),e.jsx(P,{className:"h-6 w-1/3 mb-8"}),e.jsx(P,{className:"h-64 w-full"})]});if(Ne(h.error))return e.jsx(Be,{});if(h.error||!h.data)return e.jsx("div",{className:"page",children:e.jsx(Te,{variant:"destructive",children:e.jsx(Ee,{children:"Task not found."})})});const o=h.data.task,ee=h.data.parents||[],M=f(o.name,o.slug),C=(h.data.sisters||[]).filter(s=>s.id!==o.id),se=h.data.recommended_frameworks||[],S=h.data.benchmarks||[],q=new Map(S.map(s=>[s.id,s])),ae=new Set(S.map(s=>s.id)),H=(((z=I.data)==null?void 0:z.results)||[]).filter(s=>ae.has(s.id)).map(s=>{const a=q.get(s.id);return{...s,best_model_name:(a==null?void 0:a.best_model_name)??s.best_model_name,best_paper_route:a==null?void 0:a.best_paper_route,best_paper_title:a==null?void 0:a.best_paper_title,best_code_url:a==null?void 0:a.best_code_url}}),F=H.length?H:S.map(s=>({id:s.id,name:s.name,slug:s.slug,full_name:s.full_name,recent_paper_count:0,baseline_paper_count:0,all_time_paper_count:s.paper_count||0,trend_score:0,support_weighted_score:0,rate_change:null,latest_reported_on:null,best_model_name:s.best_model_name,best_paper_route:s.best_paper_route,best_paper_title:s.best_paper_title,best_code_url:s.best_code_url,history:[]})),T=Ae(F,s=>{var a;return(a=q.get(s.id))==null?void 0:a.parent_dataset_id}),re=m?T:T.slice(0,5),ne=T.slice(5).reduce((s,a)=>s+a.members.length,0),Q=((U=I.data)==null?void 0:U.recent_days)||90,te=y.some(s=>(B.get(s.id)||[]).length>0),ie=y.length>0,D=F.length>0,ce=(()=>{const s=new Set;return S.forEach(a=>s.add(a.id)),B.forEach(a=>a.forEach(t=>s.add(t.id))),s.size})(),le=s=>{_(a=>{const t=new Set(a);return t.has(s)?t.delete(s):t.add(s),t})};return e.jsxs("div",{className:"page",children:[e.jsx(Le,{task:o,area:h.data.area,parents:ee}),e.jsxs("div",{className:o.image_url?`task-hero-grid${o.slug==="auto-research"?" task-hero-grid--wide":""}`:void 0,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--accent-text)",letterSpacing:"0.1em",marginBottom:8},children:"TASK"}),e.jsx("h1",{className:"domain-mega-title",children:M}),e.jsx(ue,{kind:"task",entityId:o.id}),o.description&&e.jsx(W,{className:"task-explainer",text:o.description}),e.jsxs("div",{className:"task-quickstats",children:[e.jsxs("span",{children:[e.jsx("span",{className:"num",children:(o.paper_count??0).toLocaleString()}),"PAPERS"]}),e.jsxs("span",{children:[e.jsx("span",{className:"num",children:ce}),"BENCHMARKS"]}),e.jsxs("span",{children:[e.jsxs("span",{className:"num",children:[$.length,"+"]}),"METHODS USED"]})]}),e.jsx(Re,{frameworks:se})]}),o.image_url&&e.jsxs("figure",{className:`task-figure-card${o.slug==="omni-models"?" task-figure-card--compact":""}`,children:[e.jsx("div",{className:"task-figure-img-wrap",children:e.jsx("img",{className:"task-figure-img",src:pe(o.image_url)??void 0,alt:`${M} schematic`,onError:s=>{var a,t;(t=(a=s.currentTarget.parentElement)==null?void 0:a.parentElement)==null||t.style.setProperty("display","none")}})}),e.jsxs("figcaption",{children:["Figure · ",M,o.image_credit&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx(W,{className:"task-image-credit",text:o.image_credit})]})]})]})]}),o.slug==="healthcare"&&e.jsx(Ie,{task:o,relatedTasks:C}),o.slug==="robotics"&&e.jsx(Ce,{}),e.jsxs("div",{className:"task-page-grid",style:{marginTop:28},children:[e.jsxs("div",{children:[D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"task-section-head",id:"benchmarks",children:[e.jsxs("div",{className:"task-section-eyebrow",children:[Q,"-day reporting activity · select a benchmark"]}),e.jsxs("div",{className:"task-section-title",children:["Benchmarks ",e.jsxs("span",{className:"meta",children:["[",F.length,"]"]})]})]}),e.jsxs("div",{className:"benchmark-trend-table",role:"table","aria-label":"Trending benchmarks",children:[e.jsxs("div",{className:"benchmark-trend-head",role:"row",children:[e.jsx("span",{role:"columnheader",children:"Trend"}),e.jsx("span",{role:"columnheader",children:"Benchmark"}),e.jsx("span",{role:"columnheader",children:"Best model"}),e.jsx("span",{role:"columnheader",children:"Paper title"}),e.jsx("span",{role:"columnheader",children:"Code"}),e.jsx("span",{role:"columnheader",children:"Compare"})]}),re.map(({key:s,members:a})=>{const t=a[0],b=p=>p===t?"standard":Fe(p.name,t.name),u=[t,...a.slice(1).sort((p,A)=>b(p).localeCompare(b(A),void 0,{sensitivity:"base"}))],r=u.find(p=>p.id===x[s])??t;return e.jsxs("div",{className:"benchmark-trend-row",role:"row",children:[e.jsxs("div",{className:"benchmark-trend-cell",role:"cell",children:[e.jsx(ke,{history:r.history,benchmarkName:r.name}),e.jsxs("div",{className:"benchmark-trend-meta",children:[e.jsxs("span",{children:[e.jsx("strong",{children:r.recent_paper_count})," ",r.recent_paper_count===1?"paper":"papers"," /"," ",Q,"d"]}),r.rate_change==null?r.recent_paper_count>0&&e.jsx("span",{className:"benchmark-trend-change is-new",children:"new"}):e.jsxs("span",{className:`benchmark-trend-change ${r.rate_change>=1?"is-up":"is-down"}`,children:[r.rate_change>=1?"↑":"↓"," ",r.rate_change.toFixed(1),"×"]})]})]}),e.jsxs("div",{className:"benchmark-trend-benchmark",role:"cell",children:[e.jsx(g,{className:"bench-row-name",to:E(r.slug||r.id,n),children:r.name}),u.length>1&&e.jsx("div",{className:"bench-row-variants",role:"group","aria-label":`Evaluation protocols for ${t.name}`,children:u.map(p=>e.jsx("button",{type:"button",className:"bench-row-variant","aria-pressed":p.id===r.id,title:p.name,onClick:()=>k(A=>({...A,[s]:p.id})),children:b(p)},p.id))}),e.jsx("div",{className:"bench-row-sub",children:e.jsxs("span",{children:[e.jsx("strong",{children:r.all_time_paper_count})," reporting papers"]})})]}),e.jsx("div",{className:"bench-row-best",role:"cell",children:r.best_model_name?e.jsxs(e.Fragment,{children:[e.jsx($e,{size:13,className:"bench-row-best-icon"}),e.jsx("span",{className:"bench-row-best-name",children:r.best_model_name})]}):e.jsx("span",{className:"bench-row-best-empty",children:"—"})}),e.jsx("div",{className:"bench-row-paper",role:"cell",children:r.best_paper_route&&r.best_paper_title?e.jsx(g,{to:`/paper/${encodeURIComponent(r.best_paper_route)}`,children:r.best_paper_title}):e.jsx("span",{className:"bench-row-best-empty",children:"—"})}),e.jsx("div",{className:"bench-row-code",role:"cell",children:r.best_code_url?e.jsx("a",{href:r.best_code_url,target:"_blank",rel:"noopener noreferrer","aria-label":`Code for ${r.best_paper_title||r.best_model_name}`,children:e.jsx(Me,{size:18,strokeWidth:1.8,"aria-hidden":"true"})}):e.jsx("span",{className:"bench-row-best-empty",children:"—"})}),e.jsx("div",{className:"bench-row-compare",role:"cell",children:e.jsxs(g,{to:E(r.slug||r.id,n),"aria-label":`Compare ${r.best_model_name||"the best model"} with all results on ${r.name}`,children:[e.jsx("span",{children:"See all"}),e.jsx(L,{size:11,strokeWidth:2,"aria-hidden":"true"})]})})]},s)})]}),T.length>5&&e.jsx("button",{type:"button",className:"bench-show-more",onClick:()=>l(s=>!s),children:m?"− show top 5":`+ show ${ne} more benchmarks`})]}),ie&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"task-section-head",style:D?{marginTop:36}:void 0,children:[e.jsx("div",{className:"task-section-eyebrow",children:te?"Benchmarks by capability":"Task hierarchy"}),e.jsxs("div",{className:"task-section-title",children:["Subtasks ",e.jsxs("span",{className:"meta",children:["[",y.length,"]"]})]})]}),e.jsx("div",{className:"subtask-grid",children:y.map(s=>{const a=B.get(s.id)||[],t=w.has(s.id),b=t?a:a.slice(0,R),u=a.length-R;return e.jsxs("div",{className:"subtask-section",children:[e.jsxs("div",{className:"subtask-head",children:[e.jsx(g,{to:`/tasks/${s.slug||s.id}`,className:"subtask-head-name",children:f(s.name,s.slug)}),e.jsx("span",{className:"subtask-head-meta",children:a.length>0?`[${a.length} benchmark${a.length===1?"":"s"}]`:`[${(s.paper_count??0).toLocaleString()} papers]`})]}),b.length>0?b.map((r,p)=>e.jsxs("div",{className:"bench-row",onClick:()=>c(E(r.slug||r.id,s.slug||s.id)),children:[e.jsx("div",{className:"bench-row-num",children:String(p+1).padStart(2,"0")}),e.jsxs("div",{className:"bench-row-main",children:[e.jsx("div",{className:"bench-row-name",children:r.name}),e.jsx("div",{className:"bench-row-sub",children:r.paper_count!=null&&e.jsxs("span",{children:[e.jsx("strong",{children:r.paper_count})," ENTRIES"]})})]}),e.jsx("div",{className:"bench-row-arrow",children:"→"})]},r.id)):e.jsxs(g,{to:`/tasks/${s.slug||s.id}`,className:"subtask-summary",children:[e.jsxs("span",{children:[(s.paper_count??0).toLocaleString()," papers"]}),s.description&&e.jsx("span",{className:"subtask-summary-desc",children:s.description})]}),u>0&&e.jsx("button",{type:"button",className:"bench-show-more",onClick:()=>le(s.id),children:t?`− show top ${R}`:`+ show ${u} more benchmark${u===1?"":"s"}`})]},s.id)})})]}),e.jsxs("div",{className:"task-section-head",style:{marginTop:36},children:[e.jsx("div",{className:"task-section-eyebrow",children:"Top trending · sort below"}),e.jsxs("div",{className:"task-section-title",children:["Papers ",e.jsxs("span",{className:"meta",children:["[",(o.paper_count??0).toLocaleString(),"]"]})]})]}),e.jsx(xe,{feed:d}),e.jsx(je,{query:N,cards:Z,empty:"No papers in this task yet."})]}),e.jsxs("aside",{className:"task-side",children:[C.length>0&&o.slug!=="healthcare"&&e.jsxs("div",{className:"side-block",children:[e.jsx("div",{className:"side-block-num",children:"01/"}),e.jsx("div",{className:"side-block-label",children:"Sister Tasks"}),C.slice(0,8).map(s=>e.jsxs(g,{to:`/tasks/${s.slug||s.id}`,className:"side-link-row",children:[e.jsx("span",{children:f(s.name,s.slug)}),s.paper_count!=null&&e.jsx("span",{className:"count",children:s.paper_count.toLocaleString()})]},s.id))]}),$.length>0&&e.jsxs("div",{className:"side-block",children:[e.jsx("div",{className:"side-block-num",children:"02/"}),e.jsx("div",{className:"side-block-label",children:"Common Methods"}),$.map(s=>e.jsxs("div",{className:"side-method-row",children:[e.jsx(ge,{method:{slug:s.slug,name:s.name}}),e.jsxs("span",{className:"num",children:["·",s.count]})]},s.id))]})]})]})]})};export{Ie as HealthcareMedicalAiHub,Re as RecommendedFrameworkLinks,Le as TaskBreadcrumb,Ss as default}; diff --git a/assets/TagsIndexView-BwVoxBoD.js b/assets/TagsIndexView-Bqdox0Xx.js similarity index 97% rename from assets/TagsIndexView-BwVoxBoD.js rename to assets/TagsIndexView-Bqdox0Xx.js index 5bb63c740fff15b57549d69930c99f85ba913ae7..73867169fa5cf29453cee30d471b545429a4ef01 100644 --- a/assets/TagsIndexView-BwVoxBoD.js +++ b/assets/TagsIndexView-Bqdox0Xx.js @@ -1,4 +1,4 @@ -import{s as e,b as s,d as g,j as a,L as z,o as j,T as p}from"./index-DyXq7-Tg.js";import{c as k}from"./catalog-CRar2olQ.js";import{c as v,h as u}from"./colors-BkWRhvFI.js";import{d as f}from"./transform-D46m70Qr.js";import{s as S}from"./slug-BpH-Nkvz.js";import{S as L}from"./search-8ssWDP68.js";import{I as C,T as V}from"./triangle-alert-uZ3fXFkp.js";import{S as A}from"./share-2-fiavn5SS.js";import{T as H}from"./trending-up-OM6wBVvQ.js";import{M as T}from"./moon-DMVsctTM.js";import{T as F}from"./thumbs-up-CPLlGli7.js";import{D as Z}from"./database-DflzbaZ5.js";import{T as B}from"./trophy-BtgLmZ39.js";import{F as P}from"./file-text-dvKtHbmD.js";import{A as N}from"./activity-S-FQ6Anu.js";import{G as D}from"./globe-BMJtRs4F.js";import{S as E}from"./sparkles-CcIiUzzc.js";import{A as _,a as G}from"./alert-gbJBhAVE.js";import{A as I,a as U,b as W}from"./AreaSection-BxnKzNK0.js";import{T as Q}from"./TaxonomySuggestionTile-jIiLMp4q.js";import{u as R,T as $}from"./useHashScrollOnReady-D5UCCQuT.js";import{s as K}from"./areas-Dvi8w2dp.js";import"./skeleton-C3IIzpSL.js";import"./SignInToEditDialog-B-oWVno5.js";import"./button-DZeAbOf2.js";import"./input-DJqCAbs7.js";import"./textarea-DPixlM5U.js";import"./searchable-select-DiDLwvbI.js";import"./popover-CTBEUp7Y.js";import"./dialog-CfM0Uql2.js";import"./loader-circle-C75KLEgx.js";import"./useMutation-UWxBeqtn.js";import"./submissions-Cz_J-Ha2.js";import"./plus-Yh42pKZz.js";/** +import{s as e,b as s,d as g,j as a,L as z,o as j,T as p}from"./index-CjdUkE4w.js";import{c as k}from"./catalog-qXcKve0z.js";import{c as v,h as u}from"./colors-BkWRhvFI.js";import{d as f}from"./transform-CRNzYLch.js";import{s as S}from"./slug-BpH-Nkvz.js";import{S as L}from"./search-DxMn7VKI.js";import{I as C,T as V}from"./triangle-alert-DF8Mdy0J.js";import{S as A}from"./share-2-Nvga0TP8.js";import{T as H}from"./trending-up-BMb-8Pi8.js";import{M as T}from"./moon-HVqBvdxs.js";import{T as F}from"./thumbs-up-Dn_5H93T.js";import{D as Z}from"./database-b_ekt_5x.js";import{T as B}from"./trophy-BQy3NGXy.js";import{F as P}from"./file-text-CHlxsNJC.js";import{A as N}from"./activity--6WvmXv2.js";import{G as D}from"./globe-mBp0l-nC.js";import{S as E}from"./sparkles-CIfeDmV2.js";import{A as _,a as G}from"./alert-BM9Xfuyy.js";import{A as I,a as U,b as W}from"./AreaSection-iYSRoy6-.js";import{T as Q}from"./TaxonomySuggestionTile-ByzqhBFs.js";import{u as R,T as $}from"./useHashScrollOnReady-mScSLUem.js";import{s as K}from"./areas-Dvi8w2dp.js";import"./skeleton-DTWi7Ctg.js";import"./SignInToEditDialog-rWxdYNRK.js";import"./button-DetZl_ch.js";import"./input-7i-rZ7fA.js";import"./textarea-biscLKBK.js";import"./searchable-select-EPf13F1I.js";import"./popover-Df5_dywQ.js";import"./dialog-BzX9PD3v.js";import"./loader-circle-xTdSzHv_.js";import"./useMutation-BYtVrkc7.js";import"./submissions-CQ6M0giV.js";import"./plus-AztI1566.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/TaxonomySuggestionTile-jIiLMp4q.js b/assets/TaxonomySuggestionTile-ByzqhBFs.js similarity index 76% rename from assets/TaxonomySuggestionTile-jIiLMp4q.js rename to assets/TaxonomySuggestionTile-ByzqhBFs.js index afc40f8a5e7c906f702afe9a893a40d1b77c614f..fe2117b5b497876be6aaa2fa601f036780fdfd9b 100644 --- a/assets/TaxonomySuggestionTile-jIiLMp4q.js +++ b/assets/TaxonomySuggestionTile-ByzqhBFs.js @@ -1 +1 @@ -import{a as u,d as t,j as e}from"./index-DyXq7-Tg.js";import{S as c,a as m}from"./SignInToEditDialog-B-oWVno5.js";import{P as p}from"./plus-Yh42pKZz.js";function j({kind:s}){const{user:a}=u(),[i,n]=t.useState(!1),[l,o]=t.useState(!1),r=`Suggest a new ${s}...`,g=()=>{a?n(!0):o(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"tag-cell taxonomy-suggestion-cell",onClick:g,children:[e.jsxs("div",{className:"name",children:[e.jsx(p,{className:"taxonomy-suggestion-icon","aria-hidden":"true"}),r]}),e.jsx("div",{className:"meta",children:e.jsx("span",{children:"Propose an addition"})})]}),e.jsx(c,{open:i,onOpenChange:n,kind:s}),e.jsx(m,{open:l,onOpenChange:o,sectionLabel:`${s}s`,returnTo:typeof window<"u"?window.location.pathname:`/${s}s`,taxonomySuggestion:!0})]})}export{j as T}; +import{a as u,d as t,j as e}from"./index-CjdUkE4w.js";import{S as c,a as m}from"./SignInToEditDialog-rWxdYNRK.js";import{P as p}from"./plus-AztI1566.js";function j({kind:s}){const{user:a}=u(),[i,n]=t.useState(!1),[l,o]=t.useState(!1),r=`Suggest a new ${s}...`,g=()=>{a?n(!0):o(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"tag-cell taxonomy-suggestion-cell",onClick:g,children:[e.jsxs("div",{className:"name",children:[e.jsx(p,{className:"taxonomy-suggestion-icon","aria-hidden":"true"}),r]}),e.jsx("div",{className:"meta",children:e.jsx("span",{children:"Propose an addition"})})]}),e.jsx(c,{open:i,onOpenChange:n,kind:s}),e.jsx(m,{open:l,onOpenChange:o,sectionLabel:`${s}s`,returnTo:typeof window<"u"?window.location.pathname:`/${s}s`,taxonomySuggestion:!0})]})}export{j as T}; diff --git a/assets/TrendsView-DCijqOnv.js b/assets/TrendsView-DPKj3I8y.js similarity index 97% rename from assets/TrendsView-DCijqOnv.js rename to assets/TrendsView-DPKj3I8y.js index 48e3ae0daf653ac96cc9cd0811ed425d1e6cb688..ac85a6026ab284d4f186453306ad89440339c7e5 100644 --- a/assets/TrendsView-DCijqOnv.js +++ b/assets/TrendsView-DPKj3I8y.js @@ -1 +1 @@ -import{V as I,j as e,ac as X,b as G}from"./index-DyXq7-Tg.js";import{A as J,a as V}from"./alert-gbJBhAVE.js";import{S as P}from"./skeleton-C3IIzpSL.js";const m=t=>{const r=/^(\d{4})-(0[1-9]|1[0-2])$/.exec(t);if(!r)return t;const[,s,l]=r;return`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][Number(l)-1]} '${s.slice(2)}`},g=980,j=400,x=62,B=26,f=30,E=58,u=g-x-B,A=j-f-E,v=f+A,Q=t=>{if(t.length<3)return t.map((s,l)=>`${l?"L":"M"}${s[0]} ${s[1]}`).join(" ");let r=`M${t[0][0]} ${t[0][1]}`;for(let s=0;s{const[a,y]=I.useState(null),i=r.length,b=l[l.length-1],d=n=>x+u*(i===1?0:n/(i-1)),p=n=>f+A*(1-n/b);if(i===0)return null;const R=r.map((n,h)=>[d(h),p(n.percent)]),F=Q(R),_=`${F} L ${d(i-1)} ${v} L ${x} ${v} Z`,w=i<=12?1:Math.ceil(i/8),O=n=>{const h=n.currentTarget.getBoundingClientRect(),S=(n.clientX-h.left)/h.width*g,k=i>1?u/(i-1):u,q=Math.max(0,Math.min(i-1,Math.round((S-x)/k)));y(q)},H=`trend-gradient-${t}`;return e.jsxs("figure",{className:"trend-chart",children:[e.jsxs("div",{className:"trend-chart-visual",children:[e.jsxs("svg",{viewBox:`0 0 ${g} ${j}`,width:"100%",role:"img","aria-label":`${c} by ${o.toLowerCase()}, from ${m(r[0].month)} (${r[0].percent}%) to ${m(r[i-1].month)} (${r[i-1].percent}%)`,style:{display:"block",overflow:"visible",cursor:"crosshair"},onPointerMove:O,onPointerLeave:()=>y(null),children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:H,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",style:{stopColor:s,stopOpacity:.26}}),e.jsx("stop",{offset:"100%",style:{stopColor:s,stopOpacity:.02}})]})}),l.map(n=>e.jsxs("g",{children:[e.jsx("line",{x1:x,x2:g-B,y1:p(n),y2:p(n),stroke:"var(--hairline)",strokeWidth:1}),e.jsxs("text",{x:x-14,y:p(n)+4,textAnchor:"end",style:W,children:[n,"%"]})]},n)),e.jsx("path",{d:_,fill:`url(#${H})`}),e.jsx("path",{d:F,fill:"none",stroke:s,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),r.map((n,h)=>{const S=h===i-1,k=h%w===0&&i-1-h>=w/2;return!S&&!k?null:e.jsx("text",{x:d(h),y:v+24,textAnchor:"middle",style:W,children:m(n.month)},n.month)}),e.jsx("text",{x:x+u/2,y:j-4,textAnchor:"middle",style:z,children:o}),e.jsx("text",{transform:`translate(16 ${f+A/2}) rotate(-90)`,textAnchor:"middle",style:z,children:c}),a!=null&&e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:d(a),x2:d(a),y1:f,y2:v,stroke:s,strokeWidth:1,strokeDasharray:"3 4",opacity:.5}),e.jsx("circle",{cx:d(a),cy:p(r[a].percent),r:5,fill:"var(--bg)",stroke:s,strokeWidth:2})]})]}),a!=null&&e.jsxs("div",{style:{position:"absolute",left:`${d(a)/g*100}%`,top:`${p(r[a].percent)/j*100}%`,transform:"translate(-50%, calc(-100% - 14px))",background:"var(--bg-elevated)",border:"1px solid var(--hairline)",borderRadius:6,boxShadow:"0 8px 26px rgba(0,0,0,.13)",padding:"7px 12px",pointerEvents:"none",whiteSpace:"nowrap",zIndex:3},children:[e.jsx("div",{style:{fontFamily:"var(--serif)",fontStyle:"italic",color:"var(--ink-faint)",fontSize:13,marginBottom:2},children:m(r[a].month)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,fontFamily:"var(--mono)",fontWeight:600,fontSize:15,color:"var(--ink)"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:s,display:"inline-block"}}),r[a].percent,"%"]})]})]}),e.jsxs("details",{className:"trend-chart-table",children:[e.jsx("summary",{style:{fontFamily:"var(--mono)",fontSize:11,letterSpacing:"0.04em",color:"var(--ink-faint)",cursor:"pointer"},children:"View data table"}),e.jsxs("table",{style:{marginTop:8,borderCollapse:"collapse",fontFamily:"var(--mono)",fontSize:12,color:"var(--ink-soft)"},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{textAlign:"left",padding:"3px 18px 3px 0"},children:o}),e.jsx("th",{style:{textAlign:"right",padding:"3px 0"},children:c})]})}),e.jsx("tbody",{children:r.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"2px 18px 2px 0"},children:m(n.month)}),e.jsxs("td",{style:{textAlign:"right",padding:"2px 0"},children:[n.percent,"%"]})]},n.month))})]})]})]})};class Y{constructor(r){this.request=r}trends(){return this.request("/stats/trends")}}const K=new Y(X),$={maxWidth:960,padding:"48px 0 8px",borderTop:"1px solid var(--hairline)",marginTop:48},T={fontFamily:"var(--serif)",fontSize:34,fontWeight:500,letterSpacing:"-0.02em",margin:"0 0 10px",color:"var(--ink)"},M={fontFamily:"var(--serif)",fontSize:18,lineHeight:1.55,color:"var(--ink-soft)",maxWidth:620,margin:"0 0 8px"},C={fontFamily:"var(--mono)",fontSize:12,fontWeight:600,letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--ink-faint)",marginBottom:8},N={fontFamily:"var(--serif)",fontSize:17,lineHeight:1.6,color:"var(--ink-soft)",margin:0},D={height:320,marginTop:26},te=()=>{const t=G({queryKey:["research-trends"],queryFn:()=>K.trends(),staleTime:36e5});return e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["Research ",e.jsx("em",{children:"Trends"})]}),e.jsx("div",{className:"feed-subtitle",children:"How open science is changing across machine learning — tracked over time from arXiv and the Hugging Face Hub."})]})}),t.error&&e.jsx(J,{variant:"destructive",children:e.jsx(V,{children:"Failed to load research trends. Please try again."})}),e.jsxs("section",{style:$,children:[e.jsx("h2",{style:T,children:"Code Availability"}),e.jsx("p",{style:M,children:"The percentage of published papers that have at least one official code implementation on GitHub."}),e.jsx("div",{style:{marginTop:26},children:t.data?e.jsx(L,{id:"code",data:t.data.code_availability,color:"var(--trend-code)",yTicks:[0,20,40,60,80],yLabel:"Code Availability",xLabel:"Paper Publication Date"}):!t.error&&e.jsx(P,{style:D})})]}),e.jsxs("section",{style:$,children:[e.jsx("h2",{style:T,children:"Papers with Hugging Face artifacts"}),e.jsx("p",{style:M,children:"The percentage of published papers linked to at least one Hugging Face artifact — a model, dataset or Space — making the work directly runnable and reusable."}),e.jsx("div",{style:{marginTop:26},children:t.data?e.jsx(L,{id:"hf",data:t.data.hf_artifacts,color:"var(--trend-hf)",yTicks:[0,10,20,30,40,50],yLabel:"HF Artifact Coverage",xLabel:"Paper Publication Date"}):!t.error&&e.jsx(P,{style:D})})]}),e.jsxs("section",{style:{...$,paddingBottom:72},children:[e.jsx("h2",{style:{...T,fontSize:27},children:"How the data is collected"}),e.jsxs("div",{style:{display:"grid",gap:24,maxWidth:680},children:[e.jsxs("div",{children:[e.jsx("div",{style:C,children:"Code Availability"}),e.jsx("p",{style:N,children:"For every open-access machine learning paper, we check whether an official code implementation is linked on GitHub. The date axis is the paper's publication date."})]}),e.jsxs("div",{children:[e.jsx("div",{style:C,children:"Hugging Face artifacts"}),e.jsx("p",{style:N,children:"We resolve links between papers and the Hugging Face Hub, counting a paper as covered when it references at least one model, dataset or Space. The date axis is the paper's publication date."})]}),e.jsx("p",{style:{fontFamily:"var(--mono)",fontSize:12,lineHeight:1.6,color:"var(--ink-faint)",margin:"8px 0 0",letterSpacing:"0.02em"},children:"Figures use complete publication months. Historical Hugging Face coverage reflects artifacts currently linked in the catalog."})]})]})]})};export{te as default}; +import{V as I,j as e,ac as X,b as G}from"./index-CjdUkE4w.js";import{A as J,a as V}from"./alert-BM9Xfuyy.js";import{S as P}from"./skeleton-DTWi7Ctg.js";const m=t=>{const r=/^(\d{4})-(0[1-9]|1[0-2])$/.exec(t);if(!r)return t;const[,s,l]=r;return`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][Number(l)-1]} '${s.slice(2)}`},g=980,j=400,x=62,B=26,f=30,E=58,u=g-x-B,A=j-f-E,v=f+A,Q=t=>{if(t.length<3)return t.map((s,l)=>`${l?"L":"M"}${s[0]} ${s[1]}`).join(" ");let r=`M${t[0][0]} ${t[0][1]}`;for(let s=0;s{const[a,y]=I.useState(null),i=r.length,b=l[l.length-1],d=n=>x+u*(i===1?0:n/(i-1)),p=n=>f+A*(1-n/b);if(i===0)return null;const R=r.map((n,h)=>[d(h),p(n.percent)]),F=Q(R),_=`${F} L ${d(i-1)} ${v} L ${x} ${v} Z`,w=i<=12?1:Math.ceil(i/8),O=n=>{const h=n.currentTarget.getBoundingClientRect(),S=(n.clientX-h.left)/h.width*g,k=i>1?u/(i-1):u,q=Math.max(0,Math.min(i-1,Math.round((S-x)/k)));y(q)},H=`trend-gradient-${t}`;return e.jsxs("figure",{className:"trend-chart",children:[e.jsxs("div",{className:"trend-chart-visual",children:[e.jsxs("svg",{viewBox:`0 0 ${g} ${j}`,width:"100%",role:"img","aria-label":`${c} by ${o.toLowerCase()}, from ${m(r[0].month)} (${r[0].percent}%) to ${m(r[i-1].month)} (${r[i-1].percent}%)`,style:{display:"block",overflow:"visible",cursor:"crosshair"},onPointerMove:O,onPointerLeave:()=>y(null),children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:H,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",style:{stopColor:s,stopOpacity:.26}}),e.jsx("stop",{offset:"100%",style:{stopColor:s,stopOpacity:.02}})]})}),l.map(n=>e.jsxs("g",{children:[e.jsx("line",{x1:x,x2:g-B,y1:p(n),y2:p(n),stroke:"var(--hairline)",strokeWidth:1}),e.jsxs("text",{x:x-14,y:p(n)+4,textAnchor:"end",style:W,children:[n,"%"]})]},n)),e.jsx("path",{d:_,fill:`url(#${H})`}),e.jsx("path",{d:F,fill:"none",stroke:s,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),r.map((n,h)=>{const S=h===i-1,k=h%w===0&&i-1-h>=w/2;return!S&&!k?null:e.jsx("text",{x:d(h),y:v+24,textAnchor:"middle",style:W,children:m(n.month)},n.month)}),e.jsx("text",{x:x+u/2,y:j-4,textAnchor:"middle",style:z,children:o}),e.jsx("text",{transform:`translate(16 ${f+A/2}) rotate(-90)`,textAnchor:"middle",style:z,children:c}),a!=null&&e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:d(a),x2:d(a),y1:f,y2:v,stroke:s,strokeWidth:1,strokeDasharray:"3 4",opacity:.5}),e.jsx("circle",{cx:d(a),cy:p(r[a].percent),r:5,fill:"var(--bg)",stroke:s,strokeWidth:2})]})]}),a!=null&&e.jsxs("div",{style:{position:"absolute",left:`${d(a)/g*100}%`,top:`${p(r[a].percent)/j*100}%`,transform:"translate(-50%, calc(-100% - 14px))",background:"var(--bg-elevated)",border:"1px solid var(--hairline)",borderRadius:6,boxShadow:"0 8px 26px rgba(0,0,0,.13)",padding:"7px 12px",pointerEvents:"none",whiteSpace:"nowrap",zIndex:3},children:[e.jsx("div",{style:{fontFamily:"var(--serif)",fontStyle:"italic",color:"var(--ink-faint)",fontSize:13,marginBottom:2},children:m(r[a].month)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,fontFamily:"var(--mono)",fontWeight:600,fontSize:15,color:"var(--ink)"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:s,display:"inline-block"}}),r[a].percent,"%"]})]})]}),e.jsxs("details",{className:"trend-chart-table",children:[e.jsx("summary",{style:{fontFamily:"var(--mono)",fontSize:11,letterSpacing:"0.04em",color:"var(--ink-faint)",cursor:"pointer"},children:"View data table"}),e.jsxs("table",{style:{marginTop:8,borderCollapse:"collapse",fontFamily:"var(--mono)",fontSize:12,color:"var(--ink-soft)"},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{textAlign:"left",padding:"3px 18px 3px 0"},children:o}),e.jsx("th",{style:{textAlign:"right",padding:"3px 0"},children:c})]})}),e.jsx("tbody",{children:r.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"2px 18px 2px 0"},children:m(n.month)}),e.jsxs("td",{style:{textAlign:"right",padding:"2px 0"},children:[n.percent,"%"]})]},n.month))})]})]})]})};class Y{constructor(r){this.request=r}trends(){return this.request("/stats/trends")}}const K=new Y(X),$={maxWidth:960,padding:"48px 0 8px",borderTop:"1px solid var(--hairline)",marginTop:48},T={fontFamily:"var(--serif)",fontSize:34,fontWeight:500,letterSpacing:"-0.02em",margin:"0 0 10px",color:"var(--ink)"},M={fontFamily:"var(--serif)",fontSize:18,lineHeight:1.55,color:"var(--ink-soft)",maxWidth:620,margin:"0 0 8px"},C={fontFamily:"var(--mono)",fontSize:12,fontWeight:600,letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--ink-faint)",marginBottom:8},N={fontFamily:"var(--serif)",fontSize:17,lineHeight:1.6,color:"var(--ink-soft)",margin:0},D={height:320,marginTop:26},te=()=>{const t=G({queryKey:["research-trends"],queryFn:()=>K.trends(),staleTime:36e5});return e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["Research ",e.jsx("em",{children:"Trends"})]}),e.jsx("div",{className:"feed-subtitle",children:"How open science is changing across machine learning — tracked over time from arXiv and the Hugging Face Hub."})]})}),t.error&&e.jsx(J,{variant:"destructive",children:e.jsx(V,{children:"Failed to load research trends. Please try again."})}),e.jsxs("section",{style:$,children:[e.jsx("h2",{style:T,children:"Code Availability"}),e.jsx("p",{style:M,children:"The percentage of published papers that have at least one official code implementation on GitHub."}),e.jsx("div",{style:{marginTop:26},children:t.data?e.jsx(L,{id:"code",data:t.data.code_availability,color:"var(--trend-code)",yTicks:[0,20,40,60,80],yLabel:"Code Availability",xLabel:"Paper Publication Date"}):!t.error&&e.jsx(P,{style:D})})]}),e.jsxs("section",{style:$,children:[e.jsx("h2",{style:T,children:"Papers with Hugging Face artifacts"}),e.jsx("p",{style:M,children:"The percentage of published papers linked to at least one Hugging Face artifact — a model, dataset or Space — making the work directly runnable and reusable."}),e.jsx("div",{style:{marginTop:26},children:t.data?e.jsx(L,{id:"hf",data:t.data.hf_artifacts,color:"var(--trend-hf)",yTicks:[0,10,20,30,40,50],yLabel:"HF Artifact Coverage",xLabel:"Paper Publication Date"}):!t.error&&e.jsx(P,{style:D})})]}),e.jsxs("section",{style:{...$,paddingBottom:72},children:[e.jsx("h2",{style:{...T,fontSize:27},children:"How the data is collected"}),e.jsxs("div",{style:{display:"grid",gap:24,maxWidth:680},children:[e.jsxs("div",{children:[e.jsx("div",{style:C,children:"Code Availability"}),e.jsx("p",{style:N,children:"For every open-access machine learning paper, we check whether an official code implementation is linked on GitHub. The date axis is the paper's publication date."})]}),e.jsxs("div",{children:[e.jsx("div",{style:C,children:"Hugging Face artifacts"}),e.jsx("p",{style:N,children:"We resolve links between papers and the Hugging Face Hub, counting a paper as covered when it references at least one model, dataset or Space. The date axis is the paper's publication date."})]}),e.jsx("p",{style:{fontFamily:"var(--mono)",fontSize:12,lineHeight:1.6,color:"var(--ink-faint)",margin:"8px 0 0",letterSpacing:"0.02em"},children:"Figures use complete publication months. Historical Hugging Face coverage reflects artifacts currently linked in the catalog."})]})]})]})};export{te as default}; diff --git a/assets/UserProfileView-BnW4I15t.js b/assets/UserProfileView-kB3mGrtz.js similarity index 89% rename from assets/UserProfileView-BnW4I15t.js rename to assets/UserProfileView-kB3mGrtz.js index af690c0800dafc52a9d9d03b8db03dcb2015746c..9b15bd8c7e584b9cea30ceff7e2dbd62fccce89f 100644 --- a/assets/UserProfileView-BnW4I15t.js +++ b/assets/UserProfileView-kB3mGrtz.js @@ -1 +1 @@ -import{aV as n,u as i,b as o,j as e,ao as d}from"./index-DyXq7-Tg.js";import{C as l}from"./OrganizationContributionGraph-DsoZR4EG.js";import"./skeleton-C3IIzpSL.js";import"./catalog-CRar2olQ.js";const c={async get(s){const a=await n(`/profiles/${encodeURIComponent(s)}`),r=await a.json();if(!a.redirected)return r;const t=decodeURIComponent(new URL(a.url).pathname.split("/").pop()||r.username);return{...r,username:t,redirected_from_alias:!0}}},x=()=>{const{username:s=""}=i(),a=o({queryKey:["user-profile",s.toLowerCase()],queryFn:()=>c.get(s)});return a.isLoading?e.jsx("div",{className:"page",children:"Loading profile…"}):a.data?a.data.redirected_from_alias?e.jsx(d,{to:`/${a.data.username}`,replace:!0}):e.jsxs("div",{className:"page",style:{maxWidth:960},children:[e.jsxs("h1",{children:["@",a.data.username]}),e.jsx("p",{children:"Canonical Papers with Code contributions"}),e.jsx(l,{data:a.data.calendar,organizationName:`@${a.data.username}`,title:"Canonical contributions",noun:"contribution"}),a.data.is_owner&&e.jsxs("section",{className:"mt-10",children:[e.jsx("h2",{children:"Your submissions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Limits and duplicate behavior are documented on ",e.jsx("a",{href:"/rate-limits",children:"the policy page"}),"."]}),e.jsx("div",{className:"mt-4 space-y-3",children:a.data.submissions.map(r=>e.jsxs("article",{className:"rounded-md border p-4",children:[e.jsx("strong",{children:r.edit_type})," · ",r.status,e.jsxs("details",{className:"mt-2 text-xs",children:[e.jsx("summary",{children:"Original and applied payload"}),e.jsx("pre",{children:JSON.stringify({proposed:r.proposed_payload,applied:r.applied_payload},null,2)})]}),r.review_reason&&e.jsx("p",{children:r.review_reason})]},r.id))})]})]}):e.jsx("div",{className:"page",children:e.jsx("h1",{children:"Profile not found"})})};export{x as default}; +import{az as n,u as i,b as o,j as e,ao as d}from"./index-CjdUkE4w.js";import{C as l}from"./OrganizationContributionGraph-JI11b4D1.js";import"./skeleton-DTWi7Ctg.js";import"./catalog-qXcKve0z.js";const c={async get(s){const a=await n(`/profiles/${encodeURIComponent(s)}`),r=await a.json();if(!a.redirected)return r;const t=decodeURIComponent(new URL(a.url).pathname.split("/").pop()||r.username);return{...r,username:t,redirected_from_alias:!0}}},x=()=>{const{username:s=""}=i(),a=o({queryKey:["user-profile",s.toLowerCase()],queryFn:()=>c.get(s)});return a.isLoading?e.jsx("div",{className:"page",children:"Loading profile…"}):a.data?a.data.redirected_from_alias?e.jsx(d,{to:`/${a.data.username}`,replace:!0}):e.jsxs("div",{className:"page",style:{maxWidth:960},children:[e.jsxs("h1",{children:["@",a.data.username]}),e.jsx("p",{children:"Canonical Papers with Code contributions"}),e.jsx(l,{data:a.data.calendar,organizationName:`@${a.data.username}`,title:"Canonical contributions",noun:"contribution"}),a.data.is_owner&&e.jsxs("section",{className:"mt-10",children:[e.jsx("h2",{children:"Your submissions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Limits and duplicate behavior are documented on ",e.jsx("a",{href:"/rate-limits",children:"the policy page"}),"."]}),e.jsx("div",{className:"mt-4 space-y-3",children:a.data.submissions.map(r=>e.jsxs("article",{className:"rounded-md border p-4",children:[e.jsx("strong",{children:r.edit_type})," · ",r.status,e.jsxs("details",{className:"mt-2 text-xs",children:[e.jsx("summary",{children:"Original and applied payload"}),e.jsx("pre",{children:JSON.stringify({proposed:r.proposed_payload,applied:r.applied_payload},null,2)})]}),r.review_reason&&e.jsx("p",{children:r.review_reason})]},r.id))})]})]}):e.jsx("div",{className:"page",children:e.jsx("h1",{children:"Profile not found"})})};export{x as default}; diff --git a/assets/account-cbblajck.js b/assets/account-DoluPGSd.js similarity index 89% rename from assets/account-cbblajck.js rename to assets/account-DoluPGSd.js index 843c6b83abc67cc5d6159ba84c1b31ce3aa4aa54..49bed73301782991cc2b00d225c9f84e10bbac12 100644 --- a/assets/account-cbblajck.js +++ b/assets/account-DoluPGSd.js @@ -1 +1 @@ -import{ac as r}from"./index-DyXq7-Tg.js";class t{constructor(e){this.request=e}getPreferences(){return this.request("/me/preferences")}updatePreferences(e){return this.request("/me/preferences",{method:"PUT",body:JSON.stringify(e)})}getRateLimitPolicy(){return this.request("/rate-limits",{credentials:"omit"})}getBookmarkIds(){return this.request("/me/bookmarks/ids")}getBookmarks(){return this.request("/me/bookmarks")}addBookmark(e){return this.request(`/me/bookmarks/${e}`,{method:"POST"})}removeBookmark(e){return this.request(`/me/bookmarks/${e}`,{method:"DELETE"})}}const m=new t(r);export{m as a}; +import{ac as r}from"./index-CjdUkE4w.js";class t{constructor(e){this.request=e}getPreferences(){return this.request("/me/preferences")}updatePreferences(e){return this.request("/me/preferences",{method:"PUT",body:JSON.stringify(e)})}getRateLimitPolicy(){return this.request("/rate-limits",{credentials:"omit"})}getBookmarkIds(){return this.request("/me/bookmarks/ids")}getBookmarks(){return this.request("/me/bookmarks")}addBookmark(e){return this.request(`/me/bookmarks/${e}`,{method:"POST"})}removeBookmark(e){return this.request(`/me/bookmarks/${e}`,{method:"DELETE"})}}const m=new t(r);export{m as a}; diff --git a/assets/activity-S-FQ6Anu.js b/assets/activity--6WvmXv2.js similarity index 89% rename from assets/activity-S-FQ6Anu.js rename to assets/activity--6WvmXv2.js index 712add152170d2dfc50d29e0e27dd86b57965ef2..974b2f67de84c5a5d6fe84358bac10579c2c9705 100644 --- a/assets/activity-S-FQ6Anu.js +++ b/assets/activity--6WvmXv2.js @@ -1,4 +1,4 @@ -import{s as t}from"./index-DyXq7-Tg.js";/** +import{s as t}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/alert-gbJBhAVE.js b/assets/alert-BM9Xfuyy.js similarity index 92% rename from assets/alert-gbJBhAVE.js rename to assets/alert-BM9Xfuyy.js index 298e47c5b7eb4ab7f3d54ced0ce7fedb41170bc1..ab0ecc8a86920fd168aaed54720522d578ae94c4 100644 --- a/assets/alert-gbJBhAVE.js +++ b/assets/alert-BM9Xfuyy.js @@ -1 +1 @@ -import{d as r,j as s,G as d,ae as i}from"./index-DyXq7-Tg.js";const o=i("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),n=r.forwardRef(({className:e,variant:t,...a},l)=>s.jsx("div",{ref:l,role:"alert",className:d(o({variant:t}),e),...a}));n.displayName="Alert";const v=r.forwardRef(({className:e,...t},a)=>s.jsx("h5",{ref:a,className:d("mb-1 font-medium leading-none tracking-tight",e),...t}));v.displayName="AlertTitle";const c=r.forwardRef(({className:e,...t},a)=>s.jsx("div",{ref:a,className:d("text-sm [&_p]:leading-relaxed",e),...t}));c.displayName="AlertDescription";export{n as A,c as a}; +import{d as r,j as s,I as d,ae as i}from"./index-CjdUkE4w.js";const o=i("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),n=r.forwardRef(({className:e,variant:t,...a},l)=>s.jsx("div",{ref:l,role:"alert",className:d(o({variant:t}),e),...a}));n.displayName="Alert";const v=r.forwardRef(({className:e,...t},a)=>s.jsx("h5",{ref:a,className:d("mb-1 font-medium leading-none tracking-tight",e),...t}));v.displayName="AlertTitle";const c=r.forwardRef(({className:e,...t},a)=>s.jsx("div",{ref:a,className:d("text-sm [&_p]:leading-relaxed",e),...t}));c.displayName="AlertDescription";export{n as A,c as a}; diff --git a/assets/apiErrors-BSvbQBb0.js b/assets/apiErrors-BSvbQBb0.js deleted file mode 100644 index e239d538e255fb6c2658f00a09fd1cb5c8849b02..0000000000000000000000000000000000000000 --- a/assets/apiErrors-BSvbQBb0.js +++ /dev/null @@ -1 +0,0 @@ -import{U as s}from"./index-DyXq7-Tg.js";const i=o=>o instanceof s&&o.status===404;export{i}; diff --git a/assets/apiErrors-D0w5By9R.js b/assets/apiErrors-D0w5By9R.js new file mode 100644 index 0000000000000000000000000000000000000000..a96c31efb9180ba9c61f46ef0552297422c1392e --- /dev/null +++ b/assets/apiErrors-D0w5By9R.js @@ -0,0 +1 @@ +import{A as s}from"./index-CjdUkE4w.js";const i=o=>o instanceof s&&o.status===404;export{i}; diff --git a/assets/arrow-left-PA_b6law.js b/assets/arrow-left-CkQb0MI4.js similarity index 86% rename from assets/arrow-left-PA_b6law.js rename to assets/arrow-left-CkQb0MI4.js index 2ef032a4716d6d9a2fba327e180aa075859212dc..8a520070cf34c6410724d42a54ed342a8b40ff09 100644 --- a/assets/arrow-left-PA_b6law.js +++ b/assets/arrow-left-CkQb0MI4.js @@ -1,4 +1,4 @@ -import{s as e}from"./index-DyXq7-Tg.js";/** +import{s as e}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/arrow-right-BzPanrWZ.js b/assets/arrow-right-BrRhWCQS.js similarity index 86% rename from assets/arrow-right-BzPanrWZ.js rename to assets/arrow-right-BrRhWCQS.js index 598f909b9703d52b64a8c6c7328c6953165ae7f2..0c4bfd59f88a22fe90a62ee3bdd4783e00c059ea 100644 --- a/assets/arrow-right-BzPanrWZ.js +++ b/assets/arrow-right-BrRhWCQS.js @@ -1,4 +1,4 @@ -import{s as r}from"./index-DyXq7-Tg.js";/** +import{s as r}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/badge-e6t3GCyf.js b/assets/badge-C8r6F6JD.js similarity index 90% rename from assets/badge-e6t3GCyf.js rename to assets/badge-C8r6F6JD.js index e15f2ff6b6b1973d0425947b56c36d3045716ba1..f06738ae575c2ce0b48aaea87051a0705c1b5761 100644 --- a/assets/badge-e6t3GCyf.js +++ b/assets/badge-C8r6F6JD.js @@ -1 +1 @@ -import{j as n,G as o,ae as a}from"./index-DyXq7-Tg.js";const s=a("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function d({className:r,variant:e,...t}){return n.jsx("div",{className:o(s({variant:e}),r),...t})}export{d as B}; +import{j as n,I as o,ae as a}from"./index-CjdUkE4w.js";const s=a("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function d({className:r,variant:e,...t}){return n.jsx("div",{className:o(s({variant:e}),r),...t})}export{d as B}; diff --git a/assets/button-DZeAbOf2.js b/assets/button-DetZl_ch.js similarity index 89% rename from assets/button-DZeAbOf2.js rename to assets/button-DetZl_ch.js index 7fdb915723fcda1724196185b46ca624707cab75..da5bdc64ddada126024a4848ea27d54479b448b1 100644 --- a/assets/button-DZeAbOf2.js +++ b/assets/button-DetZl_ch.js @@ -1 +1 @@ -import{d as a,j as d,az as u,G as c,ae as f}from"./index-DyXq7-Tg.js";const g=f("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),v=a.forwardRef(({className:e,variant:t,size:r,asChild:n=!1,...o},s)=>{const i=n?u:"button";return d.jsx(i,{className:c(g({variant:t,size:r,className:e})),ref:s,...o})});v.displayName="Button";export{v as B}; +import{d as a,j as d,aA as u,I as c,ae as f}from"./index-CjdUkE4w.js";const g=f("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),v=a.forwardRef(({className:e,variant:t,size:r,asChild:n=!1,...o},s)=>{const i=n?u:"button";return d.jsx(i,{className:c(g({variant:t,size:r,className:e})),ref:s,...o})});v.displayName="Button";export{v as B}; diff --git a/assets/catalog-CRar2olQ.js b/assets/catalog-qXcKve0z.js similarity index 97% rename from assets/catalog-CRar2olQ.js rename to assets/catalog-qXcKve0z.js index a54e4fed428b5e3554d79a0e7118fdfa94af5a42..60afd34059fcb7b575f03eb303350c429008b567 100644 --- a/assets/catalog-CRar2olQ.js +++ b/assets/catalog-qXcKve0z.js @@ -1 +1 @@ -import{ac as o}from"./index-DyXq7-Tg.js";function s(a,e){const t=new URLSearchParams;for(const[i,n]of Object.entries(e??{}))n!==void 0&&n!==""&&t.set(i,String(n));const r=t.toString();return`${a}${r?`?${r}`:""}`}class u{constructor(e){this.request=e}listAreas(e){return this.request(s("/areas/",e))}getArea(e){return this.request(`/areas/${e}`)}areasWithTasks(){return this.request("/areas/with-tasks/")}listTasks(e){return this.request(s("/tasks/",e))}getTask(e){return this.request(`/tasks/${e}`)}topTasks(e){return this.request(s("/tasks/top",{limit:e}))}trendingTasks(e){return this.request(s("/tasks/trending",e))}taskChildren(e,t){return this.request(s(`/tasks/${e}/children`,t))}taskParents(e){return this.request(`/tasks/${e}/parents`)}taskPage(e,t){return this.request(s(`/tasks/${e}/page`,t))}trendingBenchmarks(e,t){return this.request(s(`/tasks/${encodeURIComponent(e)}/trending-benchmarks`,t))}frameworkCatalog(){return this.request("/frameworks/")}listMethods(e){return this.request(s("/methods/",e))}methodIndex(){return this.request("/methods/index/cards")}trendingMethods(e){return this.request(s("/methods/trending",e))}getMethod(e){return this.request(`/methods/${encodeURIComponent(e)}`)}relatedMethods(e){return this.request(`/methods/${encodeURIComponent(e)}/related`)}methodTrend(e,t){return this.request(s(`/methods/${encodeURIComponent(e)}/trend`,t))}listDatasets(e){const{task_id:t,...r}=e??{};return this.request(s("/datasets/",{...r,task:r.task??t}))}getDataset(e){return this.request(`/datasets/${e}`)}getDatasetBySlug(e,t){return this.request(s(`/datasets/${e}`,t))}async datasetTasks(e){return(await this.request(`/datasets/${e}/tasks/`)).results}async leaderboardMetrics(e,t){return(await this.request(`/datasets/${e}/tasks/${t}/metrics`)).metrics}metricDirections(){return this.request("/metrics/directions")}conferences(){return this.request("/conferences/")}conferenceDeadlines(){return this.request("/conferences/deadlines")}getConference(e){return this.request(`/conferences/${e}`)}conferenceAreasWithTasks(e){return this.request(`/conferences/${e}/areas-with-tasks`)}organizations(e=!1){return this.request(`/organizations/${e?"?featured_only=true":""}`)}searchOrganizations(e,t){return this.request(s("/organizations/",{q:e,limit:t}))}organizationIndex(){return this.request("/organizations/index/cards")}getOrganization(e){return this.request(`/organizations/${e}`)}organizationContributions(e){return this.request(`/organizations/${e}/contributions`)}organizationAreasWithTasks(e){return this.request(`/organizations/${e}/areas-with-tasks`)}audit(e){return this.request(s("/admin/catalog-audit",{cursor:e}))}acknowledgeAudit(){return this.request("/admin/catalog-audit/acknowledge",{method:"POST"})}rollbackEvent(e){return this.request(`/admin/catalog-audit/${e}/rollback`,{method:"POST"})}}const d=new u(o);export{d as c}; +import{ac as o}from"./index-CjdUkE4w.js";function s(a,e){const t=new URLSearchParams;for(const[i,n]of Object.entries(e??{}))n!==void 0&&n!==""&&t.set(i,String(n));const r=t.toString();return`${a}${r?`?${r}`:""}`}class u{constructor(e){this.request=e}listAreas(e){return this.request(s("/areas/",e))}getArea(e){return this.request(`/areas/${e}`)}areasWithTasks(){return this.request("/areas/with-tasks/")}listTasks(e){return this.request(s("/tasks/",e))}getTask(e){return this.request(`/tasks/${e}`)}topTasks(e){return this.request(s("/tasks/top",{limit:e}))}trendingTasks(e){return this.request(s("/tasks/trending",e))}taskChildren(e,t){return this.request(s(`/tasks/${e}/children`,t))}taskParents(e){return this.request(`/tasks/${e}/parents`)}taskPage(e,t){return this.request(s(`/tasks/${e}/page`,t))}trendingBenchmarks(e,t){return this.request(s(`/tasks/${encodeURIComponent(e)}/trending-benchmarks`,t))}frameworkCatalog(){return this.request("/frameworks/")}listMethods(e){return this.request(s("/methods/",e))}methodIndex(){return this.request("/methods/index/cards")}trendingMethods(e){return this.request(s("/methods/trending",e))}getMethod(e){return this.request(`/methods/${encodeURIComponent(e)}`)}relatedMethods(e){return this.request(`/methods/${encodeURIComponent(e)}/related`)}methodTrend(e,t){return this.request(s(`/methods/${encodeURIComponent(e)}/trend`,t))}listDatasets(e){const{task_id:t,...r}=e??{};return this.request(s("/datasets/",{...r,task:r.task??t}))}getDataset(e){return this.request(`/datasets/${e}`)}getDatasetBySlug(e,t){return this.request(s(`/datasets/${e}`,t))}async datasetTasks(e){return(await this.request(`/datasets/${e}/tasks/`)).results}async leaderboardMetrics(e,t){return(await this.request(`/datasets/${e}/tasks/${t}/metrics`)).metrics}metricDirections(){return this.request("/metrics/directions")}conferences(){return this.request("/conferences/")}conferenceDeadlines(){return this.request("/conferences/deadlines")}getConference(e){return this.request(`/conferences/${e}`)}conferenceAreasWithTasks(e){return this.request(`/conferences/${e}/areas-with-tasks`)}organizations(e=!1){return this.request(`/organizations/${e?"?featured_only=true":""}`)}searchOrganizations(e,t){return this.request(s("/organizations/",{q:e,limit:t}))}organizationIndex(){return this.request("/organizations/index/cards")}getOrganization(e){return this.request(`/organizations/${e}`)}organizationContributions(e){return this.request(`/organizations/${e}/contributions`)}organizationAreasWithTasks(e){return this.request(`/organizations/${e}/areas-with-tasks`)}audit(e){return this.request(s("/admin/catalog-audit",{cursor:e}))}acknowledgeAudit(){return this.request("/admin/catalog-audit/acknowledge",{method:"POST"})}rollbackEvent(e){return this.request(`/admin/catalog-audit/${e}/rollback`,{method:"POST"})}}const d=new u(o);export{d as c}; diff --git a/assets/chat-B1EBF720.js b/assets/chat-B1EBF720.js new file mode 100644 index 0000000000000000000000000000000000000000..de4c356d52e860a4d7ee89792ed4d55885e30bdf --- /dev/null +++ b/assets/chat-B1EBF720.js @@ -0,0 +1 @@ +import{a5 as i,ac as p,ay as h,az as m}from"./index-CjdUkE4w.js";const c=encodeURIComponent,n=s=>`/chat/artifacts/${c(s)}`,a=(s,e)=>`${n(s)}/versions/${c(e)}`,u=s=>s.split("/").map(encodeURIComponent).join("/"),S={preview:(s,e)=>i(`/api/v1${a(s,e)}/preview`),file:(s,e,t,r)=>i(`/api/v1${a(s,e)}/${t}/${u(r)}`),pdfExport:s=>i(`/api/v1${n(s)}/export/pdf`),sourceZip:(s,e)=>i(`/api/v1${a(s,e)}/export/source.zip`),sharedRoot:(s,e)=>i(`/api/v1/chat/shares/${c(s)}/artifacts/${c(e)}`)};class l{constructor(e){this.request=e}listSessions(e){const t=new URLSearchParams({limit:"50"});return e&&t.set("cursor",e),this.request(`/chat/sessions?${t.toString()}`)}createSession(e,t="low"){return this.request("/chat/sessions",{method:"POST",body:JSON.stringify({selected_model:e||null,reasoning_effort:t})})}getSession(e){return this.request(`/chat/sessions/${e}`)}updateSession(e,t){return this.request(`/chat/sessions/${e}`,{method:"PATCH",body:JSON.stringify(t)})}removeSession(e){return this.request(`/chat/sessions/${e}`,{method:"DELETE"})}archiveOldChats(){return this.request("/chat/sessions/archive-old",{method:"POST"})}archiveOldestChats(){return this.request("/chat/sessions/archive-oldest",{method:"POST"})}cancelSession(e){return this.request(`/chat/sessions/${e}/cancel`,{method:"POST"})}createOrRefreshShare(e){return this.request(`/chat/sessions/${e}/share`,{method:"POST"})}getSessionPublicShare(e){return this.request(`/chat/sessions/${encodeURIComponent(e)}/public-share`,{credentials:"omit"})}getSharedChat(e){return this.request(`/chat/shares/${encodeURIComponent(e)}`,{credentials:"omit"})}getModels(){return this.request("/chat/models")}getUsage(){return this.request("/chat/usage",{cache:"no-store"})}getOpenAIUsage(){return this.request("/chat/openai-usage",{cache:"no-store"})}getAvailability(){return this.request("/chat/availability",{cache:"no-store"})}getAutocompleteVocabulary(){return this.request("/chat/autocomplete-vocabulary")}getInferenceBilling(){return this.request("/me/inference-billing",{cache:"no-store"})}selectInferenceBillingAccount(e){return this.request("/me/inference-billing",{method:"PATCH",body:JSON.stringify({bill_to:e})})}prewarmPaperContext(e){return this.request("/chat/paper-context/prewarm",{method:"POST",body:JSON.stringify({route_id:e}),credentials:"omit",cache:"no-store"})}getSandboxSpend(e){const t=e?`?environment=${encodeURIComponent(e)}`:"";return this.request(`/chat/admin/sandbox-spend${t}`,{cache:"no-store"})}getWebSearchBudget(){return this.request("/chat/admin/web-search-budget",{cache:"no-store"})}getOpenRouterCredential(){return this.request("/chat/openrouter-key",{cache:"no-store"})}connectOpenRouterCredential(e){return this.request("/chat/openrouter-key",{method:"PUT",body:JSON.stringify({api_key:e})})}setOpenRouterFallback(e){return this.request("/chat/openrouter-key",{method:"PATCH",body:JSON.stringify({enabled:e})})}disconnectOpenRouterCredential(){return this.request("/chat/openrouter-key",{method:"DELETE"})}reportLatency(e,t){return h(`/chat/latency/${encodeURIComponent(e)}`,{method:"POST",keepalive:!0,body:JSON.stringify(t)})}reportFeedback(e,t,r){return this.request(`/chat/messages/${encodeURIComponent(e)}/feedback`,{method:"POST",body:JSON.stringify({value:t,...r?{comment:r}:{}})})}getPosterVersions(e){return this.request(n(e),{cache:"no-store"}).then(t=>t.versions)}getPosterManifest(e,t){return this.request(`${a(e,t)}/manifest`,{cache:"no-store"})}getLatexPaper(e){return this.request(n(e),{cache:"no-store"})}getLatexPaperHistory(e,t){const r=new URLSearchParams({limit:"20"});return t&&r.set("cursor",t),this.request(`${n(e)}/versions?${r}`,{cache:"no-store"})}getLatexPaperManifest(e,t){return this.request(`${a(e,t)}/manifest`,{cache:"no-store"})}getArtifactSource(e,t,r){return m(`${a(e,t)}/source/${u(r)}`,{cache:"no-store"}).then(o=>o.text())}saveLatexPaper(e,t,r){return this.request(`${n(e)}/save-compile`,{method:"POST",body:JSON.stringify({expected_parent_version_id:t,files:Object.entries(r).map(([o,d])=>({path:o,content:d}))})})}restoreLatexPaperVersion(e,t,r){return this.request(`${n(e)}/versions/restore`,{method:"POST",body:JSON.stringify({source_version_id:t,expected_parent_version_id:r})})}uploadLatexPaperFigure(e,t,r){const o=new FormData;return o.set("expected_parent_version_id",t),o.set("path",`figures/${r.name}`),o.set("figure",r),this.request(`${n(e)}/figures`,{method:"POST",body:o})}refreshLatexPaperCompile(e){return this.request(`${n(e)}/refresh-compile`,{method:"POST"})}stream(e,t){return h("/chat/stream",{method:"POST",headers:{Accept:"text/event-stream"},body:JSON.stringify(e),signal:t})}resumeStream(e,t,r){return h(`/chat/sessions/${encodeURIComponent(e)}/stream`,{method:"GET",headers:{Accept:"text/event-stream",...r&&r>0?{"Last-Event-ID":String(r)}:{}},signal:t})}}const f=new l(p);export{S as a,f as c}; diff --git a/assets/chat-Ix1IrIwq.js b/assets/chat-Ix1IrIwq.js deleted file mode 100644 index 25965977561c41284ea1475b90e13e5cd944fb7d..0000000000000000000000000000000000000000 --- a/assets/chat-Ix1IrIwq.js +++ /dev/null @@ -1 +0,0 @@ -import{ac as n,ay as r}from"./index-DyXq7-Tg.js";class o{constructor(e){this.request=e}listSessions(e){const t=new URLSearchParams({limit:"50"});return e&&t.set("cursor",e),this.request(`/chat/sessions?${t.toString()}`)}createSession(e,t="low"){return this.request("/chat/sessions",{method:"POST",body:JSON.stringify({selected_model:e||null,reasoning_effort:t})})}getSession(e){return this.request(`/chat/sessions/${e}`)}updateSession(e,t){return this.request(`/chat/sessions/${e}`,{method:"PATCH",body:JSON.stringify(t)})}removeSession(e){return this.request(`/chat/sessions/${e}`,{method:"DELETE"})}archiveOldChats(){return this.request("/chat/sessions/archive-old",{method:"POST"})}archiveOldestChats(){return this.request("/chat/sessions/archive-oldest",{method:"POST"})}cancelSession(e){return this.request(`/chat/sessions/${e}/cancel`,{method:"POST"})}createOrRefreshShare(e){return this.request(`/chat/sessions/${e}/share`,{method:"POST"})}getSessionPublicShare(e){return this.request(`/chat/sessions/${encodeURIComponent(e)}/public-share`,{credentials:"omit"})}getSharedChat(e){return this.request(`/chat/shares/${encodeURIComponent(e)}`,{credentials:"omit"})}getModels(){return this.request("/chat/models")}getUsage(){return this.request("/chat/usage",{cache:"no-store"})}getOpenAIUsage(){return this.request("/chat/openai-usage",{cache:"no-store"})}getAvailability(){return this.request("/chat/availability",{cache:"no-store"})}getAutocompleteVocabulary(){return this.request("/chat/autocomplete-vocabulary")}getInferenceBilling(){return this.request("/me/inference-billing",{cache:"no-store"})}selectInferenceBillingAccount(e){return this.request("/me/inference-billing",{method:"PATCH",body:JSON.stringify({bill_to:e})})}prewarmPaperContext(e){return this.request("/chat/paper-context/prewarm",{method:"POST",body:JSON.stringify({route_id:e}),credentials:"omit",cache:"no-store"})}getSandboxSpend(e){const t=e?`?environment=${encodeURIComponent(e)}`:"";return this.request(`/chat/admin/sandbox-spend${t}`,{cache:"no-store"})}getWebSearchBudget(){return this.request("/chat/admin/web-search-budget",{cache:"no-store"})}getOpenRouterCredential(){return this.request("/chat/openrouter-key",{cache:"no-store"})}connectOpenRouterCredential(e){return this.request("/chat/openrouter-key",{method:"PUT",body:JSON.stringify({api_key:e})})}setOpenRouterFallback(e){return this.request("/chat/openrouter-key",{method:"PATCH",body:JSON.stringify({enabled:e})})}disconnectOpenRouterCredential(){return this.request("/chat/openrouter-key",{method:"DELETE"})}reportLatency(e,t){return r(`/chat/latency/${encodeURIComponent(e)}`,{method:"POST",keepalive:!0,body:JSON.stringify(t)})}reportFeedback(e,t,s){return this.request(`/chat/messages/${encodeURIComponent(e)}/feedback`,{method:"POST",body:JSON.stringify({value:t,...s?{comment:s}:{}})})}stream(e,t){return r("/chat/stream",{method:"POST",headers:{Accept:"text/event-stream"},body:JSON.stringify(e),signal:t})}resumeStream(e,t,s){return r(`/chat/sessions/${encodeURIComponent(e)}/stream`,{method:"GET",headers:{Accept:"text/event-stream",...s&&s>0?{"Last-Event-ID":String(s)}:{}},signal:t})}}const c=new o(n);export{c}; diff --git a/assets/chatLifecycle-B6B3Dpfi.js b/assets/chatLifecycle-B6B3Dpfi.js new file mode 100644 index 0000000000000000000000000000000000000000..7510fae2300328e8d002c34440f42144c9d09f6a --- /dev/null +++ b/assets/chatLifecycle-B6B3Dpfi.js @@ -0,0 +1,163 @@ +var wL=Object.defineProperty;var ck=n=>{throw TypeError(n)};var _L=(n,e,t)=>e in n?wL(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ae=(n,e,t)=>_L(n,typeof e!="symbol"?e+"":e,t),J0=(n,e,t)=>e.has(n)||ck("Cannot "+t);var f=(n,e,t)=>(J0(n,e,"read from private field"),t?t.call(n):e.get(n)),M=(n,e,t)=>e.has(n)?ck("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),$=(n,e,t,s)=>(J0(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t),P=(n,e,t)=>(J0(n,e,"access private method"),t);var os=(n,e,t,s)=>({set _(i){$(n,e,i,t)},get _(){return f(n,e,s)}});import{s as To,d as V,j as S,V as ee,b as yo,a4 as G_,a5 as SL,L as Md,a6 as xL,X as n0,a7 as um,a8 as s0,a9 as kL,i as FC,aa as Id,A as AL,C as EL}from"./index-CjdUkE4w.js";import{u as zC,a as CL,c as $L,P as HC,i as TL,b as BC,e as K_,A as PL,o as RL,U as ML,V as IL,W as OL,X as NL,Y as LL,Z as DL,_ as qC,$ as jL}from"./chatSessions-9VEG8seW.js";/* empty css */import{H as Ip,a as Op,b as Np}from"./hover-card-CIBIV2Hx.js";import{f as FL,i as VC,p as zL,C as HL,a as BL,T as qL}from"./CatalogEntityPreviewLink-DY_jhXy9.js";import{G as i0}from"./github-4bW4WI_e.js";import{F as UC}from"./file-text-CHlxsNJC.js";import{r as VL,a as UL,P as r0,c as WL}from"./PaperPreviewLink-zGfFNaz6.js";import{M as GL,d as KL}from"./index-tLcwYp0U.js";import{r as ZL}from"./index-Dj6aE-6E.js";import{u as ad}from"./useMutation-BYtVrkc7.js";import{c as ts,a as zo}from"./chat-B1EBF720.js";import{T as XL}from"./thumbs-up-Dn_5H93T.js";import{C as YL}from"./copy-SoF5zg-g.js";import{q as o0}from"./queryOptions-C9woPjwX.js";import{A as JL}from"./arrow-left-CkQb0MI4.js";import{E as WC}from"./external-link-CTLWFJ8S.js";import{P as QL}from"./plus-AztI1566.js";import{S as eD}from"./search-DxMn7VKI.js";import{C as GC,a as KC}from"./chevron-up-BwiJ46dh.js";import{A as tD}from"./AuthorAvatar-D9249Frl.js";import{p as nD}from"./papers-DgZwjF3K.js";/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const sD=To("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const hk=To("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Z_=To("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const iD=To("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const rD=To("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const oD=To("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ZC=To("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const aD=To("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const lD=To("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);function a0({selection:n,editable:e=!1,onRemove:t}){const s=V.useId(),i=V.useRef(null),[r,o]=V.useState(!1),[a,l]=V.useState(!1),c=`Selection · Page ${n.page}`;return V.useEffect(()=>{const h=i.current;!h||r||l(h.scrollHeight>h.clientHeight+1)},[r,n.text]),S.jsxs("div",{className:`chat-paper-selection${e?" is-editable":""}`,children:[S.jsxs("div",{className:"chat-paper-selection-header",children:[S.jsx("span",{className:"chat-paper-selection-label",children:c}),S.jsxs("div",{className:"chat-paper-selection-actions",children:[(a||r)&&S.jsx("button",{type:"button",className:"chat-paper-selection-toggle","aria-expanded":r,"aria-controls":s,onClick:()=>o(h=>!h),children:r?"Collapse":"Expand"}),e&&t&&S.jsx("button",{type:"button",className:"chat-paper-selection-remove","aria-label":"Remove selected paper passage",onClick:t,children:"Remove"})]})]}),S.jsx("blockquote",{id:s,ref:i,className:`chat-paper-selection-quote${r?" is-expanded":""}`,children:n.text})]})}const cD=RL(),lse=({onSend:n,busy:e,placeholder:t,autoFocus:s,draft:i,onDraftChange:r,onStop:o,disabled:a=!1,describedBy:l,paperMentionsEnabled:c=!1,paperSelectionEnabled:h=!0,paperArtifactsEnabled:u=!1})=>{const[d,p]=V.useState(cD),m=i??d,g=V.useRef(null),[b,y]=V.useState(0),w=j=>{i||p(j),r==null||r(j)},v=zC({draft:m,onChange:w,enabled:c,textareaRef:g}),x=u&&m.text==="/",{completion:k,trackCaret:E}=CL(m,v.open||x);V.useEffect(()=>{const j=g.current;j&&(j.style.height="auto",j.style.height=`${Math.min($L(j),200)}px`)},[m.text,k]),V.useEffect(()=>{var j;s&&((j=g.current)==null||j.focus())},[s]);const T=()=>{const j=m.text.length-m.text.trimStart().length,L=m.text.trim(),B=!!m.paperSelection&&!h;if(!L||e||a||B)return;const Z=j+L.length,q={text:L,paperMentions:m.paperMentions.filter(H=>H.start>=j&&H.end<=Z).map(H=>({...H,start:H.start-j,end:H.end-j})),...m.paperSelection?{paperSelection:m.paperSelection}:{}};n(q)},O=!!m.paperSelection&&!h,F=!!m.text.trim()&&!O;return S.jsxs("div",{className:"chat-composer ph-no-capture","data-ph-no-autocapture":"true","data-ph-no-capture":"true",children:[m.paperSelection&&S.jsx(a0,{selection:m.paperSelection,editable:!0,onRemove:()=>{var j;w({text:m.text,paperMentions:m.paperMentions}),(j=g.current)==null||j.focus()}}),O&&S.jsx("div",{className:"chat-paper-selection-disabled",role:"status",children:"Paper selection is currently disabled. Remove the selected passage or wait for the feature to recover."}),S.jsxs("div",{className:"chat-composer-textarea-wrap",children:[S.jsx(HC,{text:m.text,mentions:m.paperMentions,scrollTop:b,completion:k}),S.jsx("textarea",{className:"ph-no-capture","data-ph-no-autocapture":"true","data-ph-no-capture":"true",ref:g,rows:1,value:m.text,placeholder:t||(m.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:j=>{v.updateText(j.target.value,j.target.selectionStart),E(j.target)},onSelect:j=>{v.refresh(j.currentTarget.selectionStart),E(j.currentTarget)},onClick:j=>{v.refresh(j.currentTarget.selectionStart),E(j.currentTarget)},onScroll:j=>y(j.currentTarget.scrollTop),onBlur:j=>{var L,B;(B=(L=j.relatedTarget)==null?void 0:L.closest)!=null&&B.call(L,".chat-paper-picker, .chat-slash-command")||window.setTimeout(v.close,0)},onKeyDown:j=>{if(!v.keyDown(j)){if(TL(j)&&k){j.preventDefault();const L=m.text+k;v.updateText(L,L.length),window.requestAnimationFrame(()=>{var B;return(B=g.current)==null?void 0:B.setSelectionRange(L.length,L.length)});return}j.key==="Enter"&&!j.shiftKey&&!j.nativeEvent.isComposing&&(j.preventDefault(),T())}},role:"combobox","aria-expanded":v.open||x,"aria-controls":v.open?v.pickerId:x?"chat-write-paper-command":void 0,"aria-activedescendant":v.open&&v.results.length?`${v.optionIdPrefix}-${v.activeIndex}`:x?"chat-write-paper-command":void 0,"aria-autocomplete":"list","aria-describedby":[l,v.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),S.jsx(BC,{open:v.open,query:v.query,results:v.results,activeIndex:v.activeIndex,loading:v.loading,error:v.error,onSelect:v.select,id:v.pickerId,optionIdPrefix:v.optionIdPrefix}),x&&S.jsxs("button",{type:"button",id:"chat-write-paper-command",className:"chat-slash-command",role:"option",onMouseDown:j=>{var L;j.preventDefault(),w({...m,text:"/write-paper "}),(L=g.current)==null||L.focus()},children:[S.jsx("code",{children:"/write-paper"}),S.jsx("span",{children:"Draft a paper from this research chat"})]})]}),v.message&&S.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:v.message}),S.jsxs("div",{className:"chat-composer-row",children:[S.jsx("div",{className:"chat-composer-tools",children:S.jsxs("span",{className:"chat-composer-hint",children:[k?"Tab to complete · ":"","Enter to send · Shift+Enter for newline"]})}),S.jsx("button",{type:"button",className:`chat-send${e||F?" chat-send-on":""}`,onClick:e?o:T,disabled:a||(e?!o:!F),"aria-label":e?"Stop generating":"Send message",children:e?o?S.jsx("span",{"aria-hidden":"true",children:"■"}):S.jsx(K_,{light:!0}):S.jsx(PL,{})})]})]})};function hD(){const[n,e]=V.useState(!1);return V.useEffect(()=>{const t=window.setTimeout(()=>e(!0),15e3);return()=>window.clearTimeout(t)},[]),S.jsxs("div",{className:"chat-waiting chat-compaction-status",role:"status","aria-live":"polite",children:[S.jsx("span",{className:"chat-thinking",children:"Summarizing earlier context…"}),n&&S.jsx("span",{className:"chat-compaction-explanation",children:"This conversation is long. Preserving its details may take up to a minute."})]})}const uD="https://huggingface.co/pro",dD="https://huggingface.co/docs/inference-providers/pricing",fD="https://paperswithcode.co/chat",pD=({action:n,onRetryWithLuna:e,onArchiveOldChats:t,onArchiveOldestChats:s,archivePending:i,hfBilling:r,openRouterFallbackEnabled:o})=>{switch(n){case"reauthorize":return S.jsx("a",{href:"/settings",children:"Re-sign in with Hugging Face"});case"hf_billing":return S.jsxs(S.Fragment,{children:[e&&S.jsx("button",{type:"button",onClick:e,children:"Retry with GPT-6 Luna"}),(r==null?void 0:r.account_type)==="Free"&&!r.bill_to?S.jsx("a",{href:uD,target:"_blank",rel:"noreferrer",children:"Upgrade to Hugging Face PRO — $9/month for 20× more included credits"}):S.jsx("a",{href:(r==null?void 0:r.usage_url)??"/settings",target:r?"_blank":void 0,rel:r?"noreferrer":void 0,children:"Review Hugging Face usage and billing"}),S.jsx("a",{href:dD,target:"_blank",rel:"noreferrer",children:"Inference Providers pricing and billing details"})]});case"retry_with_luna":return e?S.jsx("button",{type:"button",onClick:e,children:"Retry with GPT-6 Luna"}):null;case"openrouter_budget":return S.jsxs(S.Fragment,{children:[o?S.jsx("span",{children:"This response started on the shared allowance. Your connected OpenRouter key will be used when you explicitly retry."}):S.jsx("a",{href:"/settings#openrouter-byok",children:"Connect your own OpenRouter key"}),S.jsx("span",{children:"Or select a Hugging Face-backed model and explicitly retry."})]});case"continue_on_production":return S.jsx("a",{href:fD,children:"Continue on paperswithcode.co"});case"openrouter_unavailable":return S.jsxs(S.Fragment,{children:[S.jsx("a",{href:"/settings#openrouter-byok",children:"Bring your own key in Settings"}),S.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback",target:"_blank",rel:"noreferrer",children:"File an issue"})]});case"openrouter_billing":return S.jsx("a",{href:"https://openrouter.ai/settings/credits",target:"_blank",rel:"noreferrer",children:"Review OpenRouter billing"});case"openrouter_settings":return S.jsx("a",{href:"/settings#openrouter-byok",children:"Review OpenRouter settings"});case"archive_chats":return t||s?S.jsxs("span",{className:"chat-error-actions",children:[t&&S.jsx("button",{type:"button",disabled:i!==null,onClick:t,children:i==="old"?"Archiving…":"Archive chats older than 30 days"}),s&&S.jsx("button",{type:"button",disabled:i!==null,onClick:s,children:i==="oldest"?"Archiving…":"Archive oldest 50 chats"})]}):null}},mD=n=>{var i;const{msg:e,onRetryCompaction:t}=n,s=ML(e.errorCode);return S.jsxs("div",{className:"chat-error",children:[((i=e.blocks)==null?void 0:i.some(r=>r.kind==="answer"&&r.text.trim()))&&S.jsx("strong",{children:"Incomplete—response interrupted. "}),s.includes("retry")&&t&&S.jsx("button",{type:"button",onClick:t,children:"Retry"}),S.jsx("span",{children:IL(e.errorCode,e.error)}),s.map(r=>r==="retry"?null:S.jsx(pD,{...n,action:r},r))]})},Q0=new Map,XC=n=>{if(!n)return Promise.resolve();const e=Q0.get(n);if(e)return e;const t=new Promise(s=>{const i=new Image;i.onload=()=>{s()},i.onerror=()=>{Q0.delete(n),s()},i.src=n});return Q0.set(n,t),t},gD=new Set(["huggingface.co","www.huggingface.co"]),yD=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function bD(n){let e;try{e=new URL(n)}catch{return null}if(e.protocol!=="https:"||!gD.has(e.hostname))return null;const t=e.pathname.split("/").filter(Boolean),s=t[0]==="datasets"?"dataset":"model",i=s==="dataset"?t.slice(1):t;if(i.length!==2||s==="model"&&yD.has(i[0])||i.some(c=>!c||c==="."||c===".."))return null;const r=i.join("/"),o=i.map(encodeURIComponent).join("/"),a=s==="dataset"?`datasets/${o}`:o,l=s==="dataset"?"datasets":"models";return{type:s,repoId:r,url:`https://huggingface.co/${a}`,thumbnailUrl:`https://cdn-thumbnails.huggingface.co/social-thumbnails/${l}/${o}.png`}}const vD=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,wD=({repo:n})=>{const[e,t]=ee.useState(!1);return S.jsxs("div",{className:"hf-preview-card",children:[e?S.jsx("div",{className:"hf-preview-fallback","aria-hidden":"true",children:"🤗"}):S.jsx("img",{className:"hf-preview-image","data-testid":"hf-preview-image",src:n.thumbnailUrl,alt:"",loading:"eager",decoding:"async",onError:()=>t(!0)}),S.jsxs("div",{className:"hf-preview-meta",children:[S.jsxs("span",{className:"hf-preview-kind",children:["Hugging Face ",n.type]}),S.jsx("strong",{children:n.repoId}),S.jsx("span",{children:"huggingface.co"})]})]})},_D=({repo:n,children:e})=>{const[t,s]=ee.useState(!1),i=ee.useRef(null),r=ee.useCallback(()=>{XC(n.thumbnailUrl)},[n.thumbnailUrl]);return ee.useEffect(()=>{const o=i.current;if(!o||typeof IntersectionObserver>"u")return;const a=new IntersectionObserver(([l])=>{l.isIntersecting&&(r(),a.disconnect())},{rootMargin:"200px"});return a.observe(o),()=>a.disconnect()},[r]),S.jsxs(Ip,{open:t,onOpenChange:o=>{(!o||!vD())&&s(o)},openDelay:150,closeDelay:100,children:[S.jsx(Op,{asChild:!0,children:S.jsx("a",{ref:i,className:"chat-paper-link chat-hf-link",href:n.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:r,onFocus:r,children:e})}),S.jsx(Np,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(wD,{repo:n})})]})},SD=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,xD=({repo:n,preview:e,unavailable:t})=>{const[s,i]=ee.useState(!1),r=!!(e!=null&&e.avatarUrl)&&!s;return S.jsxs("div",{className:"github-preview-card",children:[r?S.jsx("img",{className:"github-preview-image","data-testid":"github-preview-image",src:e==null?void 0:e.avatarUrl,alt:"",loading:"eager",decoding:"async",onError:()=>i(!0)}):S.jsx("div",{className:"github-preview-fallback","aria-hidden":"true",children:S.jsx(i0,{})}),S.jsxs("div",{className:"github-preview-meta",children:[S.jsx("span",{className:"github-preview-kind",children:"GitHub repository"}),S.jsx("strong",{children:n.repoId}),(e==null?void 0:e.description)&&S.jsx("span",{className:"github-preview-description",children:e.description}),e?S.jsxs("span",{className:"github-preview-stats",children:[e.language&&S.jsxs(S.Fragment,{children:[e.language," · "]}),"★ ",e.stars.toLocaleString()," · ⑂ ",e.forks.toLocaleString(),e.archived&&S.jsx(S.Fragment,{children:" · Archived"})]}):S.jsx("span",{children:t?"Preview unavailable":"Loading preview…"})]})]})},kD=({repo:n,children:e})=>{var c;const[t,s]=ee.useState(!1),[i,r]=ee.useState(!1),o=ee.useRef(null),a=ee.useCallback(()=>r(!0),[]),l=yo({queryKey:["github-repository-preview",n.repoId.toLowerCase()],queryFn:({signal:h})=>FL(n,h),enabled:t||i,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return ee.useEffect(()=>{const h=o.current;if(!h||typeof IntersectionObserver>"u")return;const u=new IntersectionObserver(([d])=>{d.isIntersecting&&(a(),u.disconnect())},{rootMargin:"200px"});return u.observe(h),()=>u.disconnect()},[a]),ee.useEffect(()=>{var h;(h=l.data)!=null&&h.avatarUrl&&XC(l.data.avatarUrl)},[(c=l.data)==null?void 0:c.avatarUrl]),S.jsxs(Ip,{open:t,onOpenChange:h=>{(!h||!SD())&&s(h)},openDelay:150,closeDelay:100,children:[S.jsx(Op,{asChild:!0,children:S.jsxs("a",{ref:o,className:"chat-github-link",href:n.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:a,onFocus:a,children:[S.jsx(i0,{"aria-hidden":"true"}),e]})}),S.jsx(Np,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(xD,{repo:n,preview:l.data,unavailable:l.isError})})]})},AD=/^p\d+b\d+$/;function cse(n,e){const t=n.blocks[e];return t?t.label!=="Section-Header"?[{page:t.page,bbox:t.bbox}]:Object.entries(n.blocks).filter(([s,i])=>s===e||i.section===e).map(([,s])=>({page:s.page,bbox:s.bbox})):[]}function ED(n){const e=[...n.matchAll(/\]\(pdf:(p\d+b\d+)\)/g)].map(t=>t[1]);return[...new Set(e)]}const CD=320,uk=12,$D=170;function TD(n,e){const t=Math.min(CD,e*.7),s=e-uk-t-n.left,i=uk-n.left;return{left:Math.max(i,Math.min(0,s)),below:n.top<$D}}function PD(n){const[e,t]=n;return!e||e===e.toUpperCase()||t&&t!==t.toLowerCase()?n:e.toUpperCase()+n.slice(1)}const RD=V.createContext(null),YC=()=>V.useContext(RD);function JC(n){return n.length>220?`${n.slice(0,220).trimEnd()}…`:n}function MD({anchor:n,children:e}){var l;const t=YC(),[s,i]=V.useState({left:0,below:!1}),r=(l=t==null?void 0:t.layout)==null?void 0:l.blocks[n];if(!t||!r)return S.jsx("span",{className:"chat-invalid-citation",children:e});const o=r.label==="Section-Header",a=c=>i(TD(c.getBoundingClientRect(),window.innerWidth));return S.jsxs("button",{type:"button",className:"chat-pdf-citation",onClick:()=>t.open(n),onMouseEnter:c=>a(c.currentTarget),onFocus:c=>a(c.currentTarget),"aria-label":`${o?"Jump to section":"Jump to passage"} on page ${r.page}`,children:[S.jsx(UC,{"aria-hidden":"true"}),S.jsx("span",{children:V.Children.map(e,(c,h)=>h===0&&typeof c=="string"?PD(c):c)}),S.jsxs("span",{className:`chat-pdf-citation-preview${s.below?" is-below":""}`,role:"tooltip",style:{left:s.left},children:[S.jsxs("strong",{children:["Page ",r.page,o?" · section":""]}),r.text&&S.jsx("span",{children:JC(r.text)})]})]})}function ID({text:n}){const e=YC(),t=e==null?void 0:e.layout;if(!e||!t)return null;const s=ED(n).filter(i=>t.blocks[i]);return s.length?S.jsxs("details",{className:"chat-pdf-sources",children:[S.jsxs("summary",{children:["Sources (",s.length,")"]}),S.jsx("ol",{children:s.map(i=>{const r=t.blocks[i];return S.jsx("li",{children:S.jsxs("button",{type:"button",onClick:()=>e.open(i),children:[S.jsxs("span",{className:"chat-pdf-sources-page",children:["p. ",r.page]}),S.jsx("span",{children:JC(r.text)||r.label})]})},i)})})]}):null}const OD=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function ND(n){try{return new URL(n).hostname.replace(/^www\./,"")}catch{return"Web source"}}const LD=({citation:n})=>{const[e,t]=ee.useState(!1),[s,i]=ee.useState(!1),r=n.thumbnail_url,o=n.favicon_url;return S.jsxs("div",{className:"web-preview-card",children:[r&&!e&&S.jsx("img",{className:"web-preview-image","data-testid":"web-preview-image",src:r,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>t(!0)}),S.jsxs("div",{className:"web-preview-meta",children:[S.jsxs("div",{className:"web-preview-source",children:[o&&!s&&S.jsx("img",{src:o,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>i(!0)}),S.jsx("span",{children:ND(n.url??"")}),n.published&&S.jsxs(S.Fragment,{children:[S.jsx("span",{"aria-hidden":"true",children:"·"}),S.jsx("time",{children:n.published.slice(0,10)})]})]}),S.jsx("strong",{children:n.title}),n.excerpt&&S.jsx("p",{children:n.excerpt.replace(/\s+/g," ").trim()})]})]})},DD=({citation:n,children:e})=>{const[t,s]=ee.useState(!1),i=n.url??"";return S.jsxs(Ip,{open:t,onOpenChange:r=>{(!r||!OD())&&s(r)},openDelay:150,closeDelay:100,children:[S.jsx(Op,{asChild:!0,children:S.jsx("a",{href:i,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:e})}),S.jsx(Np,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(LD,{citation:n})})]})},jD=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,FD=n=>n==="semantic_scholar"?"Semantic Scholar":"External paper",zD=({citation:n})=>{var e,t;return S.jsxs("div",{className:"external-paper-preview-card",children:[S.jsxs("div",{className:"external-paper-preview-source",children:[S.jsx("span",{children:FD(n.provider)}),n.published&&S.jsxs(S.Fragment,{children:[S.jsx("span",{"aria-hidden":"true",children:"·"}),S.jsx("time",{children:n.published.slice(0,10)})]})]}),S.jsx("strong",{children:n.title}),(((e=n.authors)==null?void 0:e.length)??0)>0&&S.jsx("p",{className:"external-paper-preview-authors",children:(t=n.authors)==null?void 0:t.join(", ")}),n.excerpt&&S.jsx("p",{children:n.excerpt.replace(/\s+/g," ").trim()}),n.citation_count!==null&&n.citation_count!==void 0&&S.jsxs("span",{className:"external-paper-preview-citations",children:[n.citation_count.toLocaleString()," citations"]})]})},HD=({citation:n,children:e})=>{const[t,s]=ee.useState(!1);return S.jsxs(Ip,{open:t,onOpenChange:i=>{(!i||!jD())&&s(i)},openDelay:150,closeDelay:100,children:[S.jsx(Op,{asChild:!0,children:S.jsx("a",{href:n.url??"",className:"chat-external-paper-citation",target:"_blank",rel:"noopener noreferrer",children:e})}),S.jsx(Np,{className:"external-paper-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(zD,{citation:n})})]})};function BD(n){const e=[];let t=0,s=null;for(const i of n.match(/.*(?:\n|$)/g)??[]){if(!i)continue;const r=i.endsWith(` +`)?i.slice(0,-1):i;if(s){const l=r.match(/^ {0,3}(`+|~+)[ \t]*$/);l&&l[1][0]===s.marker&&l[1].length>=s.length&&(e.push({start:s.start,end:t+i.length}),s=null),t+=i.length;continue}const o=r.match(/^ {0,3}(`{3,}|~{3,})/);if(o){s={marker:o[1][0],length:o[1].length,start:t},t+=i.length;continue}let a=0;for(;ae>=t.start&&e=0&&n[s]==="\\";s-=1)t+=1;return t%2===0}function pk(n,e,t,s){const i=[];let r=0;for(;rs.name),published:e.metadata.published,conference:e.metadata.conference,citationCount:e.metadata.citation_count,tasks:e.metadata.tasks};if(t)return{routeId:n,title:t.title,arxivId:t.arxiv_id??null,source:t.arxiv_id?"arxiv":"external",sourceUrl:t.source_url,thumbnailUrl:t.thumbnail_url??null,authors:t.authors??[],published:t.published??null,conference:t.conference??null,citationCount:t.citation_count??null,tasks:[]}}const QC=({routeId:n,paper:e,citation:t,className:s="chat-paper-link",children:i})=>S.jsx(r0,{routeId:n,initialData:VD(n,e,t),className:s,target:"_blank",children:i});function UD(n){const e=n.lastIndexOf("[");if(e===-1)return n;const t=n.slice(e);return/^\[[^\]]*(\]\(?[^)\s]*)?$/.test(t)?n.slice(0,e):n}const WD=n=>n.startsWith("paper:")||n.startsWith("pdf:")||VC(n)?n:KL(n);function GD(n){try{const e=new URL(n);return e.protocol==="https:"&&(e.hostname==="github.com"||e.hostname==="www.github.com")}catch{return!1}}const Xb=({text:n,streaming:e,papers:t,citations:s,webCitations:i})=>{const r=qD(e?UD(n):n);return S.jsxs(S.Fragment,{children:[S.jsx(GL,{remarkPlugins:[ZL,UL],rehypePlugins:[VL],urlTransform:WD,components:{a:({href:o,children:a})=>{if(o!=null&&o.startsWith("paper:")){const h=o.slice(6);return!t[h]&&!(s!=null&&s[h])?S.jsx("span",{className:"chat-invalid-citation",children:a}):S.jsx(QC,{routeId:h,paper:t[h],citation:s==null?void 0:s[h],children:a})}if(o!=null&&o.startsWith("pdf:")){const h=o.slice(4);return AD.test(h)?S.jsx(MD,{anchor:h,children:a}):S.jsx("span",{className:"chat-invalid-citation",children:a})}if(o&&VC(o)){const h=zL(o);return h?S.jsx(HL,{entity:h,children:a}):S.jsx("span",{className:"chat-invalid-citation",children:a})}const l=o?bD(o):null;if(l)return S.jsx(_D,{repo:l,children:a});const c=o?BL(o):null;return c?S.jsx(kD,{repo:c,children:a}):o&&GD(o)?S.jsxs("a",{href:o,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[S.jsx(i0,{"aria-hidden":"true"}),a]}):o!=null&&o.startsWith("https://")&&(i!=null&&i[o])?i[o].source_type==="paper"?S.jsx(HD,{citation:i[o],children:a}):S.jsx(DD,{citation:i[o],children:a}):o!=null&&o.startsWith("https://")?S.jsx("a",{href:o,className:"chat-external-link",target:"_blank",rel:"noopener noreferrer",children:a}):S.jsx("span",{children:a})}},children:r}),!e&&S.jsx(ID,{text:r})]})},KD=({messageId:n})=>{const[e,t]=ee.useState(null),[s,i]=ee.useState(!1),[r,o]=ee.useState(""),a=ee.useRef(null),l=`chat-feedback-panel-${n}`,c=ad({mutationFn:({value:d,comment:p})=>p===void 0?ts.reportFeedback(n,d):ts.reportFeedback(n,d,p),onSuccess:(d,{value:p})=>{t(p),i(!1),o("")}}),h=c.isPending;ee.useEffect(()=>{var d;s&&((d=a.current)==null||d.focus())},[s]);const u=(d,p)=>{h||c.mutate({value:d,comment:p})};return S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"chat-feedback","aria-label":"Rate this response",children:[S.jsx("span",{className:"chat-feedback-label",children:e===null?"Was this helpful?":"Thanks for your feedback"}),S.jsx("button",{type:"button",className:`chat-feedback-action${e===!0?" chat-feedback-action-selected":""}`,"aria-label":"Helpful response","aria-pressed":e===!0,disabled:h,onClick:()=>{i(!1),u(!0)},children:S.jsx(XL,{"aria-hidden":"true"})}),S.jsx("button",{type:"button",className:`chat-feedback-action${e===!1?" chat-feedback-action-selected":""}`,"aria-label":"Unhelpful response","aria-pressed":e===!1,"aria-expanded":s,"aria-controls":l,disabled:h,onClick:()=>{c.reset(),i(!0)},children:S.jsx(lD,{"aria-hidden":"true"})}),c.isError&&S.jsx("span",{className:"chat-feedback-error",role:"status",children:"Couldn’t send feedback."})]}),s&&S.jsxs("div",{className:"chat-feedback-panel",id:l,role:"group","aria-labelledby":`${l}-title`,children:[S.jsx("div",{className:"chat-feedback-panel-title",id:`${l}-title`,children:"Additional feedback"}),S.jsx("label",{className:"chat-feedback-panel-label",htmlFor:`${l}-comment`,children:"Tell us what went wrong (optional)"}),S.jsx("textarea",{ref:a,id:`${l}-comment`,className:"chat-feedback-comment",value:r,maxLength:500,rows:4,disabled:h,onChange:d=>o(d.target.value),onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),i(!1))}}),S.jsxs("div",{className:"chat-feedback-panel-actions",children:[S.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:h,onClick:()=>u(!1),children:"Skip"}),S.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:h,onClick:()=>u(!1,r.trim()||void 0),children:h?"Submitting…":"Submit"})]})]})]})},ZD=Object.freeze({status:"aborted"});function J(n,e,t){function s(a,l){var c;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(c=a._zod).traits??(c.traits=new Set),a._zod.traits.add(n),e(a,l);for(const h in o.prototype)h in a||Object.defineProperty(a,h,{value:o.prototype[h].bind(a)});a._zod.constr=o,a._zod.def=l}const i=(t==null?void 0:t.Parent)??Object;class r extends i{}Object.defineProperty(r,"name",{value:n});function o(a){var l;const c=t!=null&&t.Parent?new r:this;s(c,a),(l=c._zod).deferred??(l.deferred=[]);for(const h of c._zod.deferred)h();return c}return Object.defineProperty(o,"init",{value:s}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,c;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(c=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:c.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class ef extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const e$={};function Ea(n){return e$}function XD(n){const e=Object.values(n).filter(s=>typeof s=="number");return Object.entries(n).filter(([s,i])=>e.indexOf(+s)===-1).map(([s,i])=>i)}function YD(n,e){return typeof e=="bigint"?e.toString():e}function X_(n){return{get value(){{const e=n();return Object.defineProperty(this,"value",{value:e}),e}}}}function Y_(n){return n==null}function J_(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function JD(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,i=t>s?t:s,r=Number.parseInt(n.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return r%o/10**i}function Ct(n,e,t){Object.defineProperty(n,e,{get(){{const s=t();return n[e]=s,s}},set(s){Object.defineProperty(n,e,{value:s})},configurable:!0})}function l0(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function Gu(n){return JSON.stringify(n)}const t$=Error.captureStackTrace?Error.captureStackTrace:(...n)=>{};function Wg(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const QD=X_(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Gg(n){if(Wg(n)===!1)return!1;const e=n.constructor;if(e===void 0)return!0;const t=e.prototype;return!(Wg(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}const e2=new Set(["string","number","symbol"]);function Lp(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ec(n,e,t){const s=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(s._zod.parent=n),s}function be(n){const e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function t2(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}const n2={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function s2(n,e){const t={},s=n._zod.def;for(const i in e){if(!(i in s.shape))throw new Error(`Unrecognized key: "${i}"`);e[i]&&(t[i]=s.shape[i])}return Ec(n,{...n._zod.def,shape:t,checks:[]})}function i2(n,e){const t={...n._zod.def.shape},s=n._zod.def;for(const i in e){if(!(i in s.shape))throw new Error(`Unrecognized key: "${i}"`);e[i]&&delete t[i]}return Ec(n,{...n._zod.def,shape:t,checks:[]})}function r2(n,e){if(!Gg(e))throw new Error("Invalid input to extend: expected a plain object");const t={...n._zod.def,get shape(){const s={...n._zod.def.shape,...e};return l0(this,"shape",s),s},checks:[]};return Ec(n,t)}function o2(n,e){return Ec(n,{...n._zod.def,get shape(){const t={...n._zod.def.shape,...e._zod.def.shape};return l0(this,"shape",t),t},catchall:e._zod.def.catchall,checks:[]})}function a2(n,e,t){const s=e._zod.def.shape,i={...s};if(t)for(const r in t){if(!(r in s))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(i[r]=n?new n({type:"optional",innerType:s[r]}):s[r])}else for(const r in s)i[r]=n?new n({type:"optional",innerType:s[r]}):s[r];return Ec(e,{...e._zod.def,shape:i,checks:[]})}function l2(n,e,t){const s=e._zod.def.shape,i={...s};if(t)for(const r in t){if(!(r in i))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(i[r]=new n({type:"nonoptional",innerType:s[r]}))}else for(const r in s)i[r]=new n({type:"nonoptional",innerType:s[r]});return Ec(e,{...e._zod.def,shape:i,checks:[]})}function Od(n,e=0){var t;for(let s=e;s{var s;return(s=t).path??(s.path=[]),t.path.unshift(n),t})}function dm(n){return typeof n=="string"?n:n==null?void 0:n.message}function Ca(n,e,t){var i,r,o,a,l,c;const s={...n,path:n.path??[]};if(!n.message){const h=dm((o=(r=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:r.error)==null?void 0:o.call(r,n))??dm((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??dm((l=t.customError)==null?void 0:l.call(t,n))??dm((c=t.localeError)==null?void 0:c.call(t,n))??"Invalid input";s.message=h}return delete s.inst,delete s.continue,e!=null&&e.reportInput||delete s.input,s}function Q_(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function tf(...n){const[e,t,s]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:s}:{...e}}const n$=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),Object.defineProperty(n,"message",{get(){return JSON.stringify(e,YD,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},s$=J("$ZodError",n$),i$=J("$ZodError",n$,{Parent:Error});function c2(n,e=t=>t.message){const t={},s=[];for(const i of n.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):s.push(e(i));return{formErrors:s,fieldErrors:t}}function h2(n,e){const t=e||function(r){return r.message},s={_errors:[]},i=r=>{for(const o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>i({issues:a}));else if(o.code==="invalid_key")i({issues:o.issues});else if(o.code==="invalid_element")i({issues:o.issues});else if(o.path.length===0)s._errors.push(t(o));else{let a=s,l=0;for(;l(e,t,s,i)=>{const r=s?Object.assign(s,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise)throw new ef;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(l=>Ca(l,r,Ea())));throw t$(a,i==null?void 0:i.callee),a}return o.value},d2=n=>async(e,t,s,i)=>{const r=s?Object.assign(s,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(l=>Ca(l,r,Ea())));throw t$(a,i==null?void 0:i.callee),a}return o.value},r$=n=>(e,t,s)=>{const i=s?{...s,async:!1}:{async:!1},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)throw new ef;return r.issues.length?{success:!1,error:new(n??s$)(r.issues.map(o=>Ca(o,i,Ea())))}:{success:!0,data:r.value}},o$=r$(i$),a$=n=>async(e,t,s)=>{const i=s?Object.assign(s,{async:!0}):{async:!0};let r=e._zod.run({value:t,issues:[]},i);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new n(r.issues.map(o=>Ca(o,i,Ea())))}:{success:!0,data:r.value}},f2=a$(i$),p2=/^[cC][^\s-]{8,}$/,m2=/^[0-9a-z]+$/,g2=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,y2=/^[0-9a-vA-V]{20}$/,b2=/^[A-Za-z0-9]{27}$/,v2=/^[a-zA-Z0-9_-]{21}$/,w2=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,_2=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,mk=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,S2=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,x2="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function k2(){return new RegExp(x2,"u")}const A2=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,E2=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,C2=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,$2=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,T2=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,l$=/^[A-Za-z0-9_-]*$/,P2=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,R2=/^\+(?:[0-9]){6,14}[0-9]$/,c$="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",M2=new RegExp(`^${c$}$`);function h$(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function I2(n){return new RegExp(`^${h$(n)}$`)}function O2(n){const e=h$({precision:n.precision}),t=["Z"];n.local&&t.push(""),n.offset&&t.push("([+-]\\d{2}:\\d{2})");const s=`${e}(?:${t.join("|")})`;return new RegExp(`^${c$}T(?:${s})$`)}const N2=n=>{const e=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},L2=/^\d+$/,D2=/^-?\d+(?:\.\d+)?/i,j2=/true|false/i,F2=/null/i,z2=/undefined/i,H2=/^[^A-Z]*$/,B2=/^[^a-z]*$/,Ds=J("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),u$={number:"number",bigint:"bigint",object:"date"},d$=J("$ZodCheckLessThan",(n,e)=>{Ds.init(n,e);const t=u$[typeof e.value];n._zod.onattach.push(s=>{const i=s._zod.bag,r=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value{(e.inclusive?s.value<=e.value:s.value{Ds.init(n,e);const t=u$[typeof e.value];n._zod.onattach.push(s=>{const i=s._zod.bag,r=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>r&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),n._zod.check=s=>{(e.inclusive?s.value>=e.value:s.value>e.value)||s.issues.push({origin:t,code:"too_small",minimum:e.value,input:s.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),q2=J("$ZodCheckMultipleOf",(n,e)=>{Ds.init(n,e),n._zod.onattach.push(t=>{var s;(s=t._zod.bag).multipleOf??(s.multipleOf=e.value)}),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):JD(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),V2=J("$ZodCheckNumberFormat",(n,e)=>{var o;Ds.init(n,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),s=t?"int":"number",[i,r]=n2[e.format];n._zod.onattach.push(a=>{const l=a._zod.bag;l.format=e.format,l.minimum=i,l.maximum=r,t&&(l.pattern=L2)}),n._zod.check=a=>{const l=a.value;if(t){if(!Number.isInteger(l)){a.issues.push({expected:s,format:e.format,code:"invalid_type",input:l,inst:n});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,continue:!e.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,continue:!e.abort});return}}lr&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:r,inst:n})}}),U2=J("$ZodCheckMaxLength",(n,e)=>{var t;Ds.init(n,e),(t=n._zod.def).when??(t.when=s=>{const i=s.value;return!Y_(i)&&i.length!==void 0}),n._zod.onattach.push(s=>{const i=s._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum{const i=s.value;if(i.length<=e.maximum)return;const o=Q_(i);s.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),W2=J("$ZodCheckMinLength",(n,e)=>{var t;Ds.init(n,e),(t=n._zod.def).when??(t.when=s=>{const i=s.value;return!Y_(i)&&i.length!==void 0}),n._zod.onattach.push(s=>{const i=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(s._zod.bag.minimum=e.minimum)}),n._zod.check=s=>{const i=s.value;if(i.length>=e.minimum)return;const o=Q_(i);s.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),G2=J("$ZodCheckLengthEquals",(n,e)=>{var t;Ds.init(n,e),(t=n._zod.def).when??(t.when=s=>{const i=s.value;return!Y_(i)&&i.length!==void 0}),n._zod.onattach.push(s=>{const i=s._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),n._zod.check=s=>{const i=s.value,r=i.length;if(r===e.length)return;const o=Q_(i),a=r>e.length;s.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:s.value,inst:n,continue:!e.abort})}}),c0=J("$ZodCheckStringFormat",(n,e)=>{var t,s;Ds.init(n,e),n._zod.onattach.push(i=>{const r=i._zod.bag;r.format=e.format,e.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(e.pattern))}),e.pattern?(t=n._zod).check??(t.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(s=n._zod).check??(s.check=()=>{})}),K2=J("$ZodCheckRegex",(n,e)=>{c0.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),Z2=J("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=H2),c0.init(n,e)}),X2=J("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=B2),c0.init(n,e)}),Y2=J("$ZodCheckIncludes",(n,e)=>{Ds.init(n,e);const t=Lp(e.includes),s=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=s,n._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(s)}),n._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:n,continue:!e.abort})}}),J2=J("$ZodCheckStartsWith",(n,e)=>{Ds.init(n,e);const t=new RegExp(`^${Lp(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=s=>{s.value.startsWith(e.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:s.value,inst:n,continue:!e.abort})}}),Q2=J("$ZodCheckEndsWith",(n,e)=>{Ds.init(n,e);const t=new RegExp(`.*${Lp(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=s=>{s.value.endsWith(e.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:s.value,inst:n,continue:!e.abort})}}),ej=J("$ZodCheckOverwrite",(n,e)=>{Ds.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class tj{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const s=e.split(` +`).filter(o=>o),i=Math.min(...s.map(o=>o.length-o.trimStart().length)),r=s.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of r)this.content.push(o)}compile(){const e=Function,t=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(r=>` ${r}`)];return new e(...t,i.join(` +`))}}const nj={major:4,minor:0,patch:0},wt=J("$ZodType",(n,e)=>{var i;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=nj;const s=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&s.unshift(n);for(const r of s)for(const o of r._zod.onattach)o(n);if(s.length===0)(t=n._zod).deferred??(t.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const r=(o,a,l)=>{let c=Od(o),h;for(const u of a){if(u._zod.def.when){if(!u._zod.def.when(o))continue}else if(c)continue;const d=o.issues.length,p=u._zod.check(o);if(p instanceof Promise&&(l==null?void 0:l.async)===!1)throw new ef;if(h||p instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await p,o.issues.length!==d&&(c||(c=Od(o,d)))});else{if(o.issues.length===d)continue;c||(c=Od(o,d))}}return h?h.then(()=>o):o};n._zod.run=(o,a)=>{const l=n._zod.parse(o,a);if(l instanceof Promise){if(a.async===!1)throw new ef;return l.then(c=>r(c,s,a))}return r(l,s,a)}}n["~standard"]={validate:r=>{var o;try{const a=o$(n,r);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return f2(n,r).then(l=>{var c;return l.success?{value:l.data}:{issues:(c=l.error)==null?void 0:c.issues}})}},vendor:"zod",version:1}}),eS=J("$ZodString",(n,e)=>{var t;wt.init(n,e),n._zod.pattern=[...((t=n==null?void 0:n._zod.bag)==null?void 0:t.patterns)??[]].pop()??N2(n._zod.bag),n._zod.parse=(s,i)=>{if(e.coerce)try{s.value=String(s.value)}catch{}return typeof s.value=="string"||s.issues.push({expected:"string",code:"invalid_type",input:s.value,inst:n}),s}}),Mt=J("$ZodStringFormat",(n,e)=>{c0.init(n,e),eS.init(n,e)}),sj=J("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=_2),Mt.init(n,e)}),ij=J("$ZodUUID",(n,e)=>{if(e.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(s===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=mk(s))}else e.pattern??(e.pattern=mk());Mt.init(n,e)}),rj=J("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=S2),Mt.init(n,e)}),oj=J("$ZodURL",(n,e)=>{Mt.init(n,e),n._zod.check=t=>{try{const s=t.value,i=new URL(s),r=i.href;e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:P2.source,input:t.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort})),!s.endsWith("/")&&r.endsWith("/")?t.value=r.slice(0,-1):t.value=r;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),aj=J("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=k2()),Mt.init(n,e)}),lj=J("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=v2),Mt.init(n,e)}),cj=J("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=p2),Mt.init(n,e)}),hj=J("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=m2),Mt.init(n,e)}),uj=J("$ZodULID",(n,e)=>{e.pattern??(e.pattern=g2),Mt.init(n,e)}),dj=J("$ZodXID",(n,e)=>{e.pattern??(e.pattern=y2),Mt.init(n,e)}),fj=J("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=b2),Mt.init(n,e)}),pj=J("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=O2(e)),Mt.init(n,e)}),mj=J("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=M2),Mt.init(n,e)}),gj=J("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=I2(e)),Mt.init(n,e)}),yj=J("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=w2),Mt.init(n,e)}),bj=J("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=A2),Mt.init(n,e),n._zod.onattach.push(t=>{const s=t._zod.bag;s.format="ipv4"})}),vj=J("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=E2),Mt.init(n,e),n._zod.onattach.push(t=>{const s=t._zod.bag;s.format="ipv6"}),n._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}}),wj=J("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=C2),Mt.init(n,e)}),_j=J("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=$2),Mt.init(n,e),n._zod.check=t=>{const[s,i]=t.value.split("/");try{if(!i)throw new Error;const r=Number(i);if(`${r}`!==i)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${s}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}}});function p$(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const Sj=J("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=T2),Mt.init(n,e),n._zod.onattach.push(t=>{t._zod.bag.contentEncoding="base64"}),n._zod.check=t=>{p$(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});function xj(n){if(!l$.test(n))return!1;const e=n.replace(/[-_]/g,s=>s==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return p$(t)}const kj=J("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=l$),Mt.init(n,e),n._zod.onattach.push(t=>{t._zod.bag.contentEncoding="base64url"}),n._zod.check=t=>{xj(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),Aj=J("$ZodE164",(n,e)=>{e.pattern??(e.pattern=R2),Mt.init(n,e)});function Ej(n,e=null){try{const t=n.split(".");if(t.length!==3)return!1;const[s]=t;if(!s)return!1;const i=JSON.parse(atob(s));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const Cj=J("$ZodJWT",(n,e)=>{Mt.init(n,e),n._zod.check=t=>{Ej(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),m$=J("$ZodNumber",(n,e)=>{wt.init(n,e),n._zod.pattern=n._zod.bag.pattern??D2,n._zod.parse=(t,s)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const i=t.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return t;const r=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...r?{received:r}:{}}),t}}),$j=J("$ZodNumber",(n,e)=>{V2.init(n,e),m$.init(n,e)}),Tj=J("$ZodBoolean",(n,e)=>{wt.init(n,e),n._zod.pattern=j2,n._zod.parse=(t,s)=>{if(e.coerce)try{t.value=!!t.value}catch{}const i=t.value;return typeof i=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),t}}),Pj=J("$ZodUndefined",(n,e)=>{wt.init(n,e),n._zod.pattern=z2,n._zod.values=new Set([void 0]),n._zod.optin="optional",n._zod.optout="optional",n._zod.parse=(t,s)=>{const i=t.value;return typeof i>"u"||t.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:n}),t}}),Rj=J("$ZodNull",(n,e)=>{wt.init(n,e),n._zod.pattern=F2,n._zod.values=new Set([null]),n._zod.parse=(t,s)=>{const i=t.value;return i===null||t.issues.push({expected:"null",code:"invalid_type",input:i,inst:n}),t}}),Mj=J("$ZodAny",(n,e)=>{wt.init(n,e),n._zod.parse=t=>t}),Ij=J("$ZodUnknown",(n,e)=>{wt.init(n,e),n._zod.parse=t=>t}),Oj=J("$ZodNever",(n,e)=>{wt.init(n,e),n._zod.parse=(t,s)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function gk(n,e,t){n.issues.length&&e.issues.push(...ll(t,n.issues)),e.value[t]=n.value}const Nj=J("$ZodArray",(n,e)=>{wt.init(n,e),n._zod.parse=(t,s)=>{const i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),t;t.value=Array(i.length);const r=[];for(let o=0;ogk(c,t,o))):gk(l,t,o)}return r.length?Promise.all(r).then(()=>t):t}});function fm(n,e,t){n.issues.length&&e.issues.push(...ll(t,n.issues)),e.value[t]=n.value}function yk(n,e,t,s){n.issues.length?s[t]===void 0?t in s?e.value[t]=void 0:e.value[t]=n.value:e.issues.push(...ll(t,n.issues)):n.value===void 0?t in s&&(e.value[t]=void 0):e.value[t]=n.value}const Lj=J("$ZodObject",(n,e)=>{wt.init(n,e);const t=X_(()=>{const u=Object.keys(e.shape);for(const p of u)if(!(e.shape[p]instanceof wt))throw new Error(`Invalid element at key "${p}": expected a Zod schema`);const d=t2(e.shape);return{shape:e.shape,keys:u,keySet:new Set(u),numKeys:u.length,optionalKeys:new Set(d)}});Ct(n._zod,"propValues",()=>{const u=e.shape,d={};for(const p in u){const m=u[p]._zod;if(m.values){d[p]??(d[p]=new Set);for(const g of m.values)d[p].add(g)}}return d});const s=u=>{const d=new tj(["shape","payload","ctx"]),p=t.value,m=w=>{const v=Gu(w);return`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`};d.write("const input = payload.value;");const g=Object.create(null);let b=0;for(const w of p.keys)g[w]=`key_${b++}`;d.write("const newResult = {}");for(const w of p.keys)if(p.optionalKeys.has(w)){const v=g[w];d.write(`const ${v} = ${m(w)};`);const x=Gu(w);d.write(` + if (${v}.issues.length) { + if (input[${x}] === undefined) { + if (${x} in input) { + newResult[${x}] = undefined; + } + } else { + payload.issues = payload.issues.concat( + ${v}.issues.map((iss) => ({ + ...iss, + path: iss.path ? [${x}, ...iss.path] : [${x}], + })) + ); + } + } else if (${v}.value === undefined) { + if (${x} in input) newResult[${x}] = undefined; + } else { + newResult[${x}] = ${v}.value; + } + `)}else{const v=g[w];d.write(`const ${v} = ${m(w)};`),d.write(` + if (${v}.issues.length) payload.issues = payload.issues.concat(${v}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${Gu(w)}, ...iss.path] : [${Gu(w)}] + })));`),d.write(`newResult[${Gu(w)}] = ${v}.value`)}d.write("payload.value = newResult;"),d.write("return payload;");const y=d.compile();return(w,v)=>y(u,w,v)};let i;const r=Wg,o=!e$.jitless,l=o&&QD.value,c=e.catchall;let h;n._zod.parse=(u,d)=>{h??(h=t.value);const p=u.value;if(!r(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:n}),u;const m=[];if(o&&l&&(d==null?void 0:d.async)===!1&&d.jitless!==!0)i||(i=s(e.shape)),u=i(u,d);else{u.value={};const v=h.shape;for(const x of h.keys){const k=v[x],E=k._zod.run({value:p[x],issues:[]},d),T=k._zod.optin==="optional"&&k._zod.optout==="optional";E instanceof Promise?m.push(E.then(O=>T?yk(O,u,x,p):fm(O,u,x))):T?yk(E,u,x,p):fm(E,u,x)}}if(!c)return m.length?Promise.all(m).then(()=>u):u;const g=[],b=h.keySet,y=c._zod,w=y.def.type;for(const v of Object.keys(p)){if(b.has(v))continue;if(w==="never"){g.push(v);continue}const x=y.run({value:p[v],issues:[]},d);x instanceof Promise?m.push(x.then(k=>fm(k,u,v))):fm(x,u,v)}return g.length&&u.issues.push({code:"unrecognized_keys",keys:g,input:p,inst:n}),m.length?Promise.all(m).then(()=>u):u}});function bk(n,e,t,s){for(const i of n)if(i.issues.length===0)return e.value=i.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(i=>i.issues.map(r=>Ca(r,s,Ea())))}),e}const g$=J("$ZodUnion",(n,e)=>{wt.init(n,e),Ct(n._zod,"optin",()=>e.options.some(t=>t._zod.optin==="optional")?"optional":void 0),Ct(n._zod,"optout",()=>e.options.some(t=>t._zod.optout==="optional")?"optional":void 0),Ct(n._zod,"values",()=>{if(e.options.every(t=>t._zod.values))return new Set(e.options.flatMap(t=>Array.from(t._zod.values)))}),Ct(n._zod,"pattern",()=>{if(e.options.every(t=>t._zod.pattern)){const t=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${t.map(s=>J_(s.source)).join("|")})$`)}}),n._zod.parse=(t,s)=>{let i=!1;const r=[];for(const o of e.options){const a=o._zod.run({value:t.value,issues:[]},s);if(a instanceof Promise)r.push(a),i=!0;else{if(a.issues.length===0)return a;r.push(a)}}return i?Promise.all(r).then(o=>bk(o,t,n,s)):bk(r,t,n,s)}}),Dj=J("$ZodDiscriminatedUnion",(n,e)=>{g$.init(n,e);const t=n._zod.parse;Ct(n._zod,"propValues",()=>{const i={};for(const r of e.options){const o=r._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(const[a,l]of Object.entries(o)){i[a]||(i[a]=new Set);for(const c of l)i[a].add(c)}}return i});const s=X_(()=>{const i=e.options,r=new Map;for(const o of i){const a=o._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(const l of a){if(r.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);r.set(l,o)}}return r});n._zod.parse=(i,r)=>{const o=i.value;if(!Wg(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:n}),i;const a=s.value.get(o==null?void 0:o[e.discriminator]);return a?a._zod.run(i,r):e.unionFallback?t(i,r):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:o,path:[e.discriminator],inst:n}),i)}}),jj=J("$ZodIntersection",(n,e)=>{wt.init(n,e),n._zod.parse=(t,s)=>{const i=t.value,r=e.left._zod.run({value:i,issues:[]},s),o=e.right._zod.run({value:i,issues:[]},s);return r instanceof Promise||o instanceof Promise?Promise.all([r,o]).then(([l,c])=>vk(t,l,c)):vk(t,r,o)}});function Yb(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(Gg(n)&&Gg(e)){const t=Object.keys(e),s=Object.keys(n).filter(r=>t.indexOf(r)!==-1),i={...n,...e};for(const r of s){const o=Yb(n[r],e[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};i[r]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let s=0;s{wt.init(n,e),n._zod.parse=(t,s)=>{const i=t.value;if(!Gg(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),t;const r=[];if(e.keyType._zod.values){const o=e.keyType._zod.values;t.value={};for(const l of o)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){const c=e.valueType._zod.run({value:i[l],issues:[]},s);c instanceof Promise?r.push(c.then(h=>{h.issues.length&&t.issues.push(...ll(l,h.issues)),t.value[l]=h.value})):(c.issues.length&&t.issues.push(...ll(l,c.issues)),t.value[l]=c.value)}let a;for(const l in i)o.has(l)||(a=a??[],a.push(l));a&&a.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:a})}else{t.value={};for(const o of Reflect.ownKeys(i)){if(o==="__proto__")continue;const a=e.keyType._zod.run({value:o,issues:[]},s);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){t.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(c=>Ca(c,s,Ea())),input:o,path:[o],inst:n}),t.value[a.value]=a.value;continue}const l=e.valueType._zod.run({value:i[o],issues:[]},s);l instanceof Promise?r.push(l.then(c=>{c.issues.length&&t.issues.push(...ll(o,c.issues)),t.value[a.value]=c.value})):(l.issues.length&&t.issues.push(...ll(o,l.issues)),t.value[a.value]=l.value)}}return r.length?Promise.all(r).then(()=>t):t}}),zj=J("$ZodEnum",(n,e)=>{wt.init(n,e);const t=XD(e.entries);n._zod.values=new Set(t),n._zod.pattern=new RegExp(`^(${t.filter(s=>e2.has(typeof s)).map(s=>typeof s=="string"?Lp(s):s.toString()).join("|")})$`),n._zod.parse=(s,i)=>{const r=s.value;return n._zod.values.has(r)||s.issues.push({code:"invalid_value",values:t,input:r,inst:n}),s}}),Hj=J("$ZodLiteral",(n,e)=>{wt.init(n,e),n._zod.values=new Set(e.values),n._zod.pattern=new RegExp(`^(${e.values.map(t=>typeof t=="string"?Lp(t):t?t.toString():String(t)).join("|")})$`),n._zod.parse=(t,s)=>{const i=t.value;return n._zod.values.has(i)||t.issues.push({code:"invalid_value",values:e.values,input:i,inst:n}),t}}),Bj=J("$ZodTransform",(n,e)=>{wt.init(n,e),n._zod.parse=(t,s)=>{const i=e.transform(t.value,t);if(s.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(t.value=o,t));if(i instanceof Promise)throw new ef;return t.value=i,t}}),qj=J("$ZodOptional",(n,e)=>{wt.init(n,e),n._zod.optin="optional",n._zod.optout="optional",Ct(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Ct(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${J_(t.source)})?$`):void 0}),n._zod.parse=(t,s)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(t,s):t.value===void 0?t:e.innerType._zod.run(t,s)}),Vj=J("$ZodNullable",(n,e)=>{wt.init(n,e),Ct(n._zod,"optin",()=>e.innerType._zod.optin),Ct(n._zod,"optout",()=>e.innerType._zod.optout),Ct(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${J_(t.source)}|null)$`):void 0}),Ct(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(t,s)=>t.value===null?t:e.innerType._zod.run(t,s)}),Uj=J("$ZodDefault",(n,e)=>{wt.init(n,e),n._zod.optin="optional",Ct(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,s)=>{if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,s);return i instanceof Promise?i.then(r=>wk(r,e)):wk(i,e)}});function wk(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const Wj=J("$ZodPrefault",(n,e)=>{wt.init(n,e),n._zod.optin="optional",Ct(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,s)=>(t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,s))}),Gj=J("$ZodNonOptional",(n,e)=>{wt.init(n,e),Ct(n._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(s=>s!==void 0)):void 0}),n._zod.parse=(t,s)=>{const i=e.innerType._zod.run(t,s);return i instanceof Promise?i.then(r=>_k(r,n)):_k(i,n)}});function _k(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}const Kj=J("$ZodCatch",(n,e)=>{wt.init(n,e),n._zod.optin="optional",Ct(n._zod,"optout",()=>e.innerType._zod.optout),Ct(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,s)=>{const i=e.innerType._zod.run(t,s);return i instanceof Promise?i.then(r=>(t.value=r.value,r.issues.length&&(t.value=e.catchValue({...t,error:{issues:r.issues.map(o=>Ca(o,s,Ea()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(r=>Ca(r,s,Ea()))},input:t.value}),t.issues=[]),t)}}),Zj=J("$ZodPipe",(n,e)=>{wt.init(n,e),Ct(n._zod,"values",()=>e.in._zod.values),Ct(n._zod,"optin",()=>e.in._zod.optin),Ct(n._zod,"optout",()=>e.out._zod.optout),n._zod.parse=(t,s)=>{const i=e.in._zod.run(t,s);return i instanceof Promise?i.then(r=>Sk(r,e,s)):Sk(i,e,s)}});function Sk(n,e,t){return Od(n)?n:e.out._zod.run({value:n.value,issues:n.issues},t)}const Xj=J("$ZodReadonly",(n,e)=>{wt.init(n,e),Ct(n._zod,"propValues",()=>e.innerType._zod.propValues),Ct(n._zod,"values",()=>e.innerType._zod.values),Ct(n._zod,"optin",()=>e.innerType._zod.optin),Ct(n._zod,"optout",()=>e.innerType._zod.optout),n._zod.parse=(t,s)=>{const i=e.innerType._zod.run(t,s);return i instanceof Promise?i.then(xk):xk(i)}});function xk(n){return n.value=Object.freeze(n.value),n}const Yj=J("$ZodCustom",(n,e)=>{Ds.init(n,e),wt.init(n,e),n._zod.parse=(t,s)=>t,n._zod.check=t=>{const s=t.value,i=e.fn(s);if(i instanceof Promise)return i.then(r=>kk(r,t,s,n));kk(i,t,s,n)}});function kk(n,e,t,s){if(!n){const i={code:"custom",input:t,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(i.params=s._zod.def.params),e.issues.push(tf(i))}}class Jj{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){const s=t[0];if(this._map.set(e,s),s&&typeof s=="object"&&"id"in s){if(this._idmap.has(s.id))throw new Error(`ID ${s.id} already exists in the registry`);this._idmap.set(s.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const s={...this.get(t)??{}};return delete s.id,{...s,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function Qj(){return new Jj}const pm=Qj();function eF(n,e){return new n({type:"string",...be(e)})}function tF(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...be(e)})}function Ak(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...be(e)})}function nF(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...be(e)})}function sF(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...be(e)})}function iF(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...be(e)})}function rF(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...be(e)})}function y$(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...be(e)})}function oF(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...be(e)})}function aF(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...be(e)})}function lF(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...be(e)})}function cF(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...be(e)})}function hF(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...be(e)})}function uF(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...be(e)})}function dF(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...be(e)})}function fF(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...be(e)})}function pF(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...be(e)})}function mF(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...be(e)})}function gF(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...be(e)})}function yF(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...be(e)})}function bF(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...be(e)})}function vF(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...be(e)})}function wF(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...be(e)})}function _F(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...be(e)})}function SF(n,e){return new n({type:"string",format:"date",check:"string_format",...be(e)})}function xF(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...be(e)})}function kF(n,e){return new n({type:"string",format:"duration",check:"string_format",...be(e)})}function AF(n,e){return new n({type:"number",checks:[],...be(e)})}function EF(n,e){return new n({type:"number",coerce:!0,checks:[],...be(e)})}function CF(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...be(e)})}function $F(n,e){return new n({type:"boolean",...be(e)})}function TF(n,e){return new n({type:"undefined",...be(e)})}function PF(n,e){return new n({type:"null",...be(e)})}function RF(n){return new n({type:"any"})}function MF(n){return new n({type:"unknown"})}function IF(n,e){return new n({type:"never",...be(e)})}function Ek(n,e){return new d$({check:"less_than",...be(e),value:n,inclusive:!1})}function eb(n,e){return new d$({check:"less_than",...be(e),value:n,inclusive:!0})}function Ck(n,e){return new f$({check:"greater_than",...be(e),value:n,inclusive:!1})}function tb(n,e){return new f$({check:"greater_than",...be(e),value:n,inclusive:!0})}function $k(n,e){return new q2({check:"multiple_of",...be(e),value:n})}function b$(n,e){return new U2({check:"max_length",...be(e),maximum:n})}function Kg(n,e){return new W2({check:"min_length",...be(e),minimum:n})}function v$(n,e){return new G2({check:"length_equals",...be(e),length:n})}function OF(n,e){return new K2({check:"string_format",format:"regex",...be(e),pattern:n})}function NF(n){return new Z2({check:"string_format",format:"lowercase",...be(n)})}function LF(n){return new X2({check:"string_format",format:"uppercase",...be(n)})}function DF(n,e){return new Y2({check:"string_format",format:"includes",...be(e),includes:n})}function jF(n,e){return new J2({check:"string_format",format:"starts_with",...be(e),prefix:n})}function FF(n,e){return new Q2({check:"string_format",format:"ends_with",...be(e),suffix:n})}function Dp(n){return new ej({check:"overwrite",tx:n})}function zF(n){return Dp(e=>e.normalize(n))}function HF(){return Dp(n=>n.trim())}function BF(){return Dp(n=>n.toLowerCase())}function qF(){return Dp(n=>n.toUpperCase())}function VF(n,e,t){return new n({type:"array",element:e,...be(t)})}function UF(n,e,t){const s=be(t);return s.abort??(s.abort=!0),new n({type:"custom",check:"custom",fn:e,...s})}function WF(n,e,t){return new n({type:"custom",check:"custom",fn:e,...be(t)})}const GF=J("ZodISODateTime",(n,e)=>{pj.init(n,e),jt.init(n,e)});function w$(n){return _F(GF,n)}const KF=J("ZodISODate",(n,e)=>{mj.init(n,e),jt.init(n,e)});function ZF(n){return SF(KF,n)}const XF=J("ZodISOTime",(n,e)=>{gj.init(n,e),jt.init(n,e)});function YF(n){return xF(XF,n)}const JF=J("ZodISODuration",(n,e)=>{yj.init(n,e),jt.init(n,e)});function QF(n){return kF(JF,n)}const ez=(n,e)=>{s$.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>h2(n,t)},flatten:{value:t=>c2(n,t)},addIssue:{value:t=>n.issues.push(t)},addIssues:{value:t=>n.issues.push(...t)},isEmpty:{get(){return n.issues.length===0}}})},h0=J("ZodError",ez,{Parent:Error}),tz=u2(h0),nz=d2(h0),sz=r$(h0),iz=a$(h0),$t=J("ZodType",(n,e)=>(wt.init(n,e),n.def=e,Object.defineProperty(n,"_def",{value:e}),n.check=(...t)=>n.clone({...e,checks:[...e.checks??[],...t.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),n.clone=(t,s)=>Ec(n,t,s),n.brand=()=>n,n.register=(t,s)=>(t.add(n,s),n),n.parse=(t,s)=>tz(n,t,s,{callee:n.parse}),n.safeParse=(t,s)=>sz(n,t,s),n.parseAsync=async(t,s)=>nz(n,t,s,{callee:n.parseAsync}),n.safeParseAsync=async(t,s)=>iz(n,t,s),n.spa=n.safeParseAsync,n.refine=(t,s)=>n.check(Xz(t,s)),n.superRefine=t=>n.check(Yz(t)),n.overwrite=t=>n.check(Dp(t)),n.optional=()=>Dt(n),n.nullable=()=>Rk(n),n.nullish=()=>Dt(Rk(n)),n.nonoptional=t=>Bz(n,t),n.array=()=>oe(n),n.or=t=>Ke([n,t]),n.and=t=>sS(n,t),n.transform=t=>tv(n,E$(t)),n.default=t=>Fz(n,t),n.prefault=t=>Hz(n,t),n.catch=t=>Vz(n,t),n.pipe=t=>tv(n,t),n.readonly=()=>Gz(n),n.describe=t=>{const s=n.clone();return pm.add(s,{description:t}),s},Object.defineProperty(n,"description",{get(){var t;return(t=pm.get(n))==null?void 0:t.description},configurable:!0}),n.meta=(...t)=>{if(t.length===0)return pm.get(n);const s=n.clone();return pm.add(s,t[0]),s},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n)),_$=J("_ZodString",(n,e)=>{eS.init(n,e),$t.init(n,e);const t=n._zod.bag;n.format=t.format??null,n.minLength=t.minimum??null,n.maxLength=t.maximum??null,n.regex=(...s)=>n.check(OF(...s)),n.includes=(...s)=>n.check(DF(...s)),n.startsWith=(...s)=>n.check(jF(...s)),n.endsWith=(...s)=>n.check(FF(...s)),n.min=(...s)=>n.check(Kg(...s)),n.max=(...s)=>n.check(b$(...s)),n.length=(...s)=>n.check(v$(...s)),n.nonempty=(...s)=>n.check(Kg(1,...s)),n.lowercase=s=>n.check(NF(s)),n.uppercase=s=>n.check(LF(s)),n.trim=()=>n.check(HF()),n.normalize=(...s)=>n.check(zF(...s)),n.toLowerCase=()=>n.check(BF()),n.toUpperCase=()=>n.check(qF())}),rz=J("ZodString",(n,e)=>{eS.init(n,e),_$.init(n,e),n.email=t=>n.check(tF(oz,t)),n.url=t=>n.check(y$(S$,t)),n.jwt=t=>n.check(wF(Sz,t)),n.emoji=t=>n.check(oF(lz,t)),n.guid=t=>n.check(Ak(Tk,t)),n.uuid=t=>n.check(nF(mm,t)),n.uuidv4=t=>n.check(sF(mm,t)),n.uuidv6=t=>n.check(iF(mm,t)),n.uuidv7=t=>n.check(rF(mm,t)),n.nanoid=t=>n.check(aF(cz,t)),n.guid=t=>n.check(Ak(Tk,t)),n.cuid=t=>n.check(lF(hz,t)),n.cuid2=t=>n.check(cF(uz,t)),n.ulid=t=>n.check(hF(dz,t)),n.base64=t=>n.check(yF(vz,t)),n.base64url=t=>n.check(bF(wz,t)),n.xid=t=>n.check(uF(fz,t)),n.ksuid=t=>n.check(dF(pz,t)),n.ipv4=t=>n.check(fF(mz,t)),n.ipv6=t=>n.check(pF(gz,t)),n.cidrv4=t=>n.check(mF(yz,t)),n.cidrv6=t=>n.check(gF(bz,t)),n.e164=t=>n.check(vF(_z,t)),n.datetime=t=>n.check(w$(t)),n.date=t=>n.check(ZF(t)),n.time=t=>n.check(YF(t)),n.duration=t=>n.check(QF(t))});function D(n){return eF(rz,n)}const jt=J("ZodStringFormat",(n,e)=>{Mt.init(n,e),_$.init(n,e)}),oz=J("ZodEmail",(n,e)=>{rj.init(n,e),jt.init(n,e)}),Tk=J("ZodGUID",(n,e)=>{sj.init(n,e),jt.init(n,e)}),mm=J("ZodUUID",(n,e)=>{ij.init(n,e),jt.init(n,e)}),S$=J("ZodURL",(n,e)=>{oj.init(n,e),jt.init(n,e)});function az(n){return y$(S$,n)}const lz=J("ZodEmoji",(n,e)=>{aj.init(n,e),jt.init(n,e)}),cz=J("ZodNanoID",(n,e)=>{lj.init(n,e),jt.init(n,e)}),hz=J("ZodCUID",(n,e)=>{cj.init(n,e),jt.init(n,e)}),uz=J("ZodCUID2",(n,e)=>{hj.init(n,e),jt.init(n,e)}),dz=J("ZodULID",(n,e)=>{uj.init(n,e),jt.init(n,e)}),fz=J("ZodXID",(n,e)=>{dj.init(n,e),jt.init(n,e)}),pz=J("ZodKSUID",(n,e)=>{fj.init(n,e),jt.init(n,e)}),mz=J("ZodIPv4",(n,e)=>{bj.init(n,e),jt.init(n,e)}),gz=J("ZodIPv6",(n,e)=>{vj.init(n,e),jt.init(n,e)}),yz=J("ZodCIDRv4",(n,e)=>{wj.init(n,e),jt.init(n,e)}),bz=J("ZodCIDRv6",(n,e)=>{_j.init(n,e),jt.init(n,e)}),vz=J("ZodBase64",(n,e)=>{Sj.init(n,e),jt.init(n,e)}),wz=J("ZodBase64URL",(n,e)=>{kj.init(n,e),jt.init(n,e)}),_z=J("ZodE164",(n,e)=>{Aj.init(n,e),jt.init(n,e)}),Sz=J("ZodJWT",(n,e)=>{Cj.init(n,e),jt.init(n,e)}),tS=J("ZodNumber",(n,e)=>{m$.init(n,e),$t.init(n,e),n.gt=(s,i)=>n.check(Ck(s,i)),n.gte=(s,i)=>n.check(tb(s,i)),n.min=(s,i)=>n.check(tb(s,i)),n.lt=(s,i)=>n.check(Ek(s,i)),n.lte=(s,i)=>n.check(eb(s,i)),n.max=(s,i)=>n.check(eb(s,i)),n.int=s=>n.check(Pk(s)),n.safe=s=>n.check(Pk(s)),n.positive=s=>n.check(Ck(0,s)),n.nonnegative=s=>n.check(tb(0,s)),n.negative=s=>n.check(Ek(0,s)),n.nonpositive=s=>n.check(eb(0,s)),n.multipleOf=(s,i)=>n.check($k(s,i)),n.step=(s,i)=>n.check($k(s,i)),n.finite=()=>n;const t=n._zod.bag;n.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),n.isFinite=!0,n.format=t.format??null});function Le(n){return AF(tS,n)}const xz=J("ZodNumberFormat",(n,e)=>{$j.init(n,e),tS.init(n,e)});function Pk(n){return CF(xz,n)}const kz=J("ZodBoolean",(n,e)=>{Tj.init(n,e),$t.init(n,e)});function Xe(n){return $F(kz,n)}const Az=J("ZodUndefined",(n,e)=>{Pj.init(n,e),$t.init(n,e)});function Jb(n){return TF(Az,n)}const Ez=J("ZodNull",(n,e)=>{Rj.init(n,e),$t.init(n,e)});function Cz(n){return PF(Ez,n)}const $z=J("ZodAny",(n,e)=>{Mj.init(n,e),$t.init(n,e)});function nS(){return RF($z)}const Tz=J("ZodUnknown",(n,e)=>{Ij.init(n,e),$t.init(n,e)});function vt(){return MF(Tz)}const Pz=J("ZodNever",(n,e)=>{Oj.init(n,e),$t.init(n,e)});function Qb(n){return IF(Pz,n)}const Rz=J("ZodArray",(n,e)=>{Nj.init(n,e),$t.init(n,e),n.element=e.element,n.min=(t,s)=>n.check(Kg(t,s)),n.nonempty=t=>n.check(Kg(1,t)),n.max=(t,s)=>n.check(b$(t,s)),n.length=(t,s)=>n.check(v$(t,s)),n.unwrap=()=>n.element});function oe(n,e){return VF(Rz,n,e)}const x$=J("ZodObject",(n,e)=>{Lj.init(n,e),$t.init(n,e),Ct(n,"shape",()=>e.shape),n.keyof=()=>ni(Object.keys(n._zod.def.shape)),n.catchall=t=>n.clone({...n._zod.def,catchall:t}),n.passthrough=()=>n.clone({...n._zod.def,catchall:vt()}),n.loose=()=>n.clone({...n._zod.def,catchall:vt()}),n.strict=()=>n.clone({...n._zod.def,catchall:Qb()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>r2(n,t),n.merge=t=>o2(n,t),n.pick=t=>s2(n,t),n.omit=t=>i2(n,t),n.partial=(...t)=>a2(C$,n,t[0]),n.required=(...t)=>l2($$,n,t[0])});function K(n,e){const t={type:"object",get shape(){return l0(this,"shape",{...n}),this.shape},...be(e)};return new x$(t)}function zn(n,e){return new x$({type:"object",get shape(){return l0(this,"shape",{...n}),this.shape},catchall:vt(),...be(e)})}const k$=J("ZodUnion",(n,e)=>{g$.init(n,e),$t.init(n,e),n.options=e.options});function Ke(n,e){return new k$({type:"union",options:n,...be(e)})}const Mz=J("ZodDiscriminatedUnion",(n,e)=>{k$.init(n,e),Dj.init(n,e)});function A$(n,e,t){return new Mz({type:"union",options:e,discriminator:n,...be(t)})}const Iz=J("ZodIntersection",(n,e)=>{jj.init(n,e),$t.init(n,e)});function sS(n,e){return new Iz({type:"intersection",left:n,right:e})}const Oz=J("ZodRecord",(n,e)=>{Fj.init(n,e),$t.init(n,e),n.keyType=e.keyType,n.valueType=e.valueType});function Ye(n,e,t){return new Oz({type:"record",keyType:n,valueType:e,...be(t)})}const ev=J("ZodEnum",(n,e)=>{zj.init(n,e),$t.init(n,e),n.enum=e.entries,n.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));n.extract=(s,i)=>{const r={};for(const o of s)if(t.has(o))r[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new ev({...e,checks:[],...be(i),entries:r})},n.exclude=(s,i)=>{const r={...e.entries};for(const o of s)if(t.has(o))delete r[o];else throw new Error(`Key ${o} not found in enum`);return new ev({...e,checks:[],...be(i),entries:r})}});function ni(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(s=>[s,s])):n;return new ev({type:"enum",entries:t,...be(e)})}const Nz=J("ZodLiteral",(n,e)=>{Hj.init(n,e),$t.init(n,e),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function U(n,e){return new Nz({type:"literal",values:Array.isArray(n)?n:[n],...be(e)})}const Lz=J("ZodTransform",(n,e)=>{Bj.init(n,e),$t.init(n,e),n._zod.parse=(t,s)=>{t.addIssue=r=>{if(typeof r=="string")t.issues.push(tf(r,t.value,e));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),o.continue??(o.continue=!0),t.issues.push(tf(o))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(r=>(t.value=r,t)):(t.value=i,t)}});function E$(n){return new Lz({type:"transform",transform:n})}const C$=J("ZodOptional",(n,e)=>{qj.init(n,e),$t.init(n,e),n.unwrap=()=>n._zod.def.innerType});function Dt(n){return new C$({type:"optional",innerType:n})}const Dz=J("ZodNullable",(n,e)=>{Vj.init(n,e),$t.init(n,e),n.unwrap=()=>n._zod.def.innerType});function Rk(n){return new Dz({type:"nullable",innerType:n})}const jz=J("ZodDefault",(n,e)=>{Uj.init(n,e),$t.init(n,e),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function Fz(n,e){return new jz({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():e}})}const zz=J("ZodPrefault",(n,e)=>{Wj.init(n,e),$t.init(n,e),n.unwrap=()=>n._zod.def.innerType});function Hz(n,e){return new zz({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():e}})}const $$=J("ZodNonOptional",(n,e)=>{Gj.init(n,e),$t.init(n,e),n.unwrap=()=>n._zod.def.innerType});function Bz(n,e){return new $$({type:"nonoptional",innerType:n,...be(e)})}const qz=J("ZodCatch",(n,e)=>{Kj.init(n,e),$t.init(n,e),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function Vz(n,e){return new qz({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const Uz=J("ZodPipe",(n,e)=>{Zj.init(n,e),$t.init(n,e),n.in=e.in,n.out=e.out});function tv(n,e){return new Uz({type:"pipe",in:n,out:e})}const Wz=J("ZodReadonly",(n,e)=>{Xj.init(n,e),$t.init(n,e)});function Gz(n){return new Wz({type:"readonly",innerType:n})}const T$=J("ZodCustom",(n,e)=>{Yj.init(n,e),$t.init(n,e)});function Kz(n){const e=new Ds({check:"custom"});return e._zod.check=n,e}function Zz(n,e){return UF(T$,n??(()=>!0),e)}function Xz(n,e={}){return WF(T$,n,e)}function Yz(n){const e=Kz(t=>(t.addIssue=s=>{if(typeof s=="string")t.issues.push(tf(s,t.value,e._zod.def));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),t.issues.push(tf(i))}},n(t.value,t)));return e}function P$(n,e){return tv(E$(n),e)}const Jz={custom:"custom"};function Qz(n){return EF(tS,n)}const u0="2025-11-25",eH=[u0,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Ga="io.modelcontextprotocol/related-task",d0="2.0",fn=Zz(n=>n!==null&&(typeof n=="object"||typeof n=="function")),R$=Ke([D(),Le().int()]),M$=D();zn({ttl:Le().optional(),pollInterval:Le().optional()});const tH=K({ttl:Le().optional()}),nH=K({taskId:D()}),iS=zn({progressToken:R$.optional(),[Ga]:nH.optional()}),si=K({_meta:iS.optional()}),jp=si.extend({task:tH.optional()}),sH=n=>jp.safeParse(n).success,qn=K({method:D(),params:si.loose().optional()}),_i=K({_meta:iS.optional()}),Si=K({method:D(),params:_i.loose().optional()}),Vn=zn({_meta:iS.optional()}),Fp=Ke([D(),Le().int()]),I$=K({jsonrpc:U(d0),id:Fp,...qn.shape}).strict(),nv=n=>I$.safeParse(n).success,O$=K({jsonrpc:U(d0),...Si.shape}).strict(),iH=n=>O$.safeParse(n).success,rS=K({jsonrpc:U(d0),id:Fp,result:Vn}).strict(),ld=n=>rS.safeParse(n).success;var Pe;(function(n){n[n.ConnectionClosed=-32e3]="ConnectionClosed",n[n.RequestTimeout=-32001]="RequestTimeout",n[n.ParseError=-32700]="ParseError",n[n.InvalidRequest=-32600]="InvalidRequest",n[n.MethodNotFound=-32601]="MethodNotFound",n[n.InvalidParams=-32602]="InvalidParams",n[n.InternalError=-32603]="InternalError",n[n.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(Pe||(Pe={}));const oS=K({jsonrpc:U(d0),id:Fp.optional(),error:K({code:Le().int(),message:D(),data:vt().optional()})}).strict(),rH=n=>oS.safeParse(n).success,Jm=Ke([I$,O$,rS,oS]);Ke([rS,oS]);const Yc=Vn.strict(),oH=_i.extend({requestId:Fp.optional(),reason:D().optional()}),aS=Si.extend({method:U("notifications/cancelled"),params:oH}),aH=K({src:D(),mimeType:D().optional(),sizes:oe(D()).optional(),theme:ni(["light","dark"]).optional()}),zp=K({icons:oe(aH).optional()}),pu=K({name:D(),title:D().optional()}),f0=pu.extend({...pu.shape,...zp.shape,version:D(),websiteUrl:D().optional(),description:D().optional()}),lH=sS(K({applyDefaults:Xe().optional()}),Ye(D(),vt())),cH=P$(n=>n&&typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0?{form:{}}:n,sS(K({form:lH.optional(),url:fn.optional()}),Ye(D(),vt()).optional())),hH=zn({list:fn.optional(),cancel:fn.optional(),requests:zn({sampling:zn({createMessage:fn.optional()}).optional(),elicitation:zn({create:fn.optional()}).optional()}).optional()}),uH=zn({list:fn.optional(),cancel:fn.optional(),requests:zn({tools:zn({call:fn.optional()}).optional()}).optional()}),dH=K({experimental:Ye(D(),fn).optional(),sampling:K({context:fn.optional(),tools:fn.optional()}).optional(),elicitation:cH.optional(),roots:K({listChanged:Xe().optional()}).optional(),tasks:hH.optional(),extensions:Ye(D(),fn).optional()}),fH=si.extend({protocolVersion:D(),capabilities:dH,clientInfo:f0}),pH=qn.extend({method:U("initialize"),params:fH}),mH=K({experimental:Ye(D(),fn).optional(),logging:fn.optional(),completions:fn.optional(),prompts:K({listChanged:Xe().optional()}).optional(),resources:K({subscribe:Xe().optional(),listChanged:Xe().optional()}).optional(),tools:K({listChanged:Xe().optional()}).optional(),tasks:uH.optional(),extensions:Ye(D(),fn).optional()}),N$=Vn.extend({protocolVersion:D(),capabilities:mH,serverInfo:f0,instructions:D().optional()}),L$=Si.extend({method:U("notifications/initialized"),params:_i.optional()}),gH=n=>L$.safeParse(n).success,p0=qn.extend({method:U("ping"),params:si.optional()}),yH=K({progress:Le(),total:Dt(Le()),message:Dt(D())}),bH=K({..._i.shape,...yH.shape,progressToken:R$}),lS=Si.extend({method:U("notifications/progress"),params:bH}),vH=si.extend({cursor:M$.optional()}),Hp=qn.extend({params:vH.optional()}),Bp=Vn.extend({nextCursor:M$.optional()}),wH=ni(["working","input_required","completed","failed","cancelled"]),qp=K({taskId:D(),status:wH,ttl:Ke([Le(),Cz()]),createdAt:D(),lastUpdatedAt:D(),pollInterval:Dt(Le()),statusMessage:Dt(D())}),nf=Vn.extend({task:qp}),_H=_i.merge(qp),Zg=Si.extend({method:U("notifications/tasks/status"),params:_H}),cS=qn.extend({method:U("tasks/get"),params:si.extend({taskId:D()})}),hS=Vn.merge(qp),uS=qn.extend({method:U("tasks/result"),params:si.extend({taskId:D()})});Vn.loose();const dS=Hp.extend({method:U("tasks/list")}),fS=Bp.extend({tasks:oe(qp)}),pS=qn.extend({method:U("tasks/cancel"),params:si.extend({taskId:D()})}),SH=Vn.merge(qp),D$=K({uri:D(),mimeType:Dt(D()),_meta:Ye(D(),vt()).optional()}),j$=D$.extend({text:D()}),mS=D().refine(n=>{try{return atob(n),!0}catch{return!1}},{message:"Invalid Base64 string"}),F$=D$.extend({blob:mS}),Vp=ni(["user","assistant"]),Ru=K({audience:oe(Vp).optional(),priority:Le().min(0).max(1).optional(),lastModified:w$({offset:!0}).optional()}),z$=K({...pu.shape,...zp.shape,uri:D(),description:Dt(D()),mimeType:Dt(D()),size:Dt(Le()),annotations:Ru.optional(),_meta:Dt(zn({}))}),xH=K({...pu.shape,...zp.shape,uriTemplate:D(),description:Dt(D()),mimeType:Dt(D()),annotations:Ru.optional(),_meta:Dt(zn({}))}),H$=Hp.extend({method:U("resources/list")}),gS=Bp.extend({resources:oe(z$)}),B$=Hp.extend({method:U("resources/templates/list")}),yS=Bp.extend({resourceTemplates:oe(xH)}),bS=si.extend({uri:D()}),kH=bS,q$=qn.extend({method:U("resources/read"),params:kH}),vS=Vn.extend({contents:oe(Ke([j$,F$]))}),wS=Si.extend({method:U("notifications/resources/list_changed"),params:_i.optional()}),AH=bS,EH=qn.extend({method:U("resources/subscribe"),params:AH}),CH=bS,$H=qn.extend({method:U("resources/unsubscribe"),params:CH}),TH=_i.extend({uri:D()}),PH=Si.extend({method:U("notifications/resources/updated"),params:TH}),RH=K({name:D(),description:Dt(D()),required:Dt(Xe())}),MH=K({...pu.shape,...zp.shape,description:Dt(D()),arguments:Dt(oe(RH)),_meta:Dt(zn({}))}),V$=Hp.extend({method:U("prompts/list")}),_S=Bp.extend({prompts:oe(MH)}),IH=si.extend({name:D(),arguments:Ye(D(),D()).optional()}),OH=qn.extend({method:U("prompts/get"),params:IH}),SS=K({type:U("text"),text:D(),annotations:Ru.optional(),_meta:Ye(D(),vt()).optional()}),xS=K({type:U("image"),data:mS,mimeType:D(),annotations:Ru.optional(),_meta:Ye(D(),vt()).optional()}),kS=K({type:U("audio"),data:mS,mimeType:D(),annotations:Ru.optional(),_meta:Ye(D(),vt()).optional()}),NH=K({type:U("tool_use"),name:D(),id:D(),input:Ye(D(),vt()),_meta:Ye(D(),vt()).optional()}),U$=K({type:U("resource"),resource:Ke([j$,F$]),annotations:Ru.optional(),_meta:Ye(D(),vt()).optional()}),W$=z$.extend({type:U("resource_link")}),Up=Ke([SS,xS,kS,W$,U$]),LH=K({role:Vp,content:Up}),G$=Vn.extend({description:D().optional(),messages:oe(LH)}),AS=Si.extend({method:U("notifications/prompts/list_changed"),params:_i.optional()}),DH=K({title:D().optional(),readOnlyHint:Xe().optional(),destructiveHint:Xe().optional(),idempotentHint:Xe().optional(),openWorldHint:Xe().optional()}),jH=K({taskSupport:ni(["required","optional","forbidden"]).optional()}),ES=K({...pu.shape,...zp.shape,description:D().optional(),inputSchema:K({type:U("object"),properties:Ye(D(),fn).optional(),required:oe(D()).optional()}).catchall(vt()),outputSchema:K({type:U("object"),properties:Ye(D(),fn).optional(),required:oe(D()).optional()}).catchall(vt()).optional(),annotations:DH.optional(),execution:jH.optional(),_meta:Ye(D(),vt()).optional()}),FH=Hp.extend({method:U("tools/list")}),CS=Bp.extend({tools:oe(ES)}),lc=Vn.extend({content:oe(Up).default([]),structuredContent:Ye(D(),vt()).optional(),isError:Xe().optional()});lc.or(Vn.extend({toolResult:vt()}));const zH=jp.extend({name:D(),arguments:Ye(D(),vt()).optional()}),K$=qn.extend({method:U("tools/call"),params:zH}),$S=Si.extend({method:U("notifications/tools/list_changed"),params:_i.optional()}),HH=K({autoRefresh:Xe().default(!0),debounceMs:Le().int().nonnegative().default(300)}),Z$=ni(["debug","info","notice","warning","error","critical","alert","emergency"]),BH=si.extend({level:Z$}),qH=qn.extend({method:U("logging/setLevel"),params:BH}),VH=_i.extend({level:Z$,logger:D().optional(),data:vt()}),X$=Si.extend({method:U("notifications/message"),params:VH}),UH=K({name:D().optional()}),WH=K({hints:oe(UH).optional(),costPriority:Le().min(0).max(1).optional(),speedPriority:Le().min(0).max(1).optional(),intelligencePriority:Le().min(0).max(1).optional()}),GH=K({mode:ni(["auto","required","none"]).optional()}),KH=K({type:U("tool_result"),toolUseId:D().describe("The unique identifier for the corresponding tool call."),content:oe(Up).default([]),structuredContent:K({}).loose().optional(),isError:Xe().optional(),_meta:Ye(D(),vt()).optional()}),ZH=A$("type",[SS,xS,kS]),Xg=A$("type",[SS,xS,kS,NH,KH]),XH=K({role:Vp,content:Ke([Xg,oe(Xg)]),_meta:Ye(D(),vt()).optional()}),YH=jp.extend({messages:oe(XH),modelPreferences:WH.optional(),systemPrompt:D().optional(),includeContext:ni(["none","thisServer","allServers"]).optional(),temperature:Le().optional(),maxTokens:Le().int(),stopSequences:oe(D()).optional(),metadata:fn.optional(),tools:oe(ES).optional(),toolChoice:GH.optional()}),TS=qn.extend({method:U("sampling/createMessage"),params:YH}),Y$=Vn.extend({model:D(),stopReason:Dt(ni(["endTurn","stopSequence","maxTokens"]).or(D())),role:Vp,content:ZH}),J$=Vn.extend({model:D(),stopReason:Dt(ni(["endTurn","stopSequence","maxTokens","toolUse"]).or(D())),role:Vp,content:Ke([Xg,oe(Xg)])}),JH=K({type:U("boolean"),title:D().optional(),description:D().optional(),default:Xe().optional()}),QH=K({type:U("string"),title:D().optional(),description:D().optional(),minLength:Le().optional(),maxLength:Le().optional(),format:ni(["email","uri","date","date-time"]).optional(),default:D().optional()}),eB=K({type:ni(["number","integer"]),title:D().optional(),description:D().optional(),minimum:Le().optional(),maximum:Le().optional(),default:Le().optional()}),tB=K({type:U("string"),title:D().optional(),description:D().optional(),enum:oe(D()),default:D().optional()}),nB=K({type:U("string"),title:D().optional(),description:D().optional(),oneOf:oe(K({const:D(),title:D()})),default:D().optional()}),sB=K({type:U("string"),title:D().optional(),description:D().optional(),enum:oe(D()),enumNames:oe(D()).optional(),default:D().optional()}),iB=Ke([tB,nB]),rB=K({type:U("array"),title:D().optional(),description:D().optional(),minItems:Le().optional(),maxItems:Le().optional(),items:K({type:U("string"),enum:oe(D())}),default:oe(D()).optional()}),oB=K({type:U("array"),title:D().optional(),description:D().optional(),minItems:Le().optional(),maxItems:Le().optional(),items:K({anyOf:oe(K({const:D(),title:D()}))}),default:oe(D()).optional()}),aB=Ke([rB,oB]),lB=Ke([sB,iB,aB]),cB=Ke([lB,JH,QH,eB]),hB=jp.extend({mode:U("form").optional(),message:D(),requestedSchema:K({type:U("object"),properties:Ye(D(),cB),required:oe(D()).optional()})}),uB=jp.extend({mode:U("url"),message:D(),elicitationId:D(),url:D().url()}),dB=Ke([hB,uB]),Q$=qn.extend({method:U("elicitation/create"),params:dB}),fB=_i.extend({elicitationId:D()}),pB=Si.extend({method:U("notifications/elicitation/complete"),params:fB}),eT=Vn.extend({action:ni(["accept","decline","cancel"]),content:P$(n=>n===null?void 0:n,Ye(D(),Ke([D(),Le(),Xe(),oe(D())])).optional())}),mB=K({type:U("ref/resource"),uri:D()}),gB=K({type:U("ref/prompt"),name:D()}),yB=si.extend({ref:Ke([gB,mB]),argument:K({name:D(),value:D()}),context:K({arguments:Ye(D(),D()).optional()}).optional()}),bB=qn.extend({method:U("completion/complete"),params:yB}),tT=Vn.extend({completion:zn({values:oe(D()).max(100),total:Dt(Le().int()),hasMore:Dt(Xe())})}),vB=K({uri:D().startsWith("file://"),name:D().optional(),_meta:Ye(D(),vt()).optional()}),wB=qn.extend({method:U("roots/list"),params:si.optional()}),_B=Vn.extend({roots:oe(vB)}),SB=Si.extend({method:U("notifications/roots/list_changed"),params:_i.optional()});Ke([p0,pH,bB,qH,OH,V$,H$,B$,q$,EH,$H,K$,FH,cS,uS,dS,pS]);Ke([aS,lS,L$,SB,Zg]);Ke([Yc,Y$,J$,eT,_B,hS,fS,nf]);Ke([p0,TS,Q$,wB,cS,uS,dS,pS]);Ke([aS,lS,X$,PH,wS,$S,AS,Zg,pB]);Ke([Yc,N$,tT,G$,_S,gS,yS,vS,lc,CS,hS,fS,nf]);class Ae extends Error{constructor(e,t,s){super(`MCP error ${e}: ${t}`),this.code=e,this.data=s,this.name="McpError"}static fromError(e,t,s){if(e===Pe.UrlElicitationRequired&&s){const i=s;if(i.elicitations)return new xB(i.elicitations,t)}return new Ae(e,t,s)}}class xB extends Ae{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(Pe.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){var e;return((e=this.data)==null?void 0:e.elicitations)??[]}}function PS(n){return!!n._zod}function Lo(n,e){return PS(n)?o$(n,e):n.safeParse(e)}function nT(n){var t,s;if(!n)return;let e;if(PS(n)?e=(s=(t=n._zod)==null?void 0:t.def)==null?void 0:s.shape:e=n.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function sT(n){var i;if(PS(n)){const o=(i=n._zod)==null?void 0:i.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}const t=n._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const s=n.value;if(s!==void 0)return s}function Fa(n){return n==="completed"||n==="failed"||n==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Mk(n){const e=nT(n),t=e==null?void 0:e.method;if(!t)throw new Error("Schema is missing a method literal");const s=sT(t);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function Ik(n,e){const t=Lo(n,e);if(!t.success)throw t.error;return t.data}const kB=6e4;class iT{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(aS,t=>{this._oncancel(t)}),this.setNotificationHandler(lS,t=>{this._onprogress(t)}),this.setRequestHandler(p0,t=>({})),this._taskStore=e==null?void 0:e.taskStore,this._taskMessageQueue=e==null?void 0:e.taskMessageQueue,this._taskStore&&(this.setRequestHandler(cS,async(t,s)=>{const i=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!i)throw new Ae(Pe.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(uS,async(t,s)=>{const i=async()=>{var a;const r=t.params.taskId;if(this._taskMessageQueue){let l;for(;l=await this._taskMessageQueue.dequeue(r,s.sessionId);){if(l.type==="response"||l.type==="error"){const c=l.message,h=c.id,u=this._requestResolvers.get(h);if(u)if(this._requestResolvers.delete(h),l.type==="response")u(c);else{const d=c,p=new Ae(d.error.code,d.error.message,d.error.data);u(p)}else{const d=l.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${h}`))}continue}await((a=this._transport)==null?void 0:a.send(l.message,{relatedRequestId:s.requestId}))}}const o=await this._taskStore.getTask(r,s.sessionId);if(!o)throw new Ae(Pe.InvalidParams,`Task not found: ${r}`);if(!Fa(o.status))return await this._waitForTaskUpdate(r,s.signal),await i();if(Fa(o.status)){const l=await this._taskStore.getTaskResult(r,s.sessionId);return this._clearTaskQueue(r),{...l,_meta:{...l._meta,[Ga]:{taskId:r}}}}return await i()};return await i()}),this.setRequestHandler(dS,async(t,s)=>{var i;try{const{tasks:r,nextCursor:o}=await this._taskStore.listTasks((i=t.params)==null?void 0:i.cursor,s.sessionId);return{tasks:r,nextCursor:o,_meta:{}}}catch(r){throw new Ae(Pe.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(pS,async(t,s)=>{try{const i=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!i)throw new Ae(Pe.InvalidParams,`Task not found: ${t.params.taskId}`);if(Fa(i.status))throw new Ae(Pe.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(t.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(t.params.taskId);const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new Ae(Pe.InvalidParams,`Task not found after cancellation: ${t.params.taskId}`);return{_meta:{},...r}}catch(i){throw i instanceof Ae?i:new Ae(Pe.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;const t=this._requestHandlerAbortControllers.get(e.params.requestId);t==null||t.abort(e.params.reason)}_setupTimeout(e,t,s,i,r=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(i,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:r,onTimeout:i})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const s=Date.now()-t.startTime;if(t.maxTotalTimeout&&s>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),Ae.fromError(Pe.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:s});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var r,o,a;if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;const t=(r=this.transport)==null?void 0:r.onclose;this._transport.onclose=()=>{t==null||t(),this._onclose()};const s=(o=this.transport)==null?void 0:o.onerror;this._transport.onerror=l=>{s==null||s(l),this._onerror(l)};const i=(a=this._transport)==null?void 0:a.onmessage;this._transport.onmessage=(l,c)=>{i==null||i(l,c),ld(l)||rH(l)?this._onresponse(l):nv(l)?this._onrequest(l,c):iH(l)?this._onnotification(l):this._onerror(new Error(`Unknown message type: ${JSON.stringify(l)}`))},await this._transport.start()}_onclose(){var s;const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const i of this._timeoutInfo.values())clearTimeout(i.timeoutId);this._timeoutInfo.clear();for(const i of this._requestHandlerAbortControllers.values())i.abort();this._requestHandlerAbortControllers.clear();const t=Ae.fromError(Pe.ConnectionClosed,"Connection closed");this._transport=void 0,(s=this.onclose)==null||s.call(this);for(const i of e.values())i(t)}_onerror(e){var t;(t=this.onerror)==null||t.call(this,e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,t){var h,u,d,p;const s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,i=this._transport,r=(d=(u=(h=e.params)==null?void 0:h._meta)==null?void 0:u[Ga])==null?void 0:d.taskId;if(s===void 0){const m={jsonrpc:"2.0",id:e.id,error:{code:Pe.MethodNotFound,message:"Method not found"}};r&&this._taskMessageQueue?this._enqueueTaskMessage(r,{type:"error",message:m,timestamp:Date.now()},i==null?void 0:i.sessionId).catch(g=>this._onerror(new Error(`Failed to enqueue error response: ${g}`))):i==null||i.send(m).catch(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)));return}const o=new AbortController;this._requestHandlerAbortControllers.set(e.id,o);const a=sH(e.params)?e.params.task:void 0,l=this._taskStore?this.requestTaskStore(e,i==null?void 0:i.sessionId):void 0,c={signal:o.signal,sessionId:i==null?void 0:i.sessionId,_meta:(p=e.params)==null?void 0:p._meta,sendNotification:async m=>{if(o.signal.aborted)return;const g={relatedRequestId:e.id};r&&(g.relatedTask={taskId:r}),await this.notification(m,g)},sendRequest:async(m,g,b)=>{var v;if(o.signal.aborted)throw new Ae(Pe.ConnectionClosed,"Request was cancelled");const y={...b,relatedRequestId:e.id};r&&!y.relatedTask&&(y.relatedTask={taskId:r});const w=((v=y.relatedTask)==null?void 0:v.taskId)??r;return w&&l&&await l.updateTaskStatus(w,"input_required"),await this.request(m,g,y)},authInfo:t==null?void 0:t.authInfo,requestId:e.id,requestInfo:t==null?void 0:t.requestInfo,taskId:r,taskStore:l,taskRequestedTtl:a==null?void 0:a.ttl,closeSSEStream:t==null?void 0:t.closeSSEStream,closeStandaloneSSEStream:t==null?void 0:t.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,c)).then(async m=>{if(o.signal.aborted)return;const g={result:m,jsonrpc:"2.0",id:e.id};r&&this._taskMessageQueue?await this._enqueueTaskMessage(r,{type:"response",message:g,timestamp:Date.now()},i==null?void 0:i.sessionId):await(i==null?void 0:i.send(g))},async m=>{if(o.signal.aborted)return;const g={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(m.code)?m.code:Pe.InternalError,message:m.message??"Internal error",...m.data!==void 0&&{data:m.data}}};r&&this._taskMessageQueue?await this._enqueueTaskMessage(r,{type:"error",message:g,timestamp:Date.now()},i==null?void 0:i.sessionId):await(i==null?void 0:i.send(g))}).catch(m=>this._onerror(new Error(`Failed to send response: ${m}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===o&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...s}=e.params,i=Number(t),r=this._progressHandlers.get(i);if(!r){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const o=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&o&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(l){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),o(l);return}r(s)}_onresponse(e){const t=Number(e.id),s=this._requestResolvers.get(t);if(s){if(this._requestResolvers.delete(t),ld(e))s(e);else{const o=new Ae(e.error.code,e.error.message,e.error.data);s(o)}return}const i=this._responseHandlers.get(t);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let r=!1;if(ld(e)&&e.result&&typeof e.result=="object"){const o=e.result;if(o.task&&typeof o.task=="object"){const a=o.task;typeof a.taskId=="string"&&(r=!0,this._taskProgressTokens.set(a.taskId,t))}}if(r||this._progressHandlers.delete(t),ld(e))i(e);else{const o=Ae.fromError(e.error.code,e.error.message,e.error.data);i(o)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)==null?void 0:e.close())}async*requestStream(e,t,s){var o,a;const{task:i}=s??{};if(!i){try{yield{type:"result",result:await this.request(e,t,s)}}catch(l){yield{type:"error",error:l instanceof Ae?l:new Ae(Pe.InternalError,String(l))}}return}let r;try{const l=await this.request(e,nf,s);if(l.task)r=l.task.taskId,yield{type:"taskCreated",task:l.task};else throw new Ae(Pe.InternalError,"Task creation did not return a task");for(;;){const c=await this.getTask({taskId:r},s);if(yield{type:"taskStatus",task:c},Fa(c.status)){c.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:r},t,s)}:c.status==="failed"?yield{type:"error",error:new Ae(Pe.InternalError,`Task ${r} failed`)}:c.status==="cancelled"&&(yield{type:"error",error:new Ae(Pe.InternalError,`Task ${r} was cancelled`)});return}if(c.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:r},t,s)};return}const h=c.pollInterval??((o=this._options)==null?void 0:o.defaultTaskPollInterval)??1e3;await new Promise(u=>setTimeout(u,h)),(a=s==null?void 0:s.signal)==null||a.throwIfAborted()}}catch(l){yield{type:"error",error:l instanceof Ae?l:new Ae(Pe.InternalError,String(l))}}}request(e,t,s){const{relatedRequestId:i,resumptionToken:r,onresumptiontoken:o,task:a,relatedTask:l}=s??{};return new Promise((c,h)=>{var w,v,x,k,E;const u=T=>{h(T)};if(!this._transport){u(new Error("Not connected"));return}if(((w=this._options)==null?void 0:w.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(T){u(T);return}(v=s==null?void 0:s.signal)==null||v.throwIfAborted();const d=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:d};s!=null&&s.onprogress&&(this._progressHandlers.set(d,s.onprogress),p.params={...e.params,_meta:{...((x=e.params)==null?void 0:x._meta)||{},progressToken:d}}),a&&(p.params={...p.params,task:a}),l&&(p.params={...p.params,_meta:{...((k=p.params)==null?void 0:k._meta)||{},[Ga]:l}});const m=T=>{var F;this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),(F=this._transport)==null||F.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:d,reason:String(T)}},{relatedRequestId:i,resumptionToken:r,onresumptiontoken:o}).catch(j=>this._onerror(new Error(`Failed to send cancellation: ${j}`)));const O=T instanceof Ae?T:new Ae(Pe.RequestTimeout,String(T));h(O)};this._responseHandlers.set(d,T=>{var O;if(!((O=s==null?void 0:s.signal)!=null&&O.aborted)){if(T instanceof Error)return h(T);try{const F=Lo(t,T.result);F.success?c(F.data):h(F.error)}catch(F){h(F)}}}),(E=s==null?void 0:s.signal)==null||E.addEventListener("abort",()=>{var T;m((T=s==null?void 0:s.signal)==null?void 0:T.reason)});const g=(s==null?void 0:s.timeout)??kB,b=()=>m(Ae.fromError(Pe.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(d,g,s==null?void 0:s.maxTotalTimeout,b,(s==null?void 0:s.resetTimeoutOnProgress)??!1);const y=l==null?void 0:l.taskId;if(y){const T=O=>{const F=this._responseHandlers.get(d);F?F(O):this._onerror(new Error(`Response handler missing for side-channeled request ${d}`))};this._requestResolvers.set(d,T),this._enqueueTaskMessage(y,{type:"request",message:p,timestamp:Date.now()}).catch(O=>{this._cleanupTimeout(d),h(O)})}else this._transport.send(p,{relatedRequestId:i,resumptionToken:r,onresumptiontoken:o}).catch(T=>{this._cleanupTimeout(d),h(T)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},hS,t)}async getTaskResult(e,t,s){return this.request({method:"tasks/result",params:e},t,s)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},fS,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},SH,t)}async notification(e,t){var a,l,c,h;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const s=(a=t==null?void 0:t.relatedTask)==null?void 0:a.taskId;if(s){const u={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...((l=e.params)==null?void 0:l._meta)||{},[Ga]:t.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:u,timestamp:Date.now()});return}if((((c=this._options)==null?void 0:c.debouncedNotificationMethods)??[]).includes(e.method)&&!e.params&&!(t!=null&&t.relatedRequestId)&&!(t!=null&&t.relatedTask)){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var d,p;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let u={...e,jsonrpc:"2.0"};t!=null&&t.relatedTask&&(u={...u,params:{...u.params,_meta:{...((d=u.params)==null?void 0:d._meta)||{},[Ga]:t.relatedTask}}}),(p=this._transport)==null||p.send(u,t).catch(m=>this._onerror(m))});return}let o={...e,jsonrpc:"2.0"};t!=null&&t.relatedTask&&(o={...o,params:{...o.params,_meta:{...((h=o.params)==null?void 0:h._meta)||{},[Ga]:t.relatedTask}}}),await this._transport.send(o,t)}setRequestHandler(e,t){const s=Mk(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(i,r)=>{const o=Ik(e,i);return Promise.resolve(t(o,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const s=Mk(e);this._notificationHandlers.set(s,i=>{const r=Ik(e,i);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,s){var r;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const i=(r=this._options)==null?void 0:r.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,s,i)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(e,t);for(const i of s)if(i.type==="request"&&nv(i.message)){const r=i.message.id,o=this._requestResolvers.get(r);o?(o(new Ae(Pe.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(r)):this._onerror(new Error(`Resolver missing for request ${r} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){var i,r;let s=((i=this._options)==null?void 0:i.defaultTaskPollInterval)??1e3;try{const o=await((r=this._taskStore)==null?void 0:r.getTask(e));o!=null&&o.pollInterval&&(s=o.pollInterval)}catch{}return new Promise((o,a)=>{if(t.aborted){a(new Ae(Pe.InvalidRequest,"Request cancelled"));return}const l=setTimeout(o,s);t.addEventListener("abort",()=>{clearTimeout(l),a(new Ae(Pe.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async i=>{if(!e)throw new Error("No request provided");return await s.createTask(i,e.id,{method:e.method,params:e.params},t)},getTask:async i=>{const r=await s.getTask(i,t);if(!r)throw new Ae(Pe.InvalidParams,"Failed to retrieve task: Task not found");return r},storeTaskResult:async(i,r,o)=>{await s.storeTaskResult(i,r,o,t);const a=await s.getTask(i,t);if(a){const l=Zg.parse({method:"notifications/tasks/status",params:a});await this.notification(l),Fa(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>s.getTaskResult(i,t),updateTaskStatus:async(i,r,o)=>{const a=await s.getTask(i,t);if(!a)throw new Ae(Pe.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(Fa(a.status))throw new Ae(Pe.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(i,r,o,t);const l=await s.getTask(i,t);if(l){const c=Zg.parse({method:"notifications/tasks/status",params:l});await this.notification(c),Fa(l.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>s.listTasks(i,t)}}}function Ok(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function AB(n,e){const t={...n};for(const s in e){const i=s,r=e[i];if(r===void 0)continue;const o=t[i];Ok(o)&&Ok(r)?t[i]={...o,...r}:t[i]=r}return t}(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});class EB extends iT{constructor(){super(...arguments);ae(this,"_registeredMethods",new Set);ae(this,"_eventSlots",new Map);ae(this,"setRequestHandler",(t,s)=>{this._assertMethodNotRegistered(t,"setRequestHandler"),super.setRequestHandler(t,s)});ae(this,"setNotificationHandler",(t,s)=>{this._assertMethodNotRegistered(t,"setNotificationHandler"),super.setNotificationHandler(t,s)});ae(this,"replaceRequestHandler",(t,s)=>{let i=t.shape.method.value;this._registeredMethods.add(i),super.setRequestHandler(t,s)})}onEventDispatch(t,s){}_ensureEventSlot(t){let s=this._eventSlots.get(t);if(!s){let i=this.eventSchemas[t];if(!i)throw Error(`Unknown event: ${String(t)}`);s={listeners:[]},this._eventSlots.set(t,s);let r=i.shape.method.value;this._registeredMethods.add(r);let o=s;super.setNotificationHandler(i,a=>{var c;let l=a.params;this.onEventDispatch(t,l),(c=o.onHandler)==null||c.call(o,l);for(let h of[...o.listeners])h(l)})}return s}setEventHandler(t,s){let i=this._ensureEventSlot(t);i.onHandler&&s&&console.warn(`[MCP Apps] on${String(t)} handler replaced. Use addEventListener("${String(t)}", …) to add multiple listeners without replacing.`),i.onHandler=s}getEventHandler(t){var s;return(s=this._eventSlots.get(t))==null?void 0:s.onHandler}addEventListener(t,s){this._ensureEventSlot(t).listeners.push(s)}removeEventListener(t,s){let i=this._eventSlots.get(t);if(!i)return;let r=i.listeners.indexOf(s);r!==-1&&i.listeners.splice(r,1)}warnIfRequestHandlerReplaced(t,s,i){s&&i&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}_assertMethodNotRegistered(t,s){let i=t.shape.method.value;if(this._registeredMethods.has(i))throw Error(`Handler for "${i}" already registered (via ${s}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(i)}}var rT="2026-01-26",CB="ui/notifications/tool-input-partial",$B=Ke([U("light"),U("dark")]).describe("Color theme preference for the host environment."),sf=Ke([U("inline"),U("fullscreen"),U("pip")]).describe("Display mode for UI presentation."),TB=Ke([U("--color-background-primary"),U("--color-background-secondary"),U("--color-background-tertiary"),U("--color-background-inverse"),U("--color-background-ghost"),U("--color-background-info"),U("--color-background-danger"),U("--color-background-success"),U("--color-background-warning"),U("--color-background-disabled"),U("--color-text-primary"),U("--color-text-secondary"),U("--color-text-tertiary"),U("--color-text-inverse"),U("--color-text-ghost"),U("--color-text-info"),U("--color-text-danger"),U("--color-text-success"),U("--color-text-warning"),U("--color-text-disabled"),U("--color-border-primary"),U("--color-border-secondary"),U("--color-border-tertiary"),U("--color-border-inverse"),U("--color-border-ghost"),U("--color-border-info"),U("--color-border-danger"),U("--color-border-success"),U("--color-border-warning"),U("--color-border-disabled"),U("--color-ring-primary"),U("--color-ring-secondary"),U("--color-ring-inverse"),U("--color-ring-info"),U("--color-ring-danger"),U("--color-ring-success"),U("--color-ring-warning"),U("--font-sans"),U("--font-mono"),U("--font-weight-normal"),U("--font-weight-medium"),U("--font-weight-semibold"),U("--font-weight-bold"),U("--font-text-xs-size"),U("--font-text-sm-size"),U("--font-text-md-size"),U("--font-text-lg-size"),U("--font-heading-xs-size"),U("--font-heading-sm-size"),U("--font-heading-md-size"),U("--font-heading-lg-size"),U("--font-heading-xl-size"),U("--font-heading-2xl-size"),U("--font-heading-3xl-size"),U("--font-text-xs-line-height"),U("--font-text-sm-line-height"),U("--font-text-md-line-height"),U("--font-text-lg-line-height"),U("--font-heading-xs-line-height"),U("--font-heading-sm-line-height"),U("--font-heading-md-line-height"),U("--font-heading-lg-line-height"),U("--font-heading-xl-line-height"),U("--font-heading-2xl-line-height"),U("--font-heading-3xl-line-height"),U("--border-radius-xs"),U("--border-radius-sm"),U("--border-radius-md"),U("--border-radius-lg"),U("--border-radius-xl"),U("--border-radius-full"),U("--border-width-regular"),U("--shadow-hairline"),U("--shadow-sm"),U("--shadow-md"),U("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),PB=Ye(TB.describe(`Style variables for theming MCP apps. + +Individual style keys are optional - hosts may provide any subset of these values. +Values are strings containing CSS values (colors, sizes, font stacks, etc.). + +Note: This type uses \`Record\` rather than \`Partial>\` +for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Ke([D(),Jb()]).describe(`Style variables for theming MCP apps. + +Individual style keys are optional - hosts may provide any subset of these values. +Values are strings containing CSS values (colors, sizes, font stacks, etc.). + +Note: This type uses \`Record\` rather than \`Partial>\` +for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps. + +Individual style keys are optional - hosts may provide any subset of these values. +Values are strings containing CSS values (colors, sizes, font stacks, etc.). + +Note: This type uses \`Record\` rather than \`Partial>\` +for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),RB=K({method:U("ui/open-link"),params:K({url:D().describe("URL to open in the host's browser")})});K({isError:Xe().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();K({isError:Xe().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();K({isError:Xe().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var MB=K({method:U("ui/notifications/sandbox-proxy-ready"),params:K({})}),RS=K({connectDomains:oe(D()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket). + +- Maps to CSP \`connect-src\` directive +- Empty or omitted → no network connections (secure default)`),resourceDomains:oe(D()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:oe(D()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:oe(D()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),MS=K({camera:K({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:K({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:K({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:K({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),IB=K({method:U("ui/notifications/size-changed"),params:K({width:Le().optional().describe("New width in pixels."),height:Le().optional().describe("New height in pixels.")})});K({method:U("ui/notifications/tool-input"),params:K({arguments:Ye(D(),vt().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});K({method:U("ui/notifications/tool-input-partial"),params:K({arguments:Ye(D(),vt().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});K({method:U("ui/notifications/tool-cancelled"),params:K({reason:D().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var OB=K({fonts:D().optional()}),NB=K({variables:PB.optional().describe("CSS variables for theming the app."),css:OB.optional().describe("CSS blocks that apps can inject.")});K({method:U("ui/resource-teardown"),params:K({})});var LB=Ye(D(),vt()),Nk=K({text:K({}).optional().describe("Host supports text content blocks."),image:K({}).optional().describe("Host supports image content blocks."),audio:K({}).optional().describe("Host supports audio content blocks."),resource:K({}).optional().describe("Host supports resource content blocks."),resourceLink:K({}).optional().describe("Host supports resource link content blocks."),structuredContent:K({}).optional().describe("Host supports structured content.")}),DB=K({method:U("ui/notifications/request-teardown"),params:K({}).optional()}),jB=K({experimental:Ye(D(),Ye(D(),nS()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:K({}).optional().describe("Host supports opening external URLs."),downloadFile:K({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:K({listChanged:Xe().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:K({listChanged:Xe().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:K({}).optional().describe("Host accepts log messages."),sandbox:K({permissions:MS.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:RS.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Nk.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Nk.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:K({tools:K({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),FB=K({experimental:Ye(D(),Ye(D(),nS()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:K({listChanged:Xe().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:oe(sf).optional().describe("Display modes the app supports.")}),zB=K({method:U("ui/notifications/initialized"),params:K({}).optional()});K({csp:RS.optional().describe("Content Security Policy configuration for UI resources."),permissions:MS.optional().describe("Sandbox permissions requested by the UI resource."),domain:D().optional().describe(`Dedicated origin for view sandbox. + +Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists. + +**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include: +- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`) +- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`) + +If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:Xe().optional().describe(`Visual boundary preference - true if view prefers a visible border. + +Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary. + +- \`true\`: request visible border + background +- \`false\`: request no visible border + background +- omitted: host decides border`)});var Lk=K({method:U("ui/request-display-mode"),params:K({mode:sf.describe("The display mode being requested.")})});K({mode:sf.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var HB=Ke([U("model"),U("app")]).describe("Tool visibility scope - who can access the tool.");K({resourceUri:D().optional(),visibility:oe(HB).optional().describe(`Who can access this tool. Default: ["model", "app"] +- "model": Tool visible to and callable by the agent +- "app": Tool callable by the app from this server only`),csp:Qb().optional(),permissions:Qb().optional()});K({mimeTypes:oe(D()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var BB=K({method:U("ui/download-file"),params:K({contents:oe(Ke([U$,W$])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),qB=K({method:U("ui/message"),params:K({role:U("user").describe('Message role, currently only "user" is supported.'),content:oe(Up).describe("Message content blocks (text, image, etc.).")})});K({method:U("ui/notifications/sandbox-resource-ready"),params:K({html:D().describe("HTML content to load into the inner iframe."),sandbox:D().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:RS.optional().describe("CSP configuration from resource metadata."),permissions:MS.optional().describe("Sandbox permissions from resource metadata.")})});K({method:U("ui/notifications/tool-result"),params:lc.describe("Standard MCP tool execution result.")});var oT=K({toolInfo:K({id:Fp.optional().describe("JSON-RPC id of the tools/call request."),tool:ES.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:$B.optional().describe("Current color theme preference."),styles:NB.optional().describe("Style configuration for theming the app."),displayMode:sf.optional().describe("How the UI is currently displayed."),availableDisplayModes:oe(sf).optional().describe("Display modes the host supports."),containerDimensions:Ke([K({height:Le().describe("Fixed container height in pixels.")}),K({maxHeight:Ke([Le(),Jb()]).optional().describe("Maximum container height in pixels.")})]).and(Ke([K({width:Le().describe("Fixed container width in pixels.")}),K({maxWidth:Ke([Le(),Jb()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other +container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:D().optional().describe("User's language and region preference in BCP 47 format."),timeZone:D().optional().describe("User's timezone in IANA format."),userAgent:D().optional().describe("Host application identifier."),platform:Ke([U("web"),U("desktop"),U("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:K({touch:Xe().optional().describe("Whether the device supports touch input."),hover:Xe().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:K({top:Le().describe("Top safe area inset in pixels."),right:Le().describe("Right safe area inset in pixels."),bottom:Le().describe("Bottom safe area inset in pixels."),left:Le().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();K({method:U("ui/notifications/host-context-changed"),params:oT.describe("Partial context update containing only changed fields.")});var VB=K({method:U("ui/update-model-context"),params:K({content:oe(Up).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:Ye(D(),vt().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),UB=K({method:U("ui/initialize"),params:K({appInfo:f0.describe("App identification (name and version)."),appCapabilities:FB.describe("Features and capabilities this app provides."),protocolVersion:D().describe("Protocol version this app supports.")})});K({protocolVersion:D().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:f0.describe("Host application identification and version."),hostCapabilities:jB.describe("Features and capabilities provided by the host."),hostContext:oT.describe("Rich context about the host environment.")}).passthrough();class WB{constructor(e=window.parent,t){ae(this,"eventTarget");ae(this,"eventSource");ae(this,"messageListener");ae(this,"onclose");ae(this,"onerror");ae(this,"onmessage");ae(this,"sessionId");ae(this,"setProtocolVersion");this.eventTarget=e,this.eventSource=t,this.messageListener=s=>{var r,o,a;if(t&&s.source!==this.eventSource){console.debug("Ignoring message from unknown source",s);return}let i=Jm.safeParse(s.data);i.success?(console.debug("Parsed message",i.data),(r=this.onmessage)==null||r.call(this,i.data)):((o=s.data)==null?void 0:o.jsonrpc)!=="2.0"?console.debug("Ignoring non-JSON-RPC message",i.error.message,s):(console.error("Failed to parse message",i.error.message,s),(a=this.onerror)==null||a.call(this,Error("Invalid JSON-RPC message received: "+i.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(e,t){e.method!==CB&&console.debug("Sending message",e),this.eventTarget.postMessage(e,"*")}async close(){var e;window.removeEventListener("message",this.messageListener),(e=this.onclose)==null||e.call(this)}}var GB=[rT];class KB extends EB{constructor(t,s,i,r){super(r);ae(this,"_client");ae(this,"_hostInfo");ae(this,"_capabilities");ae(this,"_appCapabilities");ae(this,"_hostContext",{});ae(this,"_appInfo");ae(this,"_initializedReceived",!1);ae(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);ae(this,"replaceRequestHandler",(t,s)=>{this._baseReplaceRequestHandler(t,(i,r)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${i.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),s(i,r)))});ae(this,"eventSchemas",{sizechange:IB,sandboxready:MB,initialized:zB,requestteardown:DB,loggingmessage:X$});ae(this,"onping");ae(this,"_onmessage");ae(this,"_onopenlink");ae(this,"_ondownloadfile");ae(this,"_onrequestdisplaymode");ae(this,"_onupdatemodelcontext");ae(this,"_oncalltool");ae(this,"_onlistresources");ae(this,"_onlistresourcetemplates");ae(this,"_onreadresource");ae(this,"_onlistprompts");ae(this,"sendResourceTeardown",this.teardownResource);this._client=t,this._hostInfo=s,this._capabilities=i,this.addEventListener("initialized",()=>{this._initializedReceived=!0}),this._hostContext=(r==null?void 0:r.hostContext)||{},this.setRequestHandler(UB,o=>this._oninitialize(o)),this.setRequestHandler(p0,(o,a)=>{var l;return(l=this.onping)==null||l.call(this,o.params,a),{}}),this.replaceRequestHandler(Lk,o=>({mode:this._hostContext.displayMode??"inline"}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(t){this.setEventHandler("sizechange",t)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(t){this.setEventHandler("sandboxready",t)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(t){this.setEventHandler("initialized",t)}get onmessage(){return this._onmessage}set onmessage(t){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,t),this._onmessage=t,this.replaceRequestHandler(qB,async(s,i)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(s.params,i)})}get onopenlink(){return this._onopenlink}set onopenlink(t){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,t),this._onopenlink=t,this.replaceRequestHandler(RB,async(s,i)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(s.params,i)})}get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(t){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,t),this._ondownloadfile=t,this.replaceRequestHandler(BB,async(s,i)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(s.params,i)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(t){this.setEventHandler("requestteardown",t)}get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(t){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,t),this._onrequestdisplaymode=t,this.replaceRequestHandler(Lk,async(s,i)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(s.params,i)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(t){this.setEventHandler("loggingmessage",t)}get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(t){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,t),this._onupdatemodelcontext=t,this.replaceRequestHandler(VB,async(s,i)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(s.params,i)})}get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler(K$,async(s,i)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(s.params,i)})}set oncreatesamplingmessage(t){this.setRequestHandler(TS,async(s,i)=>t(s.params,i))}sendToolListChanged(t={}){return this.notification({method:"notifications/tools/list_changed",params:t})}get onlistresources(){return this._onlistresources}set onlistresources(t){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,t),this._onlistresources=t,this.replaceRequestHandler(H$,async(s,i)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(s.params,i)})}get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(t){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,t),this._onlistresourcetemplates=t,this.replaceRequestHandler(B$,async(s,i)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(s.params,i)})}get onreadresource(){return this._onreadresource}set onreadresource(t){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,t),this._onreadresource=t,this.replaceRequestHandler(q$,async(s,i)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(s.params,i)})}sendResourceListChanged(t={}){return this.notification({method:"notifications/resources/list_changed",params:t})}get onlistprompts(){return this._onlistprompts}set onlistprompts(t){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,t),this._onlistprompts=t,this.replaceRequestHandler(V$,async(s,i)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(s.params,i)})}sendPromptListChanged(t={}){return this.notification({method:"notifications/prompts/list_changed",params:t})}assertCapabilityForMethod(t){}assertRequestHandlerCapability(t){}assertNotificationCapability(t){}assertTaskCapability(t){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(t){throw Error("Task handlers are not supported in MCP Apps")}getCapabilities(){return this._capabilities}async _oninitialize(t){let s=t.params.protocolVersion;return this._appInfo!==void 0&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=t.params.appCapabilities,this._appInfo=t.params.appInfo,{protocolVersion:GB.includes(s)?s:rT,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(t){let s={},i=!1;for(let r of Object.keys(t)){let o=this._hostContext[r],a=t[r];ZB(o,a)||(s[r]=a,i=!0)}i&&(this._hostContext=t,this.sendHostContextChange(s))}sendHostContextChange(t){return this.notification({method:"ui/notifications/host-context-changed",params:t})}sendToolInput(t){return this.notification({method:"ui/notifications/tool-input",params:t})}sendToolInputPartial(t){return this.notification({method:"ui/notifications/tool-input-partial",params:t})}sendToolResult(t){return this.notification({method:"ui/notifications/tool-result",params:t})}sendToolCancelled(t){return this.notification({method:"ui/notifications/tool-cancelled",params:t})}sendSandboxResourceReady(t){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:t})}teardownResource(t,s){return this.request({method:"ui/resource-teardown",params:t},LB,s)}callTool(t,s){return this.request({method:"tools/call",params:t},lc,s)}listTools(t,s){return this.request({method:"tools/list",params:t},CS,s)}async connect(t){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let s=this._client.getServerCapabilities();if(!s)throw Error("Client server capabilities not available");s.tools&&(this.oncalltool=async(i,r)=>this._client.request({method:"tools/call",params:i},lc,{signal:r.signal}),s.tools.listChanged&&this._client.setNotificationHandler($S,i=>this.sendToolListChanged(i.params))),s.resources&&(this.onlistresources=async(i,r)=>this._client.request({method:"resources/list",params:i},gS,{signal:r.signal}),this.onlistresourcetemplates=async(i,r)=>this._client.request({method:"resources/templates/list",params:i},yS,{signal:r.signal}),this.onreadresource=async(i,r)=>this._client.request({method:"resources/read",params:i},vS,{signal:r.signal}),s.resources.listChanged&&this._client.setNotificationHandler(wS,i=>this.sendResourceListChanged(i.params))),s.prompts&&(this.onlistprompts=async(i,r)=>this._client.request({method:"prompts/list",params:i},_S,{signal:r.signal}),s.prompts.listChanged&&this._client.setNotificationHandler(AS,i=>this.sendPromptListChanged(i.params)))}return super.connect(t)}}function ZB(n,e){return JSON.stringify(n)===JSON.stringify(e)}const XB={x:0,y:0,width:1024,height:768},sv=28,YB=12,JB=.9;function ya(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function aT(n){if(!(!n||typeof n!="object"||Array.isArray(n)))return n}function iv(n){if(Array.isArray(n))return n.map(iv);const e=aT(n);return e?Object.fromEntries(Object.entries(e).map(([t,s])=>[t,(t==="text"||t==="originalText")&&typeof s=="string"?s.replace(/\\r\\n|\\n|\\r/gu,` +`):iv(s)])):n}function QB(n){return n.type==="text"&&typeof(n.text??n.originalText)=="string"}function lT(n){const e=String(n.text??n.originalText??""),t=ya(n.fontSize)??20,s=e.length*t*JB,i=ya(n.width);return Math.max(i&&i>0?i:0,s)}function eq(n){for(const e of n){if(e.type!=="cameraUpdate")continue;const t=ya(e.width),s=ya(e.height);if(!(!t||t<=0||!s||s<=0))return{x:ya(e.x)??0,y:ya(e.y)??0,width:t,height:s}}return XB}function tq(n,e){const t=ya(n.x);if(t===void 0)return!1;const s=lT(n),i=e.x+sv,r=e.x+e.width-sv;return tr+1}function nq(n,e){const t={...n},s=ya(t.fontSize)??20;let i=lT(t);const r=Math.max(1,e.width-sv*2);if(i>r){const o=r/i;t.fontSize=Math.max(YB,s*o),typeof t.height=="number"&&(t.height*=Number(t.fontSize)/s),i=Math.min(r,i*(Number(t.fontSize)/s))}return t.width=i,t.autoResize=!1,t.textAlign="left",t.x=e.x+(e.width-i)/2,t}function sq(n){const t=iv(n).map(aT);if(t.some(r=>r===void 0))return n;const s=t,i=eq(s);return s.map(r=>!QB(r)||!tq(r,i)?r:nq(r,i))}var rv={exports:{}},cT={},Ki={},mu={},Wp={},Ue={},rf={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.regexpCode=n.getEsmExportName=n.getProperty=n.safeStringify=n.stringify=n.strConcat=n.addCodeArg=n.str=n._=n.nil=n._Code=n.Name=n.IDENTIFIER=n._CodeOrName=void 0;class e{}n._CodeOrName=e,n.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class t extends e{constructor(w){if(super(),!n.IDENTIFIER.test(w))throw new Error("CodeGen: name must be a valid identifier");this.str=w}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}n.Name=t;class s extends e{constructor(w){super(),this._items=typeof w=="string"?[w]:w}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const w=this._items[0];return w===""||w==='""'}get str(){var w;return(w=this._str)!==null&&w!==void 0?w:this._str=this._items.reduce((v,x)=>`${v}${x}`,"")}get names(){var w;return(w=this._names)!==null&&w!==void 0?w:this._names=this._items.reduce((v,x)=>(x instanceof t&&(v[x.str]=(v[x.str]||0)+1),v),{})}}n._Code=s,n.nil=new s("");function i(y,...w){const v=[y[0]];let x=0;for(;x{if(u.scopePath===void 0)throw new Error(`CodeGen: name "${u}" has no value`);return(0,e._)`${c}${u.scopePath}`})}scopeCode(c=this._values,h,u){return this._reduceValues(c,d=>{if(d.value===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return d.value.code},h,u)}_reduceValues(c,h,u={},d){let p=e.nil;for(const m in c){const g=c[m];if(!g)continue;const b=u[m]=u[m]||new Map;g.forEach(y=>{if(b.has(y))return;b.set(y,s.Started);let w=h(y);if(w){const v=this.opts.es5?n.varKinds.var:n.varKinds.const;p=(0,e._)`${p}${v} ${y} = ${w};${this.opts._n}`}else if(w=d==null?void 0:d(y))p=(0,e._)`${p}${w}${this.opts._n}`;else throw new t(y);b.set(y,s.Completed)})}return p}}n.ValueScope=a})(ov);(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.or=n.and=n.not=n.CodeGen=n.operators=n.varKinds=n.ValueScopeName=n.ValueScope=n.Scope=n.Name=n.regexpCode=n.stringify=n.getProperty=n.nil=n.strConcat=n.str=n._=void 0;const e=rf,t=ov;var s=rf;Object.defineProperty(n,"_",{enumerable:!0,get:function(){return s._}}),Object.defineProperty(n,"str",{enumerable:!0,get:function(){return s.str}}),Object.defineProperty(n,"strConcat",{enumerable:!0,get:function(){return s.strConcat}}),Object.defineProperty(n,"nil",{enumerable:!0,get:function(){return s.nil}}),Object.defineProperty(n,"getProperty",{enumerable:!0,get:function(){return s.getProperty}}),Object.defineProperty(n,"stringify",{enumerable:!0,get:function(){return s.stringify}}),Object.defineProperty(n,"regexpCode",{enumerable:!0,get:function(){return s.regexpCode}}),Object.defineProperty(n,"Name",{enumerable:!0,get:function(){return s.Name}});var i=ov;Object.defineProperty(n,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(n,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(n,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(n,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),n.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class r{optimizeNodes(){return this}optimizeNames(_,A){return this}}class o extends r{constructor(_,A,N){super(),this.varKind=_,this.name=A,this.rhs=N}render({es5:_,_n:A}){const N=_?t.varKinds.var:this.varKind,W=this.rhs===void 0?"":` = ${this.rhs}`;return`${N} ${this.name}${W};`+A}optimizeNames(_,A){if(_[this.name.str])return this.rhs&&(this.rhs=q(this.rhs,_,A)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class a extends r{constructor(_,A,N){super(),this.lhs=_,this.rhs=A,this.sideEffects=N}render({_n:_}){return`${this.lhs} = ${this.rhs};`+_}optimizeNames(_,A){if(!(this.lhs instanceof e.Name&&!_[this.lhs.str]&&!this.sideEffects))return this.rhs=q(this.rhs,_,A),this}get names(){const _=this.lhs instanceof e.Name?{}:{...this.lhs.names};return Z(_,this.rhs)}}class l extends a{constructor(_,A,N,W){super(_,N,W),this.op=A}render({_n:_}){return`${this.lhs} ${this.op}= ${this.rhs};`+_}}class c extends r{constructor(_){super(),this.label=_,this.names={}}render({_n:_}){return`${this.label}:`+_}}class h extends r{constructor(_){super(),this.label=_,this.names={}}render({_n:_}){return`break${this.label?` ${this.label}`:""};`+_}}class u extends r{constructor(_){super(),this.error=_}render({_n:_}){return`throw ${this.error};`+_}get names(){return this.error.names}}class d extends r{constructor(_){super(),this.code=_}render({_n:_}){return`${this.code};`+_}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(_,A){return this.code=q(this.code,_,A),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class p extends r{constructor(_=[]){super(),this.nodes=_}render(_){return this.nodes.reduce((A,N)=>A+N.render(_),"")}optimizeNodes(){const{nodes:_}=this;let A=_.length;for(;A--;){const N=_[A].optimizeNodes();Array.isArray(N)?_.splice(A,1,...N):N?_[A]=N:_.splice(A,1)}return _.length>0?this:void 0}optimizeNames(_,A){const{nodes:N}=this;let W=N.length;for(;W--;){const X=N[W];X.optimizeNames(_,A)||(H(_,X.names),N.splice(W,1))}return N.length>0?this:void 0}get names(){return this.nodes.reduce((_,A)=>B(_,A.names),{})}}class m extends p{render(_){return"{"+_._n+super.render(_)+"}"+_._n}}class g extends p{}class b extends m{}b.kind="else";class y extends m{constructor(_,A){super(A),this.condition=_}render(_){let A=`if(${this.condition})`+super.render(_);return this.else&&(A+="else "+this.else.render(_)),A}optimizeNodes(){super.optimizeNodes();const _=this.condition;if(_===!0)return this.nodes;let A=this.else;if(A){const N=A.optimizeNodes();A=this.else=Array.isArray(N)?new b(N):N}if(A)return _===!1?A instanceof y?A:A.nodes:this.nodes.length?this:new y(se(_),A instanceof y?[A]:A.nodes);if(!(_===!1||!this.nodes.length))return this}optimizeNames(_,A){var N;if(this.else=(N=this.else)===null||N===void 0?void 0:N.optimizeNames(_,A),!!(super.optimizeNames(_,A)||this.else))return this.condition=q(this.condition,_,A),this}get names(){const _=super.names;return Z(_,this.condition),this.else&&B(_,this.else.names),_}}y.kind="if";class w extends m{}w.kind="for";class v extends w{constructor(_){super(),this.iteration=_}render(_){return`for(${this.iteration})`+super.render(_)}optimizeNames(_,A){if(super.optimizeNames(_,A))return this.iteration=q(this.iteration,_,A),this}get names(){return B(super.names,this.iteration.names)}}class x extends w{constructor(_,A,N,W){super(),this.varKind=_,this.name=A,this.from=N,this.to=W}render(_){const A=_.es5?t.varKinds.var:this.varKind,{name:N,from:W,to:X}=this;return`for(${A} ${N}=${W}; ${N}<${X}; ${N}++)`+super.render(_)}get names(){const _=Z(super.names,this.from);return Z(_,this.to)}}class k extends w{constructor(_,A,N,W){super(),this.loop=_,this.varKind=A,this.name=N,this.iterable=W}render(_){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(_)}optimizeNames(_,A){if(super.optimizeNames(_,A))return this.iterable=q(this.iterable,_,A),this}get names(){return B(super.names,this.iterable.names)}}class E extends m{constructor(_,A,N){super(),this.name=_,this.args=A,this.async=N}render(_){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(_)}}E.kind="func";class T extends p{render(_){return"return "+super.render(_)}}T.kind="return";class O extends m{render(_){let A="try"+super.render(_);return this.catch&&(A+=this.catch.render(_)),this.finally&&(A+=this.finally.render(_)),A}optimizeNodes(){var _,A;return super.optimizeNodes(),(_=this.catch)===null||_===void 0||_.optimizeNodes(),(A=this.finally)===null||A===void 0||A.optimizeNodes(),this}optimizeNames(_,A){var N,W;return super.optimizeNames(_,A),(N=this.catch)===null||N===void 0||N.optimizeNames(_,A),(W=this.finally)===null||W===void 0||W.optimizeNames(_,A),this}get names(){const _=super.names;return this.catch&&B(_,this.catch.names),this.finally&&B(_,this.finally.names),_}}class F extends m{constructor(_){super(),this.error=_}render(_){return`catch(${this.error})`+super.render(_)}}F.kind="catch";class j extends m{render(_){return"finally"+super.render(_)}}j.kind="finally";class L{constructor(_,A={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...A,_n:A.lines?` +`:""},this._extScope=_,this._scope=new t.Scope({parent:_}),this._nodes=[new g]}toString(){return this._root.render(this.opts)}name(_){return this._scope.name(_)}scopeName(_){return this._extScope.name(_)}scopeValue(_,A){const N=this._extScope.value(_,A);return(this._values[N.prefix]||(this._values[N.prefix]=new Set)).add(N),N}getScopeValue(_,A){return this._extScope.getValue(_,A)}scopeRefs(_){return this._extScope.scopeRefs(_,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(_,A,N,W){const X=this._scope.toName(A);return N!==void 0&&W&&(this._constants[X.str]=N),this._leafNode(new o(_,X,N)),X}const(_,A,N){return this._def(t.varKinds.const,_,A,N)}let(_,A,N){return this._def(t.varKinds.let,_,A,N)}var(_,A,N){return this._def(t.varKinds.var,_,A,N)}assign(_,A,N){return this._leafNode(new a(_,A,N))}add(_,A){return this._leafNode(new l(_,n.operators.ADD,A))}code(_){return typeof _=="function"?_():_!==e.nil&&this._leafNode(new d(_)),this}object(..._){const A=["{"];for(const[N,W]of _)A.length>1&&A.push(","),A.push(N),(N!==W||this.opts.es5)&&(A.push(":"),(0,e.addCodeArg)(A,W));return A.push("}"),new e._Code(A)}if(_,A,N){if(this._blockNode(new y(_)),A&&N)this.code(A).else().code(N).endIf();else if(A)this.code(A).endIf();else if(N)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(_){return this._elseNode(new y(_))}else(){return this._elseNode(new b)}endIf(){return this._endBlockNode(y,b)}_for(_,A){return this._blockNode(_),A&&this.code(A).endFor(),this}for(_,A){return this._for(new v(_),A)}forRange(_,A,N,W,X=this.opts.es5?t.varKinds.var:t.varKinds.let){const he=this._scope.toName(_);return this._for(new x(X,he,A,N),()=>W(he))}forOf(_,A,N,W=t.varKinds.const){const X=this._scope.toName(_);if(this.opts.es5){const he=A instanceof e.Name?A:this.var("_arr",A);return this.forRange("_i",0,(0,e._)`${he}.length`,ie=>{this.var(X,(0,e._)`${he}[${ie}]`),N(X)})}return this._for(new k("of",W,X,A),()=>N(X))}forIn(_,A,N,W=this.opts.es5?t.varKinds.var:t.varKinds.const){if(this.opts.ownProperties)return this.forOf(_,(0,e._)`Object.keys(${A})`,N);const X=this._scope.toName(_);return this._for(new k("in",W,X,A),()=>N(X))}endFor(){return this._endBlockNode(w)}label(_){return this._leafNode(new c(_))}break(_){return this._leafNode(new h(_))}return(_){const A=new T;if(this._blockNode(A),this.code(_),A.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(T)}try(_,A,N){if(!A&&!N)throw new Error('CodeGen: "try" without "catch" and "finally"');const W=new O;if(this._blockNode(W),this.code(_),A){const X=this.name("e");this._currNode=W.catch=new F(X),A(X)}return N&&(this._currNode=W.finally=new j,this.code(N)),this._endBlockNode(F,j)}throw(_){return this._leafNode(new u(_))}block(_,A){return this._blockStarts.push(this._nodes.length),_&&this.code(_).endBlock(A),this}endBlock(_){const A=this._blockStarts.pop();if(A===void 0)throw new Error("CodeGen: not in self-balancing block");const N=this._nodes.length-A;if(N<0||_!==void 0&&N!==_)throw new Error(`CodeGen: wrong number of nodes: ${N} vs ${_} expected`);return this._nodes.length=A,this}func(_,A=e.nil,N,W){return this._blockNode(new E(_,A,N)),W&&this.code(W).endFunc(),this}endFunc(){return this._endBlockNode(E)}optimize(_=1){for(;_-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(_){return this._currNode.nodes.push(_),this}_blockNode(_){this._currNode.nodes.push(_),this._nodes.push(_)}_endBlockNode(_,A){const N=this._currNode;if(N instanceof _||A&&N instanceof A)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${A?`${_.kind}/${A.kind}`:_.kind}"`)}_elseNode(_){const A=this._currNode;if(!(A instanceof y))throw new Error('CodeGen: "else" without "if"');return this._currNode=A.else=_,this}get _root(){return this._nodes[0]}get _currNode(){const _=this._nodes;return _[_.length-1]}set _currNode(_){const A=this._nodes;A[A.length-1]=_}}n.CodeGen=L;function B(R,_){for(const A in _)R[A]=(R[A]||0)+(_[A]||0);return R}function Z(R,_){return _ instanceof e._CodeOrName?B(R,_.names):R}function q(R,_,A){if(R instanceof e.Name)return N(R);if(!W(R))return R;return new e._Code(R._items.reduce((X,he)=>(he instanceof e.Name&&(he=N(he)),he instanceof e._Code?X.push(...he._items):X.push(he),X),[]));function N(X){const he=A[X.str];return he===void 0||_[X.str]!==1?X:(delete _[X.str],he)}function W(X){return X instanceof e._Code&&X._items.some(he=>he instanceof e.Name&&_[he.str]===1&&A[he.str]!==void 0)}}function H(R,_){for(const A in _)R[A]=(R[A]||0)-(_[A]||0)}function se(R){return typeof R=="boolean"||typeof R=="number"||R===null?!R:(0,e._)`!${I(R)}`}n.not=se;const Q=C(n.operators.AND);function Y(...R){return R.reduce(Q)}n.and=Y;const ye=C(n.operators.OR);function z(...R){return R.reduce(ye)}n.or=z;function C(R){return(_,A)=>_===e.nil?A:A===e.nil?_:(0,e._)`${I(_)} ${R} ${I(A)}`}function I(R){return R instanceof e.Name?R:(0,e._)`(${R})`}})(Ue);var fe={};Object.defineProperty(fe,"__esModule",{value:!0});fe.checkStrictMode=fe.getErrorPath=fe.Type=fe.useFunc=fe.setEvaluated=fe.evaluatedPropsToName=fe.mergeEvaluated=fe.eachItem=fe.unescapeJsonPointer=fe.escapeJsonPointer=fe.escapeFragment=fe.unescapeFragment=fe.schemaRefOrVal=fe.schemaHasRulesButRef=fe.schemaHasRules=fe.checkUnknownRules=fe.alwaysValidSchema=fe.toHash=void 0;const mt=Ue,iq=rf;function rq(n){const e={};for(const t of n)e[t]=!0;return e}fe.toHash=rq;function oq(n,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(hT(n,e),!uT(e,n.self.RULES.all))}fe.alwaysValidSchema=oq;function hT(n,e=n.schema){const{opts:t,self:s}=n;if(!t.strictSchema||typeof e=="boolean")return;const i=s.RULES.keywords;for(const r in e)i[r]||pT(n,`unknown keyword: "${r}"`)}fe.checkUnknownRules=hT;function uT(n,e){if(typeof n=="boolean")return!n;for(const t in n)if(e[t])return!0;return!1}fe.schemaHasRules=uT;function aq(n,e){if(typeof n=="boolean")return!n;for(const t in n)if(t!=="$ref"&&e.all[t])return!0;return!1}fe.schemaHasRulesButRef=aq;function lq({topSchemaRef:n,schemaPath:e},t,s,i){if(!i){if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="string")return(0,mt._)`${t}`}return(0,mt._)`${n}${e}${(0,mt.getProperty)(s)}`}fe.schemaRefOrVal=lq;function cq(n){return dT(decodeURIComponent(n))}fe.unescapeFragment=cq;function hq(n){return encodeURIComponent(IS(n))}fe.escapeFragment=hq;function IS(n){return typeof n=="number"?`${n}`:n.replace(/~/g,"~0").replace(/\//g,"~1")}fe.escapeJsonPointer=IS;function dT(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}fe.unescapeJsonPointer=dT;function uq(n,e){if(Array.isArray(n))for(const t of n)e(t);else e(n)}fe.eachItem=uq;function Dk({mergeNames:n,mergeToName:e,mergeValues:t,resultToName:s}){return(i,r,o,a)=>{const l=o===void 0?r:o instanceof mt.Name?(r instanceof mt.Name?n(i,r,o):e(i,r,o),o):r instanceof mt.Name?(e(i,o,r),r):t(r,o);return a===mt.Name&&!(l instanceof mt.Name)?s(i,l):l}}fe.mergeEvaluated={props:Dk({mergeNames:(n,e,t)=>n.if((0,mt._)`${t} !== true && ${e} !== undefined`,()=>{n.if((0,mt._)`${e} === true`,()=>n.assign(t,!0),()=>n.assign(t,(0,mt._)`${t} || {}`).code((0,mt._)`Object.assign(${t}, ${e})`))}),mergeToName:(n,e,t)=>n.if((0,mt._)`${t} !== true`,()=>{e===!0?n.assign(t,!0):(n.assign(t,(0,mt._)`${t} || {}`),OS(n,t,e))}),mergeValues:(n,e)=>n===!0?!0:{...n,...e},resultToName:fT}),items:Dk({mergeNames:(n,e,t)=>n.if((0,mt._)`${t} !== true && ${e} !== undefined`,()=>n.assign(t,(0,mt._)`${e} === true ? true : ${t} > ${e} ? ${t} : ${e}`)),mergeToName:(n,e,t)=>n.if((0,mt._)`${t} !== true`,()=>n.assign(t,e===!0?!0:(0,mt._)`${t} > ${e} ? ${t} : ${e}`)),mergeValues:(n,e)=>n===!0?!0:Math.max(n,e),resultToName:(n,e)=>n.var("items",e)})};function fT(n,e){if(e===!0)return n.var("props",!0);const t=n.var("props",(0,mt._)`{}`);return e!==void 0&&OS(n,t,e),t}fe.evaluatedPropsToName=fT;function OS(n,e,t){Object.keys(t).forEach(s=>n.assign((0,mt._)`${e}${(0,mt.getProperty)(s)}`,!0))}fe.setEvaluated=OS;const jk={};function dq(n,e){return n.scopeValue("func",{ref:e,code:jk[e.code]||(jk[e.code]=new iq._Code(e.code))})}fe.useFunc=dq;var av;(function(n){n[n.Num=0]="Num",n[n.Str=1]="Str"})(av||(fe.Type=av={}));function fq(n,e,t){if(n instanceof mt.Name){const s=e===av.Num;return t?s?(0,mt._)`"[" + ${n} + "]"`:(0,mt._)`"['" + ${n} + "']"`:s?(0,mt._)`"/" + ${n}`:(0,mt._)`"/" + ${n}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return t?(0,mt.getProperty)(n).toString():"/"+IS(n)}fe.getErrorPath=fq;function pT(n,e,t=n.opts.strictSchema){if(t){if(e=`strict mode: ${e}`,t===!0)throw new Error(e);n.self.logger.warn(e)}}fe.checkStrictMode=pT;var Nr={};Object.defineProperty(Nr,"__esModule",{value:!0});const Wn=Ue,pq={data:new Wn.Name("data"),valCxt:new Wn.Name("valCxt"),instancePath:new Wn.Name("instancePath"),parentData:new Wn.Name("parentData"),parentDataProperty:new Wn.Name("parentDataProperty"),rootData:new Wn.Name("rootData"),dynamicAnchors:new Wn.Name("dynamicAnchors"),vErrors:new Wn.Name("vErrors"),errors:new Wn.Name("errors"),this:new Wn.Name("this"),self:new Wn.Name("self"),scope:new Wn.Name("scope"),json:new Wn.Name("json"),jsonPos:new Wn.Name("jsonPos"),jsonLen:new Wn.Name("jsonLen"),jsonPart:new Wn.Name("jsonPart")};Nr.default=pq;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.extendErrors=n.resetErrorsCount=n.reportExtraError=n.reportError=n.keyword$DataError=n.keywordError=void 0;const e=Ue,t=fe,s=Nr;n.keywordError={message:({keyword:b})=>(0,e.str)`must pass "${b}" keyword validation`},n.keyword$DataError={message:({keyword:b,schemaType:y})=>y?(0,e.str)`"${b}" keyword must be ${y} ($data)`:(0,e.str)`"${b}" keyword is invalid ($data)`};function i(b,y=n.keywordError,w,v){const{it:x}=b,{gen:k,compositeRule:E,allErrors:T}=x,O=u(b,y,w);v??(E||T)?l(k,O):c(x,(0,e._)`[${O}]`)}n.reportError=i;function r(b,y=n.keywordError,w){const{it:v}=b,{gen:x,compositeRule:k,allErrors:E}=v,T=u(b,y,w);l(x,T),k||E||c(v,s.default.vErrors)}n.reportExtraError=r;function o(b,y){b.assign(s.default.errors,y),b.if((0,e._)`${s.default.vErrors} !== null`,()=>b.if(y,()=>b.assign((0,e._)`${s.default.vErrors}.length`,y),()=>b.assign(s.default.vErrors,null)))}n.resetErrorsCount=o;function a({gen:b,keyword:y,schemaValue:w,data:v,errsCount:x,it:k}){if(x===void 0)throw new Error("ajv implementation error");const E=b.name("err");b.forRange("i",x,s.default.errors,T=>{b.const(E,(0,e._)`${s.default.vErrors}[${T}]`),b.if((0,e._)`${E}.instancePath === undefined`,()=>b.assign((0,e._)`${E}.instancePath`,(0,e.strConcat)(s.default.instancePath,k.errorPath))),b.assign((0,e._)`${E}.schemaPath`,(0,e.str)`${k.errSchemaPath}/${y}`),k.opts.verbose&&(b.assign((0,e._)`${E}.schema`,w),b.assign((0,e._)`${E}.data`,v))})}n.extendErrors=a;function l(b,y){const w=b.const("err",y);b.if((0,e._)`${s.default.vErrors} === null`,()=>b.assign(s.default.vErrors,(0,e._)`[${w}]`),(0,e._)`${s.default.vErrors}.push(${w})`),b.code((0,e._)`${s.default.errors}++`)}function c(b,y){const{gen:w,validateName:v,schemaEnv:x}=b;x.$async?w.throw((0,e._)`new ${b.ValidationError}(${y})`):(w.assign((0,e._)`${v}.errors`,y),w.return(!1))}const h={keyword:new e.Name("keyword"),schemaPath:new e.Name("schemaPath"),params:new e.Name("params"),propertyName:new e.Name("propertyName"),message:new e.Name("message"),schema:new e.Name("schema"),parentSchema:new e.Name("parentSchema")};function u(b,y,w){const{createErrors:v}=b.it;return v===!1?(0,e._)`{}`:d(b,y,w)}function d(b,y,w={}){const{gen:v,it:x}=b,k=[p(x,w),m(b,w)];return g(b,y,k),v.object(...k)}function p({errorPath:b},{instancePath:y}){const w=y?(0,e.str)`${b}${(0,t.getErrorPath)(y,t.Type.Str)}`:b;return[s.default.instancePath,(0,e.strConcat)(s.default.instancePath,w)]}function m({keyword:b,it:{errSchemaPath:y}},{schemaPath:w,parentSchema:v}){let x=v?y:(0,e.str)`${y}/${b}`;return w&&(x=(0,e.str)`${x}${(0,t.getErrorPath)(w,t.Type.Str)}`),[h.schemaPath,x]}function g(b,{params:y,message:w},v){const{keyword:x,data:k,schemaValue:E,it:T}=b,{opts:O,propertyName:F,topSchemaRef:j,schemaPath:L}=T;v.push([h.keyword,x],[h.params,typeof y=="function"?y(b):y||(0,e._)`{}`]),O.messages&&v.push([h.message,typeof w=="function"?w(b):w]),O.verbose&&v.push([h.schema,E],[h.parentSchema,(0,e._)`${j}${L}`],[s.default.data,k]),F&&v.push([h.propertyName,F])}})(Wp);Object.defineProperty(mu,"__esModule",{value:!0});mu.boolOrEmptySchema=mu.topBoolOrEmptySchema=void 0;const mq=Wp,gq=Ue,yq=Nr,bq={message:"boolean schema is false"};function vq(n){const{gen:e,schema:t,validateName:s}=n;t===!1?mT(n,!1):typeof t=="object"&&t.$async===!0?e.return(yq.default.data):(e.assign((0,gq._)`${s}.errors`,null),e.return(!0))}mu.topBoolOrEmptySchema=vq;function wq(n,e){const{gen:t,schema:s}=n;s===!1?(t.var(e,!1),mT(n)):t.var(e,!0)}mu.boolOrEmptySchema=wq;function mT(n,e){const{gen:t,data:s}=n,i={gen:t,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:n};(0,mq.reportError)(i,bq,void 0,e)}var cn={},cc={};Object.defineProperty(cc,"__esModule",{value:!0});cc.getRules=cc.isJSONType=void 0;const _q=["string","number","integer","boolean","null","object","array"],Sq=new Set(_q);function xq(n){return typeof n=="string"&&Sq.has(n)}cc.isJSONType=xq;function kq(){const n={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...n,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},n.number,n.string,n.array,n.object],post:{rules:[]},all:{},keywords:{}}}cc.getRules=kq;var bo={};Object.defineProperty(bo,"__esModule",{value:!0});bo.shouldUseRule=bo.shouldUseGroup=bo.schemaHasRulesForType=void 0;function Aq({schema:n,self:e},t){const s=e.RULES.types[t];return s&&s!==!0&&gT(n,s)}bo.schemaHasRulesForType=Aq;function gT(n,e){return e.rules.some(t=>yT(n,t))}bo.shouldUseGroup=gT;function yT(n,e){var t;return n[e.keyword]!==void 0||((t=e.definition.implements)===null||t===void 0?void 0:t.some(s=>n[s]!==void 0))}bo.shouldUseRule=yT;Object.defineProperty(cn,"__esModule",{value:!0});cn.reportTypeError=cn.checkDataTypes=cn.checkDataType=cn.coerceAndCheckDataType=cn.getJSONTypes=cn.getSchemaTypes=cn.DataType=void 0;const Eq=cc,Cq=bo,$q=Wp,Ie=Ue,bT=fe;var sh;(function(n){n[n.Correct=0]="Correct",n[n.Wrong=1]="Wrong"})(sh||(cn.DataType=sh={}));function Tq(n){const e=vT(n.type);if(e.includes("null")){if(n.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&n.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');n.nullable===!0&&e.push("null")}return e}cn.getSchemaTypes=Tq;function vT(n){const e=Array.isArray(n)?n:n?[n]:[];if(e.every(Eq.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}cn.getJSONTypes=vT;function Pq(n,e){const{gen:t,data:s,opts:i}=n,r=Rq(e,i.coerceTypes),o=e.length>0&&!(r.length===0&&e.length===1&&(0,Cq.schemaHasRulesForType)(n,e[0]));if(o){const a=NS(e,s,i.strictNumbers,sh.Wrong);t.if(a,()=>{r.length?Mq(n,e,r):LS(n)})}return o}cn.coerceAndCheckDataType=Pq;const wT=new Set(["string","number","integer","boolean","null"]);function Rq(n,e){return e?n.filter(t=>wT.has(t)||e==="array"&&t==="array"):[]}function Mq(n,e,t){const{gen:s,data:i,opts:r}=n,o=s.let("dataType",(0,Ie._)`typeof ${i}`),a=s.let("coerced",(0,Ie._)`undefined`);r.coerceTypes==="array"&&s.if((0,Ie._)`${o} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>s.assign(i,(0,Ie._)`${i}[0]`).assign(o,(0,Ie._)`typeof ${i}`).if(NS(e,i,r.strictNumbers),()=>s.assign(a,i))),s.if((0,Ie._)`${a} !== undefined`);for(const c of t)(wT.has(c)||c==="array"&&r.coerceTypes==="array")&&l(c);s.else(),LS(n),s.endIf(),s.if((0,Ie._)`${a} !== undefined`,()=>{s.assign(i,a),Iq(n,a)});function l(c){switch(c){case"string":s.elseIf((0,Ie._)`${o} == "number" || ${o} == "boolean"`).assign(a,(0,Ie._)`"" + ${i}`).elseIf((0,Ie._)`${i} === null`).assign(a,(0,Ie._)`""`);return;case"number":s.elseIf((0,Ie._)`${o} == "boolean" || ${i} === null + || (${o} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,Ie._)`+${i}`);return;case"integer":s.elseIf((0,Ie._)`${o} === "boolean" || ${i} === null + || (${o} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,Ie._)`+${i}`);return;case"boolean":s.elseIf((0,Ie._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,Ie._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":s.elseIf((0,Ie._)`${i} === "" || ${i} === 0 || ${i} === false`),s.assign(a,null);return;case"array":s.elseIf((0,Ie._)`${o} === "string" || ${o} === "number" + || ${o} === "boolean" || ${i} === null`).assign(a,(0,Ie._)`[${i}]`)}}}function Iq({gen:n,parentData:e,parentDataProperty:t},s){n.if((0,Ie._)`${e} !== undefined`,()=>n.assign((0,Ie._)`${e}[${t}]`,s))}function lv(n,e,t,s=sh.Correct){const i=s===sh.Correct?Ie.operators.EQ:Ie.operators.NEQ;let r;switch(n){case"null":return(0,Ie._)`${e} ${i} null`;case"array":r=(0,Ie._)`Array.isArray(${e})`;break;case"object":r=(0,Ie._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":r=o((0,Ie._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":r=o();break;default:return(0,Ie._)`typeof ${e} ${i} ${n}`}return s===sh.Correct?r:(0,Ie.not)(r);function o(a=Ie.nil){return(0,Ie.and)((0,Ie._)`typeof ${e} == "number"`,a,t?(0,Ie._)`isFinite(${e})`:Ie.nil)}}cn.checkDataType=lv;function NS(n,e,t,s){if(n.length===1)return lv(n[0],e,t,s);let i;const r=(0,bT.toHash)(n);if(r.array&&r.object){const o=(0,Ie._)`typeof ${e} != "object"`;i=r.null?o:(0,Ie._)`!${e} || ${o}`,delete r.null,delete r.array,delete r.object}else i=Ie.nil;r.number&&delete r.integer;for(const o in r)i=(0,Ie.and)(i,lv(o,e,t,s));return i}cn.checkDataTypes=NS;const Oq={message:({schema:n})=>`must be ${n}`,params:({schema:n,schemaValue:e})=>typeof n=="string"?(0,Ie._)`{type: ${n}}`:(0,Ie._)`{type: ${e}}`};function LS(n){const e=Nq(n);(0,$q.reportError)(e,Oq)}cn.reportTypeError=LS;function Nq(n){const{gen:e,data:t,schema:s}=n,i=(0,bT.schemaRefOrVal)(n,s,"type");return{gen:e,keyword:"type",data:t,schema:s.type,schemaCode:i,schemaValue:i,parentSchema:s,params:{},it:n}}var m0={};Object.defineProperty(m0,"__esModule",{value:!0});m0.assignDefaults=void 0;const Rc=Ue,Lq=fe;function Dq(n,e){const{properties:t,items:s}=n.schema;if(e==="object"&&t)for(const i in t)Fk(n,i,t[i].default);else e==="array"&&Array.isArray(s)&&s.forEach((i,r)=>Fk(n,r,i.default))}m0.assignDefaults=Dq;function Fk(n,e,t){const{gen:s,compositeRule:i,data:r,opts:o}=n;if(t===void 0)return;const a=(0,Rc._)`${r}${(0,Rc.getProperty)(e)}`;if(i){(0,Lq.checkStrictMode)(n,`default is ignored for: ${a}`);return}let l=(0,Rc._)`${a} === undefined`;o.useDefaults==="empty"&&(l=(0,Rc._)`${l} || ${a} === null || ${a} === ""`),s.if(l,(0,Rc._)`${a} = ${(0,Rc.stringify)(t)}`)}var Cr={},qe={};Object.defineProperty(qe,"__esModule",{value:!0});qe.validateUnion=qe.validateArray=qe.usePattern=qe.callValidateCode=qe.schemaProperties=qe.allSchemaProperties=qe.noPropertyInData=qe.propertyInData=qe.isOwnProperty=qe.hasPropFunc=qe.reportMissingProp=qe.checkMissingProp=qe.checkReportMissingProp=void 0;const kt=Ue,DS=fe,Po=Nr,jq=fe;function Fq(n,e){const{gen:t,data:s,it:i}=n;t.if(FS(t,s,e,i.opts.ownProperties),()=>{n.setParams({missingProperty:(0,kt._)`${e}`},!0),n.error()})}qe.checkReportMissingProp=Fq;function zq({gen:n,data:e,it:{opts:t}},s,i){return(0,kt.or)(...s.map(r=>(0,kt.and)(FS(n,e,r,t.ownProperties),(0,kt._)`${i} = ${r}`)))}qe.checkMissingProp=zq;function Hq(n,e){n.setParams({missingProperty:e},!0),n.error()}qe.reportMissingProp=Hq;function _T(n){return n.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,kt._)`Object.prototype.hasOwnProperty`})}qe.hasPropFunc=_T;function jS(n,e,t){return(0,kt._)`${_T(n)}.call(${e}, ${t})`}qe.isOwnProperty=jS;function Bq(n,e,t,s){const i=(0,kt._)`${e}${(0,kt.getProperty)(t)} !== undefined`;return s?(0,kt._)`${i} && ${jS(n,e,t)}`:i}qe.propertyInData=Bq;function FS(n,e,t,s){const i=(0,kt._)`${e}${(0,kt.getProperty)(t)} === undefined`;return s?(0,kt.or)(i,(0,kt.not)(jS(n,e,t))):i}qe.noPropertyInData=FS;function ST(n){return n?Object.keys(n).filter(e=>e!=="__proto__"):[]}qe.allSchemaProperties=ST;function qq(n,e){return ST(e).filter(t=>!(0,DS.alwaysValidSchema)(n,e[t]))}qe.schemaProperties=qq;function Vq({schemaCode:n,data:e,it:{gen:t,topSchemaRef:s,schemaPath:i,errorPath:r},it:o},a,l,c){const h=c?(0,kt._)`${n}, ${e}, ${s}${i}`:e,u=[[Po.default.instancePath,(0,kt.strConcat)(Po.default.instancePath,r)],[Po.default.parentData,o.parentData],[Po.default.parentDataProperty,o.parentDataProperty],[Po.default.rootData,Po.default.rootData]];o.opts.dynamicRef&&u.push([Po.default.dynamicAnchors,Po.default.dynamicAnchors]);const d=(0,kt._)`${h}, ${t.object(...u)}`;return l!==kt.nil?(0,kt._)`${a}.call(${l}, ${d})`:(0,kt._)`${a}(${d})`}qe.callValidateCode=Vq;const Uq=(0,kt._)`new RegExp`;function Wq({gen:n,it:{opts:e}},t){const s=e.unicodeRegExp?"u":"",{regExp:i}=e.code,r=i(t,s);return n.scopeValue("pattern",{key:r.toString(),ref:r,code:(0,kt._)`${i.code==="new RegExp"?Uq:(0,jq.useFunc)(n,i)}(${t}, ${s})`})}qe.usePattern=Wq;function Gq(n){const{gen:e,data:t,keyword:s,it:i}=n,r=e.name("valid");if(i.allErrors){const a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(r,!0),o(()=>e.break()),r;function o(a){const l=e.const("len",(0,kt._)`${t}.length`);e.forRange("i",0,l,c=>{n.subschema({keyword:s,dataProp:c,dataPropType:DS.Type.Num},r),e.if((0,kt.not)(r),a)})}}qe.validateArray=Gq;function Kq(n){const{gen:e,schema:t,keyword:s,it:i}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");if(t.some(l=>(0,DS.alwaysValidSchema)(i,l))&&!i.opts.unevaluated)return;const o=e.let("valid",!1),a=e.name("_valid");e.block(()=>t.forEach((l,c)=>{const h=n.subschema({keyword:s,schemaProp:c,compositeRule:!0},a);e.assign(o,(0,kt._)`${o} || ${a}`),n.mergeValidEvaluated(h,a)||e.if((0,kt.not)(o))})),n.result(o,()=>n.reset(),()=>n.error(!0))}qe.validateUnion=Kq;Object.defineProperty(Cr,"__esModule",{value:!0});Cr.validateKeywordUsage=Cr.validSchemaType=Cr.funcKeywordCode=Cr.macroKeywordCode=void 0;const cs=Ue,Qa=Nr,Zq=qe,Xq=Wp;function Yq(n,e){const{gen:t,keyword:s,schema:i,parentSchema:r,it:o}=n,a=e.macro.call(o.self,i,r,o),l=xT(t,s,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);const c=t.name("valid");n.subschema({schema:a,schemaPath:cs.nil,errSchemaPath:`${o.errSchemaPath}/${s}`,topSchemaRef:l,compositeRule:!0},c),n.pass(c,()=>n.error(!0))}Cr.macroKeywordCode=Yq;function Jq(n,e){var t;const{gen:s,keyword:i,schema:r,parentSchema:o,$data:a,it:l}=n;eV(l,e);const c=!a&&e.compile?e.compile.call(l.self,r,o,l):e.validate,h=xT(s,i,c),u=s.let("valid");n.block$data(u,d),n.ok((t=e.valid)!==null&&t!==void 0?t:u);function d(){if(e.errors===!1)g(),e.modifying&&zk(n),b(()=>n.error());else{const y=e.async?p():m();e.modifying&&zk(n),b(()=>Qq(n,y))}}function p(){const y=s.let("ruleErrs",null);return s.try(()=>g((0,cs._)`await `),w=>s.assign(u,!1).if((0,cs._)`${w} instanceof ${l.ValidationError}`,()=>s.assign(y,(0,cs._)`${w}.errors`),()=>s.throw(w))),y}function m(){const y=(0,cs._)`${h}.errors`;return s.assign(y,null),g(cs.nil),y}function g(y=e.async?(0,cs._)`await `:cs.nil){const w=l.opts.passContext?Qa.default.this:Qa.default.self,v=!("compile"in e&&!a||e.schema===!1);s.assign(u,(0,cs._)`${y}${(0,Zq.callValidateCode)(n,h,w,v)}`,e.modifying)}function b(y){var w;s.if((0,cs.not)((w=e.valid)!==null&&w!==void 0?w:u),y)}}Cr.funcKeywordCode=Jq;function zk(n){const{gen:e,data:t,it:s}=n;e.if(s.parentData,()=>e.assign(t,(0,cs._)`${s.parentData}[${s.parentDataProperty}]`))}function Qq(n,e){const{gen:t}=n;t.if((0,cs._)`Array.isArray(${e})`,()=>{t.assign(Qa.default.vErrors,(0,cs._)`${Qa.default.vErrors} === null ? ${e} : ${Qa.default.vErrors}.concat(${e})`).assign(Qa.default.errors,(0,cs._)`${Qa.default.vErrors}.length`),(0,Xq.extendErrors)(n)},()=>n.error())}function eV({schemaEnv:n},e){if(e.async&&!n.$async)throw new Error("async keyword in sync schema")}function xT(n,e,t){if(t===void 0)throw new Error(`keyword "${e}" failed to compile`);return n.scopeValue("keyword",typeof t=="function"?{ref:t}:{ref:t,code:(0,cs.stringify)(t)})}function tV(n,e,t=!1){return!e.length||e.some(s=>s==="array"?Array.isArray(n):s==="object"?n&&typeof n=="object"&&!Array.isArray(n):typeof n==s||t&&typeof n>"u")}Cr.validSchemaType=tV;function nV({schema:n,opts:e,self:t,errSchemaPath:s},i,r){if(Array.isArray(i.keyword)?!i.keyword.includes(r):i.keyword!==r)throw new Error("ajv implementation error");const o=i.dependencies;if(o!=null&&o.some(a=>!Object.prototype.hasOwnProperty.call(n,a)))throw new Error(`parent schema must have dependencies of ${r}: ${o.join(",")}`);if(i.validateSchema&&!i.validateSchema(n[r])){const l=`keyword "${r}" value is invalid at path "${s}": `+t.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")t.logger.error(l);else throw new Error(l)}}Cr.validateKeywordUsage=nV;var xa={};Object.defineProperty(xa,"__esModule",{value:!0});xa.extendSubschemaMode=xa.extendSubschemaData=xa.getSubschema=void 0;const xr=Ue,kT=fe;function sV(n,{keyword:e,schemaProp:t,schema:s,schemaPath:i,errSchemaPath:r,topSchemaRef:o}){if(e!==void 0&&s!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){const a=n.schema[e];return t===void 0?{schema:a,schemaPath:(0,xr._)`${n.schemaPath}${(0,xr.getProperty)(e)}`,errSchemaPath:`${n.errSchemaPath}/${e}`}:{schema:a[t],schemaPath:(0,xr._)`${n.schemaPath}${(0,xr.getProperty)(e)}${(0,xr.getProperty)(t)}`,errSchemaPath:`${n.errSchemaPath}/${e}/${(0,kT.escapeFragment)(t)}`}}if(s!==void 0){if(i===void 0||r===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:i,topSchemaRef:o,errSchemaPath:r}}throw new Error('either "keyword" or "schema" must be passed')}xa.getSubschema=sV;function iV(n,e,{dataProp:t,dataPropType:s,data:i,dataTypes:r,propertyName:o}){if(i!==void 0&&t!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:a}=e;if(t!==void 0){const{errorPath:c,dataPathArr:h,opts:u}=e,d=a.let("data",(0,xr._)`${e.data}${(0,xr.getProperty)(t)}`,!0);l(d),n.errorPath=(0,xr.str)`${c}${(0,kT.getErrorPath)(t,s,u.jsPropertySyntax)}`,n.parentDataProperty=(0,xr._)`${t}`,n.dataPathArr=[...h,n.parentDataProperty]}if(i!==void 0){const c=i instanceof xr.Name?i:a.let("data",i,!0);l(c),o!==void 0&&(n.propertyName=o)}r&&(n.dataTypes=r);function l(c){n.data=c,n.dataLevel=e.dataLevel+1,n.dataTypes=[],e.definedProperties=new Set,n.parentData=e.data,n.dataNames=[...e.dataNames,c]}}xa.extendSubschemaData=iV;function rV(n,{jtdDiscriminator:e,jtdMetadata:t,compositeRule:s,createErrors:i,allErrors:r}){s!==void 0&&(n.compositeRule=s),i!==void 0&&(n.createErrors=i),r!==void 0&&(n.allErrors=r),n.jtdDiscriminator=e,n.jtdMetadata=t}xa.extendSubschemaMode=rV;var Dn={},g0=function n(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var s,i,r;if(Array.isArray(e)){if(s=e.length,s!=t.length)return!1;for(i=s;i--!==0;)if(!n(e[i],t[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(r=Object.keys(e),s=r.length,s!==Object.keys(t).length)return!1;for(i=s;i--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[i]))return!1;for(i=s;i--!==0;){var o=r[i];if(!n(e[o],t[o]))return!1}return!0}return e!==e&&t!==t},AT={exports:{}},ba=AT.exports=function(n,e,t){typeof e=="function"&&(t=e,e={}),t=e.cb||t;var s=typeof t=="function"?t:t.pre||function(){},i=t.post||function(){};Qm(e,s,i,n,"",n)};ba.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};ba.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};ba.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};ba.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Qm(n,e,t,s,i,r,o,a,l,c){if(s&&typeof s=="object"&&!Array.isArray(s)){e(s,i,r,o,a,l,c);for(var h in s){var u=s[h];if(Array.isArray(u)){if(h in ba.arrayKeywords)for(var d=0;de+=ET(s)),e===1/0))return 1/0}return e}function CT(n,e="",t){t!==!1&&(e=ih(e));const s=n.parse(e);return $T(n,s)}Dn.getFullPath=CT;function $T(n,e){return n.serialize(e).split("#")[0]+"#"}Dn._getFullPath=$T;const pV=/#\/?$/;function ih(n){return n?n.replace(pV,""):""}Dn.normalizeId=ih;function mV(n,e,t){return t=ih(t),n.resolve(e,t)}Dn.resolveUrl=mV;const gV=/^[a-z_][-a-z0-9._]*$/i;function yV(n,e){if(typeof n=="boolean")return{};const{schemaId:t,uriResolver:s}=this.opts,i=ih(n[t]||e),r={"":i},o=CT(s,i,!1),a={},l=new Set;return hV(n,{allKeys:!0},(u,d,p,m)=>{if(m===void 0)return;const g=o+d;let b=r[m];typeof u[t]=="string"&&(b=y.call(this,u[t])),w.call(this,u.$anchor),w.call(this,u.$dynamicAnchor),r[d]=b;function y(v){const x=this.opts.uriResolver.resolve;if(v=ih(b?x(b,v):v),l.has(v))throw h(v);l.add(v);let k=this.refs[v];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?c(u,k.schema,v):v!==ih(g)&&(v[0]==="#"?(c(u,a[v],v),a[v]=u):this.refs[v]=g),v}function w(v){if(typeof v=="string"){if(!gV.test(v))throw new Error(`invalid anchor "${v}"`);y.call(this,`#${v}`)}}}),a;function c(u,d,p){if(d!==void 0&&!cV(u,d))throw h(p)}function h(u){return new Error(`reference "${u}" resolves to more than one schema`)}}Dn.getSchemaRefs=yV;Object.defineProperty(Ki,"__esModule",{value:!0});Ki.getData=Ki.KeywordCxt=Ki.validateFunctionCode=void 0;const TT=mu,Hk=cn,zS=bo,Yg=cn,bV=m0,Nd=Cr,nb=xa,we=Ue,Ee=Nr,vV=Dn,vo=fe,Ku=Wp;function wV(n){if(MT(n)&&(IT(n),RT(n))){xV(n);return}PT(n,()=>(0,TT.topBoolOrEmptySchema)(n))}Ki.validateFunctionCode=wV;function PT({gen:n,validateName:e,schema:t,schemaEnv:s,opts:i},r){i.code.es5?n.func(e,(0,we._)`${Ee.default.data}, ${Ee.default.valCxt}`,s.$async,()=>{n.code((0,we._)`"use strict"; ${Bk(t,i)}`),SV(n,i),n.code(r)}):n.func(e,(0,we._)`${Ee.default.data}, ${_V(i)}`,s.$async,()=>n.code(Bk(t,i)).code(r))}function _V(n){return(0,we._)`{${Ee.default.instancePath}="", ${Ee.default.parentData}, ${Ee.default.parentDataProperty}, ${Ee.default.rootData}=${Ee.default.data}${n.dynamicRef?(0,we._)`, ${Ee.default.dynamicAnchors}={}`:we.nil}}={}`}function SV(n,e){n.if(Ee.default.valCxt,()=>{n.var(Ee.default.instancePath,(0,we._)`${Ee.default.valCxt}.${Ee.default.instancePath}`),n.var(Ee.default.parentData,(0,we._)`${Ee.default.valCxt}.${Ee.default.parentData}`),n.var(Ee.default.parentDataProperty,(0,we._)`${Ee.default.valCxt}.${Ee.default.parentDataProperty}`),n.var(Ee.default.rootData,(0,we._)`${Ee.default.valCxt}.${Ee.default.rootData}`),e.dynamicRef&&n.var(Ee.default.dynamicAnchors,(0,we._)`${Ee.default.valCxt}.${Ee.default.dynamicAnchors}`)},()=>{n.var(Ee.default.instancePath,(0,we._)`""`),n.var(Ee.default.parentData,(0,we._)`undefined`),n.var(Ee.default.parentDataProperty,(0,we._)`undefined`),n.var(Ee.default.rootData,Ee.default.data),e.dynamicRef&&n.var(Ee.default.dynamicAnchors,(0,we._)`{}`)})}function xV(n){const{schema:e,opts:t,gen:s}=n;PT(n,()=>{t.$comment&&e.$comment&&NT(n),$V(n),s.let(Ee.default.vErrors,null),s.let(Ee.default.errors,0),t.unevaluated&&kV(n),OT(n),RV(n)})}function kV(n){const{gen:e,validateName:t}=n;n.evaluated=e.const("evaluated",(0,we._)`${t}.evaluated`),e.if((0,we._)`${n.evaluated}.dynamicProps`,()=>e.assign((0,we._)`${n.evaluated}.props`,(0,we._)`undefined`)),e.if((0,we._)`${n.evaluated}.dynamicItems`,()=>e.assign((0,we._)`${n.evaluated}.items`,(0,we._)`undefined`))}function Bk(n,e){const t=typeof n=="object"&&n[e.schemaId];return t&&(e.code.source||e.code.process)?(0,we._)`/*# sourceURL=${t} */`:we.nil}function AV(n,e){if(MT(n)&&(IT(n),RT(n))){EV(n,e);return}(0,TT.boolOrEmptySchema)(n,e)}function RT({schema:n,self:e}){if(typeof n=="boolean")return!n;for(const t in n)if(e.RULES.all[t])return!0;return!1}function MT(n){return typeof n.schema!="boolean"}function EV(n,e){const{schema:t,gen:s,opts:i}=n;i.$comment&&t.$comment&&NT(n),TV(n),PV(n);const r=s.const("_errs",Ee.default.errors);OT(n,r),s.var(e,(0,we._)`${r} === ${Ee.default.errors}`)}function IT(n){(0,vo.checkUnknownRules)(n),CV(n)}function OT(n,e){if(n.opts.jtd)return qk(n,[],!1,e);const t=(0,Hk.getSchemaTypes)(n.schema),s=(0,Hk.coerceAndCheckDataType)(n,t);qk(n,t,!s,e)}function CV(n){const{schema:e,errSchemaPath:t,opts:s,self:i}=n;e.$ref&&s.ignoreKeywordsWithRef&&(0,vo.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${t}"`)}function $V(n){const{schema:e,opts:t}=n;e.default!==void 0&&t.useDefaults&&t.strictSchema&&(0,vo.checkStrictMode)(n,"default is ignored in the schema root")}function TV(n){const e=n.schema[n.opts.schemaId];e&&(n.baseId=(0,vV.resolveUrl)(n.opts.uriResolver,n.baseId,e))}function PV(n){if(n.schema.$async&&!n.schemaEnv.$async)throw new Error("async schema in sync schema")}function NT({gen:n,schemaEnv:e,schema:t,errSchemaPath:s,opts:i}){const r=t.$comment;if(i.$comment===!0)n.code((0,we._)`${Ee.default.self}.logger.log(${r})`);else if(typeof i.$comment=="function"){const o=(0,we.str)`${s}/$comment`,a=n.scopeValue("root",{ref:e.root});n.code((0,we._)`${Ee.default.self}.opts.$comment(${r}, ${o}, ${a}.schema)`)}}function RV(n){const{gen:e,schemaEnv:t,validateName:s,ValidationError:i,opts:r}=n;t.$async?e.if((0,we._)`${Ee.default.errors} === 0`,()=>e.return(Ee.default.data),()=>e.throw((0,we._)`new ${i}(${Ee.default.vErrors})`)):(e.assign((0,we._)`${s}.errors`,Ee.default.vErrors),r.unevaluated&&MV(n),e.return((0,we._)`${Ee.default.errors} === 0`))}function MV({gen:n,evaluated:e,props:t,items:s}){t instanceof we.Name&&n.assign((0,we._)`${e}.props`,t),s instanceof we.Name&&n.assign((0,we._)`${e}.items`,s)}function qk(n,e,t,s){const{gen:i,schema:r,data:o,allErrors:a,opts:l,self:c}=n,{RULES:h}=c;if(r.$ref&&(l.ignoreKeywordsWithRef||!(0,vo.schemaHasRulesButRef)(r,h))){i.block(()=>jT(n,"$ref",h.all.$ref.definition));return}l.jtd||IV(n,e),i.block(()=>{for(const d of h.rules)u(d);u(h.post)});function u(d){(0,zS.shouldUseGroup)(r,d)&&(d.type?(i.if((0,Yg.checkDataType)(d.type,o,l.strictNumbers)),Vk(n,d),e.length===1&&e[0]===d.type&&t&&(i.else(),(0,Yg.reportTypeError)(n)),i.endIf()):Vk(n,d),a||i.if((0,we._)`${Ee.default.errors} === ${s||0}`))}}function Vk(n,e){const{gen:t,schema:s,opts:{useDefaults:i}}=n;i&&(0,bV.assignDefaults)(n,e.type),t.block(()=>{for(const r of e.rules)(0,zS.shouldUseRule)(s,r)&&jT(n,r.keyword,r.definition,e.type)})}function IV(n,e){n.schemaEnv.meta||!n.opts.strictTypes||(OV(n,e),n.opts.allowUnionTypes||NV(n,e),LV(n,n.dataTypes))}function OV(n,e){if(e.length){if(!n.dataTypes.length){n.dataTypes=e;return}e.forEach(t=>{LT(n.dataTypes,t)||HS(n,`type "${t}" not allowed by context "${n.dataTypes.join(",")}"`)}),jV(n,e)}}function NV(n,e){e.length>1&&!(e.length===2&&e.includes("null"))&&HS(n,"use allowUnionTypes to allow union type keyword")}function LV(n,e){const t=n.self.RULES.all;for(const s in t){const i=t[s];if(typeof i=="object"&&(0,zS.shouldUseRule)(n.schema,i)){const{type:r}=i.definition;r.length&&!r.some(o=>DV(e,o))&&HS(n,`missing type "${r.join(",")}" for keyword "${s}"`)}}}function DV(n,e){return n.includes(e)||e==="number"&&n.includes("integer")}function LT(n,e){return n.includes(e)||e==="integer"&&n.includes("number")}function jV(n,e){const t=[];for(const s of n.dataTypes)LT(e,s)?t.push(s):e.includes("integer")&&s==="number"&&t.push("integer");n.dataTypes=t}function HS(n,e){const t=n.schemaEnv.baseId+n.errSchemaPath;e+=` at "${t}" (strictTypes)`,(0,vo.checkStrictMode)(n,e,n.opts.strictTypes)}let DT=class{constructor(e,t,s){if((0,Nd.validateKeywordUsage)(e,t,s),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=s,this.data=e.data,this.schema=e.schema[s],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,vo.schemaRefOrVal)(e,this.schema,s,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",FT(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Nd.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${s} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const("_errs",Ee.default.errors))}result(e,t,s){this.failResult((0,we.not)(e),t,s)}failResult(e,t,s){this.gen.if(e),s?s():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,we.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail((0,we._)`${t} !== undefined && (${(0,we.or)(this.invalid$data(),e)})`)}error(e,t,s){if(t){this.setParams(t),this._error(e,s),this.setParams({});return}this._error(e,s)}_error(e,t){(e?Ku.reportExtraError:Ku.reportError)(this,this.def.error,t)}$dataError(){(0,Ku.reportError)(this,this.def.$dataError||Ku.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Ku.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,s=we.nil){this.gen.block(()=>{this.check$data(e,s),t()})}check$data(e=we.nil,t=we.nil){if(!this.$data)return;const{gen:s,schemaCode:i,schemaType:r,def:o}=this;s.if((0,we.or)((0,we._)`${i} === undefined`,t)),e!==we.nil&&s.assign(e,!0),(r.length||o.validateSchema)&&(s.elseIf(this.invalid$data()),this.$dataError(),e!==we.nil&&s.assign(e,!1)),s.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:s,def:i,it:r}=this;return(0,we.or)(o(),a());function o(){if(s.length){if(!(t instanceof we.Name))throw new Error("ajv implementation error");const l=Array.isArray(s)?s:[s];return(0,we._)`${(0,Yg.checkDataTypes)(l,t,r.opts.strictNumbers,Yg.DataType.Wrong)}`}return we.nil}function a(){if(i.validateSchema){const l=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,we._)`!${l}(${t})`}return we.nil}}subschema(e,t){const s=(0,nb.getSubschema)(this.it,e);(0,nb.extendSubschemaData)(s,this.it,e),(0,nb.extendSubschemaMode)(s,e);const i={...this.it,...s,items:void 0,props:void 0};return AV(i,t),i}mergeEvaluated(e,t){const{it:s,gen:i}=this;s.opts.unevaluated&&(s.props!==!0&&e.props!==void 0&&(s.props=vo.mergeEvaluated.props(i,e.props,s.props,t)),s.items!==!0&&e.items!==void 0&&(s.items=vo.mergeEvaluated.items(i,e.items,s.items,t)))}mergeValidEvaluated(e,t){const{it:s,gen:i}=this;if(s.opts.unevaluated&&(s.props!==!0||s.items!==!0))return i.if(t,()=>this.mergeEvaluated(e,we.Name)),!0}};Ki.KeywordCxt=DT;function jT(n,e,t,s){const i=new DT(n,t,e);"code"in t?t.code(i,s):i.$data&&t.validate?(0,Nd.funcKeywordCode)(i,t):"macro"in t?(0,Nd.macroKeywordCode)(i,t):(t.compile||t.validate)&&(0,Nd.funcKeywordCode)(i,t)}const FV=/^\/(?:[^~]|~0|~1)*$/,zV=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function FT(n,{dataLevel:e,dataNames:t,dataPathArr:s}){let i,r;if(n==="")return Ee.default.rootData;if(n[0]==="/"){if(!FV.test(n))throw new Error(`Invalid JSON-pointer: ${n}`);i=n,r=Ee.default.rootData}else{const c=zV.exec(n);if(!c)throw new Error(`Invalid JSON-pointer: ${n}`);const h=+c[1];if(i=c[2],i==="#"){if(h>=e)throw new Error(l("property/index",h));return s[e-h]}if(h>e)throw new Error(l("data",h));if(r=t[e-h],!i)return r}let o=r;const a=i.split("/");for(const c of a)c&&(r=(0,we._)`${r}${(0,we.getProperty)((0,vo.unescapeJsonPointer)(c))}`,o=(0,we._)`${o} && ${r}`);return o;function l(c,h){return`Cannot access ${c} ${h} levels up, current level is ${e}`}}Ki.getData=FT;var Gp={};Object.defineProperty(Gp,"__esModule",{value:!0});let HV=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Gp.default=HV;var Mu={};Object.defineProperty(Mu,"__esModule",{value:!0});const sb=Dn;let BV=class extends Error{constructor(e,t,s,i){super(i||`can't resolve reference ${s} from id ${t}`),this.missingRef=(0,sb.resolveUrl)(e,t,s),this.missingSchema=(0,sb.normalizeId)((0,sb.getFullPath)(e,this.missingRef))}};Mu.default=BV;var Rs={};Object.defineProperty(Rs,"__esModule",{value:!0});Rs.resolveSchema=Rs.getCompilingSchema=Rs.resolveRef=Rs.compileSchema=Rs.SchemaEnv=void 0;const ki=Ue,qV=Gp,za=Nr,qi=Dn,Uk=fe,VV=Ki;let y0=class{constructor(e){var t;this.refs={},this.dynamicAnchors={};let s;typeof e.schema=="object"&&(s=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(t=e.baseId)!==null&&t!==void 0?t:(0,qi.normalizeId)(s==null?void 0:s[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=s==null?void 0:s.$async,this.refs={}}};Rs.SchemaEnv=y0;function BS(n){const e=zT.call(this,n);if(e)return e;const t=(0,qi.getFullPath)(this.opts.uriResolver,n.root.baseId),{es5:s,lines:i}=this.opts.code,{ownProperties:r}=this.opts,o=new ki.CodeGen(this.scope,{es5:s,lines:i,ownProperties:r});let a;n.$async&&(a=o.scopeValue("Error",{ref:qV.default,code:(0,ki._)`require("ajv/dist/runtime/validation_error").default`}));const l=o.scopeName("validate");n.validateName=l;const c={gen:o,allErrors:this.opts.allErrors,data:za.default.data,parentData:za.default.parentData,parentDataProperty:za.default.parentDataProperty,dataNames:[za.default.data],dataPathArr:[ki.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:n.schema,code:(0,ki.stringify)(n.schema)}:{ref:n.schema}),validateName:l,ValidationError:a,schema:n.schema,schemaEnv:n,rootId:t,baseId:n.baseId||t,schemaPath:ki.nil,errSchemaPath:n.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,ki._)`""`,opts:this.opts,self:this};let h;try{this._compilations.add(n),(0,VV.validateFunctionCode)(c),o.optimize(this.opts.code.optimize);const u=o.toString();h=`${o.scopeRefs(za.default.scope)}return ${u}`,this.opts.code.process&&(h=this.opts.code.process(h,n));const p=new Function(`${za.default.self}`,`${za.default.scope}`,h)(this,this.scope.get());if(this.scope.value(l,{ref:p}),p.errors=null,p.schema=n.schema,p.schemaEnv=n,n.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:l,validateCode:u,scopeValues:o._values}),this.opts.unevaluated){const{props:m,items:g}=c;p.evaluated={props:m instanceof ki.Name?void 0:m,items:g instanceof ki.Name?void 0:g,dynamicProps:m instanceof ki.Name,dynamicItems:g instanceof ki.Name},p.source&&(p.source.evaluated=(0,ki.stringify)(p.evaluated))}return n.validate=p,n}catch(u){throw delete n.validate,delete n.validateName,h&&this.logger.error("Error compiling schema, function code:",h),u}finally{this._compilations.delete(n)}}Rs.compileSchema=BS;function UV(n,e,t){var s;t=(0,qi.resolveUrl)(this.opts.uriResolver,e,t);const i=n.refs[t];if(i)return i;let r=KV.call(this,n,t);if(r===void 0){const o=(s=n.localRefs)===null||s===void 0?void 0:s[t],{schemaId:a}=this.opts;o&&(r=new y0({schema:o,schemaId:a,root:n,baseId:e}))}if(r!==void 0)return n.refs[t]=WV.call(this,r)}Rs.resolveRef=UV;function WV(n){return(0,qi.inlineRef)(n.schema,this.opts.inlineRefs)?n.schema:n.validate?n:BS.call(this,n)}function zT(n){for(const e of this._compilations)if(GV(e,n))return e}Rs.getCompilingSchema=zT;function GV(n,e){return n.schema===e.schema&&n.root===e.root&&n.baseId===e.baseId}function KV(n,e){let t;for(;typeof(t=this.refs[e])=="string";)e=t;return t||this.schemas[e]||b0.call(this,n,e)}function b0(n,e){const t=this.opts.uriResolver.parse(e),s=(0,qi._getFullPath)(this.opts.uriResolver,t);let i=(0,qi.getFullPath)(this.opts.uriResolver,n.baseId,void 0);if(Object.keys(n.schema).length>0&&s===i)return ib.call(this,t,n);const r=(0,qi.normalizeId)(s),o=this.refs[r]||this.schemas[r];if(typeof o=="string"){const a=b0.call(this,n,o);return typeof(a==null?void 0:a.schema)!="object"?void 0:ib.call(this,t,a)}if(typeof(o==null?void 0:o.schema)=="object"){if(o.validate||BS.call(this,o),r===(0,qi.normalizeId)(e)){const{schema:a}=o,{schemaId:l}=this.opts,c=a[l];return c&&(i=(0,qi.resolveUrl)(this.opts.uriResolver,i,c)),new y0({schema:a,schemaId:l,root:n,baseId:i})}return ib.call(this,t,o)}}Rs.resolveSchema=b0;const ZV=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function ib(n,{baseId:e,schema:t,root:s}){var i;if(((i=n.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(const a of n.fragment.slice(1).split("/")){if(typeof t=="boolean")return;const l=t[(0,Uk.unescapeFragment)(a)];if(l===void 0)return;t=l;const c=typeof t=="object"&&t[this.opts.schemaId];!ZV.has(a)&&c&&(e=(0,qi.resolveUrl)(this.opts.uriResolver,e,c))}let r;if(typeof t!="boolean"&&t.$ref&&!(0,Uk.schemaHasRulesButRef)(t,this.RULES)){const a=(0,qi.resolveUrl)(this.opts.uriResolver,e,t.$ref);r=b0.call(this,s,a)}const{schemaId:o}=this.opts;if(r=r||new y0({schema:t,schemaId:o,root:s,baseId:e}),r.schema!==r.root.schema)return r}const XV="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",YV="Meta-schema for $data reference (JSON AnySchema extension proposal)",JV="object",QV=["$data"],eU={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},tU=!1,nU={$id:XV,description:YV,type:JV,required:QV,properties:eU,additionalProperties:tU};var qS={},v0={exports:{}};const sU=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),HT=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),VS=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),BT=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),iU=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function qT(n){let e="",t=0,s=0;for(s=0;s=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102))return"";e+=n[s];break}for(s+=1;s=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102))return"";e+=n[s]}return e}const rU=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Wk(n){return n.length=0,!0}function oU(n,e,t){if(n.length){const s=qT(n);if(s!=="")e.push(s);else return t.error=!0,!1;n.length=0}return!0}function aU(n){let e=0;const t={error:!1,address:"",zone:""},s=[],i=[];let r=!1,o=!1,a=oU;for(let l=0;l7){t.error=!0;break}l>0&&n[l-1]===":"&&(r=!0),s.push(":");continue}else if(c==="%"){if(!a(i,s,t))break;a=Wk}else{i.push(c);continue}}return i.length&&(a===Wk?t.zone=i.join(""):o?s.push(i.join("")):s.push(qT(i))),t.address=s.join(""),t}function VT(n){if(lU(n,":")<2)return{host:n,isIPV6:!1};const e=aU(n);if(e.error)return{host:n,isIPV6:!1};{let t=e.address,s=e.address;return e.zone&&(t+="%"+e.zone,s+="%25"+e.zone),{host:t,isIPV6:!0,escapedHost:s}}}function lU(n,e){let t=0;for(let s=0;shU[s])}function fU(n,e=!1){if(n.indexOf("%")===-1)return n;let t="";for(let s=0;s65535))return"URI port is malformed."}function Qg(n,e){const t=Object.assign({},e),s={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let i=!1,r=!1;t.reference==="suffix"&&(t.scheme?n=t.scheme+":"+n:n="//"+n);const o=n.match(qU);o!==null&&o[1].indexOf("\\")!==-1&&(s.error="URI authority must not contain a literal backslash.",i=!0);const a=n.match(VU);if(a!==null){const c=a[1],h=c.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(s.error=s.error||"URI authority must not contain a literal backslash.",i=!0):c.length!==h.length&&(s.error=s.error||"URI authority introducer must not contain whitespace.",i=!0))}const l=n.match(BU);if(l){s.scheme=l[1],s.userinfo=l[3],s.host=l[4],s.port=parseInt(l[5],10),s.path=l[6]||"",s.query=l[7],s.fragment=l[8],isNaN(s.port)&&(s.port=l[5]);const c=UU(s,l);if(c!==void 0&&(s.error=s.error||c,i=!0),s.host)if(LU(s.host)===!1){const d=PU(s.host);s.host=d.host.toLowerCase(),r=d.isIPV6}else r=!0;s.scheme===void 0&&s.userinfo===void 0&&s.host===void 0&&s.port===void 0&&s.query===void 0&&!s.path?s.reference="same-document":s.scheme===void 0?s.reference="relative":s.fragment===void 0?s.reference="absolute":s.reference="uri",t.reference&&t.reference!=="suffix"&&t.reference!==s.reference&&(s.error=s.error||"URI is not a "+t.reference+" reference.");const h=YT(t.scheme||s.scheme);if(!t.unicodeSupport&&(!h||!h.unicodeSupport)&&s.host&&(t.domainHost||h&&h.domainHost)&&r===!1&&DU(s.host))try{s.host=new URL("http://"+s.host).hostname}catch(u){s.error=s.error||"Host's domain name can not be converted to ASCII: "+u}if((!h||h&&!h.skipNormalize)&&(n.indexOf("%")!==-1&&(s.scheme!==void 0&&(s.scheme=unescape(s.scheme)),s.host!==void 0&&(s.host=NU(unescape(s.host),r))),s.path&&(s.path=IU(s.path)),s.fragment))try{s.fragment=encodeURI(decodeURIComponent(s.fragment))}catch{s.error=s.error||"URI malformed"}h&&h.parse&&h.parse(s,t)}else s.error=s.error||"URI can not be parsed.";return{parsed:s,malformedAuthorityOrPort:i}}function ey(n,e){return Qg(n,e).parsed}function WU(n,e){return QT(n,e).normalized}function QT(n,e){const{parsed:t,malformedAuthorityOrPort:s}=Qg(n,e);return{normalized:s?n:hc(t,e),malformedAuthorityOrPort:s}}function Gk(n,e){if(typeof n=="string"){const{normalized:t,malformedAuthorityOrPort:s}=QT(n,e);return s?void 0:t}if(typeof n=="object")return hc(n,e)}const WS={SCHEMES:jU,normalize:FU,resolve:zU,resolveComponent:JT,equal:HU,serialize:hc,parse:ey};v0.exports=WS;v0.exports.default=WS;v0.exports.fastUri=WS;var eP=v0.exports;Object.defineProperty(qS,"__esModule",{value:!0});const tP=eP;tP.code='require("ajv/dist/runtime/uri").default';qS.default=tP;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.CodeGen=n.Name=n.nil=n.stringify=n.str=n._=n.KeywordCxt=void 0;var e=Ki;Object.defineProperty(n,"KeywordCxt",{enumerable:!0,get:function(){return e.KeywordCxt}});var t=Ue;Object.defineProperty(n,"_",{enumerable:!0,get:function(){return t._}}),Object.defineProperty(n,"str",{enumerable:!0,get:function(){return t.str}}),Object.defineProperty(n,"stringify",{enumerable:!0,get:function(){return t.stringify}}),Object.defineProperty(n,"nil",{enumerable:!0,get:function(){return t.nil}}),Object.defineProperty(n,"Name",{enumerable:!0,get:function(){return t.Name}}),Object.defineProperty(n,"CodeGen",{enumerable:!0,get:function(){return t.CodeGen}});const s=Gp,i=Mu,r=cc,o=Rs,a=Ue,l=Dn,c=cn,h=fe,u=nU,d=qS,p=(z,C)=>new RegExp(z,C);p.code="new RegExp";const m=["removeAdditional","useDefaults","coerceTypes"],g=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),b={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},y={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},w=200;function v(z){var C,I,R,_,A,N,W,X,he,ie,ge,at,ze,Qe,lt,tt,Ft,qt,bs,js,tn,vs,ws,Fs,_s;const En=z.strict,nn=(C=z.code)===null||C===void 0?void 0:C.optimize,sn=nn===!0||nn===void 0?1:nn||0,Cn=(R=(I=z.code)===null||I===void 0?void 0:I.regExp)!==null&&R!==void 0?R:p,$n=(_=z.uriResolver)!==null&&_!==void 0?_:d.default;return{strictSchema:(N=(A=z.strictSchema)!==null&&A!==void 0?A:En)!==null&&N!==void 0?N:!0,strictNumbers:(X=(W=z.strictNumbers)!==null&&W!==void 0?W:En)!==null&&X!==void 0?X:!0,strictTypes:(ie=(he=z.strictTypes)!==null&&he!==void 0?he:En)!==null&&ie!==void 0?ie:"log",strictTuples:(at=(ge=z.strictTuples)!==null&&ge!==void 0?ge:En)!==null&&at!==void 0?at:"log",strictRequired:(Qe=(ze=z.strictRequired)!==null&&ze!==void 0?ze:En)!==null&&Qe!==void 0?Qe:!1,code:z.code?{...z.code,optimize:sn,regExp:Cn}:{optimize:sn,regExp:Cn},loopRequired:(lt=z.loopRequired)!==null&<!==void 0?lt:w,loopEnum:(tt=z.loopEnum)!==null&&tt!==void 0?tt:w,meta:(Ft=z.meta)!==null&&Ft!==void 0?Ft:!0,messages:(qt=z.messages)!==null&&qt!==void 0?qt:!0,inlineRefs:(bs=z.inlineRefs)!==null&&bs!==void 0?bs:!0,schemaId:(js=z.schemaId)!==null&&js!==void 0?js:"$id",addUsedSchema:(tn=z.addUsedSchema)!==null&&tn!==void 0?tn:!0,validateSchema:(vs=z.validateSchema)!==null&&vs!==void 0?vs:!0,validateFormats:(ws=z.validateFormats)!==null&&ws!==void 0?ws:!0,unicodeRegExp:(Fs=z.unicodeRegExp)!==null&&Fs!==void 0?Fs:!0,int32range:(_s=z.int32range)!==null&&_s!==void 0?_s:!0,uriResolver:$n}}class x{constructor(C={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,C=this.opts={...C,...v(C)};const{es5:I,lines:R}=this.opts.code;this.scope=new a.ValueScope({scope:{},prefixes:g,es5:I,lines:R}),this.logger=B(C.logger);const _=C.validateFormats;C.validateFormats=!1,this.RULES=(0,r.getRules)(),k.call(this,b,C,"NOT SUPPORTED"),k.call(this,y,C,"DEPRECATED","warn"),this._metaOpts=j.call(this),C.formats&&O.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),C.keywords&&F.call(this,C.keywords),typeof C.meta=="object"&&this.addMetaSchema(C.meta),T.call(this),C.validateFormats=_}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:C,meta:I,schemaId:R}=this.opts;let _=u;R==="id"&&(_={...u},_.id=_.$id,delete _.$id),I&&C&&this.addMetaSchema(_,_[R],!1)}defaultMeta(){const{meta:C,schemaId:I}=this.opts;return this.opts.defaultMeta=typeof C=="object"?C[I]||C:void 0}validate(C,I){let R;if(typeof C=="string"){if(R=this.getSchema(C),!R)throw new Error(`no schema with key or ref "${C}"`)}else R=this.compile(C);const _=R(I);return"$async"in R||(this.errors=R.errors),_}compile(C,I){const R=this._addSchema(C,I);return R.validate||this._compileSchemaEnv(R)}compileAsync(C,I){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:R}=this.opts;return _.call(this,C,I);async function _(ie,ge){await A.call(this,ie.$schema);const at=this._addSchema(ie,ge);return at.validate||N.call(this,at)}async function A(ie){ie&&!this.getSchema(ie)&&await _.call(this,{$ref:ie},!0)}async function N(ie){try{return this._compileSchemaEnv(ie)}catch(ge){if(!(ge instanceof i.default))throw ge;return W.call(this,ge),await X.call(this,ge.missingSchema),N.call(this,ie)}}function W({missingSchema:ie,missingRef:ge}){if(this.refs[ie])throw new Error(`AnySchema ${ie} is loaded but ${ge} cannot be resolved`)}async function X(ie){const ge=await he.call(this,ie);this.refs[ie]||await A.call(this,ge.$schema),this.refs[ie]||this.addSchema(ge,ie,I)}async function he(ie){const ge=this._loading[ie];if(ge)return ge;try{return await(this._loading[ie]=R(ie))}finally{delete this._loading[ie]}}}addSchema(C,I,R,_=this.opts.validateSchema){if(Array.isArray(C)){for(const N of C)this.addSchema(N,void 0,R,_);return this}let A;if(typeof C=="object"){const{schemaId:N}=this.opts;if(A=C[N],A!==void 0&&typeof A!="string")throw new Error(`schema ${N} must be string`)}return I=(0,l.normalizeId)(I||A),this._checkUnique(I),this.schemas[I]=this._addSchema(C,R,I,_,!0),this}addMetaSchema(C,I,R=this.opts.validateSchema){return this.addSchema(C,I,!0,R),this}validateSchema(C,I){if(typeof C=="boolean")return!0;let R;if(R=C.$schema,R!==void 0&&typeof R!="string")throw new Error("$schema must be a string");if(R=R||this.opts.defaultMeta||this.defaultMeta(),!R)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const _=this.validate(R,C);if(!_&&I){const A="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(A);else throw new Error(A)}return _}getSchema(C){let I;for(;typeof(I=E.call(this,C))=="string";)C=I;if(I===void 0){const{schemaId:R}=this.opts,_=new o.SchemaEnv({schema:{},schemaId:R});if(I=o.resolveSchema.call(this,_,C),!I)return;this.refs[C]=I}return I.validate||this._compileSchemaEnv(I)}removeSchema(C){if(C instanceof RegExp)return this._removeAllSchemas(this.schemas,C),this._removeAllSchemas(this.refs,C),this;switch(typeof C){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const I=E.call(this,C);return typeof I=="object"&&this._cache.delete(I.schema),delete this.schemas[C],delete this.refs[C],this}case"object":{const I=C;this._cache.delete(I);let R=C[this.opts.schemaId];return R&&(R=(0,l.normalizeId)(R),delete this.schemas[R],delete this.refs[R]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(C){for(const I of C)this.addKeyword(I);return this}addKeyword(C,I){let R;if(typeof C=="string")R=C,typeof I=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),I.keyword=R);else if(typeof C=="object"&&I===void 0){if(I=C,R=I.keyword,Array.isArray(R)&&!R.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(q.call(this,R,I),!I)return(0,h.eachItem)(R,A=>H.call(this,A)),this;Q.call(this,I);const _={...I,type:(0,c.getJSONTypes)(I.type),schemaType:(0,c.getJSONTypes)(I.schemaType)};return(0,h.eachItem)(R,_.type.length===0?A=>H.call(this,A,_):A=>_.type.forEach(N=>H.call(this,A,_,N))),this}getKeyword(C){const I=this.RULES.all[C];return typeof I=="object"?I.definition:!!I}removeKeyword(C){const{RULES:I}=this;delete I.keywords[C],delete I.all[C];for(const R of I.rules){const _=R.rules.findIndex(A=>A.keyword===C);_>=0&&R.rules.splice(_,1)}return this}addFormat(C,I){return typeof I=="string"&&(I=new RegExp(I)),this.formats[C]=I,this}errorsText(C=this.errors,{separator:I=", ",dataVar:R="data"}={}){return!C||C.length===0?"No errors":C.map(_=>`${R}${_.instancePath} ${_.message}`).reduce((_,A)=>_+I+A)}$dataMetaSchema(C,I){const R=this.RULES.all;C=JSON.parse(JSON.stringify(C));for(const _ of I){const A=_.split("/").slice(1);let N=C;for(const W of A)N=N[W];for(const W in R){const X=R[W];if(typeof X!="object")continue;const{$data:he}=X.definition,ie=N[W];he&&ie&&(N[W]=ye(ie))}}return C}_removeAllSchemas(C,I){for(const R in C){const _=C[R];(!I||I.test(R))&&(typeof _=="string"?delete C[R]:_&&!_.meta&&(this._cache.delete(_.schema),delete C[R]))}}_addSchema(C,I,R,_=this.opts.validateSchema,A=this.opts.addUsedSchema){let N;const{schemaId:W}=this.opts;if(typeof C=="object")N=C[W];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof C!="boolean")throw new Error("schema must be object or boolean")}let X=this._cache.get(C);if(X!==void 0)return X;R=(0,l.normalizeId)(N||R);const he=l.getSchemaRefs.call(this,C,R);return X=new o.SchemaEnv({schema:C,schemaId:W,meta:I,baseId:R,localRefs:he}),this._cache.set(X.schema,X),A&&!R.startsWith("#")&&(R&&this._checkUnique(R),this.refs[R]=X),_&&this.validateSchema(C,!0),X}_checkUnique(C){if(this.schemas[C]||this.refs[C])throw new Error(`schema with key or id "${C}" already exists`)}_compileSchemaEnv(C){if(C.meta?this._compileMetaSchema(C):o.compileSchema.call(this,C),!C.validate)throw new Error("ajv implementation error");return C.validate}_compileMetaSchema(C){const I=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,C)}finally{this.opts=I}}}x.ValidationError=s.default,x.MissingRefError=i.default,n.default=x;function k(z,C,I,R="error"){for(const _ in z){const A=_;A in C&&this.logger[R](`${I}: option ${_}. ${z[A]}`)}}function E(z){return z=(0,l.normalizeId)(z),this.schemas[z]||this.refs[z]}function T(){const z=this.opts.schemas;if(z)if(Array.isArray(z))this.addSchema(z);else for(const C in z)this.addSchema(z[C],C)}function O(){for(const z in this.opts.formats){const C=this.opts.formats[z];C&&this.addFormat(z,C)}}function F(z){if(Array.isArray(z)){this.addVocabulary(z);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const C in z){const I=z[C];I.keyword||(I.keyword=C),this.addKeyword(I)}}function j(){const z={...this.opts};for(const C of m)delete z[C];return z}const L={log(){},warn(){},error(){}};function B(z){if(z===!1)return L;if(z===void 0)return console;if(z.log&&z.warn&&z.error)return z;throw new Error("logger must implement log, warn and error methods")}const Z=/^[a-z_$][a-z0-9_$:-]*$/i;function q(z,C){const{RULES:I}=this;if((0,h.eachItem)(z,R=>{if(I.keywords[R])throw new Error(`Keyword ${R} is already defined`);if(!Z.test(R))throw new Error(`Keyword ${R} has invalid name`)}),!!C&&C.$data&&!("code"in C||"validate"in C))throw new Error('$data keyword must have "code" or "validate" function')}function H(z,C,I){var R;const _=C==null?void 0:C.post;if(I&&_)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:A}=this;let N=_?A.post:A.rules.find(({type:X})=>X===I);if(N||(N={type:I,rules:[]},A.rules.push(N)),A.keywords[z]=!0,!C)return;const W={keyword:z,definition:{...C,type:(0,c.getJSONTypes)(C.type),schemaType:(0,c.getJSONTypes)(C.schemaType)}};C.before?se.call(this,N,W,C.before):N.rules.push(W),A.all[z]=W,(R=C.implements)===null||R===void 0||R.forEach(X=>this.addKeyword(X))}function se(z,C,I){const R=z.rules.findIndex(_=>_.keyword===I);R>=0?z.rules.splice(R,0,C):(z.rules.push(C),this.logger.warn(`rule ${I} is not defined`))}function Q(z){let{metaSchema:C}=z;C!==void 0&&(z.$data&&this.opts.$data&&(C=ye(C)),z.validateSchema=this.compile(C,!0))}const Y={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ye(z){return{anyOf:[z,Y]}}})(cT);var GS={},KS={},ZS={};Object.defineProperty(ZS,"__esModule",{value:!0});const GU={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ZS.default=GU;var uc={};Object.defineProperty(uc,"__esModule",{value:!0});uc.callRef=uc.getValidate=void 0;const KU=Mu,Kk=qe,$s=Ue,Mc=Nr,Zk=Rs,gm=fe,ZU={keyword:"$ref",schemaType:"string",code(n){const{gen:e,schema:t,it:s}=n,{baseId:i,schemaEnv:r,validateName:o,opts:a,self:l}=s,{root:c}=r;if((t==="#"||t==="#/")&&i===c.baseId)return u();const h=Zk.resolveRef.call(l,c,i,t);if(h===void 0)throw new KU.default(s.opts.uriResolver,i,t);if(h instanceof Zk.SchemaEnv)return d(h);return p(h);function u(){if(r===c)return tg(n,o,r,r.$async);const m=e.scopeValue("root",{ref:c});return tg(n,(0,$s._)`${m}.validate`,c,c.$async)}function d(m){const g=nP(n,m);tg(n,g,m,m.$async)}function p(m){const g=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,$s.stringify)(m)}:{ref:m}),b=e.name("valid"),y=n.subschema({schema:m,dataTypes:[],schemaPath:$s.nil,topSchemaRef:g,errSchemaPath:t},b);n.mergeEvaluated(y),n.ok(b)}}};function nP(n,e){const{gen:t}=n;return e.validate?t.scopeValue("validate",{ref:e.validate}):(0,$s._)`${t.scopeValue("wrapper",{ref:e})}.validate`}uc.getValidate=nP;function tg(n,e,t,s){const{gen:i,it:r}=n,{allErrors:o,schemaEnv:a,opts:l}=r,c=l.passContext?Mc.default.this:$s.nil;s?h():u();function h(){if(!a.$async)throw new Error("async schema referenced by sync schema");const m=i.let("valid");i.try(()=>{i.code((0,$s._)`await ${(0,Kk.callValidateCode)(n,e,c)}`),p(e),o||i.assign(m,!0)},g=>{i.if((0,$s._)`!(${g} instanceof ${r.ValidationError})`,()=>i.throw(g)),d(g),o||i.assign(m,!1)}),n.ok(m)}function u(){n.result((0,Kk.callValidateCode)(n,e,c),()=>p(e),()=>d(e))}function d(m){const g=(0,$s._)`${m}.errors`;i.assign(Mc.default.vErrors,(0,$s._)`${Mc.default.vErrors} === null ? ${g} : ${Mc.default.vErrors}.concat(${g})`),i.assign(Mc.default.errors,(0,$s._)`${Mc.default.vErrors}.length`)}function p(m){var g;if(!r.opts.unevaluated)return;const b=(g=t==null?void 0:t.validate)===null||g===void 0?void 0:g.evaluated;if(r.props!==!0)if(b&&!b.dynamicProps)b.props!==void 0&&(r.props=gm.mergeEvaluated.props(i,b.props,r.props));else{const y=i.var("props",(0,$s._)`${m}.evaluated.props`);r.props=gm.mergeEvaluated.props(i,y,r.props,$s.Name)}if(r.items!==!0)if(b&&!b.dynamicItems)b.items!==void 0&&(r.items=gm.mergeEvaluated.items(i,b.items,r.items));else{const y=i.var("items",(0,$s._)`${m}.evaluated.items`);r.items=gm.mergeEvaluated.items(i,y,r.items,$s.Name)}}}uc.callRef=tg;uc.default=ZU;Object.defineProperty(KS,"__esModule",{value:!0});const XU=ZS,YU=uc,JU=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",XU.default,YU.default];KS.default=JU;var XS={},YS={};Object.defineProperty(YS,"__esModule",{value:!0});const ty=Ue,Ro=ty.operators,ny={maximum:{okStr:"<=",ok:Ro.LTE,fail:Ro.GT},minimum:{okStr:">=",ok:Ro.GTE,fail:Ro.LT},exclusiveMaximum:{okStr:"<",ok:Ro.LT,fail:Ro.GTE},exclusiveMinimum:{okStr:">",ok:Ro.GT,fail:Ro.LTE}},QU={message:({keyword:n,schemaCode:e})=>(0,ty.str)`must be ${ny[n].okStr} ${e}`,params:({keyword:n,schemaCode:e})=>(0,ty._)`{comparison: ${ny[n].okStr}, limit: ${e}}`},e3={keyword:Object.keys(ny),type:"number",schemaType:"number",$data:!0,error:QU,code(n){const{keyword:e,data:t,schemaCode:s}=n;n.fail$data((0,ty._)`${t} ${ny[e].fail} ${s} || isNaN(${t})`)}};YS.default=e3;var JS={};Object.defineProperty(JS,"__esModule",{value:!0});const Ld=Ue,t3={message:({schemaCode:n})=>(0,Ld.str)`must be multiple of ${n}`,params:({schemaCode:n})=>(0,Ld._)`{multipleOf: ${n}}`},n3={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:t3,code(n){const{gen:e,data:t,schemaCode:s,it:i}=n,r=i.opts.multipleOfPrecision,o=e.let("res"),a=r?(0,Ld._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${r}`:(0,Ld._)`${o} !== parseInt(${o})`;n.fail$data((0,Ld._)`(${s} === 0 || (${o} = ${t}/${s}, ${a}))`)}};JS.default=n3;var QS={},e1={};Object.defineProperty(e1,"__esModule",{value:!0});function sP(n){const e=n.length;let t=0,s=0,i;for(;s=55296&&i<=56319&&s(0,el._)`{limit: ${n}}`},o3={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:r3,code(n){const{keyword:e,data:t,schemaCode:s,it:i}=n,r=e==="maxLength"?el.operators.GT:el.operators.LT,o=i.opts.unicode===!1?(0,el._)`${t}.length`:(0,el._)`${(0,s3.useFunc)(n.gen,i3.default)}(${t})`;n.fail$data((0,el._)`${o} ${r} ${s}`)}};QS.default=o3;var t1={};Object.defineProperty(t1,"__esModule",{value:!0});const a3=qe,l3=fe,Jc=Ue,c3={message:({schemaCode:n})=>(0,Jc.str)`must match pattern "${n}"`,params:({schemaCode:n})=>(0,Jc._)`{pattern: ${n}}`},h3={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:c3,code(n){const{gen:e,data:t,$data:s,schema:i,schemaCode:r,it:o}=n,a=o.opts.unicodeRegExp?"u":"";if(s){const{regExp:l}=o.opts.code,c=l.code==="new RegExp"?(0,Jc._)`new RegExp`:(0,l3.useFunc)(e,l),h=e.let("valid");e.try(()=>e.assign(h,(0,Jc._)`${c}(${r}, ${a}).test(${t})`),()=>e.assign(h,!1)),n.fail$data((0,Jc._)`!${h}`)}else{const l=(0,a3.usePattern)(n,i);n.fail$data((0,Jc._)`!${l}.test(${t})`)}}};t1.default=h3;var n1={};Object.defineProperty(n1,"__esModule",{value:!0});const Dd=Ue,u3={message({keyword:n,schemaCode:e}){const t=n==="maxProperties"?"more":"fewer";return(0,Dd.str)`must NOT have ${t} than ${e} properties`},params:({schemaCode:n})=>(0,Dd._)`{limit: ${n}}`},d3={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:u3,code(n){const{keyword:e,data:t,schemaCode:s}=n,i=e==="maxProperties"?Dd.operators.GT:Dd.operators.LT;n.fail$data((0,Dd._)`Object.keys(${t}).length ${i} ${s}`)}};n1.default=d3;var s1={};Object.defineProperty(s1,"__esModule",{value:!0});const Zu=qe,jd=Ue,f3=fe,p3={message:({params:{missingProperty:n}})=>(0,jd.str)`must have required property '${n}'`,params:({params:{missingProperty:n}})=>(0,jd._)`{missingProperty: ${n}}`},m3={keyword:"required",type:"object",schemaType:"array",$data:!0,error:p3,code(n){const{gen:e,schema:t,schemaCode:s,data:i,$data:r,it:o}=n,{opts:a}=o;if(!r&&t.length===0)return;const l=t.length>=a.loopRequired;if(o.allErrors?c():h(),a.strictRequired){const p=n.parentSchema.properties,{definedProperties:m}=n.it;for(const g of t)if((p==null?void 0:p[g])===void 0&&!m.has(g)){const b=o.schemaEnv.baseId+o.errSchemaPath,y=`required property "${g}" is not defined at "${b}" (strictRequired)`;(0,f3.checkStrictMode)(o,y,o.opts.strictRequired)}}function c(){if(l||r)n.block$data(jd.nil,u);else for(const p of t)(0,Zu.checkReportMissingProp)(n,p)}function h(){const p=e.let("missing");if(l||r){const m=e.let("valid",!0);n.block$data(m,()=>d(p,m)),n.ok(m)}else e.if((0,Zu.checkMissingProp)(n,t,p)),(0,Zu.reportMissingProp)(n,p),e.else()}function u(){e.forOf("prop",s,p=>{n.setParams({missingProperty:p}),e.if((0,Zu.noPropertyInData)(e,i,p,a.ownProperties),()=>n.error())})}function d(p,m){n.setParams({missingProperty:p}),e.forOf(p,s,()=>{e.assign(m,(0,Zu.propertyInData)(e,i,p,a.ownProperties)),e.if((0,jd.not)(m),()=>{n.error(),e.break()})},jd.nil)}}};s1.default=m3;var i1={};Object.defineProperty(i1,"__esModule",{value:!0});const Fd=Ue,g3={message({keyword:n,schemaCode:e}){const t=n==="maxItems"?"more":"fewer";return(0,Fd.str)`must NOT have ${t} than ${e} items`},params:({schemaCode:n})=>(0,Fd._)`{limit: ${n}}`},y3={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:g3,code(n){const{keyword:e,data:t,schemaCode:s}=n,i=e==="maxItems"?Fd.operators.GT:Fd.operators.LT;n.fail$data((0,Fd._)`${t}.length ${i} ${s}`)}};i1.default=y3;var r1={},Kp={};Object.defineProperty(Kp,"__esModule",{value:!0});const iP=g0;iP.code='require("ajv/dist/runtime/equal").default';Kp.default=iP;Object.defineProperty(r1,"__esModule",{value:!0});const rb=cn,Tn=Ue,b3=fe,v3=Kp,w3={message:({params:{i:n,j:e}})=>(0,Tn.str)`must NOT have duplicate items (items ## ${e} and ${n} are identical)`,params:({params:{i:n,j:e}})=>(0,Tn._)`{i: ${n}, j: ${e}}`},_3={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:w3,code(n){const{gen:e,data:t,$data:s,schema:i,parentSchema:r,schemaCode:o,it:a}=n;if(!s&&!i)return;const l=e.let("valid"),c=r.items?(0,rb.getSchemaTypes)(r.items):[];n.block$data(l,h,(0,Tn._)`${o} === false`),n.ok(l);function h(){const m=e.let("i",(0,Tn._)`${t}.length`),g=e.let("j");n.setParams({i:m,j:g}),e.assign(l,!0),e.if((0,Tn._)`${m} > 1`,()=>(u()?d:p)(m,g))}function u(){return c.length>0&&!c.some(m=>m==="object"||m==="array")}function d(m,g){const b=e.name("item"),y=(0,rb.checkDataTypes)(c,b,a.opts.strictNumbers,rb.DataType.Wrong),w=e.const("indices",(0,Tn._)`{}`);e.for((0,Tn._)`;${m}--;`,()=>{e.let(b,(0,Tn._)`${t}[${m}]`),e.if(y,(0,Tn._)`continue`),c.length>1&&e.if((0,Tn._)`typeof ${b} == "string"`,(0,Tn._)`${b} += "_"`),e.if((0,Tn._)`typeof ${w}[${b}] == "number"`,()=>{e.assign(g,(0,Tn._)`${w}[${b}]`),n.error(),e.assign(l,!1).break()}).code((0,Tn._)`${w}[${b}] = ${m}`)})}function p(m,g){const b=(0,b3.useFunc)(e,v3.default),y=e.name("outer");e.label(y).for((0,Tn._)`;${m}--;`,()=>e.for((0,Tn._)`${g} = ${m}; ${g}--;`,()=>e.if((0,Tn._)`${b}(${t}[${m}], ${t}[${g}])`,()=>{n.error(),e.assign(l,!1).break(y)})))}}};r1.default=_3;var o1={};Object.defineProperty(o1,"__esModule",{value:!0});const hv=Ue,S3=fe,x3=Kp,k3={message:"must be equal to constant",params:({schemaCode:n})=>(0,hv._)`{allowedValue: ${n}}`},A3={keyword:"const",$data:!0,error:k3,code(n){const{gen:e,data:t,$data:s,schemaCode:i,schema:r}=n;s||r&&typeof r=="object"?n.fail$data((0,hv._)`!${(0,S3.useFunc)(e,x3.default)}(${t}, ${i})`):n.fail((0,hv._)`${r} !== ${t}`)}};o1.default=A3;var a1={};Object.defineProperty(a1,"__esModule",{value:!0});const hd=Ue,E3=fe,C3=Kp,$3={message:"must be equal to one of the allowed values",params:({schemaCode:n})=>(0,hd._)`{allowedValues: ${n}}`},T3={keyword:"enum",schemaType:"array",$data:!0,error:$3,code(n){const{gen:e,data:t,$data:s,schema:i,schemaCode:r,it:o}=n;if(!s&&i.length===0)throw new Error("enum must have non-empty array");const a=i.length>=o.opts.loopEnum;let l;const c=()=>l??(l=(0,E3.useFunc)(e,C3.default));let h;if(a||s)h=e.let("valid"),n.block$data(h,u);else{if(!Array.isArray(i))throw new Error("ajv implementation error");const p=e.const("vSchema",r);h=(0,hd.or)(...i.map((m,g)=>d(p,g)))}n.pass(h);function u(){e.assign(h,!1),e.forOf("v",r,p=>e.if((0,hd._)`${c()}(${t}, ${p})`,()=>e.assign(h,!0).break()))}function d(p,m){const g=i[m];return typeof g=="object"&&g!==null?(0,hd._)`${c()}(${t}, ${p}[${m}])`:(0,hd._)`${t} === ${g}`}}};a1.default=T3;Object.defineProperty(XS,"__esModule",{value:!0});const P3=YS,R3=JS,M3=QS,I3=t1,O3=n1,N3=s1,L3=i1,D3=r1,j3=o1,F3=a1,z3=[P3.default,R3.default,M3.default,I3.default,O3.default,N3.default,L3.default,D3.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},j3.default,F3.default];XS.default=z3;var l1={},Iu={};Object.defineProperty(Iu,"__esModule",{value:!0});Iu.validateAdditionalItems=void 0;const tl=Ue,uv=fe,H3={message:({params:{len:n}})=>(0,tl.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0,tl._)`{limit: ${n}}`},B3={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:H3,code(n){const{parentSchema:e,it:t}=n,{items:s}=e;if(!Array.isArray(s)){(0,uv.checkStrictMode)(t,'"additionalItems" is ignored when "items" is not an array of schemas');return}rP(n,s)}};function rP(n,e){const{gen:t,schema:s,data:i,keyword:r,it:o}=n;o.items=!0;const a=t.const("len",(0,tl._)`${i}.length`);if(s===!1)n.setParams({len:e.length}),n.pass((0,tl._)`${a} <= ${e.length}`);else if(typeof s=="object"&&!(0,uv.alwaysValidSchema)(o,s)){const c=t.var("valid",(0,tl._)`${a} <= ${e.length}`);t.if((0,tl.not)(c),()=>l(c)),n.ok(c)}function l(c){t.forRange("i",e.length,a,h=>{n.subschema({keyword:r,dataProp:h,dataPropType:uv.Type.Num},c),o.allErrors||t.if((0,tl.not)(c),()=>t.break())})}}Iu.validateAdditionalItems=rP;Iu.default=B3;var c1={},Ou={};Object.defineProperty(Ou,"__esModule",{value:!0});Ou.validateTuple=void 0;const Xk=Ue,ng=fe,q3=qe,V3={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(n){const{schema:e,it:t}=n;if(Array.isArray(e))return oP(n,"additionalItems",e);t.items=!0,!(0,ng.alwaysValidSchema)(t,e)&&n.ok((0,q3.validateArray)(n))}};function oP(n,e,t=n.schema){const{gen:s,parentSchema:i,data:r,keyword:o,it:a}=n;h(i),a.opts.unevaluated&&t.length&&a.items!==!0&&(a.items=ng.mergeEvaluated.items(s,t.length,a.items));const l=s.name("valid"),c=s.const("len",(0,Xk._)`${r}.length`);t.forEach((u,d)=>{(0,ng.alwaysValidSchema)(a,u)||(s.if((0,Xk._)`${c} > ${d}`,()=>n.subschema({keyword:o,schemaProp:d,dataProp:d},l)),n.ok(l))});function h(u){const{opts:d,errSchemaPath:p}=a,m=t.length,g=m===u.minItems&&(m===u.maxItems||u[e]===!1);if(d.strictTuples&&!g){const b=`"${o}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,ng.checkStrictMode)(a,b,d.strictTuples)}}}Ou.validateTuple=oP;Ou.default=V3;Object.defineProperty(c1,"__esModule",{value:!0});const U3=Ou,W3={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:n=>(0,U3.validateTuple)(n,"items")};c1.default=W3;var h1={};Object.defineProperty(h1,"__esModule",{value:!0});const Yk=Ue,G3=fe,K3=qe,Z3=Iu,X3={message:({params:{len:n}})=>(0,Yk.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0,Yk._)`{limit: ${n}}`},Y3={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:X3,code(n){const{schema:e,parentSchema:t,it:s}=n,{prefixItems:i}=t;s.items=!0,!(0,G3.alwaysValidSchema)(s,e)&&(i?(0,Z3.validateAdditionalItems)(n,i):n.ok((0,K3.validateArray)(n)))}};h1.default=Y3;var u1={};Object.defineProperty(u1,"__esModule",{value:!0});const ui=Ue,ym=fe,J3={message:({params:{min:n,max:e}})=>e===void 0?(0,ui.str)`must contain at least ${n} valid item(s)`:(0,ui.str)`must contain at least ${n} and no more than ${e} valid item(s)`,params:({params:{min:n,max:e}})=>e===void 0?(0,ui._)`{minContains: ${n}}`:(0,ui._)`{minContains: ${n}, maxContains: ${e}}`},Q3={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:J3,code(n){const{gen:e,schema:t,parentSchema:s,data:i,it:r}=n;let o,a;const{minContains:l,maxContains:c}=s;r.opts.next?(o=l===void 0?1:l,a=c):o=1;const h=e.const("len",(0,ui._)`${i}.length`);if(n.setParams({min:o,max:a}),a===void 0&&o===0){(0,ym.checkStrictMode)(r,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,ym.checkStrictMode)(r,'"minContains" > "maxContains" is always invalid'),n.fail();return}if((0,ym.alwaysValidSchema)(r,t)){let g=(0,ui._)`${h} >= ${o}`;a!==void 0&&(g=(0,ui._)`${g} && ${h} <= ${a}`),n.pass(g);return}r.items=!0;const u=e.name("valid");a===void 0&&o===1?p(u,()=>e.if(u,()=>e.break())):o===0?(e.let(u,!0),a!==void 0&&e.if((0,ui._)`${i}.length > 0`,d)):(e.let(u,!1),d()),n.result(u,()=>n.reset());function d(){const g=e.name("_valid"),b=e.let("count",0);p(g,()=>e.if(g,()=>m(b)))}function p(g,b){e.forRange("i",0,h,y=>{n.subschema({keyword:"contains",dataProp:y,dataPropType:ym.Type.Num,compositeRule:!0},g),b()})}function m(g){e.code((0,ui._)`${g}++`),a===void 0?e.if((0,ui._)`${g} >= ${o}`,()=>e.assign(u,!0).break()):(e.if((0,ui._)`${g} > ${a}`,()=>e.assign(u,!1).break()),o===1?e.assign(u,!0):e.if((0,ui._)`${g} >= ${o}`,()=>e.assign(u,!0)))}}};u1.default=Q3;var aP={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateSchemaDeps=n.validatePropertyDeps=n.error=void 0;const e=Ue,t=fe,s=qe;n.error={message:({params:{property:l,depsCount:c,deps:h}})=>{const u=c===1?"property":"properties";return(0,e.str)`must have ${u} ${h} when property ${l} is present`},params:({params:{property:l,depsCount:c,deps:h,missingProperty:u}})=>(0,e._)`{property: ${l}, + missingProperty: ${u}, + depsCount: ${c}, + deps: ${h}}`};const i={keyword:"dependencies",type:"object",schemaType:"object",error:n.error,code(l){const[c,h]=r(l);o(l,c),a(l,h)}};function r({schema:l}){const c={},h={};for(const u in l){if(u==="__proto__")continue;const d=Array.isArray(l[u])?c:h;d[u]=l[u]}return[c,h]}function o(l,c=l.schema){const{gen:h,data:u,it:d}=l;if(Object.keys(c).length===0)return;const p=h.let("missing");for(const m in c){const g=c[m];if(g.length===0)continue;const b=(0,s.propertyInData)(h,u,m,d.opts.ownProperties);l.setParams({property:m,depsCount:g.length,deps:g.join(", ")}),d.allErrors?h.if(b,()=>{for(const y of g)(0,s.checkReportMissingProp)(l,y)}):(h.if((0,e._)`${b} && (${(0,s.checkMissingProp)(l,g,p)})`),(0,s.reportMissingProp)(l,p),h.else())}}n.validatePropertyDeps=o;function a(l,c=l.schema){const{gen:h,data:u,keyword:d,it:p}=l,m=h.name("valid");for(const g in c)(0,t.alwaysValidSchema)(p,c[g])||(h.if((0,s.propertyInData)(h,u,g,p.opts.ownProperties),()=>{const b=l.subschema({keyword:d,schemaProp:g},m);l.mergeValidEvaluated(b,m)},()=>h.var(m,!0)),l.ok(m))}n.validateSchemaDeps=a,n.default=i})(aP);var d1={};Object.defineProperty(d1,"__esModule",{value:!0});const lP=Ue,eW=fe,tW={message:"property name must be valid",params:({params:n})=>(0,lP._)`{propertyName: ${n.propertyName}}`},nW={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:tW,code(n){const{gen:e,schema:t,data:s,it:i}=n;if((0,eW.alwaysValidSchema)(i,t))return;const r=e.name("valid");e.forIn("key",s,o=>{n.setParams({propertyName:o}),n.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},r),e.if((0,lP.not)(r),()=>{n.error(!0),i.allErrors||e.break()})}),n.ok(r)}};d1.default=nW;var w0={};Object.defineProperty(w0,"__esModule",{value:!0});const bm=qe,Ei=Ue,sW=Nr,vm=fe,iW={message:"must NOT have additional properties",params:({params:n})=>(0,Ei._)`{additionalProperty: ${n.additionalProperty}}`},rW={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:iW,code(n){const{gen:e,schema:t,parentSchema:s,data:i,errsCount:r,it:o}=n;if(!r)throw new Error("ajv implementation error");const{allErrors:a,opts:l}=o;if(o.props=!0,l.removeAdditional!=="all"&&(0,vm.alwaysValidSchema)(o,t))return;const c=(0,bm.allSchemaProperties)(s.properties),h=(0,bm.allSchemaProperties)(s.patternProperties);u(),n.ok((0,Ei._)`${r} === ${sW.default.errors}`);function u(){e.forIn("key",i,b=>{!c.length&&!h.length?m(b):e.if(d(b),()=>m(b))})}function d(b){let y;if(c.length>8){const w=(0,vm.schemaRefOrVal)(o,s.properties,"properties");y=(0,bm.isOwnProperty)(e,w,b)}else c.length?y=(0,Ei.or)(...c.map(w=>(0,Ei._)`${b} === ${w}`)):y=Ei.nil;return h.length&&(y=(0,Ei.or)(y,...h.map(w=>(0,Ei._)`${(0,bm.usePattern)(n,w)}.test(${b})`))),(0,Ei.not)(y)}function p(b){e.code((0,Ei._)`delete ${i}[${b}]`)}function m(b){if(l.removeAdditional==="all"||l.removeAdditional&&t===!1){p(b);return}if(t===!1){n.setParams({additionalProperty:b}),n.error(),a||e.break();return}if(typeof t=="object"&&!(0,vm.alwaysValidSchema)(o,t)){const y=e.name("valid");l.removeAdditional==="failing"?(g(b,y,!1),e.if((0,Ei.not)(y),()=>{n.reset(),p(b)})):(g(b,y),a||e.if((0,Ei.not)(y),()=>e.break()))}}function g(b,y,w){const v={keyword:"additionalProperties",dataProp:b,dataPropType:vm.Type.Str};w===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),n.subschema(v,y)}}};w0.default=rW;var f1={};Object.defineProperty(f1,"__esModule",{value:!0});const oW=Ki,Jk=qe,ob=fe,Qk=w0,aW={keyword:"properties",type:"object",schemaType:"object",code(n){const{gen:e,schema:t,parentSchema:s,data:i,it:r}=n;r.opts.removeAdditional==="all"&&s.additionalProperties===void 0&&Qk.default.code(new oW.KeywordCxt(r,Qk.default,"additionalProperties"));const o=(0,Jk.allSchemaProperties)(t);for(const u of o)r.definedProperties.add(u);r.opts.unevaluated&&o.length&&r.props!==!0&&(r.props=ob.mergeEvaluated.props(e,(0,ob.toHash)(o),r.props));const a=o.filter(u=>!(0,ob.alwaysValidSchema)(r,t[u]));if(a.length===0)return;const l=e.name("valid");for(const u of a)c(u)?h(u):(e.if((0,Jk.propertyInData)(e,i,u,r.opts.ownProperties)),h(u),r.allErrors||e.else().var(l,!0),e.endIf()),n.it.definedProperties.add(u),n.ok(l);function c(u){return r.opts.useDefaults&&!r.compositeRule&&t[u].default!==void 0}function h(u){n.subschema({keyword:"properties",schemaProp:u,dataProp:u},l)}}};f1.default=aW;var p1={};Object.defineProperty(p1,"__esModule",{value:!0});const eA=qe,wm=Ue,tA=fe,nA=fe,lW={keyword:"patternProperties",type:"object",schemaType:"object",code(n){const{gen:e,schema:t,data:s,parentSchema:i,it:r}=n,{opts:o}=r,a=(0,eA.allSchemaProperties)(t),l=a.filter(g=>(0,tA.alwaysValidSchema)(r,t[g]));if(a.length===0||l.length===a.length&&(!r.opts.unevaluated||r.props===!0))return;const c=o.strictSchema&&!o.allowMatchingProperties&&i.properties,h=e.name("valid");r.props!==!0&&!(r.props instanceof wm.Name)&&(r.props=(0,nA.evaluatedPropsToName)(e,r.props));const{props:u}=r;d();function d(){for(const g of a)c&&p(g),r.allErrors?m(g):(e.var(h,!0),m(g),e.if(h))}function p(g){for(const b in c)new RegExp(g).test(b)&&(0,tA.checkStrictMode)(r,`property ${b} matches pattern ${g} (use allowMatchingProperties)`)}function m(g){e.forIn("key",s,b=>{e.if((0,wm._)`${(0,eA.usePattern)(n,g)}.test(${b})`,()=>{const y=l.includes(g);y||n.subschema({keyword:"patternProperties",schemaProp:g,dataProp:b,dataPropType:nA.Type.Str},h),r.opts.unevaluated&&u!==!0?e.assign((0,wm._)`${u}[${b}]`,!0):!y&&!r.allErrors&&e.if((0,wm.not)(h),()=>e.break())})})}}};p1.default=lW;var m1={};Object.defineProperty(m1,"__esModule",{value:!0});const cW=fe,hW={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(n){const{gen:e,schema:t,it:s}=n;if((0,cW.alwaysValidSchema)(s,t)){n.fail();return}const i=e.name("valid");n.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),n.failResult(i,()=>n.reset(),()=>n.error())},error:{message:"must NOT be valid"}};m1.default=hW;var g1={};Object.defineProperty(g1,"__esModule",{value:!0});const uW=qe,dW={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:uW.validateUnion,error:{message:"must match a schema in anyOf"}};g1.default=dW;var y1={};Object.defineProperty(y1,"__esModule",{value:!0});const sg=Ue,fW=fe,pW={message:"must match exactly one schema in oneOf",params:({params:n})=>(0,sg._)`{passingSchemas: ${n.passing}}`},mW={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:pW,code(n){const{gen:e,schema:t,parentSchema:s,it:i}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");if(i.opts.discriminator&&s.discriminator)return;const r=t,o=e.let("valid",!1),a=e.let("passing",null),l=e.name("_valid");n.setParams({passing:a}),e.block(c),n.result(o,()=>n.reset(),()=>n.error(!0));function c(){r.forEach((h,u)=>{let d;(0,fW.alwaysValidSchema)(i,h)?e.var(l,!0):d=n.subschema({keyword:"oneOf",schemaProp:u,compositeRule:!0},l),u>0&&e.if((0,sg._)`${l} && ${o}`).assign(o,!1).assign(a,(0,sg._)`[${a}, ${u}]`).else(),e.if(l,()=>{e.assign(o,!0),e.assign(a,u),d&&n.mergeEvaluated(d,sg.Name)})})}}};y1.default=mW;var b1={};Object.defineProperty(b1,"__esModule",{value:!0});const gW=fe,yW={keyword:"allOf",schemaType:"array",code(n){const{gen:e,schema:t,it:s}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");const i=e.name("valid");t.forEach((r,o)=>{if((0,gW.alwaysValidSchema)(s,r))return;const a=n.subschema({keyword:"allOf",schemaProp:o},i);n.ok(i),n.mergeEvaluated(a)})}};b1.default=yW;var v1={};Object.defineProperty(v1,"__esModule",{value:!0});const sy=Ue,cP=fe,bW={message:({params:n})=>(0,sy.str)`must match "${n.ifClause}" schema`,params:({params:n})=>(0,sy._)`{failingKeyword: ${n.ifClause}}`},vW={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:bW,code(n){const{gen:e,parentSchema:t,it:s}=n;t.then===void 0&&t.else===void 0&&(0,cP.checkStrictMode)(s,'"if" without "then" and "else" is ignored');const i=sA(s,"then"),r=sA(s,"else");if(!i&&!r)return;const o=e.let("valid",!0),a=e.name("_valid");if(l(),n.reset(),i&&r){const h=e.let("ifClause");n.setParams({ifClause:h}),e.if(a,c("then",h),c("else",h))}else i?e.if(a,c("then")):e.if((0,sy.not)(a),c("else"));n.pass(o,()=>n.error(!0));function l(){const h=n.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);n.mergeEvaluated(h)}function c(h,u){return()=>{const d=n.subschema({keyword:h},a);e.assign(o,a),n.mergeValidEvaluated(d,o),u?e.assign(u,(0,sy._)`${h}`):n.setParams({ifClause:h})}}}};function sA(n,e){const t=n.schema[e];return t!==void 0&&!(0,cP.alwaysValidSchema)(n,t)}v1.default=vW;var w1={};Object.defineProperty(w1,"__esModule",{value:!0});const wW=fe,_W={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:n,parentSchema:e,it:t}){e.if===void 0&&(0,wW.checkStrictMode)(t,`"${n}" without "if" is ignored`)}};w1.default=_W;Object.defineProperty(l1,"__esModule",{value:!0});const SW=Iu,xW=c1,kW=Ou,AW=h1,EW=u1,CW=aP,$W=d1,TW=w0,PW=f1,RW=p1,MW=m1,IW=g1,OW=y1,NW=b1,LW=v1,DW=w1;function jW(n=!1){const e=[MW.default,IW.default,OW.default,NW.default,LW.default,DW.default,$W.default,TW.default,CW.default,PW.default,RW.default];return n?e.push(xW.default,AW.default):e.push(SW.default,kW.default),e.push(EW.default),e}l1.default=jW;var _1={},S1={};Object.defineProperty(S1,"__esModule",{value:!0});const Vt=Ue,FW={message:({schemaCode:n})=>(0,Vt.str)`must match format "${n}"`,params:({schemaCode:n})=>(0,Vt._)`{format: ${n}}`},zW={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:FW,code(n,e){const{gen:t,data:s,$data:i,schema:r,schemaCode:o,it:a}=n,{opts:l,errSchemaPath:c,schemaEnv:h,self:u}=a;if(!l.validateFormats)return;i?d():p();function d(){const m=t.scopeValue("formats",{ref:u.formats,code:l.code.formats}),g=t.const("fDef",(0,Vt._)`${m}[${o}]`),b=t.let("fType"),y=t.let("format");t.if((0,Vt._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>t.assign(b,(0,Vt._)`${g}.type || "string"`).assign(y,(0,Vt._)`${g}.validate`),()=>t.assign(b,(0,Vt._)`"string"`).assign(y,g)),n.fail$data((0,Vt.or)(w(),v()));function w(){return l.strictSchema===!1?Vt.nil:(0,Vt._)`${o} && !${y}`}function v(){const x=h.$async?(0,Vt._)`(${g}.async ? await ${y}(${s}) : ${y}(${s}))`:(0,Vt._)`${y}(${s})`,k=(0,Vt._)`(typeof ${y} == "function" ? ${x} : ${y}.test(${s}))`;return(0,Vt._)`${y} && ${y} !== true && ${b} === ${e} && !${k}`}}function p(){const m=u.formats[r];if(!m){w();return}if(m===!0)return;const[g,b,y]=v(m);g===e&&n.pass(x());function w(){if(l.strictSchema===!1){u.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${r}" ignored in schema at path "${c}"`}}function v(k){const E=k instanceof RegExp?(0,Vt.regexpCode)(k):l.code.formats?(0,Vt._)`${l.code.formats}${(0,Vt.getProperty)(r)}`:void 0,T=t.scopeValue("formats",{key:r,ref:k,code:E});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,Vt._)`${T}.validate`]:["string",k,T]}function x(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!h.$async)throw new Error("async format in sync schema");return(0,Vt._)`await ${y}(${s})`}return typeof b=="function"?(0,Vt._)`${y}(${s})`:(0,Vt._)`${y}.test(${s})`}}}};S1.default=zW;Object.defineProperty(_1,"__esModule",{value:!0});const HW=S1,BW=[HW.default];_1.default=BW;var gu={};Object.defineProperty(gu,"__esModule",{value:!0});gu.contentVocabulary=gu.metadataVocabulary=void 0;gu.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];gu.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(GS,"__esModule",{value:!0});const qW=KS,VW=XS,UW=l1,WW=_1,iA=gu,GW=[qW.default,VW.default,(0,UW.default)(),WW.default,iA.metadataVocabulary,iA.contentVocabulary];GS.default=GW;var x1={},_0={};Object.defineProperty(_0,"__esModule",{value:!0});_0.DiscrError=void 0;var rA;(function(n){n.Tag="tag",n.Mapping="mapping"})(rA||(_0.DiscrError=rA={}));Object.defineProperty(x1,"__esModule",{value:!0});const Dc=Ue,dv=_0,oA=Rs,KW=Mu,ZW=fe,XW={message:({params:{discrError:n,tagName:e}})=>n===dv.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:n,tag:e,tagName:t}})=>(0,Dc._)`{error: ${n}, tag: ${t}, tagValue: ${e}}`},YW={keyword:"discriminator",type:"object",schemaType:"object",error:XW,code(n){const{gen:e,data:t,schema:s,parentSchema:i,it:r}=n,{oneOf:o}=i;if(!r.opts.discriminator)throw new Error("discriminator: requires discriminator option");const a=s.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(s.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");const l=e.let("valid",!1),c=e.const("tag",(0,Dc._)`${t}${(0,Dc.getProperty)(a)}`);e.if((0,Dc._)`typeof ${c} == "string"`,()=>h(),()=>n.error(!1,{discrError:dv.DiscrError.Tag,tag:c,tagName:a})),n.ok(l);function h(){const p=d();e.if(!1);for(const m in p)e.elseIf((0,Dc._)`${c} === ${m}`),e.assign(l,u(p[m]));e.else(),n.error(!1,{discrError:dv.DiscrError.Mapping,tag:c,tagName:a}),e.endIf()}function u(p){const m=e.name("valid"),g=n.subschema({keyword:"oneOf",schemaProp:p},m);return n.mergeEvaluated(g,Dc.Name),m}function d(){var p;const m={},g=y(i);let b=!0;for(let x=0;xthis.addVocabulary(m)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const m=this.opts.$data?this.$dataMetaSchema(r,o):r;this.addMetaSchema(m,a,!1),this.refs["http://json-schema.org/schema"]=a}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}e.Ajv=l,n.exports=e=l,n.exports.Ajv=l,Object.defineProperty(e,"__esModule",{value:!0}),e.default=l;var c=Ki;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var h=Ue;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return h._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return h.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return h.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return h.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return h.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return h.CodeGen}});var u=Gp;Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=Mu;Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return d.default}})})(rv,rv.exports);var r4=rv.exports;const o4=G_(r4);var fv={exports:{}},hP={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.formatNames=n.fastFormats=n.fullFormats=void 0;function e(L,B){return{validate:L,compare:B}}n.fullFormats={date:e(r,o),time:e(l(!0),c),"date-time":e(d(!0),p),"iso-time":e(l(),h),"iso-date-time":e(d(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:y,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:j,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:v,int32:{type:"number",validate:E},int64:{type:"number",validate:T},float:{type:"number",validate:O},double:{type:"number",validate:O},password:!0,binary:!0},n.fastFormats={...n.fullFormats,date:e(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:e(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,c),"date-time":e(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":e(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,h),"iso-date-time":e(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,m),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},n.formatNames=Object.keys(n.fullFormats);function t(L){return L%4===0&&(L%100!==0||L%400===0)}const s=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function r(L){const B=s.exec(L);if(!B)return!1;const Z=+B[1],q=+B[2],H=+B[3];return q>=1&&q<=12&&H>=1&&H<=(q===2&&t(Z)?29:i[q])}function o(L,B){if(L&&B)return L>B?1:L23||C>59||L&&!Y)return!1;if(H<=23&&se<=59&&Q<60)return!0;const I=se-C*ye,R=H-z*ye-(I<0?1:0);return(R===23||R===-1)&&(I===59||I===-1)&&Q<61}}function c(L,B){if(!(L&&B))return;const Z=new Date("2020-01-01T"+L).valueOf(),q=new Date("2020-01-01T"+B).valueOf();if(Z&&q)return Z-q}function h(L,B){if(!(L&&B))return;const Z=a.exec(L),q=a.exec(B);if(Z&&q)return L=Z[1]+Z[2]+Z[3],B=q[1]+q[2]+q[3],L>B?1:L=x}function T(L){return Number.isInteger(L)}function O(){return!0}const F=/[^\\]\\Z/;function j(L){if(F.test(L))return!1;try{return new RegExp(L),!0}catch{return!1}}})(hP);var uP={},pv={exports:{}},dP={},Zi={},yu={},Zp={},Fe={},of={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.regexpCode=n.getEsmExportName=n.getProperty=n.safeStringify=n.stringify=n.strConcat=n.addCodeArg=n.str=n._=n.nil=n._Code=n.Name=n.IDENTIFIER=n._CodeOrName=void 0;class e{}n._CodeOrName=e,n.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class t extends e{constructor(w){if(super(),!n.IDENTIFIER.test(w))throw new Error("CodeGen: name must be a valid identifier");this.str=w}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}n.Name=t;class s extends e{constructor(w){super(),this._items=typeof w=="string"?[w]:w}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const w=this._items[0];return w===""||w==='""'}get str(){var w;return(w=this._str)!==null&&w!==void 0?w:this._str=this._items.reduce((v,x)=>`${v}${x}`,"")}get names(){var w;return(w=this._names)!==null&&w!==void 0?w:this._names=this._items.reduce((v,x)=>(x instanceof t&&(v[x.str]=(v[x.str]||0)+1),v),{})}}n._Code=s,n.nil=new s("");function i(y,...w){const v=[y[0]];let x=0;for(;x{if(u.scopePath===void 0)throw new Error(`CodeGen: name "${u}" has no value`);return(0,e._)`${c}${u.scopePath}`})}scopeCode(c=this._values,h,u){return this._reduceValues(c,d=>{if(d.value===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return d.value.code},h,u)}_reduceValues(c,h,u={},d){let p=e.nil;for(const m in c){const g=c[m];if(!g)continue;const b=u[m]=u[m]||new Map;g.forEach(y=>{if(b.has(y))return;b.set(y,s.Started);let w=h(y);if(w){const v=this.opts.es5?n.varKinds.var:n.varKinds.const;p=(0,e._)`${p}${v} ${y} = ${w};${this.opts._n}`}else if(w=d==null?void 0:d(y))p=(0,e._)`${p}${w}${this.opts._n}`;else throw new t(y);b.set(y,s.Completed)})}return p}}n.ValueScope=a})(mv);(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.or=n.and=n.not=n.CodeGen=n.operators=n.varKinds=n.ValueScopeName=n.ValueScope=n.Scope=n.Name=n.regexpCode=n.stringify=n.getProperty=n.nil=n.strConcat=n.str=n._=void 0;const e=of,t=mv;var s=of;Object.defineProperty(n,"_",{enumerable:!0,get:function(){return s._}}),Object.defineProperty(n,"str",{enumerable:!0,get:function(){return s.str}}),Object.defineProperty(n,"strConcat",{enumerable:!0,get:function(){return s.strConcat}}),Object.defineProperty(n,"nil",{enumerable:!0,get:function(){return s.nil}}),Object.defineProperty(n,"getProperty",{enumerable:!0,get:function(){return s.getProperty}}),Object.defineProperty(n,"stringify",{enumerable:!0,get:function(){return s.stringify}}),Object.defineProperty(n,"regexpCode",{enumerable:!0,get:function(){return s.regexpCode}}),Object.defineProperty(n,"Name",{enumerable:!0,get:function(){return s.Name}});var i=mv;Object.defineProperty(n,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(n,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(n,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(n,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),n.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class r{optimizeNodes(){return this}optimizeNames(_,A){return this}}class o extends r{constructor(_,A,N){super(),this.varKind=_,this.name=A,this.rhs=N}render({es5:_,_n:A}){const N=_?t.varKinds.var:this.varKind,W=this.rhs===void 0?"":` = ${this.rhs}`;return`${N} ${this.name}${W};`+A}optimizeNames(_,A){if(_[this.name.str])return this.rhs&&(this.rhs=q(this.rhs,_,A)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class a extends r{constructor(_,A,N){super(),this.lhs=_,this.rhs=A,this.sideEffects=N}render({_n:_}){return`${this.lhs} = ${this.rhs};`+_}optimizeNames(_,A){if(!(this.lhs instanceof e.Name&&!_[this.lhs.str]&&!this.sideEffects))return this.rhs=q(this.rhs,_,A),this}get names(){const _=this.lhs instanceof e.Name?{}:{...this.lhs.names};return Z(_,this.rhs)}}class l extends a{constructor(_,A,N,W){super(_,N,W),this.op=A}render({_n:_}){return`${this.lhs} ${this.op}= ${this.rhs};`+_}}class c extends r{constructor(_){super(),this.label=_,this.names={}}render({_n:_}){return`${this.label}:`+_}}class h extends r{constructor(_){super(),this.label=_,this.names={}}render({_n:_}){return`break${this.label?` ${this.label}`:""};`+_}}class u extends r{constructor(_){super(),this.error=_}render({_n:_}){return`throw ${this.error};`+_}get names(){return this.error.names}}class d extends r{constructor(_){super(),this.code=_}render({_n:_}){return`${this.code};`+_}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(_,A){return this.code=q(this.code,_,A),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class p extends r{constructor(_=[]){super(),this.nodes=_}render(_){return this.nodes.reduce((A,N)=>A+N.render(_),"")}optimizeNodes(){const{nodes:_}=this;let A=_.length;for(;A--;){const N=_[A].optimizeNodes();Array.isArray(N)?_.splice(A,1,...N):N?_[A]=N:_.splice(A,1)}return _.length>0?this:void 0}optimizeNames(_,A){const{nodes:N}=this;let W=N.length;for(;W--;){const X=N[W];X.optimizeNames(_,A)||(H(_,X.names),N.splice(W,1))}return N.length>0?this:void 0}get names(){return this.nodes.reduce((_,A)=>B(_,A.names),{})}}class m extends p{render(_){return"{"+_._n+super.render(_)+"}"+_._n}}class g extends p{}class b extends m{}b.kind="else";class y extends m{constructor(_,A){super(A),this.condition=_}render(_){let A=`if(${this.condition})`+super.render(_);return this.else&&(A+="else "+this.else.render(_)),A}optimizeNodes(){super.optimizeNodes();const _=this.condition;if(_===!0)return this.nodes;let A=this.else;if(A){const N=A.optimizeNodes();A=this.else=Array.isArray(N)?new b(N):N}if(A)return _===!1?A instanceof y?A:A.nodes:this.nodes.length?this:new y(se(_),A instanceof y?[A]:A.nodes);if(!(_===!1||!this.nodes.length))return this}optimizeNames(_,A){var N;if(this.else=(N=this.else)===null||N===void 0?void 0:N.optimizeNames(_,A),!!(super.optimizeNames(_,A)||this.else))return this.condition=q(this.condition,_,A),this}get names(){const _=super.names;return Z(_,this.condition),this.else&&B(_,this.else.names),_}}y.kind="if";class w extends m{}w.kind="for";class v extends w{constructor(_){super(),this.iteration=_}render(_){return`for(${this.iteration})`+super.render(_)}optimizeNames(_,A){if(super.optimizeNames(_,A))return this.iteration=q(this.iteration,_,A),this}get names(){return B(super.names,this.iteration.names)}}class x extends w{constructor(_,A,N,W){super(),this.varKind=_,this.name=A,this.from=N,this.to=W}render(_){const A=_.es5?t.varKinds.var:this.varKind,{name:N,from:W,to:X}=this;return`for(${A} ${N}=${W}; ${N}<${X}; ${N}++)`+super.render(_)}get names(){const _=Z(super.names,this.from);return Z(_,this.to)}}class k extends w{constructor(_,A,N,W){super(),this.loop=_,this.varKind=A,this.name=N,this.iterable=W}render(_){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(_)}optimizeNames(_,A){if(super.optimizeNames(_,A))return this.iterable=q(this.iterable,_,A),this}get names(){return B(super.names,this.iterable.names)}}class E extends m{constructor(_,A,N){super(),this.name=_,this.args=A,this.async=N}render(_){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(_)}}E.kind="func";class T extends p{render(_){return"return "+super.render(_)}}T.kind="return";class O extends m{render(_){let A="try"+super.render(_);return this.catch&&(A+=this.catch.render(_)),this.finally&&(A+=this.finally.render(_)),A}optimizeNodes(){var _,A;return super.optimizeNodes(),(_=this.catch)===null||_===void 0||_.optimizeNodes(),(A=this.finally)===null||A===void 0||A.optimizeNodes(),this}optimizeNames(_,A){var N,W;return super.optimizeNames(_,A),(N=this.catch)===null||N===void 0||N.optimizeNames(_,A),(W=this.finally)===null||W===void 0||W.optimizeNames(_,A),this}get names(){const _=super.names;return this.catch&&B(_,this.catch.names),this.finally&&B(_,this.finally.names),_}}class F extends m{constructor(_){super(),this.error=_}render(_){return`catch(${this.error})`+super.render(_)}}F.kind="catch";class j extends m{render(_){return"finally"+super.render(_)}}j.kind="finally";class L{constructor(_,A={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...A,_n:A.lines?` +`:""},this._extScope=_,this._scope=new t.Scope({parent:_}),this._nodes=[new g]}toString(){return this._root.render(this.opts)}name(_){return this._scope.name(_)}scopeName(_){return this._extScope.name(_)}scopeValue(_,A){const N=this._extScope.value(_,A);return(this._values[N.prefix]||(this._values[N.prefix]=new Set)).add(N),N}getScopeValue(_,A){return this._extScope.getValue(_,A)}scopeRefs(_){return this._extScope.scopeRefs(_,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(_,A,N,W){const X=this._scope.toName(A);return N!==void 0&&W&&(this._constants[X.str]=N),this._leafNode(new o(_,X,N)),X}const(_,A,N){return this._def(t.varKinds.const,_,A,N)}let(_,A,N){return this._def(t.varKinds.let,_,A,N)}var(_,A,N){return this._def(t.varKinds.var,_,A,N)}assign(_,A,N){return this._leafNode(new a(_,A,N))}add(_,A){return this._leafNode(new l(_,n.operators.ADD,A))}code(_){return typeof _=="function"?_():_!==e.nil&&this._leafNode(new d(_)),this}object(..._){const A=["{"];for(const[N,W]of _)A.length>1&&A.push(","),A.push(N),(N!==W||this.opts.es5)&&(A.push(":"),(0,e.addCodeArg)(A,W));return A.push("}"),new e._Code(A)}if(_,A,N){if(this._blockNode(new y(_)),A&&N)this.code(A).else().code(N).endIf();else if(A)this.code(A).endIf();else if(N)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(_){return this._elseNode(new y(_))}else(){return this._elseNode(new b)}endIf(){return this._endBlockNode(y,b)}_for(_,A){return this._blockNode(_),A&&this.code(A).endFor(),this}for(_,A){return this._for(new v(_),A)}forRange(_,A,N,W,X=this.opts.es5?t.varKinds.var:t.varKinds.let){const he=this._scope.toName(_);return this._for(new x(X,he,A,N),()=>W(he))}forOf(_,A,N,W=t.varKinds.const){const X=this._scope.toName(_);if(this.opts.es5){const he=A instanceof e.Name?A:this.var("_arr",A);return this.forRange("_i",0,(0,e._)`${he}.length`,ie=>{this.var(X,(0,e._)`${he}[${ie}]`),N(X)})}return this._for(new k("of",W,X,A),()=>N(X))}forIn(_,A,N,W=this.opts.es5?t.varKinds.var:t.varKinds.const){if(this.opts.ownProperties)return this.forOf(_,(0,e._)`Object.keys(${A})`,N);const X=this._scope.toName(_);return this._for(new k("in",W,X,A),()=>N(X))}endFor(){return this._endBlockNode(w)}label(_){return this._leafNode(new c(_))}break(_){return this._leafNode(new h(_))}return(_){const A=new T;if(this._blockNode(A),this.code(_),A.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(T)}try(_,A,N){if(!A&&!N)throw new Error('CodeGen: "try" without "catch" and "finally"');const W=new O;if(this._blockNode(W),this.code(_),A){const X=this.name("e");this._currNode=W.catch=new F(X),A(X)}return N&&(this._currNode=W.finally=new j,this.code(N)),this._endBlockNode(F,j)}throw(_){return this._leafNode(new u(_))}block(_,A){return this._blockStarts.push(this._nodes.length),_&&this.code(_).endBlock(A),this}endBlock(_){const A=this._blockStarts.pop();if(A===void 0)throw new Error("CodeGen: not in self-balancing block");const N=this._nodes.length-A;if(N<0||_!==void 0&&N!==_)throw new Error(`CodeGen: wrong number of nodes: ${N} vs ${_} expected`);return this._nodes.length=A,this}func(_,A=e.nil,N,W){return this._blockNode(new E(_,A,N)),W&&this.code(W).endFunc(),this}endFunc(){return this._endBlockNode(E)}optimize(_=1){for(;_-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(_){return this._currNode.nodes.push(_),this}_blockNode(_){this._currNode.nodes.push(_),this._nodes.push(_)}_endBlockNode(_,A){const N=this._currNode;if(N instanceof _||A&&N instanceof A)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${A?`${_.kind}/${A.kind}`:_.kind}"`)}_elseNode(_){const A=this._currNode;if(!(A instanceof y))throw new Error('CodeGen: "else" without "if"');return this._currNode=A.else=_,this}get _root(){return this._nodes[0]}get _currNode(){const _=this._nodes;return _[_.length-1]}set _currNode(_){const A=this._nodes;A[A.length-1]=_}}n.CodeGen=L;function B(R,_){for(const A in _)R[A]=(R[A]||0)+(_[A]||0);return R}function Z(R,_){return _ instanceof e._CodeOrName?B(R,_.names):R}function q(R,_,A){if(R instanceof e.Name)return N(R);if(!W(R))return R;return new e._Code(R._items.reduce((X,he)=>(he instanceof e.Name&&(he=N(he)),he instanceof e._Code?X.push(...he._items):X.push(he),X),[]));function N(X){const he=A[X.str];return he===void 0||_[X.str]!==1?X:(delete _[X.str],he)}function W(X){return X instanceof e._Code&&X._items.some(he=>he instanceof e.Name&&_[he.str]===1&&A[he.str]!==void 0)}}function H(R,_){for(const A in _)R[A]=(R[A]||0)-(_[A]||0)}function se(R){return typeof R=="boolean"||typeof R=="number"||R===null?!R:(0,e._)`!${I(R)}`}n.not=se;const Q=C(n.operators.AND);function Y(...R){return R.reduce(Q)}n.and=Y;const ye=C(n.operators.OR);function z(...R){return R.reduce(ye)}n.or=z;function C(R){return(_,A)=>_===e.nil?A:A===e.nil?_:(0,e._)`${I(_)} ${R} ${I(A)}`}function I(R){return R instanceof e.Name?R:(0,e._)`(${R})`}})(Fe);var pe={};Object.defineProperty(pe,"__esModule",{value:!0});pe.checkStrictMode=pe.getErrorPath=pe.Type=pe.useFunc=pe.setEvaluated=pe.evaluatedPropsToName=pe.mergeEvaluated=pe.eachItem=pe.unescapeJsonPointer=pe.escapeJsonPointer=pe.escapeFragment=pe.unescapeFragment=pe.schemaRefOrVal=pe.schemaHasRulesButRef=pe.schemaHasRules=pe.checkUnknownRules=pe.alwaysValidSchema=pe.toHash=void 0;const gt=Fe,a4=of;function l4(n){const e={};for(const t of n)e[t]=!0;return e}pe.toHash=l4;function c4(n,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(fP(n,e),!pP(e,n.self.RULES.all))}pe.alwaysValidSchema=c4;function fP(n,e=n.schema){const{opts:t,self:s}=n;if(!t.strictSchema||typeof e=="boolean")return;const i=s.RULES.keywords;for(const r in e)i[r]||yP(n,`unknown keyword: "${r}"`)}pe.checkUnknownRules=fP;function pP(n,e){if(typeof n=="boolean")return!n;for(const t in n)if(e[t])return!0;return!1}pe.schemaHasRules=pP;function h4(n,e){if(typeof n=="boolean")return!n;for(const t in n)if(t!=="$ref"&&e.all[t])return!0;return!1}pe.schemaHasRulesButRef=h4;function u4({topSchemaRef:n,schemaPath:e},t,s,i){if(!i){if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="string")return(0,gt._)`${t}`}return(0,gt._)`${n}${e}${(0,gt.getProperty)(s)}`}pe.schemaRefOrVal=u4;function d4(n){return mP(decodeURIComponent(n))}pe.unescapeFragment=d4;function f4(n){return encodeURIComponent(k1(n))}pe.escapeFragment=f4;function k1(n){return typeof n=="number"?`${n}`:n.replace(/~/g,"~0").replace(/\//g,"~1")}pe.escapeJsonPointer=k1;function mP(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}pe.unescapeJsonPointer=mP;function p4(n,e){if(Array.isArray(n))for(const t of n)e(t);else e(n)}pe.eachItem=p4;function aA({mergeNames:n,mergeToName:e,mergeValues:t,resultToName:s}){return(i,r,o,a)=>{const l=o===void 0?r:o instanceof gt.Name?(r instanceof gt.Name?n(i,r,o):e(i,r,o),o):r instanceof gt.Name?(e(i,o,r),r):t(r,o);return a===gt.Name&&!(l instanceof gt.Name)?s(i,l):l}}pe.mergeEvaluated={props:aA({mergeNames:(n,e,t)=>n.if((0,gt._)`${t} !== true && ${e} !== undefined`,()=>{n.if((0,gt._)`${e} === true`,()=>n.assign(t,!0),()=>n.assign(t,(0,gt._)`${t} || {}`).code((0,gt._)`Object.assign(${t}, ${e})`))}),mergeToName:(n,e,t)=>n.if((0,gt._)`${t} !== true`,()=>{e===!0?n.assign(t,!0):(n.assign(t,(0,gt._)`${t} || {}`),A1(n,t,e))}),mergeValues:(n,e)=>n===!0?!0:{...n,...e},resultToName:gP}),items:aA({mergeNames:(n,e,t)=>n.if((0,gt._)`${t} !== true && ${e} !== undefined`,()=>n.assign(t,(0,gt._)`${e} === true ? true : ${t} > ${e} ? ${t} : ${e}`)),mergeToName:(n,e,t)=>n.if((0,gt._)`${t} !== true`,()=>n.assign(t,e===!0?!0:(0,gt._)`${t} > ${e} ? ${t} : ${e}`)),mergeValues:(n,e)=>n===!0?!0:Math.max(n,e),resultToName:(n,e)=>n.var("items",e)})};function gP(n,e){if(e===!0)return n.var("props",!0);const t=n.var("props",(0,gt._)`{}`);return e!==void 0&&A1(n,t,e),t}pe.evaluatedPropsToName=gP;function A1(n,e,t){Object.keys(t).forEach(s=>n.assign((0,gt._)`${e}${(0,gt.getProperty)(s)}`,!0))}pe.setEvaluated=A1;const lA={};function m4(n,e){return n.scopeValue("func",{ref:e,code:lA[e.code]||(lA[e.code]=new a4._Code(e.code))})}pe.useFunc=m4;var gv;(function(n){n[n.Num=0]="Num",n[n.Str=1]="Str"})(gv||(pe.Type=gv={}));function g4(n,e,t){if(n instanceof gt.Name){const s=e===gv.Num;return t?s?(0,gt._)`"[" + ${n} + "]"`:(0,gt._)`"['" + ${n} + "']"`:s?(0,gt._)`"/" + ${n}`:(0,gt._)`"/" + ${n}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return t?(0,gt.getProperty)(n).toString():"/"+k1(n)}pe.getErrorPath=g4;function yP(n,e,t=n.opts.strictSchema){if(t){if(e=`strict mode: ${e}`,t===!0)throw new Error(e);n.self.logger.warn(e)}}pe.checkStrictMode=yP;var Lr={};Object.defineProperty(Lr,"__esModule",{value:!0});const Gn=Fe,y4={data:new Gn.Name("data"),valCxt:new Gn.Name("valCxt"),instancePath:new Gn.Name("instancePath"),parentData:new Gn.Name("parentData"),parentDataProperty:new Gn.Name("parentDataProperty"),rootData:new Gn.Name("rootData"),dynamicAnchors:new Gn.Name("dynamicAnchors"),vErrors:new Gn.Name("vErrors"),errors:new Gn.Name("errors"),this:new Gn.Name("this"),self:new Gn.Name("self"),scope:new Gn.Name("scope"),json:new Gn.Name("json"),jsonPos:new Gn.Name("jsonPos"),jsonLen:new Gn.Name("jsonLen"),jsonPart:new Gn.Name("jsonPart")};Lr.default=y4;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.extendErrors=n.resetErrorsCount=n.reportExtraError=n.reportError=n.keyword$DataError=n.keywordError=void 0;const e=Fe,t=pe,s=Lr;n.keywordError={message:({keyword:b})=>(0,e.str)`must pass "${b}" keyword validation`},n.keyword$DataError={message:({keyword:b,schemaType:y})=>y?(0,e.str)`"${b}" keyword must be ${y} ($data)`:(0,e.str)`"${b}" keyword is invalid ($data)`};function i(b,y=n.keywordError,w,v){const{it:x}=b,{gen:k,compositeRule:E,allErrors:T}=x,O=u(b,y,w);v??(E||T)?l(k,O):c(x,(0,e._)`[${O}]`)}n.reportError=i;function r(b,y=n.keywordError,w){const{it:v}=b,{gen:x,compositeRule:k,allErrors:E}=v,T=u(b,y,w);l(x,T),k||E||c(v,s.default.vErrors)}n.reportExtraError=r;function o(b,y){b.assign(s.default.errors,y),b.if((0,e._)`${s.default.vErrors} !== null`,()=>b.if(y,()=>b.assign((0,e._)`${s.default.vErrors}.length`,y),()=>b.assign(s.default.vErrors,null)))}n.resetErrorsCount=o;function a({gen:b,keyword:y,schemaValue:w,data:v,errsCount:x,it:k}){if(x===void 0)throw new Error("ajv implementation error");const E=b.name("err");b.forRange("i",x,s.default.errors,T=>{b.const(E,(0,e._)`${s.default.vErrors}[${T}]`),b.if((0,e._)`${E}.instancePath === undefined`,()=>b.assign((0,e._)`${E}.instancePath`,(0,e.strConcat)(s.default.instancePath,k.errorPath))),b.assign((0,e._)`${E}.schemaPath`,(0,e.str)`${k.errSchemaPath}/${y}`),k.opts.verbose&&(b.assign((0,e._)`${E}.schema`,w),b.assign((0,e._)`${E}.data`,v))})}n.extendErrors=a;function l(b,y){const w=b.const("err",y);b.if((0,e._)`${s.default.vErrors} === null`,()=>b.assign(s.default.vErrors,(0,e._)`[${w}]`),(0,e._)`${s.default.vErrors}.push(${w})`),b.code((0,e._)`${s.default.errors}++`)}function c(b,y){const{gen:w,validateName:v,schemaEnv:x}=b;x.$async?w.throw((0,e._)`new ${b.ValidationError}(${y})`):(w.assign((0,e._)`${v}.errors`,y),w.return(!1))}const h={keyword:new e.Name("keyword"),schemaPath:new e.Name("schemaPath"),params:new e.Name("params"),propertyName:new e.Name("propertyName"),message:new e.Name("message"),schema:new e.Name("schema"),parentSchema:new e.Name("parentSchema")};function u(b,y,w){const{createErrors:v}=b.it;return v===!1?(0,e._)`{}`:d(b,y,w)}function d(b,y,w={}){const{gen:v,it:x}=b,k=[p(x,w),m(b,w)];return g(b,y,k),v.object(...k)}function p({errorPath:b},{instancePath:y}){const w=y?(0,e.str)`${b}${(0,t.getErrorPath)(y,t.Type.Str)}`:b;return[s.default.instancePath,(0,e.strConcat)(s.default.instancePath,w)]}function m({keyword:b,it:{errSchemaPath:y}},{schemaPath:w,parentSchema:v}){let x=v?y:(0,e.str)`${y}/${b}`;return w&&(x=(0,e.str)`${x}${(0,t.getErrorPath)(w,t.Type.Str)}`),[h.schemaPath,x]}function g(b,{params:y,message:w},v){const{keyword:x,data:k,schemaValue:E,it:T}=b,{opts:O,propertyName:F,topSchemaRef:j,schemaPath:L}=T;v.push([h.keyword,x],[h.params,typeof y=="function"?y(b):y||(0,e._)`{}`]),O.messages&&v.push([h.message,typeof w=="function"?w(b):w]),O.verbose&&v.push([h.schema,E],[h.parentSchema,(0,e._)`${j}${L}`],[s.default.data,k]),F&&v.push([h.propertyName,F])}})(Zp);Object.defineProperty(yu,"__esModule",{value:!0});yu.boolOrEmptySchema=yu.topBoolOrEmptySchema=void 0;const b4=Zp,v4=Fe,w4=Lr,_4={message:"boolean schema is false"};function S4(n){const{gen:e,schema:t,validateName:s}=n;t===!1?bP(n,!1):typeof t=="object"&&t.$async===!0?e.return(w4.default.data):(e.assign((0,v4._)`${s}.errors`,null),e.return(!0))}yu.topBoolOrEmptySchema=S4;function x4(n,e){const{gen:t,schema:s}=n;s===!1?(t.var(e,!1),bP(n)):t.var(e,!0)}yu.boolOrEmptySchema=x4;function bP(n,e){const{gen:t,data:s}=n,i={gen:t,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:n};(0,b4.reportError)(i,_4,void 0,e)}var hn={},dc={};Object.defineProperty(dc,"__esModule",{value:!0});dc.getRules=dc.isJSONType=void 0;const k4=["string","number","integer","boolean","null","object","array"],A4=new Set(k4);function E4(n){return typeof n=="string"&&A4.has(n)}dc.isJSONType=E4;function C4(){const n={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...n,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},n.number,n.string,n.array,n.object],post:{rules:[]},all:{},keywords:{}}}dc.getRules=C4;var wo={};Object.defineProperty(wo,"__esModule",{value:!0});wo.shouldUseRule=wo.shouldUseGroup=wo.schemaHasRulesForType=void 0;function $4({schema:n,self:e},t){const s=e.RULES.types[t];return s&&s!==!0&&vP(n,s)}wo.schemaHasRulesForType=$4;function vP(n,e){return e.rules.some(t=>wP(n,t))}wo.shouldUseGroup=vP;function wP(n,e){var t;return n[e.keyword]!==void 0||((t=e.definition.implements)===null||t===void 0?void 0:t.some(s=>n[s]!==void 0))}wo.shouldUseRule=wP;Object.defineProperty(hn,"__esModule",{value:!0});hn.reportTypeError=hn.checkDataTypes=hn.checkDataType=hn.coerceAndCheckDataType=hn.getJSONTypes=hn.getSchemaTypes=hn.DataType=void 0;const T4=dc,P4=wo,R4=Zp,Oe=Fe,_P=pe;var rh;(function(n){n[n.Correct=0]="Correct",n[n.Wrong=1]="Wrong"})(rh||(hn.DataType=rh={}));function M4(n){const e=SP(n.type);if(e.includes("null")){if(n.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&n.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');n.nullable===!0&&e.push("null")}return e}hn.getSchemaTypes=M4;function SP(n){const e=Array.isArray(n)?n:n?[n]:[];if(e.every(T4.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}hn.getJSONTypes=SP;function I4(n,e){const{gen:t,data:s,opts:i}=n,r=O4(e,i.coerceTypes),o=e.length>0&&!(r.length===0&&e.length===1&&(0,P4.schemaHasRulesForType)(n,e[0]));if(o){const a=E1(e,s,i.strictNumbers,rh.Wrong);t.if(a,()=>{r.length?N4(n,e,r):C1(n)})}return o}hn.coerceAndCheckDataType=I4;const xP=new Set(["string","number","integer","boolean","null"]);function O4(n,e){return e?n.filter(t=>xP.has(t)||e==="array"&&t==="array"):[]}function N4(n,e,t){const{gen:s,data:i,opts:r}=n,o=s.let("dataType",(0,Oe._)`typeof ${i}`),a=s.let("coerced",(0,Oe._)`undefined`);r.coerceTypes==="array"&&s.if((0,Oe._)`${o} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>s.assign(i,(0,Oe._)`${i}[0]`).assign(o,(0,Oe._)`typeof ${i}`).if(E1(e,i,r.strictNumbers),()=>s.assign(a,i))),s.if((0,Oe._)`${a} !== undefined`);for(const c of t)(xP.has(c)||c==="array"&&r.coerceTypes==="array")&&l(c);s.else(),C1(n),s.endIf(),s.if((0,Oe._)`${a} !== undefined`,()=>{s.assign(i,a),L4(n,a)});function l(c){switch(c){case"string":s.elseIf((0,Oe._)`${o} == "number" || ${o} == "boolean"`).assign(a,(0,Oe._)`"" + ${i}`).elseIf((0,Oe._)`${i} === null`).assign(a,(0,Oe._)`""`);return;case"number":s.elseIf((0,Oe._)`${o} == "boolean" || ${i} === null + || (${o} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,Oe._)`+${i}`);return;case"integer":s.elseIf((0,Oe._)`${o} === "boolean" || ${i} === null + || (${o} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,Oe._)`+${i}`);return;case"boolean":s.elseIf((0,Oe._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,Oe._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":s.elseIf((0,Oe._)`${i} === "" || ${i} === 0 || ${i} === false`),s.assign(a,null);return;case"array":s.elseIf((0,Oe._)`${o} === "string" || ${o} === "number" + || ${o} === "boolean" || ${i} === null`).assign(a,(0,Oe._)`[${i}]`)}}}function L4({gen:n,parentData:e,parentDataProperty:t},s){n.if((0,Oe._)`${e} !== undefined`,()=>n.assign((0,Oe._)`${e}[${t}]`,s))}function yv(n,e,t,s=rh.Correct){const i=s===rh.Correct?Oe.operators.EQ:Oe.operators.NEQ;let r;switch(n){case"null":return(0,Oe._)`${e} ${i} null`;case"array":r=(0,Oe._)`Array.isArray(${e})`;break;case"object":r=(0,Oe._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":r=o((0,Oe._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":r=o();break;default:return(0,Oe._)`typeof ${e} ${i} ${n}`}return s===rh.Correct?r:(0,Oe.not)(r);function o(a=Oe.nil){return(0,Oe.and)((0,Oe._)`typeof ${e} == "number"`,a,t?(0,Oe._)`isFinite(${e})`:Oe.nil)}}hn.checkDataType=yv;function E1(n,e,t,s){if(n.length===1)return yv(n[0],e,t,s);let i;const r=(0,_P.toHash)(n);if(r.array&&r.object){const o=(0,Oe._)`typeof ${e} != "object"`;i=r.null?o:(0,Oe._)`!${e} || ${o}`,delete r.null,delete r.array,delete r.object}else i=Oe.nil;r.number&&delete r.integer;for(const o in r)i=(0,Oe.and)(i,yv(o,e,t,s));return i}hn.checkDataTypes=E1;const D4={message:({schema:n})=>`must be ${n}`,params:({schema:n,schemaValue:e})=>typeof n=="string"?(0,Oe._)`{type: ${n}}`:(0,Oe._)`{type: ${e}}`};function C1(n){const e=j4(n);(0,R4.reportError)(e,D4)}hn.reportTypeError=C1;function j4(n){const{gen:e,data:t,schema:s}=n,i=(0,_P.schemaRefOrVal)(n,s,"type");return{gen:e,keyword:"type",data:t,schema:s.type,schemaCode:i,schemaValue:i,parentSchema:s,params:{},it:n}}var S0={};Object.defineProperty(S0,"__esModule",{value:!0});S0.assignDefaults=void 0;const Ic=Fe,F4=pe;function z4(n,e){const{properties:t,items:s}=n.schema;if(e==="object"&&t)for(const i in t)cA(n,i,t[i].default);else e==="array"&&Array.isArray(s)&&s.forEach((i,r)=>cA(n,r,i.default))}S0.assignDefaults=z4;function cA(n,e,t){const{gen:s,compositeRule:i,data:r,opts:o}=n;if(t===void 0)return;const a=(0,Ic._)`${r}${(0,Ic.getProperty)(e)}`;if(i){(0,F4.checkStrictMode)(n,`default is ignored for: ${a}`);return}let l=(0,Ic._)`${a} === undefined`;o.useDefaults==="empty"&&(l=(0,Ic._)`${l} || ${a} === null || ${a} === ""`),s.if(l,(0,Ic._)`${a} = ${(0,Ic.stringify)(t)}`)}var $r={},Ve={};Object.defineProperty(Ve,"__esModule",{value:!0});Ve.validateUnion=Ve.validateArray=Ve.usePattern=Ve.callValidateCode=Ve.schemaProperties=Ve.allSchemaProperties=Ve.noPropertyInData=Ve.propertyInData=Ve.isOwnProperty=Ve.hasPropFunc=Ve.reportMissingProp=Ve.checkMissingProp=Ve.checkReportMissingProp=void 0;const At=Fe,$1=pe,Mo=Lr,H4=pe;function B4(n,e){const{gen:t,data:s,it:i}=n;t.if(P1(t,s,e,i.opts.ownProperties),()=>{n.setParams({missingProperty:(0,At._)`${e}`},!0),n.error()})}Ve.checkReportMissingProp=B4;function q4({gen:n,data:e,it:{opts:t}},s,i){return(0,At.or)(...s.map(r=>(0,At.and)(P1(n,e,r,t.ownProperties),(0,At._)`${i} = ${r}`)))}Ve.checkMissingProp=q4;function V4(n,e){n.setParams({missingProperty:e},!0),n.error()}Ve.reportMissingProp=V4;function kP(n){return n.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,At._)`Object.prototype.hasOwnProperty`})}Ve.hasPropFunc=kP;function T1(n,e,t){return(0,At._)`${kP(n)}.call(${e}, ${t})`}Ve.isOwnProperty=T1;function U4(n,e,t,s){const i=(0,At._)`${e}${(0,At.getProperty)(t)} !== undefined`;return s?(0,At._)`${i} && ${T1(n,e,t)}`:i}Ve.propertyInData=U4;function P1(n,e,t,s){const i=(0,At._)`${e}${(0,At.getProperty)(t)} === undefined`;return s?(0,At.or)(i,(0,At.not)(T1(n,e,t))):i}Ve.noPropertyInData=P1;function AP(n){return n?Object.keys(n).filter(e=>e!=="__proto__"):[]}Ve.allSchemaProperties=AP;function W4(n,e){return AP(e).filter(t=>!(0,$1.alwaysValidSchema)(n,e[t]))}Ve.schemaProperties=W4;function G4({schemaCode:n,data:e,it:{gen:t,topSchemaRef:s,schemaPath:i,errorPath:r},it:o},a,l,c){const h=c?(0,At._)`${n}, ${e}, ${s}${i}`:e,u=[[Mo.default.instancePath,(0,At.strConcat)(Mo.default.instancePath,r)],[Mo.default.parentData,o.parentData],[Mo.default.parentDataProperty,o.parentDataProperty],[Mo.default.rootData,Mo.default.rootData]];o.opts.dynamicRef&&u.push([Mo.default.dynamicAnchors,Mo.default.dynamicAnchors]);const d=(0,At._)`${h}, ${t.object(...u)}`;return l!==At.nil?(0,At._)`${a}.call(${l}, ${d})`:(0,At._)`${a}(${d})`}Ve.callValidateCode=G4;const K4=(0,At._)`new RegExp`;function Z4({gen:n,it:{opts:e}},t){const s=e.unicodeRegExp?"u":"",{regExp:i}=e.code,r=i(t,s);return n.scopeValue("pattern",{key:r.toString(),ref:r,code:(0,At._)`${i.code==="new RegExp"?K4:(0,H4.useFunc)(n,i)}(${t}, ${s})`})}Ve.usePattern=Z4;function X4(n){const{gen:e,data:t,keyword:s,it:i}=n,r=e.name("valid");if(i.allErrors){const a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(r,!0),o(()=>e.break()),r;function o(a){const l=e.const("len",(0,At._)`${t}.length`);e.forRange("i",0,l,c=>{n.subschema({keyword:s,dataProp:c,dataPropType:$1.Type.Num},r),e.if((0,At.not)(r),a)})}}Ve.validateArray=X4;function Y4(n){const{gen:e,schema:t,keyword:s,it:i}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");if(t.some(l=>(0,$1.alwaysValidSchema)(i,l))&&!i.opts.unevaluated)return;const o=e.let("valid",!1),a=e.name("_valid");e.block(()=>t.forEach((l,c)=>{const h=n.subschema({keyword:s,schemaProp:c,compositeRule:!0},a);e.assign(o,(0,At._)`${o} || ${a}`),n.mergeValidEvaluated(h,a)||e.if((0,At.not)(o))})),n.result(o,()=>n.reset(),()=>n.error(!0))}Ve.validateUnion=Y4;Object.defineProperty($r,"__esModule",{value:!0});$r.validateKeywordUsage=$r.validSchemaType=$r.funcKeywordCode=$r.macroKeywordCode=void 0;const hs=Fe,nl=Lr,J4=Ve,Q4=Zp;function e5(n,e){const{gen:t,keyword:s,schema:i,parentSchema:r,it:o}=n,a=e.macro.call(o.self,i,r,o),l=EP(t,s,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);const c=t.name("valid");n.subschema({schema:a,schemaPath:hs.nil,errSchemaPath:`${o.errSchemaPath}/${s}`,topSchemaRef:l,compositeRule:!0},c),n.pass(c,()=>n.error(!0))}$r.macroKeywordCode=e5;function t5(n,e){var t;const{gen:s,keyword:i,schema:r,parentSchema:o,$data:a,it:l}=n;s5(l,e);const c=!a&&e.compile?e.compile.call(l.self,r,o,l):e.validate,h=EP(s,i,c),u=s.let("valid");n.block$data(u,d),n.ok((t=e.valid)!==null&&t!==void 0?t:u);function d(){if(e.errors===!1)g(),e.modifying&&hA(n),b(()=>n.error());else{const y=e.async?p():m();e.modifying&&hA(n),b(()=>n5(n,y))}}function p(){const y=s.let("ruleErrs",null);return s.try(()=>g((0,hs._)`await `),w=>s.assign(u,!1).if((0,hs._)`${w} instanceof ${l.ValidationError}`,()=>s.assign(y,(0,hs._)`${w}.errors`),()=>s.throw(w))),y}function m(){const y=(0,hs._)`${h}.errors`;return s.assign(y,null),g(hs.nil),y}function g(y=e.async?(0,hs._)`await `:hs.nil){const w=l.opts.passContext?nl.default.this:nl.default.self,v=!("compile"in e&&!a||e.schema===!1);s.assign(u,(0,hs._)`${y}${(0,J4.callValidateCode)(n,h,w,v)}`,e.modifying)}function b(y){var w;s.if((0,hs.not)((w=e.valid)!==null&&w!==void 0?w:u),y)}}$r.funcKeywordCode=t5;function hA(n){const{gen:e,data:t,it:s}=n;e.if(s.parentData,()=>e.assign(t,(0,hs._)`${s.parentData}[${s.parentDataProperty}]`))}function n5(n,e){const{gen:t}=n;t.if((0,hs._)`Array.isArray(${e})`,()=>{t.assign(nl.default.vErrors,(0,hs._)`${nl.default.vErrors} === null ? ${e} : ${nl.default.vErrors}.concat(${e})`).assign(nl.default.errors,(0,hs._)`${nl.default.vErrors}.length`),(0,Q4.extendErrors)(n)},()=>n.error())}function s5({schemaEnv:n},e){if(e.async&&!n.$async)throw new Error("async keyword in sync schema")}function EP(n,e,t){if(t===void 0)throw new Error(`keyword "${e}" failed to compile`);return n.scopeValue("keyword",typeof t=="function"?{ref:t}:{ref:t,code:(0,hs.stringify)(t)})}function i5(n,e,t=!1){return!e.length||e.some(s=>s==="array"?Array.isArray(n):s==="object"?n&&typeof n=="object"&&!Array.isArray(n):typeof n==s||t&&typeof n>"u")}$r.validSchemaType=i5;function r5({schema:n,opts:e,self:t,errSchemaPath:s},i,r){if(Array.isArray(i.keyword)?!i.keyword.includes(r):i.keyword!==r)throw new Error("ajv implementation error");const o=i.dependencies;if(o!=null&&o.some(a=>!Object.prototype.hasOwnProperty.call(n,a)))throw new Error(`parent schema must have dependencies of ${r}: ${o.join(",")}`);if(i.validateSchema&&!i.validateSchema(n[r])){const l=`keyword "${r}" value is invalid at path "${s}": `+t.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")t.logger.error(l);else throw new Error(l)}}$r.validateKeywordUsage=r5;var ka={};Object.defineProperty(ka,"__esModule",{value:!0});ka.extendSubschemaMode=ka.extendSubschemaData=ka.getSubschema=void 0;const kr=Fe,CP=pe;function o5(n,{keyword:e,schemaProp:t,schema:s,schemaPath:i,errSchemaPath:r,topSchemaRef:o}){if(e!==void 0&&s!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){const a=n.schema[e];return t===void 0?{schema:a,schemaPath:(0,kr._)`${n.schemaPath}${(0,kr.getProperty)(e)}`,errSchemaPath:`${n.errSchemaPath}/${e}`}:{schema:a[t],schemaPath:(0,kr._)`${n.schemaPath}${(0,kr.getProperty)(e)}${(0,kr.getProperty)(t)}`,errSchemaPath:`${n.errSchemaPath}/${e}/${(0,CP.escapeFragment)(t)}`}}if(s!==void 0){if(i===void 0||r===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:i,topSchemaRef:o,errSchemaPath:r}}throw new Error('either "keyword" or "schema" must be passed')}ka.getSubschema=o5;function a5(n,e,{dataProp:t,dataPropType:s,data:i,dataTypes:r,propertyName:o}){if(i!==void 0&&t!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:a}=e;if(t!==void 0){const{errorPath:c,dataPathArr:h,opts:u}=e,d=a.let("data",(0,kr._)`${e.data}${(0,kr.getProperty)(t)}`,!0);l(d),n.errorPath=(0,kr.str)`${c}${(0,CP.getErrorPath)(t,s,u.jsPropertySyntax)}`,n.parentDataProperty=(0,kr._)`${t}`,n.dataPathArr=[...h,n.parentDataProperty]}if(i!==void 0){const c=i instanceof kr.Name?i:a.let("data",i,!0);l(c),o!==void 0&&(n.propertyName=o)}r&&(n.dataTypes=r);function l(c){n.data=c,n.dataLevel=e.dataLevel+1,n.dataTypes=[],e.definedProperties=new Set,n.parentData=e.data,n.dataNames=[...e.dataNames,c]}}ka.extendSubschemaData=a5;function l5(n,{jtdDiscriminator:e,jtdMetadata:t,compositeRule:s,createErrors:i,allErrors:r}){s!==void 0&&(n.compositeRule=s),i!==void 0&&(n.createErrors=i),r!==void 0&&(n.allErrors=r),n.jtdDiscriminator=e,n.jtdMetadata=t}ka.extendSubschemaMode=l5;var jn={},$P={exports:{}},va=$P.exports=function(n,e,t){typeof e=="function"&&(t=e,e={}),t=e.cb||t;var s=typeof t=="function"?t:t.pre||function(){},i=t.post||function(){};ig(e,s,i,n,"",n)};va.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};va.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};va.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};va.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function ig(n,e,t,s,i,r,o,a,l,c){if(s&&typeof s=="object"&&!Array.isArray(s)){e(s,i,r,o,a,l,c);for(var h in s){var u=s[h];if(Array.isArray(u)){if(h in va.arrayKeywords)for(var d=0;de+=TP(s)),e===1/0))return 1/0}return e}function PP(n,e="",t){t!==!1&&(e=oh(e));const s=n.parse(e);return RP(n,s)}jn.getFullPath=PP;function RP(n,e){return n.serialize(e).split("#")[0]+"#"}jn._getFullPath=RP;const y5=/#\/?$/;function oh(n){return n?n.replace(y5,""):""}jn.normalizeId=oh;function b5(n,e,t){return t=oh(t),n.resolve(e,t)}jn.resolveUrl=b5;const v5=/^[a-z_][-a-z0-9._]*$/i;function w5(n,e){if(typeof n=="boolean")return{};const{schemaId:t,uriResolver:s}=this.opts,i=oh(n[t]||e),r={"":i},o=PP(s,i,!1),a={},l=new Set;return f5(n,{allKeys:!0},(u,d,p,m)=>{if(m===void 0)return;const g=o+d;let b=r[m];typeof u[t]=="string"&&(b=y.call(this,u[t])),w.call(this,u.$anchor),w.call(this,u.$dynamicAnchor),r[d]=b;function y(v){const x=this.opts.uriResolver.resolve;if(v=oh(b?x(b,v):v),l.has(v))throw h(v);l.add(v);let k=this.refs[v];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?c(u,k.schema,v):v!==oh(g)&&(v[0]==="#"?(c(u,a[v],v),a[v]=u):this.refs[v]=g),v}function w(v){if(typeof v=="string"){if(!v5.test(v))throw new Error(`invalid anchor "${v}"`);y.call(this,`#${v}`)}}}),a;function c(u,d,p){if(d!==void 0&&!d5(u,d))throw h(p)}function h(u){return new Error(`reference "${u}" resolves to more than one schema`)}}jn.getSchemaRefs=w5;Object.defineProperty(Zi,"__esModule",{value:!0});Zi.getData=Zi.KeywordCxt=Zi.validateFunctionCode=void 0;const MP=yu,uA=hn,R1=wo,iy=hn,_5=S0,zd=$r,ab=ka,_e=Fe,Ce=Lr,S5=jn,_o=pe,Xu=Zp;function x5(n){if(NP(n)&&(LP(n),OP(n))){E5(n);return}IP(n,()=>(0,MP.topBoolOrEmptySchema)(n))}Zi.validateFunctionCode=x5;function IP({gen:n,validateName:e,schema:t,schemaEnv:s,opts:i},r){i.code.es5?n.func(e,(0,_e._)`${Ce.default.data}, ${Ce.default.valCxt}`,s.$async,()=>{n.code((0,_e._)`"use strict"; ${dA(t,i)}`),A5(n,i),n.code(r)}):n.func(e,(0,_e._)`${Ce.default.data}, ${k5(i)}`,s.$async,()=>n.code(dA(t,i)).code(r))}function k5(n){return(0,_e._)`{${Ce.default.instancePath}="", ${Ce.default.parentData}, ${Ce.default.parentDataProperty}, ${Ce.default.rootData}=${Ce.default.data}${n.dynamicRef?(0,_e._)`, ${Ce.default.dynamicAnchors}={}`:_e.nil}}={}`}function A5(n,e){n.if(Ce.default.valCxt,()=>{n.var(Ce.default.instancePath,(0,_e._)`${Ce.default.valCxt}.${Ce.default.instancePath}`),n.var(Ce.default.parentData,(0,_e._)`${Ce.default.valCxt}.${Ce.default.parentData}`),n.var(Ce.default.parentDataProperty,(0,_e._)`${Ce.default.valCxt}.${Ce.default.parentDataProperty}`),n.var(Ce.default.rootData,(0,_e._)`${Ce.default.valCxt}.${Ce.default.rootData}`),e.dynamicRef&&n.var(Ce.default.dynamicAnchors,(0,_e._)`${Ce.default.valCxt}.${Ce.default.dynamicAnchors}`)},()=>{n.var(Ce.default.instancePath,(0,_e._)`""`),n.var(Ce.default.parentData,(0,_e._)`undefined`),n.var(Ce.default.parentDataProperty,(0,_e._)`undefined`),n.var(Ce.default.rootData,Ce.default.data),e.dynamicRef&&n.var(Ce.default.dynamicAnchors,(0,_e._)`{}`)})}function E5(n){const{schema:e,opts:t,gen:s}=n;IP(n,()=>{t.$comment&&e.$comment&&jP(n),R5(n),s.let(Ce.default.vErrors,null),s.let(Ce.default.errors,0),t.unevaluated&&C5(n),DP(n),O5(n)})}function C5(n){const{gen:e,validateName:t}=n;n.evaluated=e.const("evaluated",(0,_e._)`${t}.evaluated`),e.if((0,_e._)`${n.evaluated}.dynamicProps`,()=>e.assign((0,_e._)`${n.evaluated}.props`,(0,_e._)`undefined`)),e.if((0,_e._)`${n.evaluated}.dynamicItems`,()=>e.assign((0,_e._)`${n.evaluated}.items`,(0,_e._)`undefined`))}function dA(n,e){const t=typeof n=="object"&&n[e.schemaId];return t&&(e.code.source||e.code.process)?(0,_e._)`/*# sourceURL=${t} */`:_e.nil}function $5(n,e){if(NP(n)&&(LP(n),OP(n))){T5(n,e);return}(0,MP.boolOrEmptySchema)(n,e)}function OP({schema:n,self:e}){if(typeof n=="boolean")return!n;for(const t in n)if(e.RULES.all[t])return!0;return!1}function NP(n){return typeof n.schema!="boolean"}function T5(n,e){const{schema:t,gen:s,opts:i}=n;i.$comment&&t.$comment&&jP(n),M5(n),I5(n);const r=s.const("_errs",Ce.default.errors);DP(n,r),s.var(e,(0,_e._)`${r} === ${Ce.default.errors}`)}function LP(n){(0,_o.checkUnknownRules)(n),P5(n)}function DP(n,e){if(n.opts.jtd)return fA(n,[],!1,e);const t=(0,uA.getSchemaTypes)(n.schema),s=(0,uA.coerceAndCheckDataType)(n,t);fA(n,t,!s,e)}function P5(n){const{schema:e,errSchemaPath:t,opts:s,self:i}=n;e.$ref&&s.ignoreKeywordsWithRef&&(0,_o.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${t}"`)}function R5(n){const{schema:e,opts:t}=n;e.default!==void 0&&t.useDefaults&&t.strictSchema&&(0,_o.checkStrictMode)(n,"default is ignored in the schema root")}function M5(n){const e=n.schema[n.opts.schemaId];e&&(n.baseId=(0,S5.resolveUrl)(n.opts.uriResolver,n.baseId,e))}function I5(n){if(n.schema.$async&&!n.schemaEnv.$async)throw new Error("async schema in sync schema")}function jP({gen:n,schemaEnv:e,schema:t,errSchemaPath:s,opts:i}){const r=t.$comment;if(i.$comment===!0)n.code((0,_e._)`${Ce.default.self}.logger.log(${r})`);else if(typeof i.$comment=="function"){const o=(0,_e.str)`${s}/$comment`,a=n.scopeValue("root",{ref:e.root});n.code((0,_e._)`${Ce.default.self}.opts.$comment(${r}, ${o}, ${a}.schema)`)}}function O5(n){const{gen:e,schemaEnv:t,validateName:s,ValidationError:i,opts:r}=n;t.$async?e.if((0,_e._)`${Ce.default.errors} === 0`,()=>e.return(Ce.default.data),()=>e.throw((0,_e._)`new ${i}(${Ce.default.vErrors})`)):(e.assign((0,_e._)`${s}.errors`,Ce.default.vErrors),r.unevaluated&&N5(n),e.return((0,_e._)`${Ce.default.errors} === 0`))}function N5({gen:n,evaluated:e,props:t,items:s}){t instanceof _e.Name&&n.assign((0,_e._)`${e}.props`,t),s instanceof _e.Name&&n.assign((0,_e._)`${e}.items`,s)}function fA(n,e,t,s){const{gen:i,schema:r,data:o,allErrors:a,opts:l,self:c}=n,{RULES:h}=c;if(r.$ref&&(l.ignoreKeywordsWithRef||!(0,_o.schemaHasRulesButRef)(r,h))){i.block(()=>HP(n,"$ref",h.all.$ref.definition));return}l.jtd||L5(n,e),i.block(()=>{for(const d of h.rules)u(d);u(h.post)});function u(d){(0,R1.shouldUseGroup)(r,d)&&(d.type?(i.if((0,iy.checkDataType)(d.type,o,l.strictNumbers)),pA(n,d),e.length===1&&e[0]===d.type&&t&&(i.else(),(0,iy.reportTypeError)(n)),i.endIf()):pA(n,d),a||i.if((0,_e._)`${Ce.default.errors} === ${s||0}`))}}function pA(n,e){const{gen:t,schema:s,opts:{useDefaults:i}}=n;i&&(0,_5.assignDefaults)(n,e.type),t.block(()=>{for(const r of e.rules)(0,R1.shouldUseRule)(s,r)&&HP(n,r.keyword,r.definition,e.type)})}function L5(n,e){n.schemaEnv.meta||!n.opts.strictTypes||(D5(n,e),n.opts.allowUnionTypes||j5(n,e),F5(n,n.dataTypes))}function D5(n,e){if(e.length){if(!n.dataTypes.length){n.dataTypes=e;return}e.forEach(t=>{FP(n.dataTypes,t)||M1(n,`type "${t}" not allowed by context "${n.dataTypes.join(",")}"`)}),H5(n,e)}}function j5(n,e){e.length>1&&!(e.length===2&&e.includes("null"))&&M1(n,"use allowUnionTypes to allow union type keyword")}function F5(n,e){const t=n.self.RULES.all;for(const s in t){const i=t[s];if(typeof i=="object"&&(0,R1.shouldUseRule)(n.schema,i)){const{type:r}=i.definition;r.length&&!r.some(o=>z5(e,o))&&M1(n,`missing type "${r.join(",")}" for keyword "${s}"`)}}}function z5(n,e){return n.includes(e)||e==="number"&&n.includes("integer")}function FP(n,e){return n.includes(e)||e==="integer"&&n.includes("number")}function H5(n,e){const t=[];for(const s of n.dataTypes)FP(e,s)?t.push(s):e.includes("integer")&&s==="number"&&t.push("integer");n.dataTypes=t}function M1(n,e){const t=n.schemaEnv.baseId+n.errSchemaPath;e+=` at "${t}" (strictTypes)`,(0,_o.checkStrictMode)(n,e,n.opts.strictTypes)}class zP{constructor(e,t,s){if((0,zd.validateKeywordUsage)(e,t,s),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=s,this.data=e.data,this.schema=e.schema[s],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,_o.schemaRefOrVal)(e,this.schema,s,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",BP(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,zd.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${s} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const("_errs",Ce.default.errors))}result(e,t,s){this.failResult((0,_e.not)(e),t,s)}failResult(e,t,s){this.gen.if(e),s?s():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,_e.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail((0,_e._)`${t} !== undefined && (${(0,_e.or)(this.invalid$data(),e)})`)}error(e,t,s){if(t){this.setParams(t),this._error(e,s),this.setParams({});return}this._error(e,s)}_error(e,t){(e?Xu.reportExtraError:Xu.reportError)(this,this.def.error,t)}$dataError(){(0,Xu.reportError)(this,this.def.$dataError||Xu.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Xu.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,s=_e.nil){this.gen.block(()=>{this.check$data(e,s),t()})}check$data(e=_e.nil,t=_e.nil){if(!this.$data)return;const{gen:s,schemaCode:i,schemaType:r,def:o}=this;s.if((0,_e.or)((0,_e._)`${i} === undefined`,t)),e!==_e.nil&&s.assign(e,!0),(r.length||o.validateSchema)&&(s.elseIf(this.invalid$data()),this.$dataError(),e!==_e.nil&&s.assign(e,!1)),s.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:s,def:i,it:r}=this;return(0,_e.or)(o(),a());function o(){if(s.length){if(!(t instanceof _e.Name))throw new Error("ajv implementation error");const l=Array.isArray(s)?s:[s];return(0,_e._)`${(0,iy.checkDataTypes)(l,t,r.opts.strictNumbers,iy.DataType.Wrong)}`}return _e.nil}function a(){if(i.validateSchema){const l=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,_e._)`!${l}(${t})`}return _e.nil}}subschema(e,t){const s=(0,ab.getSubschema)(this.it,e);(0,ab.extendSubschemaData)(s,this.it,e),(0,ab.extendSubschemaMode)(s,e);const i={...this.it,...s,items:void 0,props:void 0};return $5(i,t),i}mergeEvaluated(e,t){const{it:s,gen:i}=this;s.opts.unevaluated&&(s.props!==!0&&e.props!==void 0&&(s.props=_o.mergeEvaluated.props(i,e.props,s.props,t)),s.items!==!0&&e.items!==void 0&&(s.items=_o.mergeEvaluated.items(i,e.items,s.items,t)))}mergeValidEvaluated(e,t){const{it:s,gen:i}=this;if(s.opts.unevaluated&&(s.props!==!0||s.items!==!0))return i.if(t,()=>this.mergeEvaluated(e,_e.Name)),!0}}Zi.KeywordCxt=zP;function HP(n,e,t,s){const i=new zP(n,t,e);"code"in t?t.code(i,s):i.$data&&t.validate?(0,zd.funcKeywordCode)(i,t):"macro"in t?(0,zd.macroKeywordCode)(i,t):(t.compile||t.validate)&&(0,zd.funcKeywordCode)(i,t)}const B5=/^\/(?:[^~]|~0|~1)*$/,q5=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function BP(n,{dataLevel:e,dataNames:t,dataPathArr:s}){let i,r;if(n==="")return Ce.default.rootData;if(n[0]==="/"){if(!B5.test(n))throw new Error(`Invalid JSON-pointer: ${n}`);i=n,r=Ce.default.rootData}else{const c=q5.exec(n);if(!c)throw new Error(`Invalid JSON-pointer: ${n}`);const h=+c[1];if(i=c[2],i==="#"){if(h>=e)throw new Error(l("property/index",h));return s[e-h]}if(h>e)throw new Error(l("data",h));if(r=t[e-h],!i)return r}let o=r;const a=i.split("/");for(const c of a)c&&(r=(0,_e._)`${r}${(0,_e.getProperty)((0,_o.unescapeJsonPointer)(c))}`,o=(0,_e._)`${o} && ${r}`);return o;function l(c,h){return`Cannot access ${c} ${h} levels up, current level is ${e}`}}Zi.getData=BP;var Xp={};Object.defineProperty(Xp,"__esModule",{value:!0});class V5 extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}Xp.default=V5;var Nu={};Object.defineProperty(Nu,"__esModule",{value:!0});const lb=jn;class U5 extends Error{constructor(e,t,s,i){super(i||`can't resolve reference ${s} from id ${t}`),this.missingRef=(0,lb.resolveUrl)(e,t,s),this.missingSchema=(0,lb.normalizeId)((0,lb.getFullPath)(e,this.missingRef))}}Nu.default=U5;var Ms={};Object.defineProperty(Ms,"__esModule",{value:!0});Ms.resolveSchema=Ms.getCompilingSchema=Ms.resolveRef=Ms.compileSchema=Ms.SchemaEnv=void 0;const Ai=Fe,W5=Xp,Ha=Lr,Vi=jn,mA=pe,G5=Zi;class x0{constructor(e){var t;this.refs={},this.dynamicAnchors={};let s;typeof e.schema=="object"&&(s=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(t=e.baseId)!==null&&t!==void 0?t:(0,Vi.normalizeId)(s==null?void 0:s[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=s==null?void 0:s.$async,this.refs={}}}Ms.SchemaEnv=x0;function I1(n){const e=qP.call(this,n);if(e)return e;const t=(0,Vi.getFullPath)(this.opts.uriResolver,n.root.baseId),{es5:s,lines:i}=this.opts.code,{ownProperties:r}=this.opts,o=new Ai.CodeGen(this.scope,{es5:s,lines:i,ownProperties:r});let a;n.$async&&(a=o.scopeValue("Error",{ref:W5.default,code:(0,Ai._)`require("ajv/dist/runtime/validation_error").default`}));const l=o.scopeName("validate");n.validateName=l;const c={gen:o,allErrors:this.opts.allErrors,data:Ha.default.data,parentData:Ha.default.parentData,parentDataProperty:Ha.default.parentDataProperty,dataNames:[Ha.default.data],dataPathArr:[Ai.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:n.schema,code:(0,Ai.stringify)(n.schema)}:{ref:n.schema}),validateName:l,ValidationError:a,schema:n.schema,schemaEnv:n,rootId:t,baseId:n.baseId||t,schemaPath:Ai.nil,errSchemaPath:n.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Ai._)`""`,opts:this.opts,self:this};let h;try{this._compilations.add(n),(0,G5.validateFunctionCode)(c),o.optimize(this.opts.code.optimize);const u=o.toString();h=`${o.scopeRefs(Ha.default.scope)}return ${u}`,this.opts.code.process&&(h=this.opts.code.process(h,n));const p=new Function(`${Ha.default.self}`,`${Ha.default.scope}`,h)(this,this.scope.get());if(this.scope.value(l,{ref:p}),p.errors=null,p.schema=n.schema,p.schemaEnv=n,n.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:l,validateCode:u,scopeValues:o._values}),this.opts.unevaluated){const{props:m,items:g}=c;p.evaluated={props:m instanceof Ai.Name?void 0:m,items:g instanceof Ai.Name?void 0:g,dynamicProps:m instanceof Ai.Name,dynamicItems:g instanceof Ai.Name},p.source&&(p.source.evaluated=(0,Ai.stringify)(p.evaluated))}return n.validate=p,n}catch(u){throw delete n.validate,delete n.validateName,h&&this.logger.error("Error compiling schema, function code:",h),u}finally{this._compilations.delete(n)}}Ms.compileSchema=I1;function K5(n,e,t){var s;t=(0,Vi.resolveUrl)(this.opts.uriResolver,e,t);const i=n.refs[t];if(i)return i;let r=Y5.call(this,n,t);if(r===void 0){const o=(s=n.localRefs)===null||s===void 0?void 0:s[t],{schemaId:a}=this.opts;o&&(r=new x0({schema:o,schemaId:a,root:n,baseId:e}))}if(r!==void 0)return n.refs[t]=Z5.call(this,r)}Ms.resolveRef=K5;function Z5(n){return(0,Vi.inlineRef)(n.schema,this.opts.inlineRefs)?n.schema:n.validate?n:I1.call(this,n)}function qP(n){for(const e of this._compilations)if(X5(e,n))return e}Ms.getCompilingSchema=qP;function X5(n,e){return n.schema===e.schema&&n.root===e.root&&n.baseId===e.baseId}function Y5(n,e){let t;for(;typeof(t=this.refs[e])=="string";)e=t;return t||this.schemas[e]||k0.call(this,n,e)}function k0(n,e){const t=this.opts.uriResolver.parse(e),s=(0,Vi._getFullPath)(this.opts.uriResolver,t);let i=(0,Vi.getFullPath)(this.opts.uriResolver,n.baseId,void 0);if(Object.keys(n.schema).length>0&&s===i)return cb.call(this,t,n);const r=(0,Vi.normalizeId)(s),o=this.refs[r]||this.schemas[r];if(typeof o=="string"){const a=k0.call(this,n,o);return typeof(a==null?void 0:a.schema)!="object"?void 0:cb.call(this,t,a)}if(typeof(o==null?void 0:o.schema)=="object"){if(o.validate||I1.call(this,o),r===(0,Vi.normalizeId)(e)){const{schema:a}=o,{schemaId:l}=this.opts,c=a[l];return c&&(i=(0,Vi.resolveUrl)(this.opts.uriResolver,i,c)),new x0({schema:a,schemaId:l,root:n,baseId:i})}return cb.call(this,t,o)}}Ms.resolveSchema=k0;const J5=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function cb(n,{baseId:e,schema:t,root:s}){var i;if(((i=n.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(const a of n.fragment.slice(1).split("/")){if(typeof t=="boolean")return;const l=t[(0,mA.unescapeFragment)(a)];if(l===void 0)return;t=l;const c=typeof t=="object"&&t[this.opts.schemaId];!J5.has(a)&&c&&(e=(0,Vi.resolveUrl)(this.opts.uriResolver,e,c))}let r;if(typeof t!="boolean"&&t.$ref&&!(0,mA.schemaHasRulesButRef)(t,this.RULES)){const a=(0,Vi.resolveUrl)(this.opts.uriResolver,e,t.$ref);r=k0.call(this,s,a)}const{schemaId:o}=this.opts;if(r=r||new x0({schema:t,schemaId:o,root:s,baseId:e}),r.schema!==r.root.schema)return r}const Q5="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",eG="Meta-schema for $data reference (JSON AnySchema extension proposal)",tG="object",nG=["$data"],sG={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},iG=!1,rG={$id:Q5,description:eG,type:tG,required:nG,properties:sG,additionalProperties:iG};var O1={};Object.defineProperty(O1,"__esModule",{value:!0});const VP=eP;VP.code='require("ajv/dist/runtime/uri").default';O1.default=VP;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.CodeGen=n.Name=n.nil=n.stringify=n.str=n._=n.KeywordCxt=void 0;var e=Zi;Object.defineProperty(n,"KeywordCxt",{enumerable:!0,get:function(){return e.KeywordCxt}});var t=Fe;Object.defineProperty(n,"_",{enumerable:!0,get:function(){return t._}}),Object.defineProperty(n,"str",{enumerable:!0,get:function(){return t.str}}),Object.defineProperty(n,"stringify",{enumerable:!0,get:function(){return t.stringify}}),Object.defineProperty(n,"nil",{enumerable:!0,get:function(){return t.nil}}),Object.defineProperty(n,"Name",{enumerable:!0,get:function(){return t.Name}}),Object.defineProperty(n,"CodeGen",{enumerable:!0,get:function(){return t.CodeGen}});const s=Xp,i=Nu,r=dc,o=Ms,a=Fe,l=jn,c=hn,h=pe,u=rG,d=O1,p=(z,C)=>new RegExp(z,C);p.code="new RegExp";const m=["removeAdditional","useDefaults","coerceTypes"],g=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),b={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},y={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},w=200;function v(z){var C,I,R,_,A,N,W,X,he,ie,ge,at,ze,Qe,lt,tt,Ft,qt,bs,js,tn,vs,ws,Fs,_s;const En=z.strict,nn=(C=z.code)===null||C===void 0?void 0:C.optimize,sn=nn===!0||nn===void 0?1:nn||0,Cn=(R=(I=z.code)===null||I===void 0?void 0:I.regExp)!==null&&R!==void 0?R:p,$n=(_=z.uriResolver)!==null&&_!==void 0?_:d.default;return{strictSchema:(N=(A=z.strictSchema)!==null&&A!==void 0?A:En)!==null&&N!==void 0?N:!0,strictNumbers:(X=(W=z.strictNumbers)!==null&&W!==void 0?W:En)!==null&&X!==void 0?X:!0,strictTypes:(ie=(he=z.strictTypes)!==null&&he!==void 0?he:En)!==null&&ie!==void 0?ie:"log",strictTuples:(at=(ge=z.strictTuples)!==null&&ge!==void 0?ge:En)!==null&&at!==void 0?at:"log",strictRequired:(Qe=(ze=z.strictRequired)!==null&&ze!==void 0?ze:En)!==null&&Qe!==void 0?Qe:!1,code:z.code?{...z.code,optimize:sn,regExp:Cn}:{optimize:sn,regExp:Cn},loopRequired:(lt=z.loopRequired)!==null&<!==void 0?lt:w,loopEnum:(tt=z.loopEnum)!==null&&tt!==void 0?tt:w,meta:(Ft=z.meta)!==null&&Ft!==void 0?Ft:!0,messages:(qt=z.messages)!==null&&qt!==void 0?qt:!0,inlineRefs:(bs=z.inlineRefs)!==null&&bs!==void 0?bs:!0,schemaId:(js=z.schemaId)!==null&&js!==void 0?js:"$id",addUsedSchema:(tn=z.addUsedSchema)!==null&&tn!==void 0?tn:!0,validateSchema:(vs=z.validateSchema)!==null&&vs!==void 0?vs:!0,validateFormats:(ws=z.validateFormats)!==null&&ws!==void 0?ws:!0,unicodeRegExp:(Fs=z.unicodeRegExp)!==null&&Fs!==void 0?Fs:!0,int32range:(_s=z.int32range)!==null&&_s!==void 0?_s:!0,uriResolver:$n}}class x{constructor(C={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,C=this.opts={...C,...v(C)};const{es5:I,lines:R}=this.opts.code;this.scope=new a.ValueScope({scope:{},prefixes:g,es5:I,lines:R}),this.logger=B(C.logger);const _=C.validateFormats;C.validateFormats=!1,this.RULES=(0,r.getRules)(),k.call(this,b,C,"NOT SUPPORTED"),k.call(this,y,C,"DEPRECATED","warn"),this._metaOpts=j.call(this),C.formats&&O.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),C.keywords&&F.call(this,C.keywords),typeof C.meta=="object"&&this.addMetaSchema(C.meta),T.call(this),C.validateFormats=_}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:C,meta:I,schemaId:R}=this.opts;let _=u;R==="id"&&(_={...u},_.id=_.$id,delete _.$id),I&&C&&this.addMetaSchema(_,_[R],!1)}defaultMeta(){const{meta:C,schemaId:I}=this.opts;return this.opts.defaultMeta=typeof C=="object"?C[I]||C:void 0}validate(C,I){let R;if(typeof C=="string"){if(R=this.getSchema(C),!R)throw new Error(`no schema with key or ref "${C}"`)}else R=this.compile(C);const _=R(I);return"$async"in R||(this.errors=R.errors),_}compile(C,I){const R=this._addSchema(C,I);return R.validate||this._compileSchemaEnv(R)}compileAsync(C,I){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:R}=this.opts;return _.call(this,C,I);async function _(ie,ge){await A.call(this,ie.$schema);const at=this._addSchema(ie,ge);return at.validate||N.call(this,at)}async function A(ie){ie&&!this.getSchema(ie)&&await _.call(this,{$ref:ie},!0)}async function N(ie){try{return this._compileSchemaEnv(ie)}catch(ge){if(!(ge instanceof i.default))throw ge;return W.call(this,ge),await X.call(this,ge.missingSchema),N.call(this,ie)}}function W({missingSchema:ie,missingRef:ge}){if(this.refs[ie])throw new Error(`AnySchema ${ie} is loaded but ${ge} cannot be resolved`)}async function X(ie){const ge=await he.call(this,ie);this.refs[ie]||await A.call(this,ge.$schema),this.refs[ie]||this.addSchema(ge,ie,I)}async function he(ie){const ge=this._loading[ie];if(ge)return ge;try{return await(this._loading[ie]=R(ie))}finally{delete this._loading[ie]}}}addSchema(C,I,R,_=this.opts.validateSchema){if(Array.isArray(C)){for(const N of C)this.addSchema(N,void 0,R,_);return this}let A;if(typeof C=="object"){const{schemaId:N}=this.opts;if(A=C[N],A!==void 0&&typeof A!="string")throw new Error(`schema ${N} must be string`)}return I=(0,l.normalizeId)(I||A),this._checkUnique(I),this.schemas[I]=this._addSchema(C,R,I,_,!0),this}addMetaSchema(C,I,R=this.opts.validateSchema){return this.addSchema(C,I,!0,R),this}validateSchema(C,I){if(typeof C=="boolean")return!0;let R;if(R=C.$schema,R!==void 0&&typeof R!="string")throw new Error("$schema must be a string");if(R=R||this.opts.defaultMeta||this.defaultMeta(),!R)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const _=this.validate(R,C);if(!_&&I){const A="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(A);else throw new Error(A)}return _}getSchema(C){let I;for(;typeof(I=E.call(this,C))=="string";)C=I;if(I===void 0){const{schemaId:R}=this.opts,_=new o.SchemaEnv({schema:{},schemaId:R});if(I=o.resolveSchema.call(this,_,C),!I)return;this.refs[C]=I}return I.validate||this._compileSchemaEnv(I)}removeSchema(C){if(C instanceof RegExp)return this._removeAllSchemas(this.schemas,C),this._removeAllSchemas(this.refs,C),this;switch(typeof C){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const I=E.call(this,C);return typeof I=="object"&&this._cache.delete(I.schema),delete this.schemas[C],delete this.refs[C],this}case"object":{const I=C;this._cache.delete(I);let R=C[this.opts.schemaId];return R&&(R=(0,l.normalizeId)(R),delete this.schemas[R],delete this.refs[R]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(C){for(const I of C)this.addKeyword(I);return this}addKeyword(C,I){let R;if(typeof C=="string")R=C,typeof I=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),I.keyword=R);else if(typeof C=="object"&&I===void 0){if(I=C,R=I.keyword,Array.isArray(R)&&!R.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(q.call(this,R,I),!I)return(0,h.eachItem)(R,A=>H.call(this,A)),this;Q.call(this,I);const _={...I,type:(0,c.getJSONTypes)(I.type),schemaType:(0,c.getJSONTypes)(I.schemaType)};return(0,h.eachItem)(R,_.type.length===0?A=>H.call(this,A,_):A=>_.type.forEach(N=>H.call(this,A,_,N))),this}getKeyword(C){const I=this.RULES.all[C];return typeof I=="object"?I.definition:!!I}removeKeyword(C){const{RULES:I}=this;delete I.keywords[C],delete I.all[C];for(const R of I.rules){const _=R.rules.findIndex(A=>A.keyword===C);_>=0&&R.rules.splice(_,1)}return this}addFormat(C,I){return typeof I=="string"&&(I=new RegExp(I)),this.formats[C]=I,this}errorsText(C=this.errors,{separator:I=", ",dataVar:R="data"}={}){return!C||C.length===0?"No errors":C.map(_=>`${R}${_.instancePath} ${_.message}`).reduce((_,A)=>_+I+A)}$dataMetaSchema(C,I){const R=this.RULES.all;C=JSON.parse(JSON.stringify(C));for(const _ of I){const A=_.split("/").slice(1);let N=C;for(const W of A)N=N[W];for(const W in R){const X=R[W];if(typeof X!="object")continue;const{$data:he}=X.definition,ie=N[W];he&&ie&&(N[W]=ye(ie))}}return C}_removeAllSchemas(C,I){for(const R in C){const _=C[R];(!I||I.test(R))&&(typeof _=="string"?delete C[R]:_&&!_.meta&&(this._cache.delete(_.schema),delete C[R]))}}_addSchema(C,I,R,_=this.opts.validateSchema,A=this.opts.addUsedSchema){let N;const{schemaId:W}=this.opts;if(typeof C=="object")N=C[W];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof C!="boolean")throw new Error("schema must be object or boolean")}let X=this._cache.get(C);if(X!==void 0)return X;R=(0,l.normalizeId)(N||R);const he=l.getSchemaRefs.call(this,C,R);return X=new o.SchemaEnv({schema:C,schemaId:W,meta:I,baseId:R,localRefs:he}),this._cache.set(X.schema,X),A&&!R.startsWith("#")&&(R&&this._checkUnique(R),this.refs[R]=X),_&&this.validateSchema(C,!0),X}_checkUnique(C){if(this.schemas[C]||this.refs[C])throw new Error(`schema with key or id "${C}" already exists`)}_compileSchemaEnv(C){if(C.meta?this._compileMetaSchema(C):o.compileSchema.call(this,C),!C.validate)throw new Error("ajv implementation error");return C.validate}_compileMetaSchema(C){const I=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,C)}finally{this.opts=I}}}x.ValidationError=s.default,x.MissingRefError=i.default,n.default=x;function k(z,C,I,R="error"){for(const _ in z){const A=_;A in C&&this.logger[R](`${I}: option ${_}. ${z[A]}`)}}function E(z){return z=(0,l.normalizeId)(z),this.schemas[z]||this.refs[z]}function T(){const z=this.opts.schemas;if(z)if(Array.isArray(z))this.addSchema(z);else for(const C in z)this.addSchema(z[C],C)}function O(){for(const z in this.opts.formats){const C=this.opts.formats[z];C&&this.addFormat(z,C)}}function F(z){if(Array.isArray(z)){this.addVocabulary(z);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const C in z){const I=z[C];I.keyword||(I.keyword=C),this.addKeyword(I)}}function j(){const z={...this.opts};for(const C of m)delete z[C];return z}const L={log(){},warn(){},error(){}};function B(z){if(z===!1)return L;if(z===void 0)return console;if(z.log&&z.warn&&z.error)return z;throw new Error("logger must implement log, warn and error methods")}const Z=/^[a-z_$][a-z0-9_$:-]*$/i;function q(z,C){const{RULES:I}=this;if((0,h.eachItem)(z,R=>{if(I.keywords[R])throw new Error(`Keyword ${R} is already defined`);if(!Z.test(R))throw new Error(`Keyword ${R} has invalid name`)}),!!C&&C.$data&&!("code"in C||"validate"in C))throw new Error('$data keyword must have "code" or "validate" function')}function H(z,C,I){var R;const _=C==null?void 0:C.post;if(I&&_)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:A}=this;let N=_?A.post:A.rules.find(({type:X})=>X===I);if(N||(N={type:I,rules:[]},A.rules.push(N)),A.keywords[z]=!0,!C)return;const W={keyword:z,definition:{...C,type:(0,c.getJSONTypes)(C.type),schemaType:(0,c.getJSONTypes)(C.schemaType)}};C.before?se.call(this,N,W,C.before):N.rules.push(W),A.all[z]=W,(R=C.implements)===null||R===void 0||R.forEach(X=>this.addKeyword(X))}function se(z,C,I){const R=z.rules.findIndex(_=>_.keyword===I);R>=0?z.rules.splice(R,0,C):(z.rules.push(C),this.logger.warn(`rule ${I} is not defined`))}function Q(z){let{metaSchema:C}=z;C!==void 0&&(z.$data&&this.opts.$data&&(C=ye(C)),z.validateSchema=this.compile(C,!0))}const Y={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ye(z){return{anyOf:[z,Y]}}})(dP);var N1={},L1={},D1={};Object.defineProperty(D1,"__esModule",{value:!0});const oG={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};D1.default=oG;var fc={};Object.defineProperty(fc,"__esModule",{value:!0});fc.callRef=fc.getValidate=void 0;const aG=Nu,gA=Ve,Ts=Fe,Oc=Lr,yA=Ms,_m=pe,lG={keyword:"$ref",schemaType:"string",code(n){const{gen:e,schema:t,it:s}=n,{baseId:i,schemaEnv:r,validateName:o,opts:a,self:l}=s,{root:c}=r;if((t==="#"||t==="#/")&&i===c.baseId)return u();const h=yA.resolveRef.call(l,c,i,t);if(h===void 0)throw new aG.default(s.opts.uriResolver,i,t);if(h instanceof yA.SchemaEnv)return d(h);return p(h);function u(){if(r===c)return rg(n,o,r,r.$async);const m=e.scopeValue("root",{ref:c});return rg(n,(0,Ts._)`${m}.validate`,c,c.$async)}function d(m){const g=UP(n,m);rg(n,g,m,m.$async)}function p(m){const g=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Ts.stringify)(m)}:{ref:m}),b=e.name("valid"),y=n.subschema({schema:m,dataTypes:[],schemaPath:Ts.nil,topSchemaRef:g,errSchemaPath:t},b);n.mergeEvaluated(y),n.ok(b)}}};function UP(n,e){const{gen:t}=n;return e.validate?t.scopeValue("validate",{ref:e.validate}):(0,Ts._)`${t.scopeValue("wrapper",{ref:e})}.validate`}fc.getValidate=UP;function rg(n,e,t,s){const{gen:i,it:r}=n,{allErrors:o,schemaEnv:a,opts:l}=r,c=l.passContext?Oc.default.this:Ts.nil;s?h():u();function h(){if(!a.$async)throw new Error("async schema referenced by sync schema");const m=i.let("valid");i.try(()=>{i.code((0,Ts._)`await ${(0,gA.callValidateCode)(n,e,c)}`),p(e),o||i.assign(m,!0)},g=>{i.if((0,Ts._)`!(${g} instanceof ${r.ValidationError})`,()=>i.throw(g)),d(g),o||i.assign(m,!1)}),n.ok(m)}function u(){n.result((0,gA.callValidateCode)(n,e,c),()=>p(e),()=>d(e))}function d(m){const g=(0,Ts._)`${m}.errors`;i.assign(Oc.default.vErrors,(0,Ts._)`${Oc.default.vErrors} === null ? ${g} : ${Oc.default.vErrors}.concat(${g})`),i.assign(Oc.default.errors,(0,Ts._)`${Oc.default.vErrors}.length`)}function p(m){var g;if(!r.opts.unevaluated)return;const b=(g=t==null?void 0:t.validate)===null||g===void 0?void 0:g.evaluated;if(r.props!==!0)if(b&&!b.dynamicProps)b.props!==void 0&&(r.props=_m.mergeEvaluated.props(i,b.props,r.props));else{const y=i.var("props",(0,Ts._)`${m}.evaluated.props`);r.props=_m.mergeEvaluated.props(i,y,r.props,Ts.Name)}if(r.items!==!0)if(b&&!b.dynamicItems)b.items!==void 0&&(r.items=_m.mergeEvaluated.items(i,b.items,r.items));else{const y=i.var("items",(0,Ts._)`${m}.evaluated.items`);r.items=_m.mergeEvaluated.items(i,y,r.items,Ts.Name)}}}fc.callRef=rg;fc.default=lG;Object.defineProperty(L1,"__esModule",{value:!0});const cG=D1,hG=fc,uG=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",cG.default,hG.default];L1.default=uG;var j1={},F1={};Object.defineProperty(F1,"__esModule",{value:!0});const ry=Fe,Io=ry.operators,oy={maximum:{okStr:"<=",ok:Io.LTE,fail:Io.GT},minimum:{okStr:">=",ok:Io.GTE,fail:Io.LT},exclusiveMaximum:{okStr:"<",ok:Io.LT,fail:Io.GTE},exclusiveMinimum:{okStr:">",ok:Io.GT,fail:Io.LTE}},dG={message:({keyword:n,schemaCode:e})=>(0,ry.str)`must be ${oy[n].okStr} ${e}`,params:({keyword:n,schemaCode:e})=>(0,ry._)`{comparison: ${oy[n].okStr}, limit: ${e}}`},fG={keyword:Object.keys(oy),type:"number",schemaType:"number",$data:!0,error:dG,code(n){const{keyword:e,data:t,schemaCode:s}=n;n.fail$data((0,ry._)`${t} ${oy[e].fail} ${s} || isNaN(${t})`)}};F1.default=fG;var z1={};Object.defineProperty(z1,"__esModule",{value:!0});const Hd=Fe,pG={message:({schemaCode:n})=>(0,Hd.str)`must be multiple of ${n}`,params:({schemaCode:n})=>(0,Hd._)`{multipleOf: ${n}}`},mG={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:pG,code(n){const{gen:e,data:t,schemaCode:s,it:i}=n,r=i.opts.multipleOfPrecision,o=e.let("res"),a=r?(0,Hd._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${r}`:(0,Hd._)`${o} !== parseInt(${o})`;n.fail$data((0,Hd._)`(${s} === 0 || (${o} = ${t}/${s}, ${a}))`)}};z1.default=mG;var H1={},B1={};Object.defineProperty(B1,"__esModule",{value:!0});function WP(n){const e=n.length;let t=0,s=0,i;for(;s=55296&&i<=56319&&s(0,sl._)`{limit: ${n}}`},vG={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:bG,code(n){const{keyword:e,data:t,schemaCode:s,it:i}=n,r=e==="maxLength"?sl.operators.GT:sl.operators.LT,o=i.opts.unicode===!1?(0,sl._)`${t}.length`:(0,sl._)`${(0,gG.useFunc)(n.gen,yG.default)}(${t})`;n.fail$data((0,sl._)`${o} ${r} ${s}`)}};H1.default=vG;var q1={};Object.defineProperty(q1,"__esModule",{value:!0});const wG=Ve,_G=pe,Qc=Fe,SG={message:({schemaCode:n})=>(0,Qc.str)`must match pattern "${n}"`,params:({schemaCode:n})=>(0,Qc._)`{pattern: ${n}}`},xG={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:SG,code(n){const{gen:e,data:t,$data:s,schema:i,schemaCode:r,it:o}=n,a=o.opts.unicodeRegExp?"u":"";if(s){const{regExp:l}=o.opts.code,c=l.code==="new RegExp"?(0,Qc._)`new RegExp`:(0,_G.useFunc)(e,l),h=e.let("valid");e.try(()=>e.assign(h,(0,Qc._)`${c}(${r}, ${a}).test(${t})`),()=>e.assign(h,!1)),n.fail$data((0,Qc._)`!${h}`)}else{const l=(0,wG.usePattern)(n,i);n.fail$data((0,Qc._)`!${l}.test(${t})`)}}};q1.default=xG;var V1={};Object.defineProperty(V1,"__esModule",{value:!0});const Bd=Fe,kG={message({keyword:n,schemaCode:e}){const t=n==="maxProperties"?"more":"fewer";return(0,Bd.str)`must NOT have ${t} than ${e} properties`},params:({schemaCode:n})=>(0,Bd._)`{limit: ${n}}`},AG={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:kG,code(n){const{keyword:e,data:t,schemaCode:s}=n,i=e==="maxProperties"?Bd.operators.GT:Bd.operators.LT;n.fail$data((0,Bd._)`Object.keys(${t}).length ${i} ${s}`)}};V1.default=AG;var U1={};Object.defineProperty(U1,"__esModule",{value:!0});const Yu=Ve,qd=Fe,EG=pe,CG={message:({params:{missingProperty:n}})=>(0,qd.str)`must have required property '${n}'`,params:({params:{missingProperty:n}})=>(0,qd._)`{missingProperty: ${n}}`},$G={keyword:"required",type:"object",schemaType:"array",$data:!0,error:CG,code(n){const{gen:e,schema:t,schemaCode:s,data:i,$data:r,it:o}=n,{opts:a}=o;if(!r&&t.length===0)return;const l=t.length>=a.loopRequired;if(o.allErrors?c():h(),a.strictRequired){const p=n.parentSchema.properties,{definedProperties:m}=n.it;for(const g of t)if((p==null?void 0:p[g])===void 0&&!m.has(g)){const b=o.schemaEnv.baseId+o.errSchemaPath,y=`required property "${g}" is not defined at "${b}" (strictRequired)`;(0,EG.checkStrictMode)(o,y,o.opts.strictRequired)}}function c(){if(l||r)n.block$data(qd.nil,u);else for(const p of t)(0,Yu.checkReportMissingProp)(n,p)}function h(){const p=e.let("missing");if(l||r){const m=e.let("valid",!0);n.block$data(m,()=>d(p,m)),n.ok(m)}else e.if((0,Yu.checkMissingProp)(n,t,p)),(0,Yu.reportMissingProp)(n,p),e.else()}function u(){e.forOf("prop",s,p=>{n.setParams({missingProperty:p}),e.if((0,Yu.noPropertyInData)(e,i,p,a.ownProperties),()=>n.error())})}function d(p,m){n.setParams({missingProperty:p}),e.forOf(p,s,()=>{e.assign(m,(0,Yu.propertyInData)(e,i,p,a.ownProperties)),e.if((0,qd.not)(m),()=>{n.error(),e.break()})},qd.nil)}}};U1.default=$G;var W1={};Object.defineProperty(W1,"__esModule",{value:!0});const Vd=Fe,TG={message({keyword:n,schemaCode:e}){const t=n==="maxItems"?"more":"fewer";return(0,Vd.str)`must NOT have ${t} than ${e} items`},params:({schemaCode:n})=>(0,Vd._)`{limit: ${n}}`},PG={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:TG,code(n){const{keyword:e,data:t,schemaCode:s}=n,i=e==="maxItems"?Vd.operators.GT:Vd.operators.LT;n.fail$data((0,Vd._)`${t}.length ${i} ${s}`)}};W1.default=PG;var G1={},Yp={};Object.defineProperty(Yp,"__esModule",{value:!0});const GP=g0;GP.code='require("ajv/dist/runtime/equal").default';Yp.default=GP;Object.defineProperty(G1,"__esModule",{value:!0});const hb=hn,Pn=Fe,RG=pe,MG=Yp,IG={message:({params:{i:n,j:e}})=>(0,Pn.str)`must NOT have duplicate items (items ## ${e} and ${n} are identical)`,params:({params:{i:n,j:e}})=>(0,Pn._)`{i: ${n}, j: ${e}}`},OG={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:IG,code(n){const{gen:e,data:t,$data:s,schema:i,parentSchema:r,schemaCode:o,it:a}=n;if(!s&&!i)return;const l=e.let("valid"),c=r.items?(0,hb.getSchemaTypes)(r.items):[];n.block$data(l,h,(0,Pn._)`${o} === false`),n.ok(l);function h(){const m=e.let("i",(0,Pn._)`${t}.length`),g=e.let("j");n.setParams({i:m,j:g}),e.assign(l,!0),e.if((0,Pn._)`${m} > 1`,()=>(u()?d:p)(m,g))}function u(){return c.length>0&&!c.some(m=>m==="object"||m==="array")}function d(m,g){const b=e.name("item"),y=(0,hb.checkDataTypes)(c,b,a.opts.strictNumbers,hb.DataType.Wrong),w=e.const("indices",(0,Pn._)`{}`);e.for((0,Pn._)`;${m}--;`,()=>{e.let(b,(0,Pn._)`${t}[${m}]`),e.if(y,(0,Pn._)`continue`),c.length>1&&e.if((0,Pn._)`typeof ${b} == "string"`,(0,Pn._)`${b} += "_"`),e.if((0,Pn._)`typeof ${w}[${b}] == "number"`,()=>{e.assign(g,(0,Pn._)`${w}[${b}]`),n.error(),e.assign(l,!1).break()}).code((0,Pn._)`${w}[${b}] = ${m}`)})}function p(m,g){const b=(0,RG.useFunc)(e,MG.default),y=e.name("outer");e.label(y).for((0,Pn._)`;${m}--;`,()=>e.for((0,Pn._)`${g} = ${m}; ${g}--;`,()=>e.if((0,Pn._)`${b}(${t}[${m}], ${t}[${g}])`,()=>{n.error(),e.assign(l,!1).break(y)})))}}};G1.default=OG;var K1={};Object.defineProperty(K1,"__esModule",{value:!0});const vv=Fe,NG=pe,LG=Yp,DG={message:"must be equal to constant",params:({schemaCode:n})=>(0,vv._)`{allowedValue: ${n}}`},jG={keyword:"const",$data:!0,error:DG,code(n){const{gen:e,data:t,$data:s,schemaCode:i,schema:r}=n;s||r&&typeof r=="object"?n.fail$data((0,vv._)`!${(0,NG.useFunc)(e,LG.default)}(${t}, ${i})`):n.fail((0,vv._)`${r} !== ${t}`)}};K1.default=jG;var Z1={};Object.defineProperty(Z1,"__esModule",{value:!0});const ud=Fe,FG=pe,zG=Yp,HG={message:"must be equal to one of the allowed values",params:({schemaCode:n})=>(0,ud._)`{allowedValues: ${n}}`},BG={keyword:"enum",schemaType:"array",$data:!0,error:HG,code(n){const{gen:e,data:t,$data:s,schema:i,schemaCode:r,it:o}=n;if(!s&&i.length===0)throw new Error("enum must have non-empty array");const a=i.length>=o.opts.loopEnum;let l;const c=()=>l??(l=(0,FG.useFunc)(e,zG.default));let h;if(a||s)h=e.let("valid"),n.block$data(h,u);else{if(!Array.isArray(i))throw new Error("ajv implementation error");const p=e.const("vSchema",r);h=(0,ud.or)(...i.map((m,g)=>d(p,g)))}n.pass(h);function u(){e.assign(h,!1),e.forOf("v",r,p=>e.if((0,ud._)`${c()}(${t}, ${p})`,()=>e.assign(h,!0).break()))}function d(p,m){const g=i[m];return typeof g=="object"&&g!==null?(0,ud._)`${c()}(${t}, ${p}[${m}])`:(0,ud._)`${t} === ${g}`}}};Z1.default=BG;Object.defineProperty(j1,"__esModule",{value:!0});const qG=F1,VG=z1,UG=H1,WG=q1,GG=V1,KG=U1,ZG=W1,XG=G1,YG=K1,JG=Z1,QG=[qG.default,VG.default,UG.default,WG.default,GG.default,KG.default,ZG.default,XG.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},YG.default,JG.default];j1.default=QG;var X1={},Lu={};Object.defineProperty(Lu,"__esModule",{value:!0});Lu.validateAdditionalItems=void 0;const il=Fe,wv=pe,eK={message:({params:{len:n}})=>(0,il.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0,il._)`{limit: ${n}}`},tK={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:eK,code(n){const{parentSchema:e,it:t}=n,{items:s}=e;if(!Array.isArray(s)){(0,wv.checkStrictMode)(t,'"additionalItems" is ignored when "items" is not an array of schemas');return}KP(n,s)}};function KP(n,e){const{gen:t,schema:s,data:i,keyword:r,it:o}=n;o.items=!0;const a=t.const("len",(0,il._)`${i}.length`);if(s===!1)n.setParams({len:e.length}),n.pass((0,il._)`${a} <= ${e.length}`);else if(typeof s=="object"&&!(0,wv.alwaysValidSchema)(o,s)){const c=t.var("valid",(0,il._)`${a} <= ${e.length}`);t.if((0,il.not)(c),()=>l(c)),n.ok(c)}function l(c){t.forRange("i",e.length,a,h=>{n.subschema({keyword:r,dataProp:h,dataPropType:wv.Type.Num},c),o.allErrors||t.if((0,il.not)(c),()=>t.break())})}}Lu.validateAdditionalItems=KP;Lu.default=tK;var Y1={},Du={};Object.defineProperty(Du,"__esModule",{value:!0});Du.validateTuple=void 0;const bA=Fe,og=pe,nK=Ve,sK={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(n){const{schema:e,it:t}=n;if(Array.isArray(e))return ZP(n,"additionalItems",e);t.items=!0,!(0,og.alwaysValidSchema)(t,e)&&n.ok((0,nK.validateArray)(n))}};function ZP(n,e,t=n.schema){const{gen:s,parentSchema:i,data:r,keyword:o,it:a}=n;h(i),a.opts.unevaluated&&t.length&&a.items!==!0&&(a.items=og.mergeEvaluated.items(s,t.length,a.items));const l=s.name("valid"),c=s.const("len",(0,bA._)`${r}.length`);t.forEach((u,d)=>{(0,og.alwaysValidSchema)(a,u)||(s.if((0,bA._)`${c} > ${d}`,()=>n.subschema({keyword:o,schemaProp:d,dataProp:d},l)),n.ok(l))});function h(u){const{opts:d,errSchemaPath:p}=a,m=t.length,g=m===u.minItems&&(m===u.maxItems||u[e]===!1);if(d.strictTuples&&!g){const b=`"${o}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,og.checkStrictMode)(a,b,d.strictTuples)}}}Du.validateTuple=ZP;Du.default=sK;Object.defineProperty(Y1,"__esModule",{value:!0});const iK=Du,rK={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:n=>(0,iK.validateTuple)(n,"items")};Y1.default=rK;var J1={};Object.defineProperty(J1,"__esModule",{value:!0});const vA=Fe,oK=pe,aK=Ve,lK=Lu,cK={message:({params:{len:n}})=>(0,vA.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0,vA._)`{limit: ${n}}`},hK={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:cK,code(n){const{schema:e,parentSchema:t,it:s}=n,{prefixItems:i}=t;s.items=!0,!(0,oK.alwaysValidSchema)(s,e)&&(i?(0,lK.validateAdditionalItems)(n,i):n.ok((0,aK.validateArray)(n)))}};J1.default=hK;var Q1={};Object.defineProperty(Q1,"__esModule",{value:!0});const di=Fe,Sm=pe,uK={message:({params:{min:n,max:e}})=>e===void 0?(0,di.str)`must contain at least ${n} valid item(s)`:(0,di.str)`must contain at least ${n} and no more than ${e} valid item(s)`,params:({params:{min:n,max:e}})=>e===void 0?(0,di._)`{minContains: ${n}}`:(0,di._)`{minContains: ${n}, maxContains: ${e}}`},dK={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:uK,code(n){const{gen:e,schema:t,parentSchema:s,data:i,it:r}=n;let o,a;const{minContains:l,maxContains:c}=s;r.opts.next?(o=l===void 0?1:l,a=c):o=1;const h=e.const("len",(0,di._)`${i}.length`);if(n.setParams({min:o,max:a}),a===void 0&&o===0){(0,Sm.checkStrictMode)(r,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,Sm.checkStrictMode)(r,'"minContains" > "maxContains" is always invalid'),n.fail();return}if((0,Sm.alwaysValidSchema)(r,t)){let g=(0,di._)`${h} >= ${o}`;a!==void 0&&(g=(0,di._)`${g} && ${h} <= ${a}`),n.pass(g);return}r.items=!0;const u=e.name("valid");a===void 0&&o===1?p(u,()=>e.if(u,()=>e.break())):o===0?(e.let(u,!0),a!==void 0&&e.if((0,di._)`${i}.length > 0`,d)):(e.let(u,!1),d()),n.result(u,()=>n.reset());function d(){const g=e.name("_valid"),b=e.let("count",0);p(g,()=>e.if(g,()=>m(b)))}function p(g,b){e.forRange("i",0,h,y=>{n.subschema({keyword:"contains",dataProp:y,dataPropType:Sm.Type.Num,compositeRule:!0},g),b()})}function m(g){e.code((0,di._)`${g}++`),a===void 0?e.if((0,di._)`${g} >= ${o}`,()=>e.assign(u,!0).break()):(e.if((0,di._)`${g} > ${a}`,()=>e.assign(u,!1).break()),o===1?e.assign(u,!0):e.if((0,di._)`${g} >= ${o}`,()=>e.assign(u,!0)))}}};Q1.default=dK;var XP={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateSchemaDeps=n.validatePropertyDeps=n.error=void 0;const e=Fe,t=pe,s=Ve;n.error={message:({params:{property:l,depsCount:c,deps:h}})=>{const u=c===1?"property":"properties";return(0,e.str)`must have ${u} ${h} when property ${l} is present`},params:({params:{property:l,depsCount:c,deps:h,missingProperty:u}})=>(0,e._)`{property: ${l}, + missingProperty: ${u}, + depsCount: ${c}, + deps: ${h}}`};const i={keyword:"dependencies",type:"object",schemaType:"object",error:n.error,code(l){const[c,h]=r(l);o(l,c),a(l,h)}};function r({schema:l}){const c={},h={};for(const u in l){if(u==="__proto__")continue;const d=Array.isArray(l[u])?c:h;d[u]=l[u]}return[c,h]}function o(l,c=l.schema){const{gen:h,data:u,it:d}=l;if(Object.keys(c).length===0)return;const p=h.let("missing");for(const m in c){const g=c[m];if(g.length===0)continue;const b=(0,s.propertyInData)(h,u,m,d.opts.ownProperties);l.setParams({property:m,depsCount:g.length,deps:g.join(", ")}),d.allErrors?h.if(b,()=>{for(const y of g)(0,s.checkReportMissingProp)(l,y)}):(h.if((0,e._)`${b} && (${(0,s.checkMissingProp)(l,g,p)})`),(0,s.reportMissingProp)(l,p),h.else())}}n.validatePropertyDeps=o;function a(l,c=l.schema){const{gen:h,data:u,keyword:d,it:p}=l,m=h.name("valid");for(const g in c)(0,t.alwaysValidSchema)(p,c[g])||(h.if((0,s.propertyInData)(h,u,g,p.opts.ownProperties),()=>{const b=l.subschema({keyword:d,schemaProp:g},m);l.mergeValidEvaluated(b,m)},()=>h.var(m,!0)),l.ok(m))}n.validateSchemaDeps=a,n.default=i})(XP);var ex={};Object.defineProperty(ex,"__esModule",{value:!0});const YP=Fe,fK=pe,pK={message:"property name must be valid",params:({params:n})=>(0,YP._)`{propertyName: ${n.propertyName}}`},mK={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:pK,code(n){const{gen:e,schema:t,data:s,it:i}=n;if((0,fK.alwaysValidSchema)(i,t))return;const r=e.name("valid");e.forIn("key",s,o=>{n.setParams({propertyName:o}),n.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},r),e.if((0,YP.not)(r),()=>{n.error(!0),i.allErrors||e.break()})}),n.ok(r)}};ex.default=mK;var A0={};Object.defineProperty(A0,"__esModule",{value:!0});const xm=Ve,Ci=Fe,gK=Lr,km=pe,yK={message:"must NOT have additional properties",params:({params:n})=>(0,Ci._)`{additionalProperty: ${n.additionalProperty}}`},bK={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:yK,code(n){const{gen:e,schema:t,parentSchema:s,data:i,errsCount:r,it:o}=n;if(!r)throw new Error("ajv implementation error");const{allErrors:a,opts:l}=o;if(o.props=!0,l.removeAdditional!=="all"&&(0,km.alwaysValidSchema)(o,t))return;const c=(0,xm.allSchemaProperties)(s.properties),h=(0,xm.allSchemaProperties)(s.patternProperties);u(),n.ok((0,Ci._)`${r} === ${gK.default.errors}`);function u(){e.forIn("key",i,b=>{!c.length&&!h.length?m(b):e.if(d(b),()=>m(b))})}function d(b){let y;if(c.length>8){const w=(0,km.schemaRefOrVal)(o,s.properties,"properties");y=(0,xm.isOwnProperty)(e,w,b)}else c.length?y=(0,Ci.or)(...c.map(w=>(0,Ci._)`${b} === ${w}`)):y=Ci.nil;return h.length&&(y=(0,Ci.or)(y,...h.map(w=>(0,Ci._)`${(0,xm.usePattern)(n,w)}.test(${b})`))),(0,Ci.not)(y)}function p(b){e.code((0,Ci._)`delete ${i}[${b}]`)}function m(b){if(l.removeAdditional==="all"||l.removeAdditional&&t===!1){p(b);return}if(t===!1){n.setParams({additionalProperty:b}),n.error(),a||e.break();return}if(typeof t=="object"&&!(0,km.alwaysValidSchema)(o,t)){const y=e.name("valid");l.removeAdditional==="failing"?(g(b,y,!1),e.if((0,Ci.not)(y),()=>{n.reset(),p(b)})):(g(b,y),a||e.if((0,Ci.not)(y),()=>e.break()))}}function g(b,y,w){const v={keyword:"additionalProperties",dataProp:b,dataPropType:km.Type.Str};w===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),n.subschema(v,y)}}};A0.default=bK;var tx={};Object.defineProperty(tx,"__esModule",{value:!0});const vK=Zi,wA=Ve,ub=pe,_A=A0,wK={keyword:"properties",type:"object",schemaType:"object",code(n){const{gen:e,schema:t,parentSchema:s,data:i,it:r}=n;r.opts.removeAdditional==="all"&&s.additionalProperties===void 0&&_A.default.code(new vK.KeywordCxt(r,_A.default,"additionalProperties"));const o=(0,wA.allSchemaProperties)(t);for(const u of o)r.definedProperties.add(u);r.opts.unevaluated&&o.length&&r.props!==!0&&(r.props=ub.mergeEvaluated.props(e,(0,ub.toHash)(o),r.props));const a=o.filter(u=>!(0,ub.alwaysValidSchema)(r,t[u]));if(a.length===0)return;const l=e.name("valid");for(const u of a)c(u)?h(u):(e.if((0,wA.propertyInData)(e,i,u,r.opts.ownProperties)),h(u),r.allErrors||e.else().var(l,!0),e.endIf()),n.it.definedProperties.add(u),n.ok(l);function c(u){return r.opts.useDefaults&&!r.compositeRule&&t[u].default!==void 0}function h(u){n.subschema({keyword:"properties",schemaProp:u,dataProp:u},l)}}};tx.default=wK;var nx={};Object.defineProperty(nx,"__esModule",{value:!0});const SA=Ve,Am=Fe,xA=pe,kA=pe,_K={keyword:"patternProperties",type:"object",schemaType:"object",code(n){const{gen:e,schema:t,data:s,parentSchema:i,it:r}=n,{opts:o}=r,a=(0,SA.allSchemaProperties)(t),l=a.filter(g=>(0,xA.alwaysValidSchema)(r,t[g]));if(a.length===0||l.length===a.length&&(!r.opts.unevaluated||r.props===!0))return;const c=o.strictSchema&&!o.allowMatchingProperties&&i.properties,h=e.name("valid");r.props!==!0&&!(r.props instanceof Am.Name)&&(r.props=(0,kA.evaluatedPropsToName)(e,r.props));const{props:u}=r;d();function d(){for(const g of a)c&&p(g),r.allErrors?m(g):(e.var(h,!0),m(g),e.if(h))}function p(g){for(const b in c)new RegExp(g).test(b)&&(0,xA.checkStrictMode)(r,`property ${b} matches pattern ${g} (use allowMatchingProperties)`)}function m(g){e.forIn("key",s,b=>{e.if((0,Am._)`${(0,SA.usePattern)(n,g)}.test(${b})`,()=>{const y=l.includes(g);y||n.subschema({keyword:"patternProperties",schemaProp:g,dataProp:b,dataPropType:kA.Type.Str},h),r.opts.unevaluated&&u!==!0?e.assign((0,Am._)`${u}[${b}]`,!0):!y&&!r.allErrors&&e.if((0,Am.not)(h),()=>e.break())})})}}};nx.default=_K;var sx={};Object.defineProperty(sx,"__esModule",{value:!0});const SK=pe,xK={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(n){const{gen:e,schema:t,it:s}=n;if((0,SK.alwaysValidSchema)(s,t)){n.fail();return}const i=e.name("valid");n.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),n.failResult(i,()=>n.reset(),()=>n.error())},error:{message:"must NOT be valid"}};sx.default=xK;var ix={};Object.defineProperty(ix,"__esModule",{value:!0});const kK=Ve,AK={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:kK.validateUnion,error:{message:"must match a schema in anyOf"}};ix.default=AK;var rx={};Object.defineProperty(rx,"__esModule",{value:!0});const ag=Fe,EK=pe,CK={message:"must match exactly one schema in oneOf",params:({params:n})=>(0,ag._)`{passingSchemas: ${n.passing}}`},$K={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:CK,code(n){const{gen:e,schema:t,parentSchema:s,it:i}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");if(i.opts.discriminator&&s.discriminator)return;const r=t,o=e.let("valid",!1),a=e.let("passing",null),l=e.name("_valid");n.setParams({passing:a}),e.block(c),n.result(o,()=>n.reset(),()=>n.error(!0));function c(){r.forEach((h,u)=>{let d;(0,EK.alwaysValidSchema)(i,h)?e.var(l,!0):d=n.subschema({keyword:"oneOf",schemaProp:u,compositeRule:!0},l),u>0&&e.if((0,ag._)`${l} && ${o}`).assign(o,!1).assign(a,(0,ag._)`[${a}, ${u}]`).else(),e.if(l,()=>{e.assign(o,!0),e.assign(a,u),d&&n.mergeEvaluated(d,ag.Name)})})}}};rx.default=$K;var ox={};Object.defineProperty(ox,"__esModule",{value:!0});const TK=pe,PK={keyword:"allOf",schemaType:"array",code(n){const{gen:e,schema:t,it:s}=n;if(!Array.isArray(t))throw new Error("ajv implementation error");const i=e.name("valid");t.forEach((r,o)=>{if((0,TK.alwaysValidSchema)(s,r))return;const a=n.subschema({keyword:"allOf",schemaProp:o},i);n.ok(i),n.mergeEvaluated(a)})}};ox.default=PK;var ax={};Object.defineProperty(ax,"__esModule",{value:!0});const ay=Fe,JP=pe,RK={message:({params:n})=>(0,ay.str)`must match "${n.ifClause}" schema`,params:({params:n})=>(0,ay._)`{failingKeyword: ${n.ifClause}}`},MK={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:RK,code(n){const{gen:e,parentSchema:t,it:s}=n;t.then===void 0&&t.else===void 0&&(0,JP.checkStrictMode)(s,'"if" without "then" and "else" is ignored');const i=AA(s,"then"),r=AA(s,"else");if(!i&&!r)return;const o=e.let("valid",!0),a=e.name("_valid");if(l(),n.reset(),i&&r){const h=e.let("ifClause");n.setParams({ifClause:h}),e.if(a,c("then",h),c("else",h))}else i?e.if(a,c("then")):e.if((0,ay.not)(a),c("else"));n.pass(o,()=>n.error(!0));function l(){const h=n.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);n.mergeEvaluated(h)}function c(h,u){return()=>{const d=n.subschema({keyword:h},a);e.assign(o,a),n.mergeValidEvaluated(d,o),u?e.assign(u,(0,ay._)`${h}`):n.setParams({ifClause:h})}}}};function AA(n,e){const t=n.schema[e];return t!==void 0&&!(0,JP.alwaysValidSchema)(n,t)}ax.default=MK;var lx={};Object.defineProperty(lx,"__esModule",{value:!0});const IK=pe,OK={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:n,parentSchema:e,it:t}){e.if===void 0&&(0,IK.checkStrictMode)(t,`"${n}" without "if" is ignored`)}};lx.default=OK;Object.defineProperty(X1,"__esModule",{value:!0});const NK=Lu,LK=Y1,DK=Du,jK=J1,FK=Q1,zK=XP,HK=ex,BK=A0,qK=tx,VK=nx,UK=sx,WK=ix,GK=rx,KK=ox,ZK=ax,XK=lx;function YK(n=!1){const e=[UK.default,WK.default,GK.default,KK.default,ZK.default,XK.default,HK.default,BK.default,zK.default,qK.default,VK.default];return n?e.push(LK.default,jK.default):e.push(NK.default,DK.default),e.push(FK.default),e}X1.default=YK;var cx={},hx={};Object.defineProperty(hx,"__esModule",{value:!0});const Ut=Fe,JK={message:({schemaCode:n})=>(0,Ut.str)`must match format "${n}"`,params:({schemaCode:n})=>(0,Ut._)`{format: ${n}}`},QK={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:JK,code(n,e){const{gen:t,data:s,$data:i,schema:r,schemaCode:o,it:a}=n,{opts:l,errSchemaPath:c,schemaEnv:h,self:u}=a;if(!l.validateFormats)return;i?d():p();function d(){const m=t.scopeValue("formats",{ref:u.formats,code:l.code.formats}),g=t.const("fDef",(0,Ut._)`${m}[${o}]`),b=t.let("fType"),y=t.let("format");t.if((0,Ut._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>t.assign(b,(0,Ut._)`${g}.type || "string"`).assign(y,(0,Ut._)`${g}.validate`),()=>t.assign(b,(0,Ut._)`"string"`).assign(y,g)),n.fail$data((0,Ut.or)(w(),v()));function w(){return l.strictSchema===!1?Ut.nil:(0,Ut._)`${o} && !${y}`}function v(){const x=h.$async?(0,Ut._)`(${g}.async ? await ${y}(${s}) : ${y}(${s}))`:(0,Ut._)`${y}(${s})`,k=(0,Ut._)`(typeof ${y} == "function" ? ${x} : ${y}.test(${s}))`;return(0,Ut._)`${y} && ${y} !== true && ${b} === ${e} && !${k}`}}function p(){const m=u.formats[r];if(!m){w();return}if(m===!0)return;const[g,b,y]=v(m);g===e&&n.pass(x());function w(){if(l.strictSchema===!1){u.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${r}" ignored in schema at path "${c}"`}}function v(k){const E=k instanceof RegExp?(0,Ut.regexpCode)(k):l.code.formats?(0,Ut._)`${l.code.formats}${(0,Ut.getProperty)(r)}`:void 0,T=t.scopeValue("formats",{key:r,ref:k,code:E});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,Ut._)`${T}.validate`]:["string",k,T]}function x(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!h.$async)throw new Error("async format in sync schema");return(0,Ut._)`await ${y}(${s})`}return typeof b=="function"?(0,Ut._)`${y}(${s})`:(0,Ut._)`${y}.test(${s})`}}}};hx.default=QK;Object.defineProperty(cx,"__esModule",{value:!0});const e9=hx,t9=[e9.default];cx.default=t9;var bu={};Object.defineProperty(bu,"__esModule",{value:!0});bu.contentVocabulary=bu.metadataVocabulary=void 0;bu.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];bu.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(N1,"__esModule",{value:!0});const n9=L1,s9=j1,i9=X1,r9=cx,EA=bu,o9=[n9.default,s9.default,(0,i9.default)(),r9.default,EA.metadataVocabulary,EA.contentVocabulary];N1.default=o9;var ux={},E0={};Object.defineProperty(E0,"__esModule",{value:!0});E0.DiscrError=void 0;var CA;(function(n){n.Tag="tag",n.Mapping="mapping"})(CA||(E0.DiscrError=CA={}));Object.defineProperty(ux,"__esModule",{value:!0});const jc=Fe,_v=E0,$A=Ms,a9=Nu,l9=pe,c9={message:({params:{discrError:n,tagName:e}})=>n===_v.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:n,tag:e,tagName:t}})=>(0,jc._)`{error: ${n}, tag: ${t}, tagValue: ${e}}`},h9={keyword:"discriminator",type:"object",schemaType:"object",error:c9,code(n){const{gen:e,data:t,schema:s,parentSchema:i,it:r}=n,{oneOf:o}=i;if(!r.opts.discriminator)throw new Error("discriminator: requires discriminator option");const a=s.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(s.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");const l=e.let("valid",!1),c=e.const("tag",(0,jc._)`${t}${(0,jc.getProperty)(a)}`);e.if((0,jc._)`typeof ${c} == "string"`,()=>h(),()=>n.error(!1,{discrError:_v.DiscrError.Tag,tag:c,tagName:a})),n.ok(l);function h(){const p=d();e.if(!1);for(const m in p)e.elseIf((0,jc._)`${c} === ${m}`),e.assign(l,u(p[m]));e.else(),n.error(!1,{discrError:_v.DiscrError.Mapping,tag:c,tagName:a}),e.endIf()}function u(p){const m=e.name("valid"),g=n.subschema({keyword:"oneOf",schemaProp:p},m);return n.mergeEvaluated(g,jc.Name),m}function d(){var p;const m={},g=y(i);let b=!0;for(let x=0;xthis.addVocabulary(m)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const m=this.opts.$data?this.$dataMetaSchema(r,o):r;this.addMetaSchema(m,a,!1),this.refs["http://json-schema.org/schema"]=a}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}e.Ajv=l,n.exports=e=l,n.exports.Ajv=l,Object.defineProperty(e,"__esModule",{value:!0}),e.default=l;var c=Zi;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var h=Fe;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return h._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return h.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return h.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return h.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return h.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return h.CodeGen}});var u=Xp;Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=Nu;Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return d.default}})})(pv,pv.exports);var b9=pv.exports;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.formatLimitDefinition=void 0;const e=b9,t=Fe,s=t.operators,i={formatMaximum:{okStr:"<=",ok:s.LTE,fail:s.GT},formatMinimum:{okStr:">=",ok:s.GTE,fail:s.LT},formatExclusiveMaximum:{okStr:"<",ok:s.LT,fail:s.GTE},formatExclusiveMinimum:{okStr:">",ok:s.GT,fail:s.LTE}},r={message:({keyword:a,schemaCode:l})=>(0,t.str)`should be ${i[a].okStr} ${l}`,params:({keyword:a,schemaCode:l})=>(0,t._)`{comparison: ${i[a].okStr}, limit: ${l}}`};n.formatLimitDefinition={keyword:Object.keys(i),type:"string",schemaType:"string",$data:!0,error:r,code(a){const{gen:l,data:c,schemaCode:h,keyword:u,it:d}=a,{opts:p,self:m}=d;if(!p.validateFormats)return;const g=new e.KeywordCxt(d,m.RULES.all.format.definition,"format");g.$data?b():y();function b(){const v=l.scopeValue("formats",{ref:m.formats,code:p.code.formats}),x=l.const("fmt",(0,t._)`${v}[${g.schemaCode}]`);a.fail$data((0,t.or)((0,t._)`typeof ${x} != "object"`,(0,t._)`${x} instanceof RegExp`,(0,t._)`typeof ${x}.compare != "function"`,w(x)))}function y(){const v=g.schema,x=m.formats[v];if(!x||x===!0)return;if(typeof x!="object"||x instanceof RegExp||typeof x.compare!="function")throw new Error(`"${u}": format "${v}" does not define "compare" function`);const k=l.scopeValue("formats",{key:v,ref:x,code:p.code.formats?(0,t._)`${p.code.formats}${(0,t.getProperty)(v)}`:void 0});a.fail$data(w(k))}function w(v){return(0,t._)`${v}.compare(${c}, ${h}) ${i[u].fail} 0`}},dependencies:["format"]};const o=a=>(a.addKeyword(n.formatLimitDefinition),a);n.default=o})(uP);(function(n,e){Object.defineProperty(e,"__esModule",{value:!0});const t=hP,s=uP,i=Fe,r=new i.Name("fullFormats"),o=new i.Name("fastFormats"),a=(c,h={keywords:!0})=>{if(Array.isArray(h))return l(c,h,t.fullFormats,r),c;const[u,d]=h.mode==="fast"?[t.fastFormats,o]:[t.fullFormats,r],p=h.formats||t.formatNames;return l(c,p,u,d),h.keywords&&(0,s.default)(c),c};a.get=(c,h="full")=>{const d=(h==="fast"?t.fastFormats:t.fullFormats)[c];if(!d)throw new Error(`Unknown format "${c}"`);return d};function l(c,h,u,d){var p,m;(p=(m=c.opts.code).formats)!==null&&p!==void 0||(m.formats=(0,i._)`require("ajv-formats/dist/formats").${d}`);for(const g of h)c.addFormat(g,u[g])}n.exports=e=a,Object.defineProperty(e,"__esModule",{value:!0}),e.default=a})(fv,fv.exports);var v9=fv.exports;const w9=G_(v9);function _9(){const n=new o4({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return w9(n),n}class S9{constructor(e){this._ajv=e??_9()}getValidator(e){const t="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return s=>t(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class x9{constructor(e){this._client=e}async*callToolStream(e,t=lc,s){const i=this._client,r={...s,task:(s==null?void 0:s.task)??(i.isToolTask(e.name)?{}:void 0)},o=i.requestStream({method:"tools/call",params:e},t,r),a=i.getToolOutputValidator(e.name);for await(const l of o){if(l.type==="result"&&a){const c=l.result;if(!c.structuredContent&&!c.isError){yield{type:"error",error:new Ae(Pe.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(c.structuredContent)try{const h=a(c.structuredContent);if(!h.valid){yield{type:"error",error:new Ae(Pe.InvalidParams,`Structured content does not match the tool's output schema: ${h.errorMessage}`)};return}}catch(h){if(h instanceof Ae){yield{type:"error",error:h};return}yield{type:"error",error:new Ae(Pe.InvalidParams,`Failed to validate structured content: ${h instanceof Error?h.message:String(h)}`)};return}}yield l}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,s){return this._client.getTaskResult({taskId:e},t,s)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,s){return this._client.requestStream(e,t,s)}}function k9(n,e,t){var s;if(!n)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!((s=n.tools)!=null&&s.call))throw new Error(`${t} does not support task creation for tools/call (required for ${e})`);break}}function A9(n,e,t){var s,i;if(!n)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!((s=n.sampling)!=null&&s.createMessage))throw new Error(`${t} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!((i=n.elicitation)!=null&&i.create))throw new Error(`${t} does not support task creation for elicitation/create (required for ${e})`);break}}function lg(n,e){if(!(!n||e===null||typeof e!="object")){if(n.type==="object"&&n.properties&&typeof n.properties=="object"){const t=e,s=n.properties;for(const i of Object.keys(s)){const r=s[i];t[i]===void 0&&Object.prototype.hasOwnProperty.call(r,"default")&&(t[i]=r.default),t[i]!==void 0&&lg(r,t[i])}}if(Array.isArray(n.anyOf))for(const t of n.anyOf)typeof t!="boolean"&&lg(t,e);if(Array.isArray(n.oneOf))for(const t of n.oneOf)typeof t!="boolean"&&lg(t,e)}}function E9(n){if(!n)return{supportsFormMode:!1,supportsUrlMode:!1};const e=n.form!==void 0,t=n.url!==void 0;return{supportsFormMode:e||!e&&!t,supportsUrlMode:t}}class C9 extends iT{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=(t==null?void 0:t.capabilities)??{},this._jsonSchemaValidator=(t==null?void 0:t.jsonSchemaValidator)??new S9,t!=null&&t.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){var t,s,i,r,o,a;e.tools&&((s=(t=this._serverCapabilities)==null?void 0:t.tools)!=null&&s.listChanged)&&this._setupListChangedHandler("tools",$S,e.tools,async()=>(await this.listTools()).tools),e.prompts&&((r=(i=this._serverCapabilities)==null?void 0:i.prompts)!=null&&r.listChanged)&&this._setupListChangedHandler("prompts",AS,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&((a=(o=this._serverCapabilities)==null?void 0:o.resources)!=null&&a.listChanged)&&this._setupListChangedHandler("resources",wS,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new x9(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=AB(this._capabilities,e)}setRequestHandler(e,t){const s=nT(e),i=s==null?void 0:s.method;if(!i)throw new Error("Schema is missing a method literal");const r=sT(i);if(typeof r!="string")throw new Error("Schema method literal must be a string");const o=r;if(o==="elicitation/create"){const a=async(l,c)=>{var w,v;const h=Lo(Q$,l);if(!h.success){const x=h.error instanceof Error?h.error.message:String(h.error);throw new Ae(Pe.InvalidParams,`Invalid elicitation request: ${x}`)}const{params:u}=h.data;u.mode=u.mode??"form";const{supportsFormMode:d,supportsUrlMode:p}=E9(this._capabilities.elicitation);if(u.mode==="form"&&!d)throw new Ae(Pe.InvalidParams,"Client does not support form-mode elicitation requests");if(u.mode==="url"&&!p)throw new Ae(Pe.InvalidParams,"Client does not support URL-mode elicitation requests");const m=await Promise.resolve(t(l,c));if(u.task){const x=Lo(nf,m);if(!x.success){const k=x.error instanceof Error?x.error.message:String(x.error);throw new Ae(Pe.InvalidParams,`Invalid task creation result: ${k}`)}return x.data}const g=Lo(eT,m);if(!g.success){const x=g.error instanceof Error?g.error.message:String(g.error);throw new Ae(Pe.InvalidParams,`Invalid elicitation result: ${x}`)}const b=g.data,y=u.mode==="form"?u.requestedSchema:void 0;if(u.mode==="form"&&b.action==="accept"&&b.content&&y&&(v=(w=this._capabilities.elicitation)==null?void 0:w.form)!=null&&v.applyDefaults)try{lg(y,b.content)}catch{}return b};return super.setRequestHandler(e,a)}if(o==="sampling/createMessage"){const a=async(l,c)=>{const h=Lo(TS,l);if(!h.success){const b=h.error instanceof Error?h.error.message:String(h.error);throw new Ae(Pe.InvalidParams,`Invalid sampling request: ${b}`)}const{params:u}=h.data,d=await Promise.resolve(t(l,c));if(u.task){const b=Lo(nf,d);if(!b.success){const y=b.error instanceof Error?b.error.message:String(b.error);throw new Ae(Pe.InvalidParams,`Invalid task creation result: ${y}`)}return b.data}const m=u.tools||u.toolChoice?J$:Y$,g=Lo(m,d);if(!g.success){const b=g.error instanceof Error?g.error.message:String(g.error);throw new Ae(Pe.InvalidParams,`Invalid sampling result: ${b}`)}return g.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,t)}assertCapability(e,t){var s;if(!((s=this._serverCapabilities)!=null&&s[e]))throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{const s=await this.request({method:"initialize",params:{protocolVersion:u0,capabilities:this._capabilities,clientInfo:this._clientInfo}},N$,t);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!eH.includes(s.protocolVersion))throw new Error(`Server's protocol version is not supported: ${s.protocolVersion}`);this._serverCapabilities=s.capabilities,this._serverVersion=s.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(s.protocolVersion),this._instructions=s.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(s){throw this.close(),s}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var t,s,i,r,o;switch(e){case"logging/setLevel":if(!((t=this._serverCapabilities)!=null&&t.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!((s=this._serverCapabilities)!=null&&s.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!((i=this._serverCapabilities)!=null&&i.resources))throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!((r=this._serverCapabilities)!=null&&r.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!((o=this._serverCapabilities)!=null&&o.completions))throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){var t;switch(e){case"notifications/roots/list_changed":if(!((t=this._capabilities.roots)!=null&&t.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break}}assertTaskCapability(e){var t,s;k9((s=(t=this._serverCapabilities)==null?void 0:t.tasks)==null?void 0:s.requests,e,"Server")}assertTaskHandlerCapability(e){var t;this._capabilities&&A9((t=this._capabilities.tasks)==null?void 0:t.requests,e,"Client")}async ping(e){return this.request({method:"ping"},Yc,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},tT,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},Yc,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},G$,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},_S,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},gS,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},yS,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},vS,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},Yc,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},Yc,t)}async callTool(e,t=lc,s){if(this.isToolTaskRequired(e.name))throw new Ae(Pe.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const i=await this.request({method:"tools/call",params:e},t,s),r=this.getToolOutputValidator(e.name);if(r){if(!i.structuredContent&&!i.isError)throw new Ae(Pe.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(i.structuredContent)try{const o=r(i.structuredContent);if(!o.valid)throw new Ae(Pe.InvalidParams,`Structured content does not match the tool's output schema: ${o.errorMessage}`)}catch(o){throw o instanceof Ae?o:new Ae(Pe.InvalidParams,`Failed to validate structured content: ${o instanceof Error?o.message:String(o)}`)}}return i}isToolTask(e){var t,s,i,r;return(r=(i=(s=(t=this._serverCapabilities)==null?void 0:t.tasks)==null?void 0:s.requests)==null?void 0:i.tools)!=null&&r.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){var t;this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const s of e){if(s.outputSchema){const r=this._jsonSchemaValidator.getValidator(s.outputSchema);this._cachedToolOutputValidators.set(s.name,r)}const i=(t=s.execution)==null?void 0:t.taskSupport;(i==="required"||i==="optional")&&this._cachedKnownTaskTools.add(s.name),i==="required"&&this._cachedRequiredTaskTools.add(s.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const s=await this.request({method:"tools/list",params:e},CS,t);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,t,s,i){const r=HH.safeParse(s);if(!r.success)throw new Error(`Invalid ${e} listChanged options: ${r.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:o,debounceMs:a}=r.data,{onChanged:l}=s,c=async()=>{if(!o){l(null,null);return}try{const u=await i();l(null,u)}catch(u){const d=u instanceof Error?u:new Error(String(u));l(d,null)}},h=()=>{if(a){const u=this._listChangedDebounceTimers.get(e);u&&clearTimeout(u);const d=setTimeout(c,a);this._listChangedDebounceTimers.set(e,d)}else c()};this.setNotificationHandler(t,h)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}var dx={};/*! + * content-type + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */var TA=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,$9=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,QP=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T9=/\\([\u000b\u0020-\u00ff])/g,P9=/([\\"])/g,eR=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;dx.format=R9;dx.parse=M9;function R9(n){if(!n||typeof n!="object")throw new TypeError("argument obj is required");var e=n.parameters,t=n.type;if(!t||!eR.test(t))throw new TypeError("invalid type");var s=t;if(e&&typeof e=="object")for(var i,r=Object.keys(e).sort(),o=0;o0&&!$9.test(e))throw new TypeError("invalid parameter value");return'"'+e.replace(P9,"\\$1")+'"'}function N9(n){this.parameters=Object.create(null),this.type=n}function L9(n){if(n)try{return dx.parse(n).type}catch{const e=(n.split(";",1)[0]??"").trim().toLowerCase();return e===""||n.slice(e.length).includes(",")?void 0:e}}function Sv(n){return n?n instanceof Headers?Object.fromEntries(n.entries()):Array.isArray(n)?Object.fromEntries(n):{...n}:{}}function D9(n=fetch,e){return e?async(t,s)=>{const i={...e,...s,headers:s!=null&&s.headers?{...Sv(e.headers),...Sv(s.headers)}:e.headers};return n(t,i)}:n}let fx;fx=globalThis.crypto;async function j9(n){return(await fx).getRandomValues(new Uint8Array(n))}async function F9(n){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",t=Math.pow(2,8)-Math.pow(2,8)%e.length;let s="";for(;s.length128)throw`Expected a length between 43 and 128. Received ${n}.`;const e=await z9(n),t=await H9(e);return{code_verifier:e,code_challenge:t}}const Ln=az().superRefine((n,e)=>{if(!URL.canParse(n))return e.addIssue({code:Jz.custom,message:"URL must be parseable",fatal:!0}),ZD}).refine(n=>{const e=new URL(n);return e.protocol!=="javascript:"&&e.protocol!=="data:"&&e.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),q9=zn({resource:D().url(),authorization_servers:oe(Ln).optional(),jwks_uri:D().url().optional(),scopes_supported:oe(D()).optional(),bearer_methods_supported:oe(D()).optional(),resource_signing_alg_values_supported:oe(D()).optional(),resource_name:D().optional(),resource_documentation:D().optional(),resource_policy_uri:D().url().optional(),resource_tos_uri:D().url().optional(),tls_client_certificate_bound_access_tokens:Xe().optional(),authorization_details_types_supported:oe(D()).optional(),dpop_signing_alg_values_supported:oe(D()).optional(),dpop_bound_access_tokens_required:Xe().optional()}),tR=zn({issuer:D(),authorization_endpoint:Ln,token_endpoint:Ln,registration_endpoint:Ln.optional(),scopes_supported:oe(D()).optional(),response_types_supported:oe(D()),response_modes_supported:oe(D()).optional(),grant_types_supported:oe(D()).optional(),token_endpoint_auth_methods_supported:oe(D()).optional(),token_endpoint_auth_signing_alg_values_supported:oe(D()).optional(),service_documentation:Ln.optional(),revocation_endpoint:Ln.optional(),revocation_endpoint_auth_methods_supported:oe(D()).optional(),revocation_endpoint_auth_signing_alg_values_supported:oe(D()).optional(),introspection_endpoint:D().optional(),introspection_endpoint_auth_methods_supported:oe(D()).optional(),introspection_endpoint_auth_signing_alg_values_supported:oe(D()).optional(),code_challenge_methods_supported:oe(D()).optional(),client_id_metadata_document_supported:Xe().optional()}),V9=zn({issuer:D(),authorization_endpoint:Ln,token_endpoint:Ln,userinfo_endpoint:Ln.optional(),jwks_uri:Ln,registration_endpoint:Ln.optional(),scopes_supported:oe(D()).optional(),response_types_supported:oe(D()),response_modes_supported:oe(D()).optional(),grant_types_supported:oe(D()).optional(),acr_values_supported:oe(D()).optional(),subject_types_supported:oe(D()),id_token_signing_alg_values_supported:oe(D()),id_token_encryption_alg_values_supported:oe(D()).optional(),id_token_encryption_enc_values_supported:oe(D()).optional(),userinfo_signing_alg_values_supported:oe(D()).optional(),userinfo_encryption_alg_values_supported:oe(D()).optional(),userinfo_encryption_enc_values_supported:oe(D()).optional(),request_object_signing_alg_values_supported:oe(D()).optional(),request_object_encryption_alg_values_supported:oe(D()).optional(),request_object_encryption_enc_values_supported:oe(D()).optional(),token_endpoint_auth_methods_supported:oe(D()).optional(),token_endpoint_auth_signing_alg_values_supported:oe(D()).optional(),display_values_supported:oe(D()).optional(),claim_types_supported:oe(D()).optional(),claims_supported:oe(D()).optional(),service_documentation:D().optional(),claims_locales_supported:oe(D()).optional(),ui_locales_supported:oe(D()).optional(),claims_parameter_supported:Xe().optional(),request_parameter_supported:Xe().optional(),request_uri_parameter_supported:Xe().optional(),require_request_uri_registration:Xe().optional(),op_policy_uri:Ln.optional(),op_tos_uri:Ln.optional(),client_id_metadata_document_supported:Xe().optional()}),U9=K({...V9.shape,...tR.pick({code_challenge_methods_supported:!0}).shape}),W9=K({access_token:D(),id_token:D().optional(),token_type:D(),expires_in:Qz().optional(),scope:D().optional(),refresh_token:D().optional()}).strip(),G9=K({error:D(),error_description:D().optional(),error_uri:D().optional()}),PA=Ln.optional().or(U("").transform(()=>{})),K9=K({redirect_uris:oe(Ln),token_endpoint_auth_method:D().optional(),grant_types:oe(D()).optional(),response_types:oe(D()).optional(),client_name:D().optional(),client_uri:Ln.optional(),logo_uri:PA,scope:D().optional(),contacts:oe(D()).optional(),tos_uri:PA,policy_uri:D().optional(),jwks_uri:Ln.optional(),jwks:nS().optional(),software_id:D().optional(),software_version:D().optional(),software_statement:D().optional()}).strip(),Z9=K({client_id:D(),client_secret:D().optional(),client_id_issued_at:Le().optional(),client_secret_expires_at:Le().optional()}).strip(),X9=K9.merge(Z9);K({error:D(),error_description:D().optional()}).strip();K({token:D(),token_type_hint:D().optional()}).strip();function Y9(n){const e=typeof n=="string"?new URL(n):new URL(n.href);return e.hash="",e}function J9({requestedResource:n,configuredResource:e}){const t=typeof n=="string"?new URL(n):new URL(n.href),s=typeof e=="string"?new URL(e):new URL(e.href);if(t.origin!==s.origin||t.pathname.length=400&&n.status<500&&e!=="/"}async function h6(n,e,t,s){const i=new URL(n),r=(s==null?void 0:s.protocolVersion)??u0;let o;if(s!=null&&s.metadataUrl)o=new URL(s.metadataUrl);else{const l=l6(e,i.pathname);o=new URL(l,(s==null?void 0:s.metadataServerUrl)??i),o.search=i.search}let a=await MA(o,r,t);if(!(s!=null&&s.metadataUrl)&&c6(a,i.pathname)){const l=new URL(`/.well-known/${e}`,i);a=await MA(l,r,t)}return a}function u6(n){const e=typeof n=="string"?new URL(n):n,t=e.pathname!=="/",s=[];if(!t)return s.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),s.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),s;let i=e.pathname;return i.endsWith("/")&&(i=i.slice(0,-1)),s.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,e.origin),type:"oauth"}),s.push({url:new URL(`/.well-known/openid-configuration${i}`,e.origin),type:"oidc"}),s.push({url:new URL(`${i}/.well-known/openid-configuration`,e.origin),type:"oidc"}),s}async function iR(n,{fetchFn:e=fetch,protocolVersion:t=u0}={}){var r;const s={"MCP-Protocol-Version":t,Accept:"application/json"},i=u6(n);for(const{url:o,type:a}of i){const l=await px(o,s,e);if(l){if(!l.ok){if(await((r=l.body)==null?void 0:r.cancel()),l.status>=400&&l.status<500)continue;throw new Error(`HTTP ${l.status} trying to load ${a==="oauth"?"OAuth":"OpenID provider"} metadata from ${o}`)}return a==="oauth"?tR.parse(await l.json()):U9.parse(await l.json())}}}async function d6(n,e){let t,s;try{t=await sR(n,{resourceMetadataUrl:e==null?void 0:e.resourceMetadataUrl},e==null?void 0:e.fetchFn),t.authorization_servers&&t.authorization_servers.length>0&&(s=t.authorization_servers[0])}catch{}s||(s=String(new URL("/",n)));const i=await iR(s,{fetchFn:e==null?void 0:e.fetchFn});return{authorizationServerUrl:s,authorizationServerMetadata:i,resourceMetadata:t}}async function f6(n,{metadata:e,clientInformation:t,redirectUrl:s,scope:i,state:r,resource:o}){let a;if(e){if(a=new URL(e.authorization_endpoint),!e.response_types_supported.includes(db))throw new Error(`Incompatible auth server: does not support response type ${db}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(fb))throw new Error(`Incompatible auth server: does not support code challenge method ${fb}`)}else a=new URL("/authorize",n);const l=await B9(),c=l.code_verifier,h=l.code_challenge;return a.searchParams.set("response_type",db),a.searchParams.set("client_id",t.client_id),a.searchParams.set("code_challenge",h),a.searchParams.set("code_challenge_method",fb),a.searchParams.set("redirect_uri",String(s)),r&&a.searchParams.set("state",r),i&&a.searchParams.set("scope",i),i!=null&&i.includes("offline_access")&&a.searchParams.append("prompt","consent"),o&&a.searchParams.set("resource",o.href),{authorizationUrl:a,codeVerifier:c}}function p6(n,e,t){return new URLSearchParams({grant_type:"authorization_code",code:n,code_verifier:e,redirect_uri:String(t)})}async function rR(n,{metadata:e,tokenRequestParams:t,clientInformation:s,addClientAuthentication:i,resource:r,fetchFn:o}){const a=e!=null&&e.token_endpoint?new URL(e.token_endpoint):new URL("/token",n),l=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(r&&t.set("resource",r.href),i)await i(l,t,a,e);else if(s){const h=(e==null?void 0:e.token_endpoint_auth_methods_supported)??[],u=t6(s,h);n6(u,s,l,t)}const c=await(o??fetch)(a,{method:"POST",headers:l,body:t});if(!c.ok)throw await nR(c);return W9.parse(await c.json())}async function m6(n,{metadata:e,clientInformation:t,refreshToken:s,resource:i,addClientAuthentication:r,fetchFn:o}){const a=new URLSearchParams({grant_type:"refresh_token",refresh_token:s}),l=await rR(n,{metadata:e,tokenRequestParams:a,clientInformation:t,addClientAuthentication:r,resource:i,fetchFn:o});return{refresh_token:s,...l}}async function g6(n,e,{metadata:t,resource:s,authorizationCode:i,fetchFn:r}={}){const o=n.clientMetadata.scope;let a;if(n.prepareTokenRequest&&(a=await n.prepareTokenRequest(o)),!a){if(!i)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!n.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");const c=await n.codeVerifier();a=p6(i,c,n.redirectUrl)}const l=await n.clientInformation();return rR(e,{metadata:t,tokenRequestParams:a,clientInformation:l??void 0,addClientAuthentication:n.addClientAuthentication,resource:s,fetchFn:r})}async function y6(n,{metadata:e,clientMetadata:t,scope:s,fetchFn:i}){let r;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");r=new URL(e.registration_endpoint)}else r=new URL("/register",n);const o=await(i??fetch)(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,...s!==void 0?{scope:s}:{}})});if(!o.ok)throw await nR(o);return X9.parse(await o.json())}class gb extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const IA=10,b6=13,Ba=32;function yb(n){}function v6(n){if(typeof n=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:e=yb,onError:t=yb,onRetry:s=yb,onComment:i,maxBufferSize:r}=n,o=[];let a=0,l=!0,c,h="",u=0,d,p=!1;function m(k){if(p)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l&&(l=!1,k.charCodeAt(0)===239&&k.charCodeAt(1)===187&&k.charCodeAt(2)===191&&(k=k.slice(3))),o.length===0){const O=b(k);O!==""&&(o.push(O),a=O.length),g();return}if(k.indexOf(` +`)===-1&&k.indexOf("\r")===-1){o.push(k),a+=k.length,g();return}o.push(k);const E=o.join("");o.length=0,a=0;const T=b(E);T!==""&&(o.push(T),a=T.length),g()}function g(){r!==void 0&&(a+h.length<=r||(p=!0,o.length=0,a=0,c=void 0,h="",u=0,d=void 0,t(new gb(`Buffered data exceeded max buffer size of ${r} characters`,{type:"max-buffer-size-exceeded"}))))}function b(k){let E=0;if(k.indexOf("\r")===-1){let T=k.indexOf(` +`,E);for(;T!==-1;){if(E===T){u>0&&e({id:c,event:d,data:h}),c=void 0,h="",u=0,d=void 0,E=T+1,T=k.indexOf(` +`,E);continue}const O=k.charCodeAt(E);if(OA(k,E,O)){const F=k.charCodeAt(E+5)===Ba?E+6:E+5,j=k.slice(F,T);if(u===0&&k.charCodeAt(T+1)===IA){e({id:c,event:d,data:j}),c=void 0,h="",d=void 0,E=T+2,T=k.indexOf(` +`,E);continue}h=u===0?j:`${h} +${j}`,u++}else NA(k,E,O)?d=k.slice(k.charCodeAt(E+6)===Ba?E+7:E+6,T)||void 0:y(k,E,T);E=T+1,T=k.indexOf(` +`,E)}return k.slice(E)}for(;E20?`${k.slice(0,20)}…`:k}"`,{type:"unknown-field",field:k,value:E,line:T}));break}}function v(){u>0&&e({id:c,event:d,data:h}),c=void 0,h="",u=0,d=void 0}function x(k={}){if(k.consume&&o.length>0){const E=o.join("");y(E,0,E.length)}l=!0,c=void 0,h="",u=0,d=void 0,o.length=0,a=0,p=!1}return{feed:m,reset:x}}function OA(n,e,t){return t===100&&n.charCodeAt(e+1)===97&&n.charCodeAt(e+2)===116&&n.charCodeAt(e+3)===97&&n.charCodeAt(e+4)===58}function NA(n,e,t){return t===101&&n.charCodeAt(e+1)===118&&n.charCodeAt(e+2)===101&&n.charCodeAt(e+3)===110&&n.charCodeAt(e+4)===116&&n.charCodeAt(e+5)===58}class w6 extends TransformStream{constructor({onError:e,onRetry:t,onComment:s,maxBufferSize:i}={}){let r;super({start(o){r=v6({onEvent:a=>{o.enqueue(a)},onError(a){typeof e=="function"&&e(a),(e==="terminate"||a.type==="max-buffer-size-exceeded")&&o.error(a)},onRetry:t,onComment:s,maxBufferSize:i})},transform(o){r.feed(o)}})}}const _6={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Lc extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}class S6{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t==null?void 0:t.requestInit,this._authProvider=t==null?void 0:t.authProvider,this._fetch=t==null?void 0:t.fetch,this._fetchWithInit=D9(t==null?void 0:t.fetch,t==null?void 0:t.requestInit),this._sessionId=t==null?void 0:t.sessionId,this._reconnectionOptions=(t==null?void 0:t.reconnectionOptions)??_6}async _authThenStart(){var t;if(!this._authProvider)throw new Nc("No auth provider");let e;try{e=await Em(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(s){throw(t=this.onerror)==null||t.call(this,s),s}if(e!=="AUTHORIZED")throw new Nc;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var s;const e={};if(this._authProvider){const i=await this._authProvider.tokens();i&&(e.Authorization=`Bearer ${i.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const t=Sv((s=this._requestInit)==null?void 0:s.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){var s,i,r;const{resumptionToken:t}=e;try{const o=await this._commonHeaders();o.set("Accept","text/event-stream"),t&&o.set("last-event-id",t);const a=await(this._fetch??fetch)(this._url,{method:"GET",headers:o,signal:(s=this._abortController)==null?void 0:s.signal});if(!a.ok){if(await((i=a.body)==null?void 0:i.cancel()),a.status===401&&this._authProvider)return await this._authThenStart();if(a.status===405)return;throw new Lc(a.status,`Failed to open SSE stream: ${a.statusText}`)}this._handleSseStream(a.body,e,!0)}catch(o){throw(r=this.onerror)==null||r.call(this,o),o}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const t=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,i=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(s,e),i)}_scheduleReconnection(e,t=0){var r;const s=this._reconnectionOptions.maxRetries;if(t>=s){(r=this.onerror)==null||r.call(this,new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}const i=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(o=>{var a;(a=this.onerror)==null||a.call(this,new Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`)),this._scheduleReconnection(e,t+1)})},i)}_handleSseStream(e,t,s){if(!e)return;const{onresumptiontoken:i,replayMessageId:r}=t;let o,a=!1,l=!1;(async()=>{var h,u,d,p;try{const m=e.pipeThrough(new TextDecoderStream).pipeThrough(new w6({onRetry:y=>{this._serverRetryMs=y}})).getReader();for(;;){const{value:y,done:w}=await m.read();if(w)break;if(y.id&&(o=y.id,a=!0,i==null||i(y.id)),!!y.data&&(!y.event||y.event==="message"))try{const v=Jm.parse(JSON.parse(y.data));ld(v)&&(l=!0,r!==void 0&&(v.id=r)),(h=this.onmessage)==null||h.call(this,v)}catch(v){(u=this.onerror)==null||u.call(this,v)}}(s||a)&&!l&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:o,onresumptiontoken:i,replayMessageId:r},0)}catch(m){if((d=this.onerror)==null||d.call(this,new Error(`SSE stream disconnected: ${m}`)),(s||a)&&!l&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:o,onresumptiontoken:i,replayMessageId:r},0)}catch(y){(p=this.onerror)==null||p.call(this,new Error(`Failed to reconnect: ${y instanceof Error?y.message:String(y)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new Nc("No auth provider");if(await Em(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Nc("Failed to authorize")}async close(){var e,t;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(e=this._abortController)==null||e.abort(),(t=this.onclose)==null||t.call(this)}async send(e,t){var s,i,r,o,a,l;try{const{resumptionToken:c,onresumptiontoken:h}=t||{};if(c){this._startOrAuthSse({resumptionToken:c,replayMessageId:nv(e)?e.id:void 0}).catch(v=>{var x;return(x=this.onerror)==null?void 0:x.call(this,v)});return}const u=await this._commonHeaders();u.set("content-type","application/json"),u.set("accept","application/json, text/event-stream");const d={...this._requestInit,method:"POST",headers:u,body:JSON.stringify(e),signal:(s=this._abortController)==null?void 0:s.signal},p=await(this._fetch??fetch)(this._url,d),m=p.headers.get("mcp-session-id");if(m&&(this._sessionId=m),!p.ok){const v=await p.text().catch(()=>null);if(p.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Lc(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:x,scope:k}=RA(p);if(this._resourceMetadataUrl=x,this._scope=k,await Em(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Nc;return this._hasCompletedAuthFlow=!0,this.send(e)}if(p.status===403&&this._authProvider){const{resourceMetadataUrl:x,scope:k,error:E}=RA(p);if(E==="insufficient_scope"){const T=p.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===T)throw new Lc(403,"Server returned 403 after trying upscoping");if(k&&(this._scope=k),x&&(this._resourceMetadataUrl=x),this._lastUpscopingHeader=T??void 0,await Em(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Nc;return this.send(e)}}throw new Lc(p.status,`Error POSTing to endpoint: ${v}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,p.status===202){await((i=p.body)==null?void 0:i.cancel()),gH(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(v=>{var x;return(x=this.onerror)==null?void 0:x.call(this,v)});return}const b=(Array.isArray(e)?e:[e]).filter(v=>"method"in v&&"id"in v&&v.id!==void 0).length>0,y=p.headers.get("content-type"),w=L9(y);if(b)if(w==="text/event-stream")this._handleSseStream(p.body,{onresumptiontoken:h},!1);else if(w==="application/json"){const v=await p.json(),x=Array.isArray(v)?v.map(k=>Jm.parse(k)):[Jm.parse(v)];for(const k of x)(r=this.onmessage)==null||r.call(this,k)}else throw await((o=p.body)==null?void 0:o.cancel()),new Lc(-1,`Unexpected content type: ${y}`);else await((a=p.body)==null?void 0:a.cancel())}catch(c){throw(l=this.onerror)==null||l.call(this,c),c}}get sessionId(){return this._sessionId}async terminateSession(){var e,t,s;if(this._sessionId)try{const i=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:i,signal:(e=this._abortController)==null?void 0:e.signal},o=await(this._fetch??fetch)(this._url,r);if(await((t=o.body)==null?void 0:t.cancel()),!o.ok&&o.status!==405)throw new Lc(o.status,`Failed to terminate session: ${o.statusText}`);this._sessionId=void 0}catch(i){throw(s=this.onerror)==null||s.call(this,i),i}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t==null?void 0:t.onresumptiontoken})}}const x6="https://mcp.excalidraw.com/mcp",k6="mcp.excalidraw.com",A6="/api/v1/chat/mcp-apps/excalidraw",oR="ui://excalidraw/mcp-app.html",E6=["read_me","create_view"],aR=new Set(["export_to_excalidraw","save_checkpoint","read_checkpoint"]),C6=256*1024,$6=1024*1024,T6=1024*1024,P6=240,R6=720,M6=525;function I6(n){return!Number.isFinite(n)||n<=0?M6:Math.max(P6,Math.min(R6,Math.round(n*3/4)))}const O6={excalidraw:{id:"excalidraw",endpoint:x6,hostname:k6,resourceUri:oR,modelTools:E6,appTools:aR}};function N6(n){return O6[n]}function L6(){return new URL(SL(A6),window.location.origin)}class D6{constructor(){ae(this,"client",new C9({name:"pwc-chat-mcp-app-host",version:"1"}));ae(this,"transport",new S6(L6(),{requestInit:{credentials:"include"}}));ae(this,"connected");ae(this,"bytes",0);ae(this,"closed",!1)}connect(){return this.closed?Promise.reject(new Error("App host client is closed")):(this.connected||(this.connected=this.client.connect(this.transport).then(()=>{},e=>{throw this.connected=void 0,this.retire(),e})),this.connected)}async readResource(e){if(e!==oR)throw new Error("Unapproved App resource");await this.connect();const s=(await this.client.readResource({uri:e})).contents[0];if(!s||!("text"in s)||typeof s.text!="string"||s.mimeType!=="text/html;profile=mcp-app")throw new Error("Incompatible App resource");this.consume(s.text,T6);const i=await H6(s.text);return{text:s.text,digest:i}}async callTool(e,t){if(!aR.has(e))throw new Error("Unapproved App tool");const s=JSON.stringify(t);this.consume(s);try{await this.connect();const i=await this.client.callTool({name:e,arguments:t});return this.consume(JSON.stringify(i)),i}catch(i){throw this.retire(),i}}close(){this.closed=!0,this.connected=void 0,this.transport.close()}retire(){this.close(),wa===this&&(wa=void 0)}consume(e,t=C6){const s=new TextEncoder().encode(e).byteLength;if(s>t||this.bytes+s>$6)throw new Error("App request exceeds host limit");this.bytes+=s}}let wa;function j6(){return wa??(wa=new D6),wa}function F6(){wa==null||wa.close(),wa=void 0}function z6(n){F6()}async function H6(n){const e=new TextEncoder().encode(n),t=await crypto.subtle.digest("SHA-256",e);return[...new Uint8Array(t)].map(s=>s.toString(16).padStart(2,"0")).join("")}function B6(n,e){let t=!1,s=0;const i=()=>{t||!n.contentWindow||(t=!0,e())};n.addEventListener("load",i);const r=window.requestAnimationFrame(()=>{s=window.requestAnimationFrame(i)});return()=>{t=!0,n.removeEventListener("load",i),window.cancelAnimationFrame(r),window.cancelAnimationFrame(s)}}const q6=({block:n})=>{const e=ee.useRef(null),t=ee.useRef(null),s=ee.useRef(!1),i=ee.useRef(n),r=ee.useRef(!1);i.current=n;const[o,a]=ee.useState(),[l,c]=ee.useState("loading"),[h,u]=ee.useState(n.height),[d,p]=ee.useState(!1),[m,g]=ee.useState(0),b=ee.useRef(null),y=n.input.elements,w=!!n.permissions.clipboardWrite;r.current=d;const v=ee.useCallback(()=>{p(!1),document.fullscreenElement&&document.exitFullscreen()},[]),x=ee.useCallback(()=>{var T,O;if(d){v();return}p(!0),(O=(T=b.current)==null?void 0:T.requestFullscreen)==null||O.call(T).catch(()=>{})},[v,d]),k=ee.useCallback(()=>{z6(),a(void 0),c("loading"),g(T=>T+1)},[]);ee.useEffect(()=>{const T=b.current;if(!T)return;const O=()=>{r.current||u(I6(T.clientWidth))};O();const F=new ResizeObserver(O);return F.observe(T),()=>F.disconnect()},[]),ee.useEffect(()=>{if(!d)return;const T=b.current,O=j=>{j.key==="Escape"&&(document.fullscreenElement||v())},F=()=>{document.fullscreenElement||p(!1)};return window.addEventListener("keydown",O),document.addEventListener("fullscreenchange",F),()=>{window.removeEventListener("keydown",O),document.removeEventListener("fullscreenchange",F),document.fullscreenElement===T&&document.exitFullscreen()}},[v,d]),ee.useEffect(()=>{N6(n.provider);{c("unavailable");return}},[m,n.provider,n.resource_uri]),ee.useEffect(()=>{if(!o||l!=="ready")return;const T=e.current;if(!T)return;let O=null;const F=[],j=B6(T,()=>{T.contentWindow&&(O=new KB(null,{name:"Papers with Code",version:"1"},{serverTools:{},openLinks:{},logging:{},...w?{clipboard:{write:{}}}:{}},{hostContext:{theme:document.documentElement.dataset.theme==="dark"?"dark":"light",displayMode:d?"fullscreen":"inline"}}),O.oncalltool=async({name:L,arguments:B})=>{if(i.current.public_fork&&L!=="export_to_excalidraw")throw new Error("Shared diagrams cannot mutate owner state");return j6().callTool(L,B??{})},O.onopenlink=async({url:L})=>{const B=new URL(L);if(B.protocol!=="https:"||B.hostname!=="excalidraw.com")throw new Error("External navigation denied");if(!window.confirm("This export opens Excalidraw and uploads the diagram to its service. Continue?"))throw new Error("Export cancelled");return window.open(B.href,"_blank","noopener,noreferrer"),{}},O.onsizechange=()=>{},O.oninitialized=()=>{const L=O;if(!L){c("error");return}s.current=!0;try{const B=JSON.parse(y),Z={arguments:{elements:Array.isArray(B)?sq(B):B}};for(const q of[0,50,200,750])F.push(window.setTimeout(()=>{t.current===L&&L.sendToolInput(Z)},q));L.sendToolResult(i.current.result)}catch{c("error")}},t.current=O,O.connect(new WB(T.contentWindow??void 0,T.contentWindow)).catch(()=>c("error")))});return()=>{j(),F.forEach(L=>window.clearTimeout(L)),s.current=!1,O==null||O.teardownResource({}).catch(()=>{}),t.current===O&&(t.current=null)}},[o,l,d,y,w,m]),ee.useEffect(()=>{var T;l!=="ready"||!s.current||(T=t.current)==null||T.sendToolResult(n.result).catch(()=>{})},[n.result,l]);const E=l==="unavailable"||l==="incompatible"||l==="error";return S.jsxs("section",{ref:b,className:`chat-mcp-app${d?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[S.jsx("header",{children:S.jsx("button",{type:"button",onClick:x,children:d?"Exit fullscreen":"Fullscreen"})}),l==="loading"&&S.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),E&&S.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",S.jsx("button",{type:"button",onClick:k,children:"Retry diagram"})]}),o&&l==="ready"&&S.jsx("iframe",{ref:e,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:w?"clipboard-write":void 0,srcDoc:o,style:{height:h}},m)]})},lR={list:n=>["chatSessions",n],detail:(n,e)=>["chatSession",n,e]},pse=n=>o0({queryKey:lR.list(n),queryFn:OL,staleTime:0,refetchOnWindowFocus:!1,retry:!1}),mse=(n,e)=>o0({queryKey:lR.detail(n,e),queryFn:()=>{if(!e)throw new Error("A saved conversation is required");return ts.getSession(e)},staleTime:0,refetchOnWindowFocus:!1,retry:!1}),gse=n=>o0({queryKey:["chat","models",n],queryFn:()=>ts.getModels()}),yse=()=>o0({queryKey:["chatAvailability"],queryFn:()=>ts.getAvailability(),refetchInterval:3e4,retry:!1}),ri={posterVersions:n=>["chatArtifact",n,"posterVersions"],latexPaper:n=>["chatArtifact",n,"latexPaper"],history:(n,e)=>e===void 0?["chatArtifact",n,"history"]:["chatArtifact",n,"history",e],manifest:(n,e)=>e===void 0?["chatArtifact",n,"manifest"]:["chatArtifact",n,"manifest",e],source:(n,e,t)=>["chatArtifact",n,"source",e,t],sourceFiles:(n,e)=>e===void 0?["chatArtifact",n,"sourceFiles"]:["chatArtifact",n,"sourceFiles",e]},V6=.25,U6=4,LA=[.25,.33,.5,.67,.75,.9,1,1.1,1.25,1.5,1.75,2,2.5,3,4];function Nv(n){return Math.max(V6,Math.min(U6,n))}function dy(n,e){const t=e>0?LA:[...LA].reverse();return t.find(s=>(s-n)*e>.005)??t[t.length-1]}function W6({paperTitle:n,paperHref:e,resources:t,label:s,children:i}){const r=V.useRef(null);return V.useLayoutEffect(()=>{const o=r.current,a=document.querySelector(".app-header .brand-mark");if(!o||!a)return;const l=()=>{const h=a.getBoundingClientRect().left-o.getBoundingClientRect().left;o.style.setProperty("--reader-title-inset",`${Math.max(10,h)}px`)};l();const c=new ResizeObserver(l);return c.observe(o),c.observe(a),()=>c.disconnect()},[]),S.jsxs("div",{ref:r,className:"pdf-toolbar","aria-label":s,children:[S.jsxs("div",{className:"pdf-toolbar-paper",children:[S.jsxs(Md,{className:"pdf-toolbar-back",to:e,"aria-label":"Back",children:[S.jsx(JL,{size:15,strokeWidth:1.8,"aria-hidden":"true"}),S.jsx("span",{children:"Back"})]}),S.jsx(Md,{className:"pdf-toolbar-title",to:e,title:n,"aria-label":`${n} — open paper page`,children:n}),(t==null?void 0:t.repository)&&S.jsxs("a",{className:"pdf-toolbar-resource",href:t.repository.href,target:"_blank",rel:"noopener noreferrer",title:"Official GitHub repository","aria-label":"Open official GitHub repository",children:[S.jsx(i0,{size:15,strokeWidth:1.8,"aria-hidden":"true"}),S.jsxs("span",{"aria-label":`${t.repository.stars} GitHub stars`,children:["★ ",t.repository.stars.toLocaleString()]})]}),(t==null?void 0:t.projectPage)&&S.jsxs("a",{className:"pdf-toolbar-resource",href:t.projectPage.href,target:"_blank",rel:"noopener noreferrer",title:t.projectPage.href,"aria-label":`Open project page at ${t.projectPage.label}`,children:[S.jsx(WC,{size:14,strokeWidth:1.8,"aria-hidden":"true"}),S.jsx("span",{children:t.projectPage.label})]}),(t==null?void 0:t.huggingFace)&&S.jsxs("a",{className:"pdf-toolbar-resource",href:t.huggingFace.href,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${t.huggingFace.count} Hugging Face ${t.huggingFace.count===1?"artifact":"artifacts"}`,children:[S.jsx("span",{"aria-hidden":"true",children:"🤗"}),S.jsxs("span",{children:[t.huggingFace.count," HF ",t.huggingFace.count===1?"artifact":"artifacts"]})]})]}),i]})}function G6({paperTitle:n,paperHref:e,resources:t,page:s,pages:i,zoomPercent:r,searchOpen:o,searchQuery:a,searchMatch:l,searchCount:c,searching:h,onPage:u,onZoom:d,onZoomIn:p,onZoomOut:m,onToggleSearch:g,onCloseSearch:b,onSearchQuery:y,onSearch:w}){const v=k=>{k.preventDefault();const E=Number(new FormData(k.currentTarget).get("page"));Number.isInteger(E)&&u(E)},x=k=>{k.preventDefault();const E=k.currentTarget.elements.namedItem("zoom"),T=Number.parseFloat(E.value),O=Number.isFinite(T)&&T>0?Nv(T/100):r/100;E.value=`${Math.round(O*100)}%`,d(O)};return S.jsxs(W6,{paperTitle:n,paperHref:e,resources:t,label:"PDF controls",children:[S.jsxs("div",{className:"pdf-toolbar-controls",children:[S.jsxs("div",{className:"pdf-toolbar-group",children:[S.jsx("button",{type:"button",onClick:()=>u(s-1),disabled:s<=1,"aria-label":"Previous page",children:S.jsx(sD,{size:16,"aria-hidden":"true"})}),S.jsxs("form",{onSubmit:v,className:"pdf-page-form",children:[S.jsx("label",{className:"sr-only",htmlFor:"pdf-current-page",children:"Current page"}),S.jsx("input",{id:"pdf-current-page",name:"page",type:"number",min:1,max:i||1,defaultValue:s,"aria-label":`Page ${s} of ${i||"unknown"}`},s),S.jsxs("span",{"aria-hidden":"true",children:["/ ",i||"—"]})]}),S.jsx("button",{type:"button",onClick:()=>u(s+1),disabled:!i||s>=i,"aria-label":"Next page",children:S.jsx(xL,{size:16,"aria-hidden":"true"})})]}),S.jsxs("div",{className:"pdf-toolbar-group",children:[S.jsx("button",{type:"button",onClick:m,"aria-label":"Zoom out",children:S.jsx(oD,{size:15,"aria-hidden":"true"})}),S.jsx("form",{onSubmit:x,className:"pdf-zoom-form",children:S.jsx("input",{className:"pdf-zoom-value",name:"zoom",inputMode:"decimal",defaultValue:`${r}%`,onFocus:k=>k.currentTarget.select(),onBlur:k=>{var E;return(E=k.currentTarget.form)==null?void 0:E.requestSubmit()},"aria-label":`Zoom ${r}%`},r)}),S.jsx("button",{type:"button",onClick:p,"aria-label":"Zoom in",children:S.jsx(QL,{size:15,"aria-hidden":"true"})})]}),S.jsxs("button",{type:"button",className:"pdf-toolbar-search",onClick:g,"aria-label":"Search","aria-expanded":o,"aria-controls":"pdf-search-controls",children:[S.jsx(eD,{size:14,strokeWidth:2,"aria-hidden":"true"}),S.jsx("span",{children:"Search"})]})]}),o&&S.jsxs("div",{id:"pdf-search-controls",className:"pdf-search-controls",children:[S.jsx("label",{className:"sr-only",htmlFor:"pdf-search-input",children:"Search document"}),S.jsx("input",{id:"pdf-search-input",autoFocus:!0,value:a,onChange:k=>y(k.target.value),placeholder:"Search document"}),S.jsx("span",{role:"status",children:h&&!c?"Searching…":a?`${c?l+1:0} of ${c}${h?"+":""}`:""}),S.jsx("button",{type:"button",onClick:()=>w(-1),disabled:!c,"aria-label":"Previous match",children:S.jsx(GC,{size:16,"aria-hidden":"true"})}),S.jsx("button",{type:"button",onClick:()=>w(1),disabled:!c,"aria-label":"Next match",children:S.jsx(KC,{size:16,"aria-hidden":"true"})}),S.jsx("button",{type:"button",onClick:b,"aria-label":"Close search",title:"Close search",children:S.jsx(n0,{size:16,"aria-hidden":"true"})})]})]})}var Ud={};Ud.d=(n,e)=>{for(var t in e)Ud.o(e,t)&&!Ud.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:e[t]})};Ud.o=(n,e)=>Object.prototype.hasOwnProperty.call(n,e);var Re=globalThis.pdfjsLib={};Ud.d(Re,{AbortException:()=>$c,AnnotationEditorLayer:()=>Gw,AnnotationEditorParamsType:()=>Te,AnnotationEditorType:()=>Ne,AnnotationEditorUIManager:()=>mc,AnnotationLayer:()=>UZ,AnnotationMode:()=>Ho,ColorPicker:()=>gy,DOMSVGFactory:()=>Ex,DrawLayer:()=>Yw,FeatureTest:()=>fs,GlobalWorkerOptions:()=>mo,ImageKind:()=>cg,InvalidPDFException:()=>hR,MissingPDFException:()=>Cc,OPS:()=>Ti,OutputScale:()=>zv,PDFDataRangeTransport:()=>oM,PDFDateString:()=>vx,PDFWorker:()=>lh,PasswordResponses:()=>Y6,PermissionFlag:()=>X6,PixelsPerInch:()=>$a,RenderingCancelledException:()=>yx,TextLayer:()=>pw,UnexpectedResponseException:()=>P0,Util:()=>Se,VerbosityLevel:()=>C0,XfaLayer:()=>lM,build:()=>AZ,createValidAbsoluteUrl:()=>t8,fetchData:()=>M0,getDocument:()=>gZ,getFilenameFromUrl:()=>h8,getPdfFilenameFromUrl:()=>u8,getXfaPageViewport:()=>d8,isDataScheme:()=>I0,isPdfFile:()=>bx,noContextMenu:()=>wi,normalizeUnicode:()=>a8,setLayerDimensions:()=>pc,shadow:()=>Ge,version:()=>kZ});const is=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),cR=[1,0,0,1,0,0],Lv=[.001,0,0,.001,0,0],K6=1e7,bb=1.35,Xs={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Ho={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Z6="pdfjs_internal_editor_",Ne={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Te={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},X6={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Kn={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},cg={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},rn={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,WIDGET:20},Ju={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},C0={ERRORS:0,WARNINGS:1,INFOS:5},Ti={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},Y6={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let $0=C0.WARNINGS;function J6(n){Number.isInteger(n)&&($0=n)}function Q6(){return $0}function T0(n){$0>=C0.INFOS&&console.log(`Info: ${n}`)}function He(n){$0>=C0.WARNINGS&&console.log(`Warning: ${n}`)}function Et(n){throw new Error(n)}function dn(n,e){n||Et(e)}function e8(n){switch(n==null?void 0:n.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function t8(n,e=null,t=null){if(!n)return null;try{if(t&&typeof n=="string"){if(t.addDefaultProtocol&&n.startsWith("www.")){const i=n.match(/\./g);(i==null?void 0:i.length)>=2&&(n=`http://${n}`)}if(t.tryConvertEncoding)try{n=o8(n)}catch{}}const s=e?new URL(n,e):new URL(n);if(e8(s))return s}catch{}return null}function Ge(n,e,t,s=!1){return Object.defineProperty(n,e,{value:t,enumerable:!s,configurable:!0,writable:!1}),t}const La=function(){function e(t,s){this.message=t,this.name=s}return e.prototype=new Error,e.constructor=e,e}();class Dv extends La{constructor(e,t){super(e,"PasswordException"),this.code=t}}class jv extends La{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}}class hR extends La{constructor(e){super(e,"InvalidPDFException")}}class Cc extends La{constructor(e){super(e,"MissingPDFException")}}class P0 extends La{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}}class n8 extends La{constructor(e){super(e,"FormatError")}}class $c extends La{constructor(e){super(e,"AbortException")}}function uR(n){(typeof n!="object"||(n==null?void 0:n.length)===void 0)&&Et("Invalid argument for bytesToString");const e=n.length,t=8192;if(e>24&255,n>>16&255,n>>8&255,n&255)}function mx(n){const e=Object.create(null);for(const[t,s]of n)e[t]=s;return e}function i8(){const n=new Uint8Array(4);return n[0]=1,new Uint32Array(n.buffer,0,1)[0]===1}function r8(){try{return new Function(""),!0}catch{return!1}}class fs{static get isLittleEndian(){return Ge(this,"isLittleEndian",i8())}static get isEvalSupported(){return Ge(this,"isEvalSupported",r8())}static get isOffscreenCanvasSupported(){return Ge(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?Ge(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof(navigator==null?void 0:navigator.userAgent)=="string"&&navigator.userAgent.includes("Firefox")}):Ge(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var e,t;return Ge(this,"isCSSRoundSupported",(t=(e=globalThis.CSS)==null?void 0:e.supports)==null?void 0:t.call(e,"width: round(1.5px, 1px)"))}}const vb=Array.from(Array(256).keys(),n=>n.toString(16).padStart(2,"0"));var ko,hg,Fv;class Se{static makeHexColor(e,t,s){return`#${vb[e]}${vb[t]}${vb[s]}`}static scaleMinMax(e,t){let s;e[0]?(e[0]<0&&(s=t[0],t[0]=t[2],t[2]=s),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(s=t[1],t[1]=t[3],t[3]=s),t[1]*=e[3],t[3]*=e[3]):(s=t[0],t[0]=t[1],t[1]=s,s=t[2],t[2]=t[3],t[3]=s,e[1]<0&&(s=t[1],t[1]=t[3],t[3]=s),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(s=t[0],t[0]=t[2],t[2]=s),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){const s=e[0]*t[0]+e[1]*t[2]+t[4],i=e[0]*t[1]+e[1]*t[3]+t[5];return[s,i]}static applyInverseTransform(e,t){const s=t[0]*t[3]-t[1]*t[2],i=(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/s,r=(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/s;return[i,r]}static getAxialAlignedBoundingBox(e,t){const s=this.applyTransform(e,t),i=this.applyTransform(e.slice(2,4),t),r=this.applyTransform([e[0],e[3]],t),o=this.applyTransform([e[2],e[1]],t);return[Math.min(s[0],i[0],r[0],o[0]),Math.min(s[1],i[1],r[1],o[1]),Math.max(s[0],i[0],r[0],o[0]),Math.max(s[1],i[1],r[1],o[1])]}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){const t=[e[0],e[2],e[1],e[3]],s=e[0]*t[0]+e[1]*t[2],i=e[0]*t[1]+e[1]*t[3],r=e[2]*t[0]+e[3]*t[2],o=e[2]*t[1]+e[3]*t[3],a=(s+o)/2,l=Math.sqrt((s+o)**2-4*(s*o-r*i))/2,c=a+l||1,h=a-l||1;return[Math.sqrt(c),Math.sqrt(h)]}static normalizeRect(e){const t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){const s=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),i=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(s>i)return null;const r=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),o=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return r>o?null:[s,r,i,o]}static bezierBoundingBox(e,t,s,i,r,o,a,l,c){return c?(c[0]=Math.min(c[0],e,a),c[1]=Math.min(c[1],t,l),c[2]=Math.max(c[2],e,a),c[3]=Math.max(c[3],t,l)):c=[Math.min(e,a),Math.min(t,l),Math.max(e,a),Math.max(t,l)],P(this,ko,Fv).call(this,e,s,r,a,t,i,o,l,3*(-e+3*(s-r)+a),6*(e-2*s+r),3*(s-e),c),P(this,ko,Fv).call(this,e,s,r,a,t,i,o,l,3*(-t+3*(i-o)+l),6*(t-2*i+o),3*(i-t),c),c}}ko=new WeakSet,hg=function(e,t,s,i,r,o,a,l,c,h){if(c<=0||c>=1)return;const u=1-c,d=c*c,p=d*c,m=u*(u*(u*e+3*c*t)+3*d*s)+p*i,g=u*(u*(u*r+3*c*o)+3*d*a)+p*l;h[0]=Math.min(h[0],m),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],m),h[3]=Math.max(h[3],g)},Fv=function(e,t,s,i,r,o,a,l,c,h,u,d){if(Math.abs(c)<1e-12){Math.abs(h)>=1e-12&&P(this,ko,hg).call(this,e,t,s,i,r,o,a,l,-u/h,d);return}const p=h**2-4*u*c;if(p<0)return;const m=Math.sqrt(p),g=2*c;P(this,ko,hg).call(this,e,t,s,i,r,o,a,l,(-h+m)/g,d),P(this,ko,hg).call(this,e,t,s,i,r,o,a,l,(-h-m)/g,d)},M(Se,ko);function o8(n){return decodeURIComponent(escape(n))}let wb=null,DA=null;function a8(n){return wb||(wb=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,DA=new Map([["ſt","ſt"]])),n.replaceAll(wb,(e,t,s)=>t?t.normalize("NFKC"):DA.get(s))}function l8(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const n=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(n);else for(let e=0;e<32;e++)n[e]=Math.floor(Math.random()*255);return uR(n)}const gx="pdfjs_internal_id_",Fr={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};function c8(n){return Uint8Array.prototype.toBase64?n.toBase64():btoa(uR(n))}const Hr="http://www.w3.org/2000/svg",ol=class ol{};ae(ol,"CSS",96),ae(ol,"PDF",72),ae(ol,"PDF_TO_CSS_UNITS",ol.CSS/ol.PDF);let $a=ol;async function M0(n,e="text"){if(dd(n,document.baseURI)){const t=await fetch(n);if(!t.ok)throw new Error(t.statusText);switch(e){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"json":return t.json()}return t.text()}return new Promise((t,s)=>{const i=new XMLHttpRequest;i.open("GET",n,!0),i.responseType=e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(e){case"arraybuffer":case"blob":case"json":t(i.response);return}t(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class Jp{constructor({viewBox:e,scale:t,rotation:s,offsetX:i=0,offsetY:r=0,dontFlip:o=!1}){this.viewBox=e,this.scale=t,this.rotation=s,this.offsetX=i,this.offsetY=r;const a=(e[2]+e[0])/2,l=(e[3]+e[1])/2;let c,h,u,d;switch(s%=360,s<0&&(s+=360),s){case 180:c=-1,h=0,u=0,d=1;break;case 90:c=0,h=1,u=1,d=0;break;case 270:c=0,h=-1,u=-1,d=0;break;case 0:c=1,h=0,u=0,d=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(u=-u,d=-d);let p,m,g,b;c===0?(p=Math.abs(l-e[1])*t+i,m=Math.abs(a-e[0])*t+r,g=(e[3]-e[1])*t,b=(e[2]-e[0])*t):(p=Math.abs(a-e[0])*t+i,m=Math.abs(l-e[1])*t+r,g=(e[2]-e[0])*t,b=(e[3]-e[1])*t),this.transform=[c*t,h*t,u*t,d*t,p-c*t*a-u*t*l,m-h*t*a-d*t*l],this.width=g,this.height=b}get rawDims(){const{viewBox:e}=this;return Ge(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new Jp({viewBox:this.viewBox.slice(),scale:e,rotation:t,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(e,t){return Se.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){const t=Se.applyTransform([e[0],e[1]],this.transform),s=Se.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],s[0],s[1]]}convertToPdfPoint(e,t){return Se.applyInverseTransform([e,t],this.transform)}}class yx extends La{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function I0(n){const e=n.length;let t=0;for(;t=1&&i<=12?i-1:0;let r=parseInt(t[3],10);r=r>=1&&r<=31?r:1;let o=parseInt(t[4],10);o=o>=0&&o<=23?o:0;let a=parseInt(t[5],10);a=a>=0&&a<=59?a:0;let l=parseInt(t[6],10);l=l>=0&&l<=59?l:0;const c=t[7]||"Z";let h=parseInt(t[8],10);h=h>=0&&h<=23?h:0;let u=parseInt(t[9],10)||0;return u=u>=0&&u<=59?u:0,c==="-"?(o+=h,a+=u):c==="+"&&(o-=h,a-=u),new Date(Date.UTC(s,i,r,o,a,l))}}bf=new WeakMap,M(vx,bf);function d8(n,{scale:e=1,rotation:t=0}){const{width:s,height:i}=n.attributes.style,r=[0,0,parseInt(s),parseInt(i)];return new Jp({viewBox:r,scale:e,rotation:t})}function wx(n){if(n.startsWith("#")){const e=parseInt(n.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}return n.startsWith("rgb(")?n.slice(4,-1).split(",").map(e=>parseInt(e)):n.startsWith("rgba(")?n.slice(5,-1).split(",").map(e=>parseInt(e)).slice(0,3):(He(`Not a valid color format: "${n}"`),[0,0,0])}function f8(n){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const t of n.keys()){e.style.color=t;const s=window.getComputedStyle(e).color;n.set(t,wx(s))}e.remove()}function Lt(n){const{a:e,b:t,c:s,d:i,e:r,f:o}=n.getTransform();return[e,t,s,i,r,o]}function zr(n){const{a:e,b:t,c:s,d:i,e:r,f:o}=n.getTransform().invertSelf();return[e,t,s,i,r,o]}function pc(n,e,t=!1,s=!0){if(e instanceof Jp){const{pageWidth:i,pageHeight:r}=e.rawDims,{style:o}=n,a=fs.isCSSRoundSupported,l=`var(--scale-factor) * ${i}px`,c=`var(--scale-factor) * ${r}px`,h=a?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,u=a?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!t||e.rotation%180===0?(o.width=h,o.height=u):(o.width=u,o.height=h)}s&&n.setAttribute("data-main-rotation",e.rotation)}class zv{constructor(){const e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}}var Vo,hl,Pi,ul,vf,wf,Fy,dR,ms,fR,pR,ug,mR,Bv;const Br=class Br{constructor(e){M(this,ms);M(this,Vo,null);M(this,hl,null);M(this,Pi);M(this,ul,null);M(this,vf,null);$(this,Pi,e),f(Br,wf)||$(Br,wf,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"}))}render(){const e=$(this,Vo,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const t=f(this,Pi)._uiManager._signal;e.addEventListener("contextmenu",wi,{signal:t}),e.addEventListener("pointerdown",P(Br,Fy,dR),{signal:t});const s=$(this,ul,document.createElement("div"));s.className="buttons",e.append(s);const i=f(this,Pi).toolbarPosition;if(i){const{style:r}=e,o=f(this,Pi)._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*o}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return P(this,ms,mR).call(this),e}get div(){return f(this,Vo)}hide(){var e;f(this,Vo).classList.add("hidden"),(e=f(this,hl))==null||e.hideDropdown()}show(){var e;f(this,Vo).classList.remove("hidden"),(e=f(this,vf))==null||e.shown()}async addAltText(e){const t=await e.render();P(this,ms,ug).call(this,t),f(this,ul).prepend(t,f(this,ms,Bv)),$(this,vf,e)}addColorPicker(e){$(this,hl,e);const t=e.renderButton();P(this,ms,ug).call(this,t),f(this,ul).prepend(t,f(this,ms,Bv))}remove(){var e;f(this,Vo).remove(),(e=f(this,hl))==null||e.destroy(),$(this,hl,null)}};Vo=new WeakMap,hl=new WeakMap,Pi=new WeakMap,ul=new WeakMap,vf=new WeakMap,wf=new WeakMap,Fy=new WeakSet,dR=function(e){e.stopPropagation()},ms=new WeakSet,fR=function(e){f(this,Pi)._focusEventsAllowed=!1,e.preventDefault(),e.stopPropagation()},pR=function(e){f(this,Pi)._focusEventsAllowed=!0,e.preventDefault(),e.stopPropagation()},ug=function(e){const t=f(this,Pi)._uiManager._signal;e.addEventListener("focusin",P(this,ms,fR).bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",P(this,ms,pR).bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",wi,{signal:t})},mR=function(){const{editorType:e,_uiManager:t}=f(this,Pi),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",f(Br,wf)[e]),P(this,ms,ug).call(this,s),s.addEventListener("click",i=>{t.delete()},{signal:t._signal}),f(this,ul).append(s)},Bv=function(){const e=document.createElement("div");return e.className="divider",e},M(Br,Fy),M(Br,wf,null);let Hv=Br;var _f,dl,fl,Oa,gR,yR,bR;class p8{constructor(e){M(this,Oa);M(this,_f,null);M(this,dl,null);M(this,fl);$(this,fl,e)}show(e,t,s){const[i,r]=P(this,Oa,yR).call(this,t,s),{style:o}=f(this,dl)||$(this,dl,P(this,Oa,gR).call(this));e.append(f(this,dl)),o.insetInlineEnd=`${100*i}%`,o.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){f(this,dl).remove()}}_f=new WeakMap,dl=new WeakMap,fl=new WeakMap,Oa=new WeakSet,gR=function(){const e=$(this,dl,document.createElement("div"));e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",wi,{signal:f(this,fl)._signal});const t=$(this,_f,document.createElement("div"));return t.className="buttons",e.append(t),P(this,Oa,bR).call(this),e},yR=function(e,t){let s=0,i=0;for(const r of e){const o=r.y+r.height;if(os){i=a,s=o;continue}t?a>i&&(i=a):a{f(this,fl).highlightSelection("floating_button")},{signal:s}),f(this,_f).append(e)};function fy(n,e,t){for(const s of t)e.addEventListener(s,n[s].bind(n))}function m8(n){return Math.round(Math.min(255,Math.max(1,255*n))).toString(16).padStart(2,"0")}var zy;class g8{constructor(){M(this,zy,0)}get id(){return`${Z6}${os(this,zy)._++}`}}zy=new WeakMap;var gh,Sf,Xn,yh,dg;const rk=class rk{constructor(){M(this,yh);M(this,gh,l8());M(this,Sf,0);M(this,Xn,null)}static get _isSVGFittingCanvas(){const e='data:image/svg+xml;charset=UTF-8,',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=e;const r=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return Ge(this,"_isSVGFittingCanvas",r)}async getFromFile(e){const{lastModified:t,name:s,size:i,type:r}=e;return P(this,yh,dg).call(this,`${t}_${s}_${i}_${r}`,e)}async getFromUrl(e){return P(this,yh,dg).call(this,e,e)}async getFromBlob(e,t){const s=await t;return P(this,yh,dg).call(this,e,s)}async getFromId(e){f(this,Xn)||$(this,Xn,new Map);const t=f(this,Xn).get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){const{blobPromise:s}=t;return delete t.blobPromise,this.getFromBlob(t.id,s)}return this.getFromUrl(t.url)}getFromCanvas(e,t){f(this,Xn)||$(this,Xn,new Map);let s=f(this,Xn).get(e);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(t.width,t.height);return i.getContext("2d").drawImage(t,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${f(this,gh)}_${os(this,Sf)._++}`,refCounter:1,isSvg:!1},f(this,Xn).set(e,s),f(this,Xn).set(s.id,s),s}getSvgUrl(e){const t=f(this,Xn).get(e);return t!=null&&t.isSvg?t.svgUrl:null}deleteId(e){var i;f(this,Xn)||$(this,Xn,new Map);const t=f(this,Xn).get(e);if(!t||(t.refCounter-=1,t.refCounter!==0))return;const{bitmap:s}=t;if(!t.url&&!t.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),t.blobPromise=r.convertToBlob()}(i=s.close)==null||i.call(s),t.bitmap=null}isValidId(e){return e.startsWith(`image_${f(this,gh)}_`)}};gh=new WeakMap,Sf=new WeakMap,Xn=new WeakMap,yh=new WeakSet,dg=async function(e,t){f(this,Xn)||$(this,Xn,new Map);let s=f(this,Xn).get(e);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${f(this,gh)}_${os(this,Sf)._++}`,refCounter:0,isSvg:!1});let i;if(typeof t=="string"?(s.url=t,i=await M0(t,"blob")):t instanceof File?i=s.file=t:t instanceof Blob&&(i=t),i.type==="image/svg+xml"){const r=rk._isSVGFittingCanvas,o=new FileReader,a=new Image,l=new Promise((c,h)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,c()},o.onload=async()=>{const u=s.svgUrl=o.result;a.src=await r?`${u}#svgView(preserveAspectRatio(none))`:u},a.onerror=o.onerror=h});o.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return f(this,Xn).set(e,s),s&&f(this,Xn).set(s.id,s),s};let qv=rk;var bn,Uo,xf,vn;class y8{constructor(e=128){M(this,bn,[]);M(this,Uo,!1);M(this,xf);M(this,vn,-1);$(this,xf,e)}add({cmd:e,undo:t,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:o=!1,keepUndo:a=!1}){if(i&&e(),f(this,Uo))return;const l={cmd:e,undo:t,post:s,type:r};if(f(this,vn)===-1){f(this,bn).length>0&&(f(this,bn).length=0),$(this,vn,0),f(this,bn).push(l);return}if(o&&f(this,bn)[f(this,vn)].type===r){a&&(l.undo=f(this,bn)[f(this,vn)].undo),f(this,bn)[f(this,vn)]=l;return}const c=f(this,vn)+1;c===f(this,xf)?f(this,bn).splice(0,1):($(this,vn,c),cr===t[o]))return By._colorsMapping.get(s);return t}getHexCode(e){const t=this._colors.get(e);return t?Se.makeHexColor(...t):e}};ae(By,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Vv=By;var bh,Bs,on,Mn,vh,Vr,wh,Ri,Wo,_h,pl,rr,Mi,ml,kf,Af,Sh,Ef,or,Go,xh,Ko,ar,qy,Zo,Cf,Xo,gl,$f,Tf,wn,ct,Ur,yl,Pf,Rf,Yo,lr,Wr,Mf,oi,ue,fg,Uv,wR,_R,pg,SR,xR,kR,Wv,AR,Gv,Kv,ER,as,Oo,CR,$R,Zv,TR,fd,Xv;const nh=class nh{constructor(e,t,s,i,r,o,a,l,c,h,u){M(this,ue);M(this,bh,new AbortController);M(this,Bs,null);M(this,on,new Map);M(this,Mn,new Map);M(this,vh,null);M(this,Vr,null);M(this,wh,null);M(this,Ri,new y8);M(this,Wo,null);M(this,_h,0);M(this,pl,new Set);M(this,rr,null);M(this,Mi,null);M(this,ml,new Set);M(this,kf,!1);M(this,Af,!1);M(this,Sh,!1);M(this,Ef,null);M(this,or,null);M(this,Go,null);M(this,xh,null);M(this,Ko,!1);M(this,ar,null);M(this,qy,new g8);M(this,Zo,!1);M(this,Cf,!1);M(this,Xo,null);M(this,gl,null);M(this,$f,null);M(this,Tf,null);M(this,wn,Ne.NONE);M(this,ct,new Set);M(this,Ur,null);M(this,yl,null);M(this,Pf,null);M(this,Rf,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});M(this,Yo,[0,0]);M(this,lr,null);M(this,Wr,null);M(this,Mf,null);M(this,oi,null);const d=this._signal=f(this,bh).signal;$(this,Wr,e),$(this,Mf,t),$(this,vh,s),this._eventBus=i,i._on("editingaction",this.onEditingAction.bind(this),{signal:d}),i._on("pagechanging",this.onPageChanging.bind(this),{signal:d}),i._on("scalechanging",this.onScaleChanging.bind(this),{signal:d}),i._on("rotationchanging",this.onRotationChanging.bind(this),{signal:d}),i._on("setpreference",this.onSetPreference.bind(this),{signal:d}),i._on("switchannotationeditorparams",p=>this.updateParams(p.type,p.value),{signal:d}),P(this,ue,SR).call(this),P(this,ue,ER).call(this),P(this,ue,Wv).call(this),$(this,Vr,r.annotationStorage),$(this,Ef,r.filterFactory),$(this,yl,o),$(this,xh,a||null),$(this,kf,l),$(this,Af,c),$(this,Sh,h),$(this,Tf,u||null),this.viewParameters={realScale:$a.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const e=nh.prototype,t=o=>f(o,Wr).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&o.hasSomethingToControl(),s=(o,{target:a})=>{if(a instanceof HTMLInputElement){const{type:l}=a;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return Ge(this,"_keyboardManager",new Qp([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:s}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(o,{target:a})=>!(a instanceof HTMLButtonElement)&&f(o,Wr).contains(a)&&!o.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(o,{target:a})=>!(a instanceof HTMLButtonElement)&&f(o,Wr).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:t}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:t}]]))}destroy(){var e,t,s,i;(e=f(this,oi))==null||e.resolve(),$(this,oi,null),(t=f(this,bh))==null||t.abort(),$(this,bh,null),this._signal=null;for(const r of f(this,Mn).values())r.destroy();f(this,Mn).clear(),f(this,on).clear(),f(this,ml).clear(),$(this,Bs,null),f(this,ct).clear(),f(this,Ri).destroy(),(s=f(this,vh))==null||s.destroy(),(i=f(this,ar))==null||i.hide(),$(this,ar,null),f(this,or)&&(clearTimeout(f(this,or)),$(this,or,null)),f(this,lr)&&(clearTimeout(f(this,lr)),$(this,lr,null))}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return f(this,Tf)}get useNewAltTextFlow(){return f(this,Af)}get useNewAltTextWhenAddingImage(){return f(this,Sh)}get hcmFilter(){return Ge(this,"hcmFilter",f(this,yl)?f(this,Ef).addHCMFilter(f(this,yl).foreground,f(this,yl).background):"none")}get direction(){return Ge(this,"direction",getComputedStyle(f(this,Wr)).direction)}get highlightColors(){return Ge(this,"highlightColors",f(this,xh)?new Map(f(this,xh).split(",").map(e=>e.split("=").map(t=>t.trim()))):null)}get highlightColorNames(){return Ge(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}setMainHighlightColorPicker(e){$(this,$f,e)}editAltText(e,t=!1){var s;(s=f(this,vh))==null||s.editAltText(this,e,t)}switchToMode(e,t){this._eventBus.on("annotationeditormodechanged",t,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch("setpreference",{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){switch(e){case"enableNewAltTextWhenAddingImage":$(this,Sh,t);break}}onPageChanging({pageNumber:e}){$(this,_h,e-1)}focusMainContainer(){f(this,Wr).focus()}findParent(e,t){for(const s of f(this,Mn).values()){const{x:i,y:r,width:o,height:a}=s.div.getBoundingClientRect();if(e>=i&&e<=i+o&&t>=r&&t<=r+a)return s}return null}disableUserSelect(e=!1){f(this,Mf).classList.toggle("noUserSelect",e)}addShouldRescale(e){f(this,ml).add(e)}removeShouldRescale(e){f(this,ml).delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*$a.PDF_TO_CSS_UNITS;for(const t of f(this,ml))t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e=""){const t=document.getSelection();if(!t||t.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:r,focusOffset:o}=t,a=t.toString(),c=P(this,ue,fg).call(this,t).closest(".textLayer"),h=this.getSelectionBoxes(c);if(!h)return;t.empty();const u=P(this,ue,Uv).call(this,c),d=f(this,wn)===Ne.NONE,p=()=>{u==null||u.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:h,anchorNode:s,anchorOffset:i,focusNode:r,focusOffset:o,text:a}),d&&this.showAllEditors("highlight",!0,!0)};if(d){this.switchToMode(Ne.HIGHLIGHT,p);return}p()}addToAnnotationStorage(e){!e.isEmpty()&&f(this,Vr)&&!f(this,Vr).has(e.id)&&f(this,Vr).setValue(e.id,e)}blur(){if(this.isShiftKeyDown=!1,f(this,Ko)&&($(this,Ko,!1),P(this,ue,pg).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const t of f(this,ct))if(t.div.contains(e)){$(this,gl,[t,e]),t._focusEventsAllowed=!1;break}}focus(){if(!f(this,gl))return;const[e,t]=f(this,gl);$(this,gl,null),t.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}addEditListeners(){P(this,ue,Wv).call(this),P(this,ue,Gv).call(this)}removeEditListeners(){P(this,ue,AR).call(this),P(this,ue,Kv).call(this)}dragOver(e){for(const{type:t}of e.dataTransfer.items)for(const s of f(this,Mi))if(s.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(const t of e.dataTransfer.items)for(const s of f(this,Mi))if(s.isHandlingMimeForPasting(t.type)){s.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){var s;if(e.preventDefault(),(s=f(this,Bs))==null||s.commitOrRemove(),!this.hasSelection)return;const t=[];for(const i of f(this,ct)){const r=i.serialize(!0);r&&t.push(r)}t.length!==0&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:t}=e;for(const r of t.items)for(const o of f(this,Mi))if(o.isHandlingMimeForPasting(r.type)){o.paste(r,this.currentLayer);return}let s=t.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){He(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const l of s){const c=await i.deserialize(l);if(!c)return;r.push(c)}const o=()=>{for(const l of r)P(this,ue,Zv).call(this,l);P(this,ue,Xv).call(this,r)},a=()=>{for(const l of r)l.remove()};this.addCommands({cmd:o,undo:a,mustExec:!0})}catch(r){He(`paste: "${r.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),f(this,wn)!==Ne.NONE&&!this.isEditorHandlingKeyboard&&nh._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,f(this,Ko)&&($(this,Ko,!1),P(this,ue,pg).call(this,"main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}setEditingState(e){e?(P(this,ue,xR).call(this),P(this,ue,Gv).call(this),P(this,ue,as).call(this,{isEditing:f(this,wn)!==Ne.NONE,isEmpty:P(this,ue,fd).call(this),hasSomethingToUndo:f(this,Ri).hasSomethingToUndo(),hasSomethingToRedo:f(this,Ri).hasSomethingToRedo(),hasSelectedEditor:!1})):(P(this,ue,kR).call(this),P(this,ue,Kv).call(this),P(this,ue,as).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!f(this,Mi)){$(this,Mi,e);for(const t of f(this,Mi))P(this,ue,Oo).call(this,t.defaultPropertiesToUpdate)}}getId(){return f(this,qy).id}get currentLayer(){return f(this,Mn).get(f(this,_h))}getLayer(e){return f(this,Mn).get(e)}get currentPageIndex(){return f(this,_h)}addLayer(e){f(this,Mn).set(e.pageIndex,e),f(this,Zo)?e.enable():e.disable()}removeLayer(e){f(this,Mn).delete(e.pageIndex)}async updateMode(e,t=null,s=!1){if(f(this,wn)!==e&&!(f(this,oi)&&(await f(this,oi).promise,!f(this,oi)))){if($(this,oi,Promise.withResolvers()),$(this,wn,e),e===Ne.NONE){this.setEditingState(!1),P(this,ue,$R).call(this),f(this,oi).resolve();return}this.setEditingState(!0),await P(this,ue,CR).call(this),this.unselectAll();for(const i of f(this,Mn).values())i.updateMode(e);if(!t){s&&this.addNewEditorFromKeyboard(),f(this,oi).resolve();return}for(const i of f(this,on).values())i.annotationElementId===t?(this.setSelected(i),i.enterInEditMode()):i.unselect();f(this,oi).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==f(this,wn)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){var s;if(f(this,Mi)){switch(e){case Te.CREATE:this.currentLayer.addNewEditor();return;case Te.HIGHLIGHT_DEFAULT_COLOR:(s=f(this,$f))==null||s.updateColor(t);break;case Te.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(f(this,Pf)||$(this,Pf,new Map)).set(e,t),this.showAllEditors("highlight",t);break}for(const i of f(this,ct))i.updateParams(e,t);for(const i of f(this,Mi))i.updateDefaultParams(e,t)}}showAllEditors(e,t,s=!1){var r;for(const o of f(this,on).values())o.editorType===e&&o.show(t);(((r=f(this,Pf))==null?void 0:r.get(Te.HIGHLIGHT_SHOW_ALL))??!0)!==t&&P(this,ue,Oo).call(this,[[Te.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(f(this,Cf)!==e){$(this,Cf,e);for(const t of f(this,Mn).values())e?t.disableClick():t.enableClick(),t.div.classList.toggle("waiting",e)}}getEditors(e){const t=[];for(const s of f(this,on).values())s.pageIndex===e&&t.push(s);return t}getEditor(e){return f(this,on).get(e)}addEditor(e){f(this,on).set(e.id,e)}removeEditor(e){var t;e.div.contains(document.activeElement)&&(f(this,or)&&clearTimeout(f(this,or)),$(this,or,setTimeout(()=>{this.focusMainContainer(),$(this,or,null)},0))),f(this,on).delete(e.id),this.unselect(e),(!e.annotationElementId||!f(this,pl).has(e.annotationElementId))&&((t=f(this,Vr))==null||t.remove(e.id))}addDeletedAnnotationElement(e){f(this,pl).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return f(this,pl).has(e)}removeDeletedAnnotationElement(e){f(this,pl).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){f(this,Bs)!==e&&($(this,Bs,e),e&&P(this,ue,Oo).call(this,e.propertiesToUpdate))}updateUI(e){f(this,ue,TR)===e&&P(this,ue,Oo).call(this,e.propertiesToUpdate)}toggleSelected(e){if(f(this,ct).has(e)){f(this,ct).delete(e),e.unselect(),P(this,ue,as).call(this,{hasSelectedEditor:this.hasSelection});return}f(this,ct).add(e),e.select(),P(this,ue,Oo).call(this,e.propertiesToUpdate),P(this,ue,as).call(this,{hasSelectedEditor:!0})}setSelected(e){for(const t of f(this,ct))t!==e&&t.unselect();f(this,ct).clear(),f(this,ct).add(e),e.select(),P(this,ue,Oo).call(this,e.propertiesToUpdate),P(this,ue,as).call(this,{hasSelectedEditor:!0})}isSelected(e){return f(this,ct).has(e)}get firstSelectedEditor(){return f(this,ct).values().next().value}unselect(e){e.unselect(),f(this,ct).delete(e),P(this,ue,as).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return f(this,ct).size!==0}get isEnterHandled(){return f(this,ct).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){f(this,Ri).undo(),P(this,ue,as).call(this,{hasSomethingToUndo:f(this,Ri).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:P(this,ue,fd).call(this)})}redo(){f(this,Ri).redo(),P(this,ue,as).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:f(this,Ri).hasSomethingToRedo(),isEmpty:P(this,ue,fd).call(this)})}addCommands(e){f(this,Ri).add(e),P(this,ue,as).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:P(this,ue,fd).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const e=[...f(this,ct)],t=()=>{for(const i of e)i.remove()},s=()=>{for(const i of e)P(this,ue,Zv).call(this,i)};this.addCommands({cmd:t,undo:s,mustExec:!0})}commitOrRemove(){var e;(e=f(this,Bs))==null||e.commitOrRemove()}hasSomethingToControl(){return f(this,Bs)||this.hasSelection}selectAll(){for(const e of f(this,ct))e.commit();P(this,ue,Xv).call(this,f(this,on).values())}unselectAll(){if(!(f(this,Bs)&&(f(this,Bs).commitOrRemove(),f(this,wn)!==Ne.NONE))&&this.hasSelection){for(const e of f(this,ct))e.unselect();f(this,ct).clear(),P(this,ue,as).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,t,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;f(this,Yo)[0]+=e,f(this,Yo)[1]+=t;const[i,r]=f(this,Yo),o=[...f(this,ct)],a=1e3;f(this,lr)&&clearTimeout(f(this,lr)),$(this,lr,setTimeout(()=>{$(this,lr,null),f(this,Yo)[0]=f(this,Yo)[1]=0,this.addCommands({cmd:()=>{for(const l of o)f(this,on).has(l.id)&&l.translateInPage(i,r)},undo:()=>{for(const l of o)f(this,on).has(l.id)&&l.translateInPage(-i,-r)},mustExec:!1})},a));for(const l of o)l.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),$(this,rr,new Map);for(const e of f(this,ct))f(this,rr).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!f(this,rr))return!1;this.disableUserSelect(!1);const e=f(this,rr);$(this,rr,null);let t=!1;for(const[{x:i,y:r,pageIndex:o},a]of e)a.newX=i,a.newY=r,a.newPageIndex=o,t||(t=i!==a.savedX||r!==a.savedY||o!==a.savedPageIndex);if(!t)return!1;const s=(i,r,o,a)=>{if(f(this,on).has(i.id)){const l=f(this,Mn).get(a);l?i._setParentAndPosition(l,r,o):(i.pageIndex=a,i.x=r,i.y=o)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:o,newPageIndex:a}]of e)s(i,r,o,a)},undo:()=>{for(const[i,{savedX:r,savedY:o,savedPageIndex:a}]of e)s(i,r,o,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(f(this,rr))for(const s of f(this,rr).keys())s.drag(e,t)}rebuild(e){if(e.parent===null){const t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){var e;return((e=this.getActive())==null?void 0:e.shouldGetKeyboardEvents())||f(this,ct).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return f(this,Bs)===e}getActive(){return f(this,Bs)}getMode(){return f(this,wn)}get imageManager(){return Ge(this,"imageManager",new qv)}getSelectionBoxes(e){if(!e)return null;const t=document.getSelection();for(let c=0,h=t.rangeCount;c({x:(h-i)/o,y:1-(c+u-s)/r,width:d/o,height:u/r});break;case"180":a=(c,h,u,d)=>({x:1-(c+u-s)/r,y:1-(h+d-i)/o,width:u/r,height:d/o});break;case"270":a=(c,h,u,d)=>({x:1-(h+d-i)/o,y:(c-s)/r,width:d/o,height:u/r});break;default:a=(c,h,u,d)=>({x:(c-s)/r,y:(h-i)/o,width:u/r,height:d/o});break}const l=[];for(let c=0,h=t.rangeCount;c{d.type==="pointerup"&&d.button!==0||(c.abort(),l==null||l.toggleDrawing(!0),d.type==="pointerup"&&P(this,ue,pg).call(this,"main_toolbar"))};window.addEventListener("pointerup",u,{signal:h}),window.addEventListener("blur",u,{signal:h})}},pg=function(e=""){f(this,wn)===Ne.HIGHLIGHT?this.highlightSelection(e):f(this,kf)&&P(this,ue,wR).call(this)},SR=function(){document.addEventListener("selectionchange",P(this,ue,_R).bind(this),{signal:this._signal})},xR=function(){if(f(this,Go))return;$(this,Go,new AbortController);const e=this.combinedSignal(f(this,Go));window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})},kR=function(){var e;(e=f(this,Go))==null||e.abort(),$(this,Go,null)},Wv=function(){if(f(this,Xo))return;$(this,Xo,new AbortController);const e=this.combinedSignal(f(this,Xo));window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})},AR=function(){var e;(e=f(this,Xo))==null||e.abort(),$(this,Xo,null)},Gv=function(){if(f(this,Wo))return;$(this,Wo,new AbortController);const e=this.combinedSignal(f(this,Wo));document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})},Kv=function(){var e;(e=f(this,Wo))==null||e.abort(),$(this,Wo,null)},ER=function(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})},as=function(e){Object.entries(e).some(([s,i])=>f(this,Rf)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(f(this,Rf),e)}),f(this,wn)===Ne.HIGHLIGHT&&e.hasSelectedEditor===!1&&P(this,ue,Oo).call(this,[[Te.HIGHLIGHT_FREE,!0]]))},Oo=function(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})},CR=async function(){if(!f(this,Zo)){$(this,Zo,!0);const e=[];for(const t of f(this,Mn).values())e.push(t.enable());await Promise.all(e);for(const t of f(this,on).values())t.enable()}},$R=function(){if(this.unselectAll(),f(this,Zo)){$(this,Zo,!1);for(const e of f(this,Mn).values())e.disable();for(const e of f(this,on).values())e.disable()}},Zv=function(e){const t=f(this,Mn).get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))},TR=function(){let e=null;for(e of f(this,ct));return e},fd=function(){if(f(this,on).size===0)return!0;if(f(this,on).size===1)for(const e of f(this,on).values())return e.isEmpty();return!1},Xv=function(e){for(const t of f(this,ct))t.unselect();f(this,ct).clear();for(const t of e)t.isEmpty()||(f(this,ct).add(t),t.select());P(this,ue,as).call(this,{hasSelectedEditor:this.hasSelection})},ae(nh,"TRANSLATE_SMALL",1),ae(nh,"TRANSLATE_BIG",10);let mc=nh;var _n,cr,Ii,kh,hr,qs,Ah,ur,As,Gr,bl,dr,Jo,Gi,pd,mg;const ls=class ls{constructor(e){M(this,Gi);M(this,_n,null);M(this,cr,!1);M(this,Ii,null);M(this,kh,null);M(this,hr,null);M(this,qs,null);M(this,Ah,!1);M(this,ur,null);M(this,As,null);M(this,Gr,null);M(this,bl,null);M(this,dr,!1);$(this,As,e),$(this,dr,e._uiManager.useNewAltTextFlow),f(ls,Jo)||$(ls,Jo,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){ls._l10n??(ls._l10n=e)}async render(){const e=$(this,Ii,document.createElement("button"));e.className="altText",e.tabIndex="0";const t=$(this,kh,document.createElement("span"));e.append(t),f(this,dr)?(e.classList.add("new"),e.setAttribute("data-l10n-id",f(ls,Jo).missing),t.setAttribute("data-l10n-id",f(ls,Jo)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=f(this,As)._uiManager._signal;e.addEventListener("contextmenu",wi,{signal:s}),e.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),f(this,As)._uiManager.editAltText(f(this,As)),f(this,dr)&&f(this,As)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:f(this,Gi,pd)}})};return e.addEventListener("click",i,{capture:!0,signal:s}),e.addEventListener("keydown",r=>{r.target===e&&r.key==="Enter"&&($(this,Ah,!0),i(r))},{signal:s}),await P(this,Gi,mg).call(this),e}finish(){f(this,Ii)&&(f(this,Ii).focus({focusVisible:f(this,Ah)}),$(this,Ah,!1))}isEmpty(){return f(this,dr)?f(this,_n)===null:!f(this,_n)&&!f(this,cr)}hasData(){return f(this,dr)?f(this,_n)!==null||!!f(this,Gr):this.isEmpty()}get guessedText(){return f(this,Gr)}async setGuessedText(e){f(this,_n)===null&&($(this,Gr,e),$(this,bl,await ls._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),P(this,Gi,mg).call(this))}toggleAltTextBadge(e=!1){var t;if(!f(this,dr)||f(this,_n)){(t=f(this,ur))==null||t.remove(),$(this,ur,null);return}if(!f(this,ur)){const s=$(this,ur,document.createElement("div"));s.className="noAltTextBadge",f(this,As).div.append(s)}f(this,ur).classList.toggle("hidden",!e)}serialize(e){let t=f(this,_n);return!e&&f(this,Gr)===t&&(t=f(this,bl)),{altText:t,decorative:f(this,cr),guessedText:f(this,Gr),textWithDisclaimer:f(this,bl)}}get data(){return{altText:f(this,_n),decorative:f(this,cr)}}set data({altText:e,decorative:t,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&($(this,Gr,s),$(this,bl,i)),!(f(this,_n)===e&&f(this,cr)===t)&&(r||($(this,_n,e),$(this,cr,t)),P(this,Gi,mg).call(this))}toggle(e=!1){f(this,Ii)&&(!e&&f(this,qs)&&(clearTimeout(f(this,qs)),$(this,qs,null)),f(this,Ii).disabled=!e)}shown(){f(this,As)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:f(this,Gi,pd)}})}destroy(){var e,t;(e=f(this,Ii))==null||e.remove(),$(this,Ii,null),$(this,kh,null),$(this,hr,null),(t=f(this,ur))==null||t.remove(),$(this,ur,null)}};_n=new WeakMap,cr=new WeakMap,Ii=new WeakMap,kh=new WeakMap,hr=new WeakMap,qs=new WeakMap,Ah=new WeakMap,ur=new WeakMap,As=new WeakMap,Gr=new WeakMap,bl=new WeakMap,dr=new WeakMap,Jo=new WeakMap,Gi=new WeakSet,pd=function(){return f(this,_n)&&"added"||f(this,_n)===null&&this.guessedText&&"review"||"missing"},mg=async function(){var i,r,o;const e=f(this,Ii);if(!e)return;if(f(this,dr)){if(e.classList.toggle("done",!!f(this,_n)),e.setAttribute("data-l10n-id",f(ls,Jo)[f(this,Gi,pd)]),(i=f(this,kh))==null||i.setAttribute("data-l10n-id",f(ls,Jo)[`${f(this,Gi,pd)}-label`]),!f(this,_n)){(r=f(this,hr))==null||r.remove();return}}else{if(!f(this,_n)&&!f(this,cr)){e.classList.remove("done"),(o=f(this,hr))==null||o.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let t=f(this,hr);if(!t){$(this,hr,t=document.createElement("span")),t.className="tooltip",t.setAttribute("role","tooltip"),t.id=`alt-text-tooltip-${f(this,As).id}`;const a=100,l=f(this,As)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(f(this,qs)),$(this,qs,null)},{once:!0}),e.addEventListener("mouseenter",()=>{$(this,qs,setTimeout(()=>{$(this,qs,null),f(this,hr).classList.add("show"),f(this,As)._reportTelemetry({action:"alt_text_tooltip"})},a))},{signal:l}),e.addEventListener("mouseleave",()=>{var c;f(this,qs)&&(clearTimeout(f(this,qs)),$(this,qs,null)),(c=f(this,hr))==null||c.classList.remove("show")},{signal:l})}f(this,cr)?t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(t.removeAttribute("data-l10n-id"),t.textContent=f(this,_n)),t.parentNode||e.append(t);const s=f(this,As).getImageForAltText();s==null||s.setAttribute("aria-describedby",t.id)},M(ls,Jo,null),ae(ls,"_l10n",null);let py=ls;var vl,Oi,Ot,Eh,wl,In,_l,Qo,If,Sl,ea,Of,xl,Kr,fr,Ch,$h,ai,Nf,Vy,je,Yv,Lf,Jv,Qv,PR,RR,ew,tw,nw,MR,sw,IR,OR,NR,iw,md;const ot=class ot{constructor(e){M(this,je);M(this,vl,null);M(this,Oi,null);M(this,Ot,null);M(this,Eh,!1);M(this,wl,!1);M(this,In,null);M(this,_l,null);M(this,Qo,null);M(this,If,"");M(this,Sl,!1);M(this,ea,null);M(this,Of,!1);M(this,xl,!1);M(this,Kr,!1);M(this,fr,null);M(this,Ch,0);M(this,$h,0);M(this,ai,null);ae(this,"_editToolbar",null);ae(this,"_initialOptions",Object.create(null));ae(this,"_initialData",null);ae(this,"_isVisible",!0);ae(this,"_uiManager",null);ae(this,"_focusEventsAllowed",!0);M(this,Nf,!1);M(this,Vy,ot._zIndex++);this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;const{rotation:t,rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:o}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,o];const[a,l]=this.parentDimensions;this.x=e.x/a,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=ot.prototype._resizeWithKeyboard,t=mc.TRANSLATE_SMALL,s=mc.TRANSLATE_BIG;return Ge(this,"_resizerKeyboardManager",new Qp([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,s]}],[["Escape","mac+Escape"],ot.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return Ge(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const t=new b8({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){if(ot._l10n??(ot._l10n=e),ot._l10nResizer||(ot._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),ot._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);ot._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){Et("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return f(this,Nf)}set _isDraggable(e){var t;$(this,Nf,e),(t=this.div)==null||t.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){const[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=f(this,Vy)}setParent(e){e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):P(this,je,md).call(this),this.parent=e}focusin(e){this._focusEventsAllowed&&(f(this,Sl)?$(this,Sl,!1):this.parent.setSelected(this))}focusout(e){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const t=e.relatedTarget;t!=null&&t.closest(`#${this.id}`)||(e.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,s,i){const[r,o]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(e+s)/r,this.y=(t+i)/o,this.fixAndSetPosition()}translate(e,t){P(this,je,Yv).call(this,this.parentDimensions,e,t)}translateInPage(e,t){f(this,ea)||$(this,ea,[this.x,this.y]),P(this,je,Yv).call(this,this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}drag(e,t){f(this,ea)||$(this,ea,[this.x,this.y]);const[s,i]=this.parentDimensions;if(this.x+=e/s,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:c,y:h}=this.div.getBoundingClientRect();this.parent.findNewParent(this,c,h)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:o}=this;const[a,l]=this.getBaseTranslation();r+=a,o+=l,this.div.style.left=`${(100*r).toFixed(2)}%`,this.div.style.top=`${(100*o).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!f(this,ea)&&(f(this,ea)[0]!==this.x||f(this,ea)[1]!==this.y)}getBaseTranslation(){const[e,t]=this.parentDimensions,{_borderLineWidth:s}=ot,i=s/e,r=s/t;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const[t,s]=this.pageDimensions;let{x:i,y:r,width:o,height:a}=this;if(o*=t,a*=s,i*=t,r*=s,this._mustFixPosition)switch(e){case 0:i=Math.max(0,Math.min(t-o,i)),r=Math.max(0,Math.min(s-a,r));break;case 90:i=Math.max(0,Math.min(t-a,i)),r=Math.min(s,Math.max(o,r));break;case 180:i=Math.min(t,Math.max(o,i)),r=Math.min(s,Math.max(a,r));break;case 270:i=Math.min(t,Math.max(a,i)),r=Math.max(0,Math.min(s-o,r));break}this.x=i/=t,this.y=r/=s;const[l,c]=this.getBaseTranslation();i+=l,r+=c;const{style:h}=this.div;h.left=`${(100*i).toFixed(2)}%`,h.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,t){var s;return P(s=ot,Lf,Jv).call(s,e,t,this.parentRotation)}pageTranslationToScreen(e,t){var s;return P(s=ot,Lf,Jv).call(s,e,t,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[t,s]}=this;return[t*e,s*e]}setDims(e,t){const[s,i]=this.parentDimensions;this.div.style.width=`${(100*e/s).toFixed(2)}%`,f(this,wl)||(this.div.style.height=`${(100*t/i).toFixed(2)}%`)}fixDims(){const{style:e}=this.div,{height:t,width:s}=e,i=s.endsWith("%"),r=!f(this,wl)&&t.endsWith("%");if(i&&r)return;const[o,a]=this.parentDimensions;i||(e.width=`${(100*parseFloat(s)/o).toFixed(2)}%`),!f(this,wl)&&!r&&(e.height=`${(100*parseFloat(t)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var e;(e=f(this,Ot))==null||e.finish()}async addEditToolbar(){return this._editToolbar||f(this,xl)?this._editToolbar:(this._editToolbar=new Hv(this),this.div.append(this._editToolbar.render()),f(this,Ot)&&await this._editToolbar.addAltText(f(this,Ot)),this._editToolbar)}removeEditToolbar(){var e;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(e=f(this,Ot))==null||e.destroy())}addContainer(e){var s;const t=(s=this._editToolbar)==null?void 0:s.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){f(this,Ot)||(py.initialize(ot._l10n),$(this,Ot,new py(this)),f(this,vl)&&(f(this,Ot).data=f(this,vl),$(this,vl,null)),await this.addEditToolbar())}get altTextData(){var e;return(e=f(this,Ot))==null?void 0:e.data}set altTextData(e){f(this,Ot)&&(f(this,Ot).data=e)}get guessedAltText(){var e;return(e=f(this,Ot))==null?void 0:e.guessedText}async setGuessedAltText(e){var t;await((t=f(this,Ot))==null?void 0:t.setGuessedText(e))}serializeAltText(e){var t;return(t=f(this,Ot))==null?void 0:t.serialize(e)}hasAltText(){return!!f(this,Ot)&&!f(this,Ot).isEmpty()}hasAltTextData(){var e;return((e=f(this,Ot))==null?void 0:e.hasData())??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=f(this,Eh)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),P(this,je,sw).call(this);const[e,t]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`);const[s,i]=this.getInitialTranslation();return this.translate(s,i),fy(this,this.div,["pointerdown"]),this.div}pointerdown(e){const{isMac:t}=fs.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if($(this,Sl,!0),this._isDraggable){P(this,je,MR).call(this,e);return}P(this,je,nw).call(this,e)}get isSelected(){return this._uiManager.isSelected(this)}moveInDOM(){f(this,fr)&&clearTimeout(f(this,fr)),$(this,fr,setTimeout(()=>{var e;$(this,fr,null),(e=this.parent)==null||e.moveEditorInDOM(this)},0))}_setParentAndPosition(e,t,s){e.changeParent(this),this.x=t,this.y=s,this.fixAndSetPosition()}getRect(e,t,s=this.rotation){const i=this.parentScale,[r,o]=this.pageDimensions,[a,l]=this.pageTranslation,c=e/i,h=t/i,u=this.x*r,d=this.y*o,p=this.width*r,m=this.height*o;switch(s){case 0:return[u+c+a,o-d-h-m+l,u+c+p+a,o-d-h+l];case 90:return[u+h+a,o-d+c+l,u+h+m+a,o-d+c+p+l];case 180:return[u-c-p+a,o-d+h+l,u-c+a,o-d+h+m+l];case 270:return[u-h-m+a,o-d-c-p+l,u-h+a,o-d-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){const[s,i,r,o]=e,a=r-s,l=o-i;switch(this.rotation){case 0:return[s,t-o,a,l];case 90:return[s,t-i,l,a];case 180:return[r,t-i,a,l];case 270:return[r,t-o,l,a];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){$(this,xl,!0)}disableEditMode(){$(this,xl,!1)}isInEditMode(){return f(this,xl)}shouldGetKeyboardEvents(){return f(this,Kr)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){P(this,je,sw).call(this)}rotate(e){}serializeDeleted(){var e;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((e=this._initialData)==null?void 0:e.popupRef)||""}}serialize(e=!1,t=null){Et("An editor must be serializable")}static async deserialize(e,t,s){const i=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:s});i.rotation=e.rotation,$(i,vl,e.accessibilityData);const[r,o]=i.pageDimensions,[a,l,c,h]=i.getRectInCurrentCoords(e.rect,o);return i.x=a/r,i.y=l/o,i.width=c/r,i.height=h/o,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var e;if((e=f(this,Qo))==null||e.abort(),$(this,Qo,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),f(this,fr)&&(clearTimeout(f(this,fr)),$(this,fr,null)),P(this,je,md).call(this),this.removeEditToolbar(),f(this,ai)){for(const t of f(this,ai).values())clearTimeout(t);$(this,ai,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(P(this,je,PR).call(this),f(this,In).classList.remove("hidden"),fy(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),$(this,_l,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const t=f(this,In).children;if(!f(this,Oi)){$(this,Oi,Array.from(t));const o=P(this,je,IR).bind(this),a=P(this,je,OR).bind(this),l=this._uiManager._signal;for(const c of f(this,Oi)){const h=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",o,{signal:l}),c.addEventListener("blur",a,{signal:l}),c.addEventListener("focus",P(this,je,NR).bind(this,h),{signal:l}),c.setAttribute("data-l10n-id",ot._l10nResizer[h])}}const s=f(this,Oi)[0];let i=0;for(const o of t){if(o===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(f(this,Oi).length/4);if(r!==i){if(ri)for(let a=0;a{var i,r;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(t=this._editToolbar)==null||t.show(),(s=f(this,Ot))==null||s.toggleAltTextBadge(!1)}unselect(){var e,t,s,i,r;(e=f(this,In))==null||e.classList.add("hidden"),(t=this.div)==null||t.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(r=f(this,Ot))==null||r.toggleAltTextBadge(!0)}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return f(this,Of)}set isEditing(e){$(this,Of,e),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){$(this,wl,!0);const s=e/t,{style:i}=this.div;i.aspectRatio=s,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){f(this,ai)||$(this,ai,new Map);const{action:s}=e;let i=f(this,ai).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(e),f(this,ai).delete(s),f(this,ai).size===0&&$(this,ai,null)},ot._telemetryTimeout),f(this,ai).set(s,i);return}e.type||(e.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),$(this,Eh,!1)}disable(){this.div&&(this.div.tabIndex=-1),$(this,Eh,!0)}renderAnnotationElement(e){let t=e.container.querySelector(".annotationContent");if(!t)t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.container.prepend(t);else if(t.nodeName==="CANVAS"){const s=t;t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),s.before(t)}return t}resetAnnotationElement(e){const{firstChild:t}=e.container;(t==null?void 0:t.nodeName)==="DIV"&&t.classList.contains("annotationContent")&&t.remove()}};vl=new WeakMap,Oi=new WeakMap,Ot=new WeakMap,Eh=new WeakMap,wl=new WeakMap,In=new WeakMap,_l=new WeakMap,Qo=new WeakMap,If=new WeakMap,Sl=new WeakMap,ea=new WeakMap,Of=new WeakMap,xl=new WeakMap,Kr=new WeakMap,fr=new WeakMap,Ch=new WeakMap,$h=new WeakMap,ai=new WeakMap,Nf=new WeakMap,Vy=new WeakMap,je=new WeakSet,Yv=function([e,t],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/e,this.y+=i/t,this.fixAndSetPosition()},Lf=new WeakSet,Jv=function(e,t,s){switch(s){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}},Qv=function(e){switch(e){case 90:{const[t,s]=this.pageDimensions;return[0,-t/s,s/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,s]=this.pageDimensions;return[0,t/s,-s/t,0]}default:return[1,0,0,1]}},PR=function(){if(f(this,In))return;$(this,In,document.createElement("div")),f(this,In).classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(const s of e){const i=document.createElement("div");f(this,In).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",P(this,je,RR).bind(this,s),{signal:t}),i.addEventListener("contextmenu",wi,{signal:t}),i.tabIndex=-1}this.div.prepend(f(this,In))},RR=function(e,t){var m;t.preventDefault();const{isMac:s}=fs.platform;if(t.button!==0||t.ctrlKey&&s)return;(m=f(this,Ot))==null||m.toggle(!1);const i=this._isDraggable;this._isDraggable=!1;const r=new AbortController,o=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",P(this,je,tw).bind(this,e),{passive:!0,capture:!0,signal:o}),window.addEventListener("contextmenu",wi,{signal:o});const a=this.x,l=this.y,c=this.width,h=this.height,u=this.parent.div.style.cursor,d=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const p=()=>{var g;r.abort(),this.parent.togglePointerEvents(!0),(g=f(this,Ot))==null||g.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=u,this.div.style.cursor=d,P(this,je,ew).call(this,a,l,c,h)};window.addEventListener("pointerup",p,{signal:o}),window.addEventListener("blur",p,{signal:o})},ew=function(e,t,s,i){const r=this.x,o=this.y,a=this.width,l=this.height;r===e&&o===t&&a===s&&l===i||this.addCommands({cmd:()=>{this.width=a,this.height=l,this.x=r,this.y=o;const[c,h]=this.parentDimensions;this.setDims(c*a,h*l),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=e,this.y=t;const[c,h]=this.parentDimensions;this.setDims(c*s,h*i),this.fixAndSetPosition()},mustExec:!0})},tw=function(e,t){const[s,i]=this.parentDimensions,r=this.x,o=this.y,a=this.width,l=this.height,c=ot.MIN_SIZE/s,h=ot.MIN_SIZE/i,u=Q=>Math.round(Q*1e4)/1e4,d=P(this,je,Qv).call(this,this.rotation),p=(Q,Y)=>[d[0]*Q+d[2]*Y,d[1]*Q+d[3]*Y],m=P(this,je,Qv).call(this,360-this.rotation),g=(Q,Y)=>[m[0]*Q+m[2]*Y,m[1]*Q+m[3]*Y];let b,y,w=!1,v=!1;switch(e){case"topLeft":w=!0,b=(Q,Y)=>[0,0],y=(Q,Y)=>[Q,Y];break;case"topMiddle":b=(Q,Y)=>[Q/2,0],y=(Q,Y)=>[Q/2,Y];break;case"topRight":w=!0,b=(Q,Y)=>[Q,0],y=(Q,Y)=>[0,Y];break;case"middleRight":v=!0,b=(Q,Y)=>[Q,Y/2],y=(Q,Y)=>[0,Y/2];break;case"bottomRight":w=!0,b=(Q,Y)=>[Q,Y],y=(Q,Y)=>[0,0];break;case"bottomMiddle":b=(Q,Y)=>[Q/2,Y],y=(Q,Y)=>[Q/2,0];break;case"bottomLeft":w=!0,b=(Q,Y)=>[0,Y],y=(Q,Y)=>[Q,0];break;case"middleLeft":v=!0,b=(Q,Y)=>[0,Y/2],y=(Q,Y)=>[Q,Y/2];break}const x=b(a,l),k=y(a,l);let E=p(...k);const T=u(r+E[0]),O=u(o+E[1]);let F=1,j=1,[L,B]=this.screenToPageTranslation(t.movementX,t.movementY);if([L,B]=g(L/s,B/i),w){const Q=Math.hypot(a,l);F=j=Math.max(Math.min(Math.hypot(k[0]-x[0]-L,k[1]-x[1]-B)/Q,1/a,1/l),c/a,h/l)}else v?F=Math.max(c,Math.min(1,Math.abs(k[0]-x[0]-L)))/a:j=Math.max(h,Math.min(1,Math.abs(k[1]-x[1]-B)))/l;const Z=u(a*F),q=u(l*j);E=p(...y(Z,q));const H=T-E[0],se=O-E[1];this.width=Z,this.height=q,this.x=H,this.y=se,this.setDims(s*Z,i*q),this.fixAndSetPosition()},nw=function(e){const{isMac:t}=fs.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)},MR=function(e){const{isSelected:t}=this;this._uiManager.setUpDragSession();const s=new AbortController,i=this._uiManager.combinedSignal(s);if(t){this.div.classList.add("moving"),$(this,Ch,e.clientX),$(this,$h,e.clientY);const o=a=>{const{clientX:l,clientY:c}=a,[h,u]=this.screenToPageTranslation(l-f(this,Ch),c-f(this,$h));$(this,Ch,l),$(this,$h,c),this._uiManager.dragSelectedEditors(h,u)};window.addEventListener("pointermove",o,{passive:!0,capture:!0,signal:i})}const r=()=>{s.abort(),t&&this.div.classList.remove("moving"),$(this,Sl,!1),this._uiManager.endDragSession()||P(this,je,nw).call(this,e)};window.addEventListener("pointerup",r,{signal:i}),window.addEventListener("blur",r,{signal:i})},sw=function(){if(f(this,Qo)||!this.div)return;$(this,Qo,new AbortController);const e=this._uiManager.combinedSignal(f(this,Qo));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})},IR=function(e){ot._resizerKeyboardManager.exec(this,e)},OR=function(e){var t;f(this,Kr)&&((t=e.relatedTarget)==null?void 0:t.parentNode)!==f(this,In)&&P(this,je,md).call(this)},NR=function(e){$(this,If,f(this,Kr)?e:"")},iw=function(e){if(f(this,Oi))for(const t of f(this,Oi))t.tabIndex=e},md=function(){if($(this,Kr,!1),P(this,je,iw).call(this,-1),f(this,_l)){const{savedX:e,savedY:t,savedWidth:s,savedHeight:i}=f(this,_l);P(this,je,ew).call(this,e,t,s,i),$(this,_l,null)}},M(ot,Lf),ae(ot,"_l10n",null),ae(ot,"_l10nResizer",null),ae(ot,"_borderLineWidth",-1),ae(ot,"_colorManager",new Vv),ae(ot,"_zIndex",1),ae(ot,"_telemetryTimeout",1e3);let ut=ot;class b8 extends ut{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const zA=3285377520,ii=4294901760,er=65535;class LR{constructor(e){this.h1=e?e&4294967295:zA,this.h2=e?e&4294967295:zA}update(e){let t,s;if(typeof e=="string"){t=new Uint8Array(e.length*2),s=0;for(let g=0,b=e.length;g>>8,t[s++]=y&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),s=t.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,r=s-i*4,o=new Uint32Array(t.buffer,0,i);let a=0,l=0,c=this.h1,h=this.h2;const u=3432918353,d=461845907,p=u&er,m=d&er;for(let g=0;g>>17,a=a*d&ii|a*m&er,c^=a,c=c<<13|c>>>19,c=c*5+3864292196):(l=o[g],l=l*u&ii|l*p&er,l=l<<15|l>>>17,l=l*d&ii|l*m&er,h^=l,h=h<<13|h>>>19,h=h*5+3864292196);switch(a=0,r){case 3:a^=t[i*4+2]<<16;case 2:a^=t[i*4+1]<<8;case 1:a^=t[i*4],a=a*u&ii|a*p&er,a=a<<15|a>>>17,a=a*d&ii|a*m&er,i&1?c^=a:h^=a}this.h1=c,this.h2=h}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&ii|e*36045&er,t=t*4283543511&ii|((t<<16|e>>>16)*2950163797&ii)>>>16,e^=t>>>1,e=e*444984403&ii|e*60499&er,t=t*3301882366&ii|((t<<16|e>>>16)*3120437893&ii)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}const rw=Object.freeze({map:null,hash:"",transfer:void 0});var kl,Al,Sn,Uy,DR;class _x{constructor(){M(this,Uy);M(this,kl,!1);M(this,Al,null);M(this,Sn,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){const s=f(this,Sn).get(e);return s===void 0?t:Object.assign(t,s)}getRawValue(e){return f(this,Sn).get(e)}remove(e){if(f(this,Sn).delete(e),f(this,Sn).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const t of f(this,Sn).values())if(t instanceof ut)return;this.onAnnotationEditor(null)}}setValue(e,t){const s=f(this,Sn).get(e);let i=!1;if(s!==void 0)for(const[r,o]of Object.entries(t))s[r]!==o&&(i=!0,s[r]=o);else i=!0,f(this,Sn).set(e,t);i&&P(this,Uy,DR).call(this),t instanceof ut&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(t.constructor._type)}has(e){return f(this,Sn).has(e)}getAll(){return f(this,Sn).size>0?mx(f(this,Sn)):null}setAll(e){for(const[t,s]of Object.entries(e))this.setValue(t,s)}get size(){return f(this,Sn).size}resetModified(){f(this,kl)&&($(this,kl,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new jR(this)}get serializable(){if(f(this,Sn).size===0)return rw;const e=new Map,t=new LR,s=[],i=Object.create(null);let r=!1;for(const[o,a]of f(this,Sn)){const l=a instanceof ut?a.serialize(!1,i):a;l&&(e.set(o,l),t.update(`${o}:${JSON.stringify(l)}`),r||(r=!!l.bitmap))}if(r)for(const o of e.values())o.bitmap&&s.push(o.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:s}:rw}get editorStats(){let e=null;const t=new Map;for(const s of f(this,Sn).values()){if(!(s instanceof ut))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:r}=i;t.has(r)||t.set(r,Object.getPrototypeOf(s).constructor),e||(e=Object.create(null));const o=e[r]||(e[r]=new Map);for(const[a,l]of Object.entries(i)){if(a==="type")continue;let c=o.get(a);c||(c=new Map,o.set(a,c));const h=c.get(l)??0;c.set(l,h+1)}}for(const[s,i]of t)e[s]=i.computeTelemetryFinalData(e[s]);return e}resetModifiedIds(){$(this,Al,null)}get modifiedIds(){if(f(this,Al))return f(this,Al);const e=[];for(const t of f(this,Sn).values())!(t instanceof ut)||!t.annotationElementId||!t.serialize()||e.push(t.annotationElementId);return $(this,Al,{ids:new Set(e),hash:e.join(",")})}}kl=new WeakMap,Al=new WeakMap,Sn=new WeakMap,Uy=new WeakSet,DR=function(){f(this,kl)||($(this,kl,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var Df;class jR extends _x{constructor(t){super();M(this,Df);const{map:s,hash:i,transfer:r}=t.serializable,o=structuredClone(s,r?{transfer:r}:null);$(this,Df,{map:o,hash:i,transfer:r})}get print(){Et("Should not call PrintAnnotationStorage.print")}get serializable(){return f(this,Df)}get modifiedIds(){return Ge(this,"modifiedIds",{ids:new Set,hash:""})}}Df=new WeakMap;var Th;class v8{constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){M(this,Th,new Set);this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),f(this,Th).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,_inspectFont:t}){if(!(!e||f(this,Th).has(e.loadedName))){if(dn(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:r}=e,o=new FontFace(s,i,r);this.addNativeFontFace(o);try{await o.load(),f(this,Th).add(s),t==null||t(e)}catch{He(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}Et("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){const s=e.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw He(`Failed to load font '${s.family}': '${i}'.`),e.disableFontFace=!0,i}}return}const t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(e,i)})}}get isFontLoadingAPISupported(){var t;const e=!!((t=this._document)!=null&&t.fonts);return Ge(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){let e=!1;return(is||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),Ge(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){function t(){for(dn(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:t,callback:e};return s.push(i),i}get _loadTestFont(){const e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return Ge(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,t){function s(x,k){return x.charCodeAt(k)<<24|x.charCodeAt(k+1)<<16|x.charCodeAt(k+2)<<8|x.charCodeAt(k+3)&255}function i(x,k,E,T){const O=x.substring(0,k),F=x.substring(k+E);return O+T+F}let r,o;const a=this._document.createElement("canvas");a.width=1,a.height=1;const l=a.getContext("2d");let c=0;function h(x,k){if(++c>30){He("Load test font never loaded."),k();return}if(l.font="30px "+x,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){k();return}setTimeout(h.bind(null,x,k))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let d=this._loadTestFont;d=i(d,976,u.length,u);const m=16,g=1482184792;let b=s(d,m);for(r=0,o=u.length-3;r{v.remove(),t.complete()})}}Th=new WeakMap;class w8{constructor(e,{disableFontFace:t=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const i in e)this[i]=e[i];this.disableFontFace=t===!0,this._inspectFont=s}createNativeFontFace(){var t;if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(t=this._inspectFont)==null||t.call(this,this),e}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${c8(this.data)});`;let t;if(!this.cssFontInfo)t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}return(s=this._inspectFont)==null||s.call(this,this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let s;try{s=e.get(this.loadedName+"_path_"+t)}catch(r){He(`getPathGenerator - ignoring character: "${r}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[t]=function(r,o){};const i=[];for(let r=0,o=s.length;rp.bezierCurveTo(a,l,c,h,u,d)),r+=6}break;case Fr.MOVE_TO:{const[a,l]=s.slice(r,r+2);i.push(c=>c.moveTo(a,l)),r+=2}break;case Fr.LINE_TO:{const[a,l]=s.slice(r,r+2);i.push(c=>c.lineTo(a,l)),r+=2}break;case Fr.QUADRATIC_CURVE_TO:{const[a,l,c,h]=s.slice(r,r+4);i.push(u=>u.quadraticCurveTo(a,l,c,h)),r+=4}break;case Fr.RESTORE:i.push(a=>a.restore());break;case Fr.SAVE:i.push(a=>a.save());break;case Fr.SCALE:dn(i.length===2,"Scale command is only valid at the third position.");break;case Fr.TRANSFORM:{const[a,l,c,h,u,d]=s.slice(r,r+6);i.push(p=>p.transform(a,l,c,h,u,d)),r+=6}break;case Fr.TRANSLATE:{const[a,l]=s.slice(r,r+2);i.push(c=>c.translate(a,l)),r+=2}break}return this.compiledGlyphs[t]=function(o,a){i[0](o),i[1](o),o.scale(a,-a);for(let l=2,c=i.length;l({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)})}async _fetch(e){Et("Abstract method `_fetch` called.")}}class HR extends zR{async _fetch(e){const t=await M0(e,this.isCompressed?"arraybuffer":"text");return t instanceof ArrayBuffer?new Uint8Array(t):R0(t)}}class BR{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,t,s,i,r){return"none"}destroy(e=!1){}}var El,Cl,pr,Zr,Yn,Wy,$l,me,Zn,Fc,zc,gg,Hc,qR,ow,Bc,gd,yd,aw,bd;class S8 extends BR{constructor({docId:t,ownerDocument:s=globalThis.document}){super();M(this,me);M(this,El);M(this,Cl);M(this,pr);M(this,Zr);M(this,Yn);M(this,Wy);M(this,$l,0);$(this,Zr,t),$(this,Yn,s)}addFilter(t){if(!t)return"none";let s=f(this,me,Zn).get(t);if(s)return s;const[i,r,o]=P(this,me,gg).call(this,t),a=t.length===1?i:`${i}${r}${o}`;if(s=f(this,me,Zn).get(a),s)return f(this,me,Zn).set(t,s),s;const l=`g_${f(this,Zr)}_transfer_map_${os(this,$l)._++}`,c=P(this,me,Hc).call(this,l);f(this,me,Zn).set(t,c),f(this,me,Zn).set(a,c);const h=P(this,me,Bc).call(this,l);return P(this,me,yd).call(this,i,r,o,h),c}addHCMFilter(t,s){var m;const i=`${t}-${s}`,r="base";let o=f(this,me,Fc).get(r);if((o==null?void 0:o.key)===i||(o?((m=o.filter)==null||m.remove(),o.key=i,o.url="none",o.filter=null):(o={key:i,url:"none",filter:null},f(this,me,Fc).set(r,o)),!t||!s))return o.url;const a=P(this,me,bd).call(this,t);t=Se.makeHexColor(...a);const l=P(this,me,bd).call(this,s);if(s=Se.makeHexColor(...l),f(this,me,zc).style.color="",t==="#000000"&&s==="#ffffff"||t===s)return o.url;const c=new Array(256);for(let g=0;g<=255;g++){const b=g/255;c[g]=b<=.03928?b/12.92:((b+.055)/1.055)**2.4}const h=c.join(","),u=`g_${f(this,Zr)}_hcm_filter`,d=o.filter=P(this,me,Bc).call(this,u);P(this,me,yd).call(this,h,h,h,d),P(this,me,ow).call(this,d);const p=(g,b)=>{const y=a[g]/255,w=l[g]/255,v=new Array(b+1);for(let x=0;x<=b;x++)v[x]=y+x/b*(w-y);return v.join(",")};return P(this,me,yd).call(this,p(0,5),p(1,5),p(2,5),d),o.url=P(this,me,Hc).call(this,u),o.url}addAlphaFilter(t){let s=f(this,me,Zn).get(t);if(s)return s;const[i]=P(this,me,gg).call(this,[t]),r=`alpha_${i}`;if(s=f(this,me,Zn).get(r),s)return f(this,me,Zn).set(t,s),s;const o=`g_${f(this,Zr)}_alpha_map_${os(this,$l)._++}`,a=P(this,me,Hc).call(this,o);f(this,me,Zn).set(t,a),f(this,me,Zn).set(r,a);const l=P(this,me,Bc).call(this,o);return P(this,me,aw).call(this,i,l),a}addLuminosityFilter(t){let s=f(this,me,Zn).get(t||"luminosity");if(s)return s;let i,r;if(t?([i]=P(this,me,gg).call(this,[t]),r=`luminosity_${i}`):r="luminosity",s=f(this,me,Zn).get(r),s)return f(this,me,Zn).set(t,s),s;const o=`g_${f(this,Zr)}_luminosity_map_${os(this,$l)._++}`,a=P(this,me,Hc).call(this,o);f(this,me,Zn).set(t,a),f(this,me,Zn).set(r,a);const l=P(this,me,Bc).call(this,o);return P(this,me,qR).call(this,l),t&&P(this,me,aw).call(this,i,l),a}addHighlightHCMFilter(t,s,i,r,o){var w;const a=`${s}-${i}-${r}-${o}`;let l=f(this,me,Fc).get(t);if((l==null?void 0:l.key)===a||(l?((w=l.filter)==null||w.remove(),l.key=a,l.url="none",l.filter=null):(l={key:a,url:"none",filter:null},f(this,me,Fc).set(t,l)),!s||!i))return l.url;const[c,h]=[s,i].map(P(this,me,bd).bind(this));let u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[p,m]=[r,o].map(P(this,me,bd).bind(this));d{const E=new Array(256),T=(d-u)/k,O=v/255,F=(x-v)/(255*k);let j=0;for(let L=0;L<=k;L++){const B=Math.round(u+L*T),Z=O+L*F;for(let q=j;q<=B;q++)E[q]=Z;j=B+1}for(let L=j;L<256;L++)E[L]=E[j-1];return E.join(",")},b=`g_${f(this,Zr)}_hcm_${t}_filter`,y=l.filter=P(this,me,Bc).call(this,b);return P(this,me,ow).call(this,y),P(this,me,yd).call(this,g(p[0],m[0],5),g(p[1],m[1],5),g(p[2],m[2],5),y),l.url=P(this,me,Hc).call(this,b),l.url}destroy(t=!1){t&&f(this,me,Fc).size!==0||(f(this,pr)&&(f(this,pr).parentNode.parentNode.remove(),$(this,pr,null)),f(this,Cl)&&(f(this,Cl).clear(),$(this,Cl,null)),$(this,$l,0))}}El=new WeakMap,Cl=new WeakMap,pr=new WeakMap,Zr=new WeakMap,Yn=new WeakMap,Wy=new WeakMap,$l=new WeakMap,me=new WeakSet,Zn=function(){return f(this,Cl)||$(this,Cl,new Map)},Fc=function(){return f(this,Wy)||$(this,Wy,new Map)},zc=function(){if(!f(this,pr)){const t=f(this,Yn).createElement("div"),{style:s}=t;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=f(this,Yn).createElementNS(Hr,"svg");i.setAttribute("width",0),i.setAttribute("height",0),$(this,pr,f(this,Yn).createElementNS(Hr,"defs")),t.append(i),i.append(f(this,pr)),f(this,Yn).body.append(t)}return f(this,pr)},gg=function(t){if(t.length===1){const c=t[0],h=new Array(256);for(let d=0;d<256;d++)h[d]=c[d]/255;const u=h.join(",");return[u,u,u]}const[s,i,r]=t,o=new Array(256),a=new Array(256),l=new Array(256);for(let c=0;c<256;c++)o[c]=s[c]/255,a[c]=i[c]/255,l[c]=r[c]/255;return[o.join(","),a.join(","),l.join(",")]},Hc=function(t){if(f(this,El)===void 0){$(this,El,"");const s=f(this,Yn).URL;s!==f(this,Yn).baseURI&&(I0(s)?He('#createUrl: ignore "data:"-URL for performance reasons.'):$(this,El,s.split("#",1)[0]))}return`url(${f(this,El)}#${t})`},qR=function(t){const s=f(this,Yn).createElementNS(Hr,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(s)},ow=function(t){const s=f(this,Yn).createElementNS(Hr,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(s)},Bc=function(t){const s=f(this,Yn).createElementNS(Hr,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",t),f(this,me,zc).append(s),s},gd=function(t,s,i){const r=f(this,Yn).createElementNS(Hr,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),t.append(r)},yd=function(t,s,i,r){const o=f(this,Yn).createElementNS(Hr,"feComponentTransfer");r.append(o),P(this,me,gd).call(this,o,"feFuncR",t),P(this,me,gd).call(this,o,"feFuncG",s),P(this,me,gd).call(this,o,"feFuncB",i)},aw=function(t,s){const i=f(this,Yn).createElementNS(Hr,"feComponentTransfer");s.append(i),P(this,me,gd).call(this,i,"feFuncA",t)},bd=function(t){return f(this,me,zc).style.color=t,wx(getComputedStyle(f(this,me,zc)).getPropertyValue("color"))};class VR{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");const t=`${this.baseUrl}${e}`;return this._fetch(t).catch(s=>{throw new Error(`Unable to load font data at: ${t}`)})}async _fetch(e){Et("Abstract method `_fetch` called.")}}class UR extends VR{async _fetch(e){const t=await M0(e,"arraybuffer");return new Uint8Array(t)}}if(is){var lw=Promise.withResolvers(),Wd=null;(async()=>{const e=await um(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),t=await um(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),s=await um(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),i=await um(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);let r,o;return new Map(Object.entries({fs:e,http:t,https:s,url:i,canvas:r,path2d:o}))})().then(e=>{Wd=e,lw.resolve()},e=>{He(`loadPackages: ${e}`),Wd=new Map,lw.resolve()})}class Ta{static get promise(){return lw.promise}static get(e){return Wd==null?void 0:Wd.get(e)}}async function WR(n){const t=await Ta.get("fs").promises.readFile(n);return new Uint8Array(t)}class x8 extends BR{}class k8 extends FR{_createCanvas(e,t){return Ta.get("canvas").createCanvas(e,t)}}class A8 extends zR{async _fetch(e){return WR(e)}}class E8 extends VR{async _fetch(e){return WR(e)}}const ds={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function cw(n,e){if(!e)return;const t=e[2]-e[0],s=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],t,s),n.clip(i)}class Sx{getPattern(){Et("Abstract method `getPattern` called.")}}class C8 extends Sx{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;this._type==="axial"?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)t.addColorStop(s[0],s[1]);return t}getPattern(e,t,s,i){let r;if(i===ds.STROKE||i===ds.FILL){const o=t.current.getClippedPathBoundingBox(i,Lt(e))||[0,0,0,0],a=Math.ceil(o[2]-o[0])||1,l=Math.ceil(o[3]-o[1])||1,c=t.cachedCanvases.getCanvas("pattern",a,l),h=c.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-o[0],-o[1]),s=Se.transform(s,[1,0,0,1,o[0],o[1]]),h.transform(...t.baseTransform),this.matrix&&h.transform(...this.matrix),cw(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),r=e.createPattern(c.canvas,"no-repeat");const u=new DOMMatrix(s);r.setTransform(u)}else cw(e,this._bbox),r=this._createGradient(e);return r}}function _b(n,e,t,s,i,r,o,a){const l=e.coords,c=e.colors,h=n.data,u=n.width*4;let d;l[t+1]>l[s+1]&&(d=t,t=s,s=d,d=r,r=o,o=d),l[s+1]>l[i+1]&&(d=s,s=i,i=d,d=o,o=a,a=d),l[t+1]>l[s+1]&&(d=t,t=s,s=d,d=r,r=o,o=d);const p=(l[t]+e.offsetX)*e.scaleX,m=(l[t+1]+e.offsetY)*e.scaleY,g=(l[s]+e.offsetX)*e.scaleX,b=(l[s+1]+e.offsetY)*e.scaleY,y=(l[i]+e.offsetX)*e.scaleX,w=(l[i+1]+e.offsetY)*e.scaleY;if(m>=w)return;const v=c[r],x=c[r+1],k=c[r+2],E=c[o],T=c[o+1],O=c[o+2],F=c[a],j=c[a+1],L=c[a+2],B=Math.round(m),Z=Math.round(w);let q,H,se,Q,Y,ye,z,C;for(let I=B;I<=Z;I++){if(Iw?W=1:b===w?W=0:W=(b-I)/(b-w),q=g-(g-y)*W,H=E-(E-F)*W,se=T-(T-j)*W,Q=O-(O-L)*W}let R;Iw?R=1:R=(m-I)/(m-w),Y=p-(p-y)*R,ye=v-(v-F)*R,z=x-(x-j)*R,C=k-(k-L)*R;const _=Math.round(Math.min(q,Y)),A=Math.round(Math.max(q,Y));let N=u*I+_*4;for(let W=_;W<=A;W++)R=(q-W)/(q-Y),R<0?R=0:R>1&&(R=1),h[N++]=H-(H-ye)*R|0,h[N++]=se-(se-z)*R|0,h[N++]=Q-(Q-C)*R|0,h[N++]=255}}function $8(n,e,t){const s=e.coords,i=e.colors;let r,o;switch(e.type){case"lattice":const a=e.verticesPerRow,l=Math.floor(s.length/a)-1,c=a-1;for(r=0;r=j?x=l:E=!0,F>=L?k=c:T=!0;const B=this.getSizeAndScale(x,this.ctx.canvas.width,w),Z=this.getSizeAndScale(k,this.ctx.canvas.height,v),q=e.cachedCanvases.getCanvas("pattern",B.size,Z.size),H=q.context,se=a.createCanvasGraphics(H);if(se.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(se,i,o),H.translate(-B.scale*h,-Z.scale*u),se.transform(B.scale,0,0,Z.scale,0,0),H.save(),this.clipBbox(se,h,u,d,p),se.baseTransform=Lt(se.ctx),se.executeOperatorList(s),se.endDrawing(),H.restore(),E||T){const Q=q.canvas;E&&(x=l),T&&(k=c);const Y=this.getSizeAndScale(x,this.ctx.canvas.width,w),ye=this.getSizeAndScale(k,this.ctx.canvas.height,v),z=Y.size,C=ye.size,I=e.cachedCanvases.getCanvas("pattern-workaround",z,C),R=I.context,_=E?Math.floor(m/l):0,A=T?Math.floor(g/c):0;for(let N=0;N<=_;N++)for(let W=0;W<=A;W++)R.drawImage(Q,z*N,C*W,z,C,0,0,z,C);return{canvas:I.canvas,scaleX:Y.scale,scaleY:ye.scale,offsetX:h,offsetY:u}}return{canvas:q.canvas,scaleX:B.scale,scaleY:Z.scale,offsetX:h,offsetY:u}}getSizeAndScale(e,t,s){const i=Math.max(Gy.MAX_PATTERN_SIZE,t);let r=Math.ceil(e*s);return r>=i?r=i:s=r/e,{scale:s,size:r}}clipBbox(e,t,s,i,r){const o=i-t,a=r-s;e.ctx.rect(t,s,o,a),e.current.updateRectMinMax(Lt(e.ctx),[t,s,i,r]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,s){const i=e.ctx,r=e.current;switch(t){case HA.COLORED:const o=this.ctx;i.fillStyle=o.fillStyle,i.strokeStyle=o.strokeStyle,r.fillColor=o.fillStyle,r.strokeColor=o.strokeStyle;break;case HA.UNCOLORED:const a=Se.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,r.fillColor=a,r.strokeColor=a;break;default:throw new n8(`Unsupported paint type: ${t}`)}}getPattern(e,t,s,i){let r=s;i!==ds.SHADING&&(r=Se.transform(r,t.baseTransform),this.matrix&&(r=Se.transform(r,this.matrix)));const o=this.createPatternCanvas(t);let a=new DOMMatrix(r);a=a.translate(o.offsetX,o.offsetY),a=a.scale(1/o.scaleX,1/o.scaleY);const l=e.createPattern(o.canvas,"repeat");return l.setTransform(a),l}};ae(Gy,"MAX_PATTERN_SIZE",3e3);let hw=Gy;function M8({src:n,srcPos:e=0,dest:t,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:o=!1}){const a=fs.isLittleEndian?4278190080:255,[l,c]=o?[r,a]:[a,r],h=s>>3,u=s&7,d=n.length;t=new Uint32Array(t.buffer);let p=0;for(let m=0;m{n.save=n.__originalSave,n.restore=n.__originalRestore,n.rotate=n.__originalRotate,n.scale=n.__originalScale,n.translate=n.__originalTranslate,n.transform=n.__originalTransform,n.setTransform=n.__originalSetTransform,n.resetTransform=n.__originalResetTransform,n.clip=n.__originalClip,n.moveTo=n.__originalMoveTo,n.lineTo=n.__originalLineTo,n.bezierCurveTo=n.__originalBezierCurveTo,n.rect=n.__originalRect,n.closePath=n.__originalClosePath,n.beginPath=n.__originalBeginPath,delete n._removeMirroring},n.save=function(){e.save(),this.__originalSave()},n.restore=function(){e.restore(),this.__originalRestore()},n.translate=function(s,i){e.translate(s,i),this.__originalTranslate(s,i)},n.scale=function(s,i){e.scale(s,i),this.__originalScale(s,i)},n.transform=function(s,i,r,o,a,l){e.transform(s,i,r,o,a,l),this.__originalTransform(s,i,r,o,a,l)},n.setTransform=function(s,i,r,o,a,l){e.setTransform(s,i,r,o,a,l),this.__originalSetTransform(s,i,r,o,a,l)},n.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},n.rotate=function(s){e.rotate(s),this.__originalRotate(s)},n.clip=function(s){e.clip(s),this.__originalClip(s)},n.moveTo=function(t,s){e.moveTo(t,s),this.__originalMoveTo(t,s)},n.lineTo=function(t,s){e.lineTo(t,s),this.__originalLineTo(t,s)},n.bezierCurveTo=function(t,s,i,r,o,a){e.bezierCurveTo(t,s,i,r,o,a),this.__originalBezierCurveTo(t,s,i,r,o,a)},n.rect=function(t,s,i,r){e.rect(t,s,i,r),this.__originalRect(t,s,i,r)},n.closePath=function(){e.closePath(),this.__originalClosePath()},n.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}class N8{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,s){let i;return this.cache[e]!==void 0?(i=this.cache[e],this.canvasFactory.reset(i,t,s)):(i=this.canvasFactory.create(t,s),this.cache[e]=i),i}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}}function Cm(n,e,t,s,i,r,o,a,l,c){const[h,u,d,p,m,g]=Lt(n);if(u===0&&d===0){const w=o*h+m,v=Math.round(w),x=a*p+g,k=Math.round(x),E=(o+l)*h+m,T=Math.abs(Math.round(E)-v)||1,O=(a+c)*p+g,F=Math.abs(Math.round(O)-k)||1;return n.setTransform(Math.sign(h),0,0,Math.sign(p),v,k),n.drawImage(e,t,s,i,r,0,0,T,F),n.setTransform(h,u,d,p,m,g),[T,F]}if(h===0&&p===0){const w=a*d+m,v=Math.round(w),x=o*u+g,k=Math.round(x),E=(a+c)*d+m,T=Math.abs(Math.round(E)-v)||1,O=(o+l)*u+g,F=Math.abs(Math.round(O)-k)||1;return n.setTransform(0,Math.sign(u),Math.sign(d),0,v,k),n.drawImage(e,t,s,i,r,0,0,F,T),n.setTransform(h,u,d,p,m,g),[F,T]}n.drawImage(e,t,s,i,r,o,a,l,c);const b=Math.hypot(h,u),y=Math.hypot(d,p);return[b*l,y*c]}function L8(n){const{width:e,height:t}=n;if(e>UA||t>UA)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),r=e+1;let o=new Uint8Array(r*(t+1)),a,l,c;const h=e+7&-8;let u=new Uint8Array(h*t),d=0;for(const y of n.data){let w=128;for(;w>0;)u[d++]=y&w?0:255,w>>=1}let p=0;for(d=0,u[d]!==0&&(o[0]=1,++p),l=1;l>2)+(u[d+1]?4:0)+(u[d-h+1]?8:0),i[y]&&(o[c+l]=i[y],++p),d++;if(u[d-h]!==u[d]&&(o[c+l]=u[d]?2:4,++p),p>s)return null}for(d=h*(t-1),c=a*r,u[d]!==0&&(o[c]=8,++p),l=1;ls)return null;const m=new Int32Array([0,r,-1,0,-r,0,0,0,1]),g=new Path2D;for(a=0;p&&a<=t;a++){let y=a*r;const w=y+e;for(;y>4,o[y]&=x>>2|x<<2),g.lineTo(y%r,y/r|0),o[y]||--p}while(v!==y);--a}return u=null,o=null,function(y){y.save(),y.scale(1/e,-1/t),y.translate(0,-t),y.fill(g),y.beginPath(),y.restore()}}class WA{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=cR,this.textMatrixScale=1,this.fontMatrix=Lv,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=Kn.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,s){[t,s]=Se.applyTransform([t,s],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(e,t){const s=Se.applyTransform(t,e),i=Se.applyTransform(t.slice(2),e),r=Se.applyTransform([t[0],t[3]],e),o=Se.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,s[0],i[0],r[0],o[0]),this.minY=Math.min(this.minY,s[1],i[1],r[1],o[1]),this.maxX=Math.max(this.maxX,s[0],i[0],r[0],o[0]),this.maxY=Math.max(this.maxY,s[1],i[1],r[1],o[1])}updateScalingPathMinMax(e,t){Se.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.minY=Math.min(this.minY,t[1]),this.maxX=Math.max(this.maxX,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,s,i,r,o,a,l,c,h){const u=Se.bezierBoundingBox(t,s,i,r,o,a,l,c,h);h||this.updateRectMinMax(e,u)}getPathBoundingBox(e=ds.FILL,t=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(e===ds.STROKE){t||Et("Stroke bounding box must include transform.");const i=Se.singularValueDecompose2dScale(t),r=i[0]*this.lineWidth/2,o=i[1]*this.lineWidth/2;s[0]-=r,s[1]-=o,s[2]+=r,s[3]+=o}return s}updateClipFromPath(){const e=Se.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=ds.FILL,t=null){return Se.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function GA(n,e){if(typeof ImageData<"u"&&e instanceof ImageData){n.putImageData(e,0,0);return}const t=e.height,s=e.width,i=t%Ps,r=(t-i)/Ps,o=i===0?r:r+1,a=n.createImageData(s,Ps);let l=0,c;const h=e.data,u=a.data;let d,p,m,g;if(e.kind===cg.GRAYSCALE_1BPP){const b=h.byteLength,y=new Uint32Array(u.buffer,0,u.byteLength>>2),w=y.length,v=s+7>>3,x=4294967295,k=fs.isLittleEndian?4278190080:255;for(d=0;dv?s:E*8-7,F=O&-8;let j=0,L=0;for(;T>=1}for(;c=r&&(m=i,g=s*m),c=0,p=g;p--;)u[c++]=h[l++],u[c++]=h[l++],u[c++]=h[l++],u[c++]=255;n.putImageData(a,0,d*Ps)}else throw new Error(`bad image kind: ${e.kind}`)}function KA(n,e){if(e.bitmap){n.drawImage(e.bitmap,0,0);return}const t=e.height,s=e.width,i=t%Ps,r=(t-i)/Ps,o=i===0?r:r+1,a=n.createImageData(s,Ps);let l=0;const c=e.data,h=a.data;for(let u=0;uVA&&typeof s=="function",h=c?Date.now()+I8:0;let u=0;const d=this.commonObjs,p=this.objs;let m;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,s),a;if(m=o[a],m!==Ti.dependency)this[m].apply(this,r[a]);else for(const g of r[a]){const b=g.startsWith("g_")?d:p;if(!b.has(g))return b.get(g,s),a}if(a++,a===l)return a;if(c&&++u>VA){if(Date.now()>h)return s(),a;u=0}}}endDrawing(){P(this,Na,uw).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const t of e.values())typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),P(this,Na,dw).call(this)}_scaleImage(e,t){const s=e.width??e.displayWidth,i=e.height??e.displayHeight;let r=Math.max(Math.hypot(t[0],t[1]),1),o=Math.max(Math.hypot(t[2],t[3]),1),a=s,l=i,c="prescale1",h,u;for(;r>2&&a>1||o>2&&l>1;){let d=a,p=l;r>2&&a>1&&(d=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),r/=a/d),o>2&&l>1&&(p=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,o/=l/p),h=this.cachedCanvases.getCanvas(c,d,p),u=h.context,u.clearRect(0,0,d,p),u.drawImage(e,0,0,a,l,0,0,d,p),e=h.canvas,a=d,l=p,c=c==="prescale1"?"prescale2":"prescale1"}return{img:e,paintWidth:a,paintHeight:l}}_createMaskCanvas(e){const t=this.ctx,{width:s,height:i}=e,r=this.current.fillColor,o=this.current.patternFill,a=Lt(t);let l,c,h,u;if((e.bitmap||e.data)&&e.count>1){const O=e.bitmap||e.data.buffer;c=JSON.stringify(o?a:[a.slice(0,4),r]),l=this._cachedBitmapsMap.get(O),l||(l=new Map,this._cachedBitmapsMap.set(O,l));const F=l.get(c);if(F&&!o){const j=Math.round(Math.min(a[0],a[2])+a[4]),L=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:F,offsetX:j,offsetY:L}}h=F}h||(u=this.cachedCanvases.getCanvas("maskCanvas",s,i),KA(u.context,e));let d=Se.transform(a,[1/s,0,0,-1/i,0,0]);d=Se.transform(d,[1,0,0,1,0,-i]);const[p,m,g,b]=Se.getAxialAlignedBoundingBox([0,0,s,i],d),y=Math.round(g-p)||1,w=Math.round(b-m)||1,v=this.cachedCanvases.getCanvas("fillCanvas",y,w),x=v.context,k=p,E=m;x.translate(-k,-E),x.transform(...d),h||(h=this._scaleImage(u.canvas,zr(x)),h=h.img,l&&o&&l.set(c,h)),x.imageSmoothingEnabled=ZA(Lt(x),e.interpolate),Cm(x,h,0,0,h.width,h.height,0,0,s,i),x.globalCompositeOperation="source-in";const T=Se.transform(zr(x),[1,0,0,1,-k,-E]);return x.fillStyle=o?r.getPattern(t,this,T,ds.FILL):r,x.fillRect(0,0,s,i),l&&!o&&(this.cachedCanvases.delete("fillCanvas"),l.set(c,v.canvas)),{canvas:v.canvas,offsetX:Math.round(k),offsetY:Math.round(E)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=D8[e]}setLineJoin(e){this.ctx.lineJoin=j8[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(e),s.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[t,s]of e)switch(t){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,t=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,e,t);this.suspendedCtx=this.ctx,this.ctx=i.context;const r=this.ctx;r.setTransform(...Lt(this.suspendedCtx)),Qu(this.suspendedCtx,r),O8(r,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Qu(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,s,i){const r=i[0],o=i[1],a=i[2]-r,l=i[3]-o;a===0||l===0||(this.genericComposeSMask(t.context,s,a,l,t.subtype,t.backdrop,t.transferMap,r,o,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(s.canvas,0,0),e.restore())}genericComposeSMask(e,t,s,i,r,o,a,l,c,h,u){let d=e.canvas,p=l-h,m=c-u;if(o){const b=Se.makeHexColor(...o);if(p<0||m<0||p+s>d.width||m+i>d.height){const y=this.cachedCanvases.getCanvas("maskExtension",s,i),w=y.context;w.drawImage(d,-p,-m),w.globalCompositeOperation="destination-atop",w.fillStyle=b,w.fillRect(0,0,s,i),w.globalCompositeOperation="source-over",d=y.canvas,p=m=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const y=new Path2D;y.rect(p,m,s,i),e.clip(y),e.globalCompositeOperation="destination-atop",e.fillStyle=b,e.fillRect(p,m,s,i),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),r==="Alpha"&&a?t.filter=this.filterFactory.addAlphaFilter(a):r==="Luminosity"&&(t.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(l,c,s,i),t.clip(g),t.globalCompositeOperation="destination-in",t.drawImage(d,p,m,s,i,l,c,s,i),t.restore()}save(){this.inSMaskMode?(Qu(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Qu(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,s,i,r,o){this.ctx.transform(e,t,s,i,r,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,s){const i=this.ctx,r=this.current;let o=r.x,a=r.y,l,c;const h=Lt(i),u=h[0]===0&&h[3]===0||h[1]===0&&h[2]===0,d=u?s.slice(0):null;for(let p=0,m=0,g=e.length;pqA&&(c=qA),this.current.fontSizeScale=t/c,this.ctx.font=`${l} ${a} ${c}px ${o}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,s,i,r,o){this.current.textMatrix=[e,t,s,i,r,o],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,t,s,i){const r=this.ctx,o=this.current,a=o.font,l=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,h=l&Kn.FILL_STROKE_MASK,u=!!(l&Kn.ADD_TO_PATH_FLAG),d=o.patternFill&&!a.missingFile;let p;(a.disableFontFace||u||d)&&(p=a.getPathGenerator(this.commonObjs,e)),a.disableFontFace||d?(r.save(),r.translate(t,s),r.beginPath(),p(r,c),i&&r.setTransform(...i),(h===Kn.FILL||h===Kn.FILL_STROKE)&&r.fill(),(h===Kn.STROKE||h===Kn.FILL_STROKE)&&r.stroke(),r.restore()):((h===Kn.FILL||h===Kn.FILL_STROKE)&&r.fillText(e,t,s),(h===Kn.STROKE||h===Kn.FILL_STROKE)&&r.strokeText(e,t,s)),u&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Lt(r),x:t,y:s,fontSize:c,addToPath:p})}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);const t=e.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i0&&t[i]<255){s=!0;break}return Ge(this,"isFontSubpixelAAEnabled",s)}showText(e){const t=this.current,s=t.font;if(s.isType3Font)return this.showType3Text(e);const i=t.fontSize;if(i===0)return;const r=this.ctx,o=t.fontSizeScale,a=t.charSpacing,l=t.wordSpacing,c=t.fontDirection,h=t.textHScale*c,u=e.length,d=s.vertical,p=d?1:-1,m=s.defaultVMetrics,g=i*t.fontMatrix[0],b=t.textRenderingMode===Kn.FILL&&!s.disableFontFace&&!t.patternFill;r.save(),r.transform(...t.textMatrix),r.translate(t.x,t.y+t.textRise),c>0?r.scale(h,-1):r.scale(h,1);let y;if(t.patternFill){r.save();const E=t.fillColor.getPattern(r,this,zr(r),ds.FILL);y=Lt(r),r.restore(),r.fillStyle=E}let w=t.lineWidth;const v=t.textMatrixScale;if(v===0||w===0){const E=t.textRenderingMode&Kn.FILL_STROKE_MASK;(E===Kn.STROKE||E===Kn.FILL_STROKE)&&(w=this.getSinglePixelWidth())}else w/=v;if(o!==1&&(r.scale(o,o),w/=o),r.lineWidth=w,s.isInvalidPDFjsFont){const E=[];let T=0;for(const O of e)E.push(O.unicode),T+=O.width;r.fillText(E.join(""),0,0),t.x+=T*g*h,r.restore(),this.compose();return}let x=0,k;for(k=0;k0){const H=r.measureText(F).width*1e3/i*o;if(Znew ok(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new hw(e,s,this.ctx,r,i)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,s){this.ctx.strokeStyle=this.current.strokeColor=Se.makeHexColor(e,t,s)}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent"}setFillRGBColor(e,t,s){this.ctx.fillStyle=this.current.fillColor=Se.makeHexColor(e,t,s),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,t=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=R8(this.getObject(e)),this.cachedPatterns.set(e,s)),t&&(s.matrix=t),s}shadingFill(e){if(!this.contentVisible)return;const t=this.ctx;this.save();const s=this._getPattern(e);t.fillStyle=s.getPattern(t,this,zr(t),ds.SHADING);const i=zr(t);if(i){const{width:r,height:o}=t.canvas,[a,l,c,h]=Se.getAxialAlignedBoundingBox([0,0,r,o],i);this.ctx.fillRect(a,l,c-a,h-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Et("Should not call beginInlineImage")}beginImageData(){Et("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=Lt(this.ctx),t)){const s=t[2]-t[0],i=t[3]-t[1];this.ctx.rect(t[0],t[1],s,i),this.current.updateRectMinMax(Lt(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const t=this.ctx;e.isolated||T0("TODO: Support non-isolated groups."),e.knockout&&He("Knockout groups not supported.");const s=Lt(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let i=Se.getAxialAlignedBoundingBox(e.bbox,Lt(t));const r=[0,0,t.canvas.width,t.canvas.height];i=Se.intersect(i,r)||[0,0,0,0];const o=Math.floor(i[0]),a=Math.floor(i[1]),l=Math.max(Math.ceil(i[2])-o,1),c=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,l,c]);let h="groupAt"+this.groupLevel;e.smask&&(h+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(h,l,c),d=u.context;d.translate(-o,-a),d.transform(...s),e.smask?this.smaskStack.push({canvas:u.canvas,context:d,offsetX:o,offsetY:a,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(o,a),t.save()),Qu(t,d),this.ctx=d,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;const t=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=Lt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const r=Se.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],i);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(r)}}beginAnnotation(e,t,s,i,r){if(P(this,Na,uw).call(this),$m(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){const o=t[2]-t[0],a=t[3]-t[1];if(r&&this.annotationCanvasMap){s=s.slice(),s[4]-=t[0],s[5]-=t[1],t=t.slice(),t[0]=t[1]=0,t[2]=o,t[3]=a;const[l,c]=Se.singularValueDecompose2dScale(Lt(this.ctx)),{viewportScale:h}=this,u=Math.ceil(o*this.outputScaleX*h),d=Math.ceil(a*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(u,d);const{canvas:p,context:m}=this.annotationCanvas;this.annotationCanvasMap.set(e,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=m,this.ctx.save(),this.ctx.setTransform(l,0,0,-c,0,a*c),$m(this.ctx)}else $m(this.ctx),this.endPath(),this.ctx.rect(t[0],t[1],o,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new WA(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),P(this,Na,dw).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;const t=e.count;e=this.getObject(e.data,e),e.count=t;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=L8(e)),i.compiled)){i.compiled(s);return}const r=this._createMaskCanvas(e),o=r.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(o,r.offsetX,r.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,s=0,i=0,r,o){if(!this.contentVisible)return;e=this.getObject(e.data,e);const a=this.ctx;a.save();const l=Lt(a);a.transform(t,s,i,r,0,0);const c=this._createMaskCanvas(e);a.setTransform(1,0,0,1,c.offsetX-l[4],c.offsetY-l[5]);for(let h=0,u=o.length;hu?h/u:1,a=c>u?c/u:1}}this._cachedScaleForStroking[0]=o,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(e){const{ctx:t}=this,{lineWidth:s}=this.current,[i,r]=this.getScaleForStroking();if(t.lineWidth=s||1,i===1&&r===1){t.stroke();return}const o=t.getLineDash();if(e&&t.save(),t.scale(i,r),o.length>0){const a=Math.max(i,r);t.setLineDash(o.map(l=>l/a)),t.lineDashOffset/=a}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};Na=new WeakSet,uw=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},dw=function(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!=="none"){const t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}};let ah=ok;for(const n in Ti)ah.prototype[n]!==void 0&&(ah.prototype[Ti[n]]=ah.prototype[n]);var Ff,zf;class mo{static get workerPort(){return f(this,Ff)}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw new Error("Invalid `workerPort` type.");$(this,Ff,e)}static get workerSrc(){return f(this,zf)}static set workerSrc(e){if(typeof e!="string")throw new Error("Invalid `workerSrc` type.");$(this,zf,e)}}Ff=new WeakMap,zf=new WeakMap,M(mo,Ff,null),M(mo,zf,"");const Tm={DATA:1,ERROR:2},Jt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function zs(n){switch(n instanceof Error||typeof n=="object"&&n!==null||Et('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),n.name){case"AbortException":return new $c(n.message);case"MissingPDFException":return new Cc(n.message);case"PasswordException":return new Dv(n.message,n.code);case"UnexpectedResponseException":return new P0(n.message,n.status);case"UnknownErrorException":return new jv(n.message,n.details);default:return new jv(n.message,n.toString())}}var Ph,vi,GR,KR,ZR,yg;class vd{constructor(e,t,s){M(this,vi);M(this,Ph,new AbortController);this.sourceName=e,this.targetName=t,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",P(this,vi,GR).bind(this),{signal:f(this,Ph).signal})}on(e,t){const s=this.actionHandler;if(s[e])throw new Error(`There is already an actionName called "${e}"`);s[e]=t}send(e,t,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},s)}sendWithPromise(e,t,s){const i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},s)}catch(o){r.reject(o)}return r.promise}sendWithStream(e,t,s,i){const r=this.streamId++,o=this.sourceName,a=this.targetName,l=this.comObj;return new ReadableStream({start:c=>{const h=Promise.withResolvers();return this.streamControllers[r]={controller:c,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:o,targetName:a,action:e,streamId:r,data:t,desiredSize:c.desiredSize},i),h.promise},pull:c=>{const h=Promise.withResolvers();return this.streamControllers[r].pullCall=h,l.postMessage({sourceName:o,targetName:a,stream:Jt.PULL,streamId:r,desiredSize:c.desiredSize}),h.promise},cancel:c=>{dn(c instanceof Error,"cancel must have a valid reason");const h=Promise.withResolvers();return this.streamControllers[r].cancelCall=h,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:o,targetName:a,stream:Jt.CANCEL,streamId:r,reason:zs(c)}),h.promise}},s)}destroy(){var e;(e=f(this,Ph))==null||e.abort(),$(this,Ph,null)}}Ph=new WeakMap,vi=new WeakSet,GR=function({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){P(this,vi,ZR).call(this,e);return}if(e.callback){const s=e.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],e.callback===Tm.DATA)i.resolve(e.data);else if(e.callback===Tm.ERROR)i.reject(zs(e.reason));else throw new Error("Unexpected callback case");return}const t=this.actionHandler[e.action];if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const s=this.sourceName,i=e.sourceName,r=this.comObj;new Promise(function(o){o(t(e.data))}).then(function(o){r.postMessage({sourceName:s,targetName:i,callback:Tm.DATA,callbackId:e.callbackId,data:o})},function(o){r.postMessage({sourceName:s,targetName:i,callback:Tm.ERROR,callbackId:e.callbackId,reason:zs(o)})});return}if(e.streamId){P(this,vi,KR).call(this,e);return}t(e.data)},KR=function(e){const t=e.streamId,s=this.sourceName,i=e.sourceName,r=this.comObj,o=this,a=this.actionHandler[e.action],l={enqueue(c,h=1,u){if(this.isCancelled)return;const d=this.desiredSize;this.desiredSize-=h,d>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:Jt.ENQUEUE,streamId:t,chunk:c},u)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Jt.CLOSE,streamId:t}),delete o.streamSinks[t])},error(c){dn(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Jt.ERROR,streamId:t,reason:zs(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[t]=l,new Promise(function(c){c(a(e.data,l))}).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Jt.START_COMPLETE,streamId:t,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:Jt.START_COMPLETE,streamId:t,reason:zs(c)})})},ZR=function(e){const t=e.streamId,s=this.sourceName,i=e.sourceName,r=this.comObj,o=this.streamControllers[t],a=this.streamSinks[t];switch(e.stream){case Jt.START_COMPLETE:e.success?o.startCall.resolve():o.startCall.reject(zs(e.reason));break;case Jt.PULL_COMPLETE:e.success?o.pullCall.resolve():o.pullCall.reject(zs(e.reason));break;case Jt.PULL:if(!a){r.postMessage({sourceName:s,targetName:i,stream:Jt.PULL_COMPLETE,streamId:t,success:!0});break}a.desiredSize<=0&&e.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=e.desiredSize,new Promise(function(l){var c;l((c=a.onPull)==null?void 0:c.call(a))}).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Jt.PULL_COMPLETE,streamId:t,success:!0})},function(l){r.postMessage({sourceName:s,targetName:i,stream:Jt.PULL_COMPLETE,streamId:t,reason:zs(l)})});break;case Jt.ENQUEUE:if(dn(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(e.chunk);break;case Jt.CLOSE:if(dn(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),P(this,vi,yg).call(this,o,t);break;case Jt.ERROR:dn(o,"error should have stream controller"),o.controller.error(zs(e.reason)),P(this,vi,yg).call(this,o,t);break;case Jt.CANCEL_COMPLETE:e.success?o.cancelCall.resolve():o.cancelCall.reject(zs(e.reason)),P(this,vi,yg).call(this,o,t);break;case Jt.CANCEL:if(!a)break;new Promise(function(l){var c;l((c=a.onCancel)==null?void 0:c.call(a,zs(e.reason)))}).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Jt.CANCEL_COMPLETE,streamId:t,success:!0})},function(l){r.postMessage({sourceName:s,targetName:i,stream:Jt.CANCEL_COMPLETE,streamId:t,reason:zs(l)})}),a.sinkCapability.reject(zs(e.reason)),a.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}},yg=async function(e,t){var s,i,r;await Promise.allSettled([(s=e.startCall)==null?void 0:s.promise,(i=e.pullCall)==null?void 0:i.promise,(r=e.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[t]};var Tl,Hf;class z8{constructor({parsedData:e,rawData:t}){M(this,Tl);M(this,Hf);$(this,Tl,e),$(this,Hf,t)}getRaw(){return f(this,Hf)}get(e){return f(this,Tl).get(e)??null}getAll(){return mx(f(this,Tl))}has(e){return f(this,Tl).has(e)}}Tl=new WeakMap,Hf=new WeakMap;const qc=Symbol("INTERNAL");var Bf,qf,Vf,Rh;class H8{constructor(e,{name:t,intent:s,usage:i,rbGroups:r}){M(this,Bf,!1);M(this,qf,!1);M(this,Vf,!1);M(this,Rh,!0);$(this,Bf,!!(e&Xs.DISPLAY)),$(this,qf,!!(e&Xs.PRINT)),this.name=t,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(f(this,Vf))return f(this,Rh);if(!f(this,Rh))return!1;const{print:e,view:t}=this.usage;return f(this,Bf)?(t==null?void 0:t.viewState)!=="OFF":f(this,qf)?(e==null?void 0:e.printState)!=="OFF":!0}_setVisible(e,t,s=!1){e!==qc&&Et("Internal method `_setVisible` called."),$(this,Vf,s),$(this,Rh,t)}}Bf=new WeakMap,qf=new WeakMap,Vf=new WeakMap,Rh=new WeakMap;var ta,ht,Mh,Ih,Uf,fw;class B8{constructor(e,t=Xs.DISPLAY){M(this,Uf);M(this,ta,null);M(this,ht,new Map);M(this,Mh,null);M(this,Ih,null);if(this.renderingIntent=t,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,$(this,Ih,e.order);for(const s of e.groups)f(this,ht).set(s.id,new H8(t,s));if(e.baseState==="OFF")for(const s of f(this,ht).values())s._setVisible(qc,!1);for(const s of e.on)f(this,ht).get(s)._setVisible(qc,!0);for(const s of e.off)f(this,ht).get(s)._setVisible(qc,!1);$(this,Mh,this.getHash())}}isVisible(e){if(f(this,ht).size===0)return!0;if(!e)return T0("Optional content group not defined."),!0;if(e.type==="OCG")return f(this,ht).has(e.id)?f(this,ht).get(e.id).visible:(He(`Optional content group not found: ${e.id}`),!0);if(e.type==="OCMD"){if(e.expression)return P(this,Uf,fw).call(this,e.expression);if(!e.policy||e.policy==="AnyOn"){for(const t of e.ids){if(!f(this,ht).has(t))return He(`Optional content group not found: ${t}`),!0;if(f(this,ht).get(t).visible)return!0}return!1}else if(e.policy==="AllOn"){for(const t of e.ids){if(!f(this,ht).has(t))return He(`Optional content group not found: ${t}`),!0;if(!f(this,ht).get(t).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(const t of e.ids){if(!f(this,ht).has(t))return He(`Optional content group not found: ${t}`),!0;if(!f(this,ht).get(t).visible)return!0}return!1}else if(e.policy==="AllOff"){for(const t of e.ids){if(!f(this,ht).has(t))return He(`Optional content group not found: ${t}`),!0;if(f(this,ht).get(t).visible)return!1}return!0}return He(`Unknown optional content policy ${e.policy}.`),!0}return He(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,s=!0){var r;const i=f(this,ht).get(e);if(!i){He(`Optional content group not found: ${e}`);return}if(s&&t&&i.rbGroups.length)for(const o of i.rbGroups)for(const a of o)a!==e&&((r=f(this,ht).get(a))==null||r._setVisible(qc,!1,!0));i._setVisible(qc,!!t,!0),$(this,ta,null)}setOCGState({state:e,preserveRB:t}){let s;for(const i of e){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const r=f(this,ht).get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,t);break;case"OFF":this.setVisibility(i,!1,t);break;case"Toggle":this.setVisibility(i,!r.visible,t);break}}$(this,ta,null)}get hasInitialVisibility(){return f(this,Mh)===null||this.getHash()===f(this,Mh)}getOrder(){return f(this,ht).size?f(this,Ih)?f(this,Ih).slice():[...f(this,ht).keys()]:null}getGroups(){return f(this,ht).size>0?mx(f(this,ht)):null}getGroup(e){return f(this,ht).get(e)||null}getHash(){if(f(this,ta)!==null)return f(this,ta);const e=new LR;for(const[t,s]of f(this,ht))e.update(`${t}:${s.visible}`);return $(this,ta,e.hexdigest())}}ta=new WeakMap,ht=new WeakMap,Mh=new WeakMap,Ih=new WeakMap,Uf=new WeakSet,fw=function(e){const t=e.length;if(t<2)return!0;const s=e[0];for(let i=1;i0){const l=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!s,this._isRangeSupported=!t,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((l,c)=>{this._onReceiveData({begin:l,chunk:c})}),e.addProgressListener((l,c)=>{this._onProgress({loaded:l,total:c})}),e.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:t}){const s=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;if(e===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(r){return r._begin!==e?!1:(r._enqueue(s),!0)});dn(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}_onProgress(e){var t,s,i,r;e.total===void 0?(s=(t=this._rangeReaders[0])==null?void 0:t.onProgress)==null||s.call(t,{loaded:e.loaded}):(r=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||r.call(i,{loaded:e.loaded,total:e.total})}_onProgressiveDone(){var e;(e=this._fullRequestReader)==null||e.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){dn(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new V8(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const s=new U8(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(s),s}cancelAllRequests(e){var t;(t=this._fullRequestReader)==null||t.cancel(e);for(const s of this._rangeReaders.slice(0))s.cancel(e);this._pdfDataRangeTransport.abort()}}class V8{constructor(e,t,s=!1,i=null){this._stream=e,this._done=s||!1,this._filename=bx(i)?i:null,this._queuedChunks=t||[],this._loaded=0;for(const r of this._queuedChunks)this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class U8{constructor(e,t,s){this._stream=e,this._begin=t,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length===0)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function W8(n){let e=!0,t=s("filename\\*","i").exec(n);if(t){t=t[1];let h=a(t);return h=unescape(h),h=l(h),h=c(h),r(h)}if(t=o(n),t){const h=c(t);return r(h)}if(t=s("filename","i").exec(n),t){t=t[1];let h=a(t);return h=c(h),r(h)}function s(h,u){return new RegExp("(?:^|;)\\s*"+h+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function i(h,u){if(h){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const d=new TextDecoder(h,{fatal:!0}),p=R0(u);u=d.decode(p),e=!1}catch{}}return u}function r(h){return e&&/[\x80-\xff]/.test(h)&&(h=i("utf-8",h),e&&(h=i("iso-8859-1",h))),h}function o(h){const u=[];let d;const p=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(d=p.exec(h))!==null;){let[,g,b,y]=d;if(g=parseInt(g,10),g in u){if(g===0)break;continue}u[g]=[b,y]}const m=[];for(let g=0;g{if(!XR(r.status))throw O0(r.status,i);this._reader=r.body.getReader(),this._headersCapability.resolve();const o=r.headers,{allowRangeRequests:a,suggestedLength:l}=kx({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=l||this._contentLength,this._filename=Ax(o),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new $c("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:JR(e),done:!1})}cancel(e){var t;(t=this._reader)==null||t.cancel(e),this._abortController.abort()}}class K8{constructor(e,t,s){this._stream=e,this._reader=null,this._loaded=0;const i=e.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;const r=new Headers(e.headers);r.append("Range",`bytes=${t}-${s-1}`);const o=i.url;fetch(o,YR(r,this._withCredentials,this._abortController)).then(a=>{if(!XR(a.status))throw O0(a.status,o);this._readCapability.resolve(),this._reader=a.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:JR(e),done:!1})}cancel(e){var t;(t=this._reader)==null||t.cancel(e),this._abortController.abort()}}const Sb=200,xb=206;function Z8(n){const e=n.response;return typeof e!="string"?e:R0(e).buffer}class X8{constructor({url:e,httpHeaders:t,withCredentials:s}){this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=xx(this.isHttp,t),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(e,t,s){const i={begin:e,end:t};for(const r in s)i[r]=s[r];return this.request(i)}requestFull(e){return this.request(e)}request(e){const t=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:t};t.open("GET",this.url),t.withCredentials=this.withCredentials;for(const[r,o]of this.headers)t.setRequestHeader(r,o);return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.expectedStatus=xb):i.expectedStatus=Sb,t.responseType="arraybuffer",e.onError&&(t.onerror=function(r){e.onError(t.status)}),t.onreadystatechange=this.onStateChange.bind(this,s),t.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=e.onHeadersReceived,i.onDone=e.onDone,i.onError=e.onError,i.onProgress=e.onProgress,t.send(null),s}onProgress(e,t){var i;const s=this.pendingRequests[e];s&&((i=s.onProgress)==null||i.call(s,t))}onStateChange(e,t){var l,c,h;const s=this.pendingRequests[e];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],i.status===0&&this.isHttp){(l=s.onError)==null||l.call(s,i.status);return}const r=i.status||Sb;if(!(r===Sb&&s.expectedStatus===xb)&&r!==s.expectedStatus){(c=s.onError)==null||c.call(s,i.status);return}const a=Z8(i);if(r===xb){const u=i.getResponseHeader("Content-Range"),d=/bytes (\d+)-(\d+)\/(\d+)/.exec(u);s.onDone({begin:parseInt(d[1],10),chunk:a})}else a?s.onDone({begin:0,chunk:a}):(h=s.onError)==null||h.call(s,i.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}class Y8{constructor(e){this._source=e,this._manager=new X8(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return dn(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new J8(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){const s=new Q8(this._manager,e,t);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(e){var t;(t=this._fullRequestReader)==null||t.cancel(e);for(const s of this._rangeRequestReaders.slice(0))s.cancel(e)}}class J8{constructor(e,t){this._manager=e;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._fullRequestId=e.requestFull(s),this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,t=this._manager.getRequestXhr(e),s=new Headers(t.getAllResponseHeaders().trim().split(/[\r\n]+/).map(o=>{const[a,...l]=o.split(": ");return[a,l.join(": ")]})),{allowRangeRequests:i,suggestedLength:r}=kx({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=Ax(s),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=O0(e,this._url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){var t;(t=this.onProgress)==null||t.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Q8{constructor(e,t,s){this._manager=e;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._requestId=e.requestRange(t,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var e;(e=this.onClosed)==null||e.call(this,this)}_onDone(e){const t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError=O0(e,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){var t;this.isStreamingSupported||(t=this.onProgress)==null||t.call(this,{loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const eZ=/^[a-z][a-z0-9\-+.]+:/i;function tZ(n){if(eZ.test(n))return new URL(n);const e=Ta.get("url");return new URL(e.pathToFileURL(n))}function QR(n,e,t){return n.protocol==="http:"?Ta.get("http").request(n,{headers:e},t):Ta.get("https").request(n,{headers:e},t)}class nZ{constructor(e){this.source=e,this.url=tZ(e.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.headers=xx(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}getFullReader(){return dn(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new rZ(this):new sZ(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const s=this.isFsUrl?new oZ(this,e,t):new iZ(this,e,t);return this._rangeRequestReaders.push(s),s}cancelAllRequests(e){var t;(t=this._fullRequestReader)==null||t.cancel(e);for(const s of this._rangeRequestReaders.slice(0))s.cancel(e)}}class eM{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new $c("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class tM{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const t=e.source;this._isStreamingSupported=!t.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}class sZ extends eM{constructor(e){super(e);const t=Object.fromEntries(e.headers),s=i=>{if(i.statusCode===404){const l=new Cc(`Missing PDF "${this._url}".`);this._storedError=l,this._headersCapability.reject(l);return}this._headersCapability.resolve(),this._setReadableStream(i);const r=new Headers(this._readableStream.headers),{allowRangeRequests:o,suggestedLength:a}=kx({responseHeaders:r,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=a||this._contentLength,this._filename=Ax(r)};this._request=QR(this._url,t,s),this._request.on("error",i=>{this._storedError=i,this._headersCapability.reject(i)}),this._request.end()}}class iZ extends tM{constructor(e,t,s){super(e);const i=Object.fromEntries(e.headers);i.Range=`bytes=${t}-${s-1}`;const r=o=>{if(o.statusCode===404){const a=new Cc(`Missing PDF "${this._url}".`);this._storedError=a;return}this._setReadableStream(o)};this._request=QR(this._url,i,r),this._request.on("error",o=>{this._storedError=o}),this._request.end()}}class rZ extends eM{constructor(e){super(e);const t=Ta.get("fs");t.promises.lstat(this._url).then(s=>{this._contentLength=s.size,this._setReadableStream(t.createReadStream(this._url)),this._headersCapability.resolve()},s=>{s.code==="ENOENT"&&(s=new Cc(`Missing PDF "${this._url}".`)),this._storedError=s,this._headersCapability.reject(s)})}}class oZ extends tM{constructor(e,t,s){super(e);const i=Ta.get("fs");this._setReadableStream(i.createReadStream(this._url,{start:t,end:s-1}))}}const aZ=1e5,xs=30,lZ=.8;var DC,na,Es,Wf,Gf,Pl,Xr,Kf,Zf,Rl,Oh,Nh,sa,Lh,Xf,Dh,Ml,Yf,Jf,Ht,Il,Ol,Qf,ia,jh,Co,nM,sM,mw,ei,bg,gw,iM,rM;let pw=(Ht=class{constructor({textContentSource:e,container:t,viewport:s}){M(this,Co);M(this,na,Promise.withResolvers());M(this,Es,null);M(this,Wf,!1);M(this,Gf,!!((DC=globalThis.FontInspector)!=null&&DC.enabled));M(this,Pl,null);M(this,Xr,null);M(this,Kf,0);M(this,Zf,0);M(this,Rl,null);M(this,Oh,null);M(this,Nh,0);M(this,sa,0);M(this,Lh,Object.create(null));M(this,Xf,[]);M(this,Dh,null);M(this,Ml,[]);M(this,Yf,new WeakMap);M(this,Jf,null);var l;if(e instanceof ReadableStream)$(this,Dh,e);else if(typeof e=="object")$(this,Dh,new ReadableStream({start(c){c.enqueue(e),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');$(this,Es,$(this,Oh,t)),$(this,sa,s.scale*(globalThis.devicePixelRatio||1)),$(this,Nh,s.rotation),$(this,Xr,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:r,pageX:o,pageY:a}=s.rawDims;$(this,Jf,[1,0,0,-1,-o,a+r]),$(this,Zf,i),$(this,Kf,r),P(l=Ht,ei,iM).call(l),pc(t,s),f(this,na).promise.finally(()=>{f(Ht,jh).delete(this),$(this,Xr,null),$(this,Lh,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:e,isFirefox:t}=fs.platform;return Ge(this,"fontFamilyMap",new Map([["sans-serif",`${e&&t?"Calibri, ":""}sans-serif`],["monospace",`${e&&t?"Lucida Console, ":""}monospace`]]))}render(){const e=()=>{f(this,Rl).read().then(({value:t,done:s})=>{if(s){f(this,na).resolve();return}f(this,Pl)??$(this,Pl,t.lang),Object.assign(f(this,Lh),t.styles),P(this,Co,nM).call(this,t.items),e()},f(this,na).reject)};return $(this,Rl,f(this,Dh).getReader()),f(Ht,jh).add(this),e(),f(this,na).promise}update({viewport:e,onBefore:t=null}){var r;const s=e.scale*(globalThis.devicePixelRatio||1),i=e.rotation;if(i!==f(this,Nh)&&(t==null||t(),$(this,Nh,i),pc(f(this,Oh),{rotation:i})),s!==f(this,sa)){t==null||t(),$(this,sa,s);const o={div:null,properties:null,ctx:P(r=Ht,ei,bg).call(r,f(this,Pl))};for(const a of f(this,Ml))o.properties=f(this,Yf).get(a),o.div=a,P(this,Co,mw).call(this,o)}}cancel(){var t;const e=new $c("TextLayer task cancelled.");(t=f(this,Rl))==null||t.cancel(e).catch(()=>{}),$(this,Rl,null),f(this,na).reject(e)}get textDivs(){return f(this,Ml)}get textContentItemsStr(){return f(this,Xf)}static cleanup(){if(!(f(this,jh).size>0)){f(this,Il).clear();for(const{canvas:e}of f(this,Ol).values())e.remove();f(this,Ol).clear()}}},na=new WeakMap,Es=new WeakMap,Wf=new WeakMap,Gf=new WeakMap,Pl=new WeakMap,Xr=new WeakMap,Kf=new WeakMap,Zf=new WeakMap,Rl=new WeakMap,Oh=new WeakMap,Nh=new WeakMap,sa=new WeakMap,Lh=new WeakMap,Xf=new WeakMap,Dh=new WeakMap,Ml=new WeakMap,Yf=new WeakMap,Jf=new WeakMap,Il=new WeakMap,Ol=new WeakMap,Qf=new WeakMap,ia=new WeakMap,jh=new WeakMap,Co=new WeakSet,nM=function(e){var i,r;if(f(this,Wf))return;(r=f(this,Xr)).ctx??(r.ctx=P(i=Ht,ei,bg).call(i,f(this,Pl)));const t=f(this,Ml),s=f(this,Xf);for(const o of e){if(t.length>aZ){He("Ignoring additional textDivs for performance reasons."),$(this,Wf,!0);return}if(o.str===void 0){if(o.type==="beginMarkedContentProps"||o.type==="beginMarkedContent"){const a=f(this,Es);$(this,Es,document.createElement("span")),f(this,Es).classList.add("markedContent"),o.id!==null&&f(this,Es).setAttribute("id",`${o.id}`),a.append(f(this,Es))}else o.type==="endMarkedContent"&&$(this,Es,f(this,Es).parentNode);continue}s.push(o.str),P(this,Co,sM).call(this,o)}},sM=function(e){var g;const t=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};f(this,Ml).push(t);const i=Se.transform(f(this,Jf),e.transform);let r=Math.atan2(i[1],i[0]);const o=f(this,Lh)[e.fontName];o.vertical&&(r+=Math.PI/2);let a=f(this,Gf)&&o.fontSubstitution||o.fontFamily;a=Ht.fontFamilyMap.get(a)||a;const l=Math.hypot(i[2],i[3]),c=l*P(g=Ht,ei,rM).call(g,a,f(this,Pl));let h,u;r===0?(h=i[4],u=i[5]-c):(h=i[4]+c*Math.sin(r),u=i[5]-c*Math.cos(r));const d="calc(var(--scale-factor)*",p=t.style;f(this,Es)===f(this,Oh)?(p.left=`${(100*h/f(this,Zf)).toFixed(2)}%`,p.top=`${(100*u/f(this,Kf)).toFixed(2)}%`):(p.left=`${d}${h.toFixed(2)}px)`,p.top=`${d}${u.toFixed(2)}px)`),p.fontSize=`${d}${(f(Ht,ia)*l).toFixed(2)}px)`,p.fontFamily=a,s.fontSize=l,t.setAttribute("role","presentation"),t.textContent=e.str,t.dir=e.dir,f(this,Gf)&&(t.dataset.fontName=o.fontSubstitutionLoadedName||e.fontName),r!==0&&(s.angle=r*(180/Math.PI));let m=!1;if(e.str.length>1)m=!0;else if(e.str!==" "&&e.transform[0]!==e.transform[3]){const b=Math.abs(e.transform[0]),y=Math.abs(e.transform[3]);b!==y&&Math.max(b,y)/Math.min(b,y)>1.5&&(m=!0)}if(m&&(s.canvasWidth=o.vertical?e.height:e.width),f(this,Yf).set(t,s),f(this,Xr).div=t,f(this,Xr).properties=s,P(this,Co,mw).call(this,f(this,Xr)),s.hasText&&f(this,Es).append(t),s.hasEOL){const b=document.createElement("br");b.setAttribute("role","presentation"),f(this,Es).append(b)}},mw=function(e){var a;const{div:t,properties:s,ctx:i}=e,{style:r}=t;let o="";if(f(Ht,ia)>1&&(o=`scale(${1/f(Ht,ia)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=r,{canvasWidth:c,fontSize:h}=s;P(a=Ht,ei,gw).call(a,i,h*f(this,sa),l);const{width:u}=i.measureText(t.textContent);u>0&&(o=`scaleX(${c*f(this,sa)/u}) ${o}`)}s.angle!==0&&(o=`rotate(${s.angle}deg) ${o}`),o.length>0&&(r.transform=o)},ei=new WeakSet,bg=function(e=null){let t=f(this,Ol).get(e||(e=""));if(!t){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=e,document.body.append(s),t=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),f(this,Ol).set(e,t),f(this,Qf).set(t,{size:0,family:""})}return t},gw=function(e,t,s){const i=f(this,Qf).get(e);t===i.size&&s===i.family||(e.font=`${t}px ${s}`,i.size=t,i.family=s)},iM=function(){if(f(this,ia)!==null)return;const e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),$(this,ia,e.getBoundingClientRect().height),e.remove()},rM=function(e,t){const s=f(this,Il).get(e);if(s)return s;const i=P(this,ei,bg).call(this,t);i.canvas.width=i.canvas.height=xs,P(this,ei,gw).call(this,i,xs,e);const r=i.measureText("");let o=r.fontBoundingBoxAscent,a=Math.abs(r.fontBoundingBoxDescent);if(o){const h=o/(o+a);return f(this,Il).set(e,h),i.canvas.width=i.canvas.height=0,h}i.strokeStyle="red",i.clearRect(0,0,xs,xs),i.strokeText("g",0,0);let l=i.getImageData(0,0,xs,xs).data;a=0;for(let h=l.length-1-3;h>=0;h-=4)if(l[h]>0){a=Math.ceil(h/4/xs);break}i.clearRect(0,0,xs,xs),i.strokeText("A",0,xs),l=i.getImageData(0,0,xs,xs).data,o=0;for(let h=0,u=l.length;h0){o=xs-Math.floor(h/4/xs);break}i.canvas.width=i.canvas.height=0;const c=o?o/(o+a):lZ;return f(this,Il).set(e,c),c},M(Ht,ei),M(Ht,Il,new Map),M(Ht,Ol,new Map),M(Ht,Qf,new WeakMap),M(Ht,ia,null),M(Ht,jh,new Set),Ht);class af{static textContent(e){const t=[],s={items:t,styles:Object.create(null)};function i(r){var l;if(!r)return;let o=null;const a=r.name;if(a==="#text")o=r.value;else if(af.shouldBuildText(a))(l=r==null?void 0:r.attributes)!=null&&l.textContent?o=r.attributes.textContent:r.value&&(o=r.value);else return;if(o!==null&&t.push({str:o}),!!r.children)for(const c of r.children)i(c)}return i(e),s}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}}const cZ=65536,hZ=100,uZ=5e3,dZ=is?k8:_8,fZ=is?A8:HR,pZ=is?x8:S8,mZ=is?E8:UR;function gZ(n={}){typeof n=="string"||n instanceof URL?n={url:n}:(n instanceof ArrayBuffer||ArrayBuffer.isView(n))&&(n={data:n});const e=new yw,{docId:t}=e,s=n.url?yZ(n.url):null,i=n.data?bZ(n.data):null,r=n.httpHeaders||null,o=n.withCredentials===!0,a=n.password??null,l=n.range instanceof oM?n.range:null,c=Number.isInteger(n.rangeChunkSize)&&n.rangeChunkSize>0?n.rangeChunkSize:cZ;let h=n.worker instanceof lh?n.worker:null;const u=n.verbosity,d=typeof n.docBaseUrl=="string"&&!I0(n.docBaseUrl)?n.docBaseUrl:null,p=typeof n.cMapUrl=="string"?n.cMapUrl:null,m=n.cMapPacked!==!1,g=n.CMapReaderFactory||fZ,b=typeof n.standardFontDataUrl=="string"?n.standardFontDataUrl:null,y=n.StandardFontDataFactory||mZ,w=n.stopAtErrors!==!0,v=Number.isInteger(n.maxImageSize)&&n.maxImageSize>-1?n.maxImageSize:-1,x=n.isEvalSupported!==!1,k=typeof n.isOffscreenCanvasSupported=="boolean"?n.isOffscreenCanvasSupported:!is,E=typeof n.isChrome=="boolean"?n.isChrome:!fs.platform.isFirefox&&typeof window<"u"&&!!(window!=null&&window.chrome),T=Number.isInteger(n.canvasMaxAreaInBytes)?n.canvasMaxAreaInBytes:-1,O=typeof n.disableFontFace=="boolean"?n.disableFontFace:is,F=n.fontExtraProperties===!0,j=n.enableXfa===!0,L=n.ownerDocument||globalThis.document,B=n.disableRange===!0,Z=n.disableStream===!0,q=n.disableAutoFetch===!0,H=n.pdfBug===!0,se=n.CanvasFactory||dZ,Q=n.FilterFactory||pZ,Y=n.enableHWA===!0,ye=l?l.length:n.length??NaN,z=typeof n.useSystemFonts=="boolean"?n.useSystemFonts:!is&&!O,C=typeof n.useWorkerFetch=="boolean"?n.useWorkerFetch:g===HR&&y===UR&&p&&b&&dd(p,document.baseURI)&&dd(b,document.baseURI);n.canvasFactory&&FA("`canvasFactory`-instance option, please use `CanvasFactory` instead."),n.filterFactory&&FA("`filterFactory`-instance option, please use `FilterFactory` instead.");const I=null;J6(u);const R={canvasFactory:new se({ownerDocument:L,enableHWA:Y}),filterFactory:new Q({docId:t,ownerDocument:L}),cMapReaderFactory:C?null:new g({baseUrl:p,isCompressed:m}),standardFontDataFactory:C?null:new y({baseUrl:b})};if(!h){const N={verbosity:u,port:mo.workerPort};h=N.port?lh.fromPort(N):new lh(N),e._worker=h}const _={docId:t,apiVersion:"4.8.69",data:i,password:a,disableAutoFetch:q,rangeChunkSize:c,length:ye,docBaseUrl:d,enableXfa:j,evaluatorOptions:{maxImageSize:v,disableFontFace:O,ignoreErrors:w,isEvalSupported:x,isOffscreenCanvasSupported:k,isChrome:E,canvasMaxAreaInBytes:T,fontExtraProperties:F,useSystemFonts:z,cMapUrl:C?p:null,standardFontDataUrl:C?b:null}},A={disableFontFace:O,fontExtraProperties:F,ownerDocument:L,pdfBug:H,styleElement:I,loadingParams:{disableAutoFetch:q,enableXfa:j}};return h.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const N=h.messageHandler.sendWithPromise("GetDocRequest",_,i?[i.buffer]:null);let W;if(l)W=new q8(l,{disableRange:B,disableStream:Z});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let X;is?X=typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&dd(s)?YA:nZ:X=dd(s)?YA:Y8,W=new X({url:s,length:ye,httpHeaders:r,withCredentials:o,rangeChunkSize:c,disableRange:B,disableStream:Z})}return N.then(X=>{if(e.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const he=new vd(t,X,h.port),ie=new SZ(he,e,W,A,R);e._transport=ie,he.send("Ready",null)})}).catch(e._capability.reject),e}function yZ(n){if(n instanceof URL)return n.href;try{return new URL(n,window.location).href}catch{if(is&&typeof n=="string")return n}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function bZ(n){if(is&&typeof Buffer<"u"&&n instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength)return n;if(typeof n=="string")return R0(n);if(n instanceof ArrayBuffer||ArrayBuffer.isView(n)||typeof n=="object"&&!isNaN(n==null?void 0:n.length))return new Uint8Array(n);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function JA(n){return typeof n=="object"&&Number.isInteger(n==null?void 0:n.num)&&n.num>=0&&Number.isInteger(n==null?void 0:n.gen)&&n.gen>=0}var Ky;const Zy=class Zy{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${os(Zy,Ky)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var e,t,s;this.destroyed=!0;try{(e=this._worker)!=null&&e.port&&(this._worker._pendingDestroy=!0),await((t=this._transport)==null?void 0:t.destroy())}catch(i){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,i}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};Ky=new WeakMap,M(Zy,Ky,0);let yw=Zy,oM=class{constructor(e,t,s=!1,i=null){this.length=e,this.initialData=t,this.progressiveDone=s,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(const s of this._rangeListeners)s(e,t)}onDataProgress(e,t){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(e,t)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(const t of this._progressiveReadListeners)t(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){Et("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class vZ{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Ge(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var ra,Yr,pi,Vc,vg;class wZ{constructor(e,t,s,i=!1){M(this,pi);M(this,ra,null);M(this,Yr,!1);this._pageIndex=e,this._pageInfo=t,this._transport=s,this._stats=i?new jA:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new aM,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new Jp({viewBox:this.view,scale:e,rotation:t,offsetX:s,offsetY:i,dontFlip:r})}getAnnotations({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Ge(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var e;return((e=this._transport._htmlForXfa)==null?void 0:e.children[this._pageIndex])||null}render({canvasContext:e,viewport:t,intent:s="display",annotationMode:i=Ho.ENABLE,transform:r=null,background:o=null,optionalContentConfigPromise:a=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:h=null,isEditing:u=!1}){var x,k;(x=this._stats)==null||x.time("Overall");const d=this._transport.getRenderingIntent(s,i,h,u),{renderingIntent:p,cacheKey:m}=d;$(this,Yr,!1),P(this,pi,vg).call(this),a||(a=this._transport.getOptionalContentConfig(p));let g=this._intentStates.get(m);g||(g=Object.create(null),this._intentStates.set(m,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const b=!!(p&Xs.PRINT);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(k=this._stats)==null||k.time("Page Request"),this._pumpOperatorList(d));const y=E=>{var T;g.renderTasks.delete(w),(this._maybeCleanupAfterRender||b)&&$(this,Yr,!0),P(this,pi,Vc).call(this,!b),E?(w.capability.reject(E),this._abortOperatorList({intentState:g,reason:E instanceof Error?E:new Error(E)})):w.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(T=globalThis.Stats)!=null&&T.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},w=new vw({callback:y,params:{canvasContext:e,viewport:t,transform:r,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!b,pdfBug:this._pdfBug,pageColors:c});(g.renderTasks||(g.renderTasks=new Set)).add(w);const v=w.task;return Promise.all([g.displayReadyCapability.promise,a]).then(([E,T])=>{var O;if(this.destroyed){y();return}if((O=this._stats)==null||O.time("Rendering"),!(T.renderingIntent&p))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");w.initializeGraphics({transparency:E,optionalContentConfig:T}),w.operatorListChanged()}).catch(y),v}getOperatorList({intent:e="display",annotationMode:t=Ho.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var c;function r(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(l))}const o=this._transport.getRenderingIntent(e,t,s,i,!0);let a=this._intentStates.get(o.cacheKey);a||(a=Object.create(null),this._intentStates.set(o.cacheKey,a));let l;return a.opListReadCapability||(l=Object.create(null),l.operatorListChanged=r,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||(a.renderTasks=new Set)).add(l),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(o)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:t===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>af.textContent(s));const t=this.streamTextContent(e);return new Promise(function(s,i){function r(){o.read().then(function({value:l,done:c}){if(c){s(a);return}a.lang??(a.lang=l.lang),Object.assign(a.styles,l.styles),a.items.push(...l.items),r()},i)}const o=t.getReader(),a={items:[],styles:Object.create(null),lang:null};r()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(const s of t.renderTasks)e.push(s.completed),s.cancel();return this.objs.clear(),$(this,Yr,!1),P(this,pi,vg).call(this),Promise.all(e)}cleanup(e=!1){$(this,Yr,!0);const t=P(this,pi,Vc).call(this,!1);return e&&t&&this._stats&&(this._stats=new jA),t}_startRenderPage(e,t){var i,r;const s=this._intentStates.get(t);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(e))}_renderPageChunk(e,t){for(let s=0,i=e.length;s{l.read().then(({value:u,done:d})=>{if(d){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,c),h())},u=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const d of c.renderTasks)d.operatorListChanged();P(this,pi,Vc).call(this,!0)}if(c.displayReadyCapability)c.displayReadyCapability.reject(u);else if(c.opListReadCapability)c.opListReadCapability.reject(u);else throw u}})};h()}_abortOperatorList({intentState:e,reason:t,force:s=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!s){if(e.renderTasks.size>0)return;if(t instanceof yx){let i=hZ;t.extraDelay>0&&t.extraDelay<1e3&&(i+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},i);return}}if(e.streamReader.cancel(new $c(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===e){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}ra=new WeakMap,Yr=new WeakMap,pi=new WeakSet,Vc=function(e=!1){if(P(this,pi,vg).call(this),!f(this,Yr)||this.destroyed)return!1;if(e)return $(this,ra,setTimeout(()=>{$(this,ra,null),P(this,pi,Vc).call(this,!1)},uZ)),!1;for(const{renderTasks:t,operatorList:s}of this._intentStates.values())if(t.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),$(this,Yr,!1),!0},vg=function(){f(this,ra)&&(clearTimeout(f(this,ra)),$(this,ra,null))};var Jr,Xy;class _Z{constructor(){M(this,Jr,new Map);M(this,Xy,Promise.resolve())}postMessage(e,t){const s={data:structuredClone(e,t?{transfer:t}:null)};f(this,Xy).then(()=>{for(const[i]of f(this,Jr))i.call(this,s)})}addEventListener(e,t,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){He("LoopbackPort - cannot use an `aborted` signal.");return}const o=()=>this.removeEventListener(e,t);i=()=>r.removeEventListener("abort",o),r.addEventListener("abort",o)}f(this,Jr).set(t,i)}removeEventListener(e,t){const s=f(this,Jr).get(t);s==null||s(),f(this,Jr).delete(t)}terminate(){for(const[,e]of f(this,Jr))e==null||e();f(this,Jr).clear()}}Jr=new WeakMap,Xy=new WeakMap;var Yy,Nl,Ll,Fh,wg,zh,_g;const Tt=class Tt{constructor({name:e=null,port:t=null,verbosity:s=Q6()}={}){M(this,Fh);var i;if(this.name=e,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,t){if((i=f(Tt,Ll))!=null&&i.has(t))throw new Error("Cannot use more than one PDFWorker per port.");(f(Tt,Ll)||$(Tt,Ll,new WeakMap)).set(t,this),this._initializeFromPort(t);return}this._initialize()}get promise(){return is?Promise.all([Ta.promise,this._readyCapability.promise]):this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new vd("main","worker",e),this._messageHandler.on("ready",function(){}),P(this,Fh,wg).call(this)}_initialize(){if(f(Tt,Nl)||f(Tt,zh,_g)){this._setupFakeWorker();return}let{workerSrc:e}=Tt;try{Tt._isSameOrigin(window.location.href,e)||(e=Tt._createCDNWrapper(new URL(e,window.location).href));const t=new Worker(e,{type:"module"}),s=new vd("main","worker",t),i=()=>{r.abort(),s.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;t.addEventListener("error",()=>{this._webWorker||i()},{signal:r.signal}),s.on("test",a=>{if(r.abort(),this.destroyed||!a){i();return}this._messageHandler=s,this._port=t,this._webWorker=t,P(this,Fh,wg).call(this)}),s.on("ready",a=>{if(r.abort(),this.destroyed){i();return}try{o()}catch{this._setupFakeWorker()}});const o=()=>{const a=new Uint8Array;s.send("test",a,[a.buffer])};o();return}catch{T0("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){f(Tt,Nl)||(He("Setting up fake worker."),$(Tt,Nl,!0)),Tt._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const t=new _Z;this._port=t;const s=`fake${os(Tt,Yy)._++}`,i=new vd(s+"_worker",s,t);e.setup(i,t),this._messageHandler=new vd(s,s+"_worker",t),P(this,Fh,wg).call(this)}).catch(e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){var e;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(e=f(Tt,Ll))==null||e.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(e){var s;if(!(e!=null&&e.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const t=(s=f(this,Ll))==null?void 0:s.get(e.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new Tt(e)}static get workerSrc(){if(mo.workerSrc)return mo.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return Ge(this,"_setupFakeWorkerGlobal",(async()=>f(this,zh,_g)?f(this,zh,_g):(await import(this.workerSrc)).WorkerMessageHandler)())}};Yy=new WeakMap,Nl=new WeakMap,Ll=new WeakMap,Fh=new WeakSet,wg=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},zh=new WeakSet,_g=function(){var e;try{return((e=globalThis.pdfjsWorker)==null?void 0:e.WorkerMessageHandler)||null}catch{return null}},M(Tt,zh),M(Tt,Yy,0),M(Tt,Nl,!1),M(Tt,Ll),is&&($(Tt,Nl,!0),mo.workerSrc||(mo.workerSrc="./pdf.worker.mjs")),Tt._isSameOrigin=(e,t)=>{let s;try{if(s=new URL(e),!s.origin||s.origin==="null")return!1}catch{return!1}const i=new URL(t,s);return s.origin===i.origin},Tt._createCDNWrapper=e=>{const t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};let lh=Tt;var Qr,mr,Hh,Bh,gr,Dl,wd;class SZ{constructor(e,t,s,i,r){M(this,Dl);M(this,Qr,new Map);M(this,mr,new Map);M(this,Hh,new Map);M(this,Bh,new Map);M(this,gr,null);this.messageHandler=e,this.loadingTask=t,this.commonObjs=new aM,this.fontLoader=new v8({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return Ge(this,"annotationStorage",new _x)}getRenderingIntent(e,t=Ho.ENABLE,s=null,i=!1,r=!1){let o=Xs.DISPLAY,a=rw;switch(e){case"any":o=Xs.ANY;break;case"display":break;case"print":o=Xs.PRINT;break;default:He(`getRenderingIntent - invalid intent: ${e}`)}const l=o&Xs.PRINT&&s instanceof jR?s:this.annotationStorage;switch(t){case Ho.DISABLE:o+=Xs.ANNOTATIONS_DISABLE;break;case Ho.ENABLE:break;case Ho.ENABLE_FORMS:o+=Xs.ANNOTATIONS_FORMS;break;case Ho.ENABLE_STORAGE:o+=Xs.ANNOTATIONS_STORAGE,a=l.serializable;break;default:He(`getRenderingIntent - invalid annotationMode: ${t}`)}i&&(o+=Xs.IS_EDITING),r&&(o+=Xs.OPLIST);const{ids:c,hash:h}=l.modifiedIds,u=[o,a.hash,h];return{renderingIntent:o,cacheKey:u.join("_"),annotationStorageSerializable:a,modifiedIds:c}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=f(this,gr))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const i of f(this,mr).values())e.push(i._destroy());f(this,mr).clear(),f(this,Hh).clear(),f(this,Bh).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then(()=>{var i;this.commonObjs.clear(),this.fontLoader.clear(),f(this,Qr).clear(),this.filterFactory.destroy(),pw.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new $c("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(s,i)=>{dn(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},i.onPull=()=>{this._fullReader.read().then(function({value:r,done:o}){if(o){i.close();return}dn(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{this._fullReader.cancel(r),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),e.on("ReaderHeadersReady",async s=>{var a;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:o}=this._fullReader;return(!i||!r)&&(this._lastProgress&&((a=t.onProgress)==null||a.call(t,this._lastProgress)),this._fullReader.onProgress=l=>{var c;(c=t.onProgress)==null||c.call(t,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:i,isRangeSupported:r,contentLength:o}}),e.on("GetRangeReader",(s,i)=>{dn(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const r=this._networkStream.getRangeReader(s.begin,s.end);if(!r){i.close();return}i.onPull=()=>{r.read().then(function({value:o,done:a}){if(a){i.close();return}dn(o instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(o),1,[o])}).catch(o=>{i.error(o)})},i.onCancel=o=>{r.cancel(o),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),e.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,t._capability.resolve(new vZ(s,this))}),e.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new Dv(s.message,s.code);break;case"InvalidPDFException":i=new hR(s.message);break;case"MissingPDFException":i=new Cc(s.message);break;case"UnexpectedResponseException":i=new P0(s.message,s.status);break;case"UnknownErrorException":i=new jv(s.message,s.details);break;default:Et("DocException - expected a valid Error.")}t._capability.reject(i)}),e.on("PasswordRequest",s=>{if($(this,gr,Promise.withResolvers()),t.onPassword){const i=r=>{r instanceof Error?f(this,gr).reject(r):f(this,gr).resolve({password:r})};try{t.onPassword(i,s.code)}catch(r){f(this,gr).reject(r)}}else f(this,gr).reject(new Dv(s.message,s.code));return f(this,gr).promise}),e.on("DataLoaded",s=>{var i;(i=t.onProgress)==null||i.call(t,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),e.on("StartRenderPage",s=>{if(this.destroyed)return;f(this,mr).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),e.on("commonobj",([s,i,r])=>{var o;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:a,fontExtraProperties:l,pdfBug:c}=this._params;if("error"in r){const p=r.error;He(`Error during font loading: ${p}`),this.commonObjs.resolve(s,p);break}const h=c&&((o=globalThis.FontInspector)!=null&&o.enabled)?(p,m)=>globalThis.FontInspector.fontAdded(p,m):null,u=new w8(r,{disableFontFace:a,inspectFont:h});this.fontLoader.bind(u).catch(()=>e.sendWithPromise("FontFallback",{id:s})).finally(()=>{!l&&u.data&&(u.data=null),this.commonObjs.resolve(s,u)});break;case"CopyLocalImage":const{imageRef:d}=r;dn(d,"The imageRef must be defined.");for(const p of f(this,mr).values())for(const[,m]of p.objs)if((m==null?void 0:m.ref)===d)return m.dataLen?(this.commonObjs.resolve(s,structuredClone(m)),m.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,r);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),e.on("obj",([s,i,r,o])=>{var l;if(this.destroyed)return;const a=f(this,mr).get(i);if(!a.objs.has(s)){if(a._intentStates.size===0){(l=o==null?void 0:o.bitmap)==null||l.close();return}switch(r){case"Image":a.objs.resolve(s,o),(o==null?void 0:o.dataLen)>K6&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(s,o);break;default:throw new Error(`Got unknown object type ${r}`)}}}),e.on("DocProgress",s=>{var i;this.destroyed||(i=t.onProgress)==null||i.call(t,{loaded:s.loaded,total:s.total})}),e.on("FetchBuiltInCMap",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(s)}),e.on("FetchStandardFontData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&He("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:((s=this._fullReader)==null?void 0:s.filename)??null},t).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const t=e-1,s=f(this,Hh).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&f(this,Bh).set(r.refStr,e);const o=new wZ(t,r,this,this._params.pdfBug);return f(this,mr).set(t,o),o});return f(this,Hh).set(t,i),i}getPageIndex(e){return JA(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return P(this,Dl,wd).call(this,"GetFieldObjects")}hasJSActions(){return P(this,Dl,wd).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return typeof e!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return P(this,Dl,wd).call(this,"GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return P(this,Dl,wd).call(this,"GetOptionalContentConfig").then(t=>new B8(t,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",t=f(this,Qr).get(e);if(t)return t;const s=this.messageHandler.sendWithPromise(e,null).then(i=>{var r,o;return{info:i[0],metadata:i[1]?new z8(i[1]):null,contentDispositionFilename:((r=this._fullReader)==null?void 0:r.filename)??null,contentLength:((o=this._fullReader)==null?void 0:o.contentLength)??null}});return f(this,Qr).set(e,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of f(this,mr).values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),f(this,Qr).clear(),this.filterFactory.destroy(!0),pw.cleanup()}}cachedPageNumber(e){if(!JA(e))return null;const t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return f(this,Bh).get(t)??null}}Qr=new WeakMap,mr=new WeakMap,Hh=new WeakMap,Bh=new WeakMap,gr=new WeakMap,Dl=new WeakSet,wd=function(e,t=null){const s=f(this,Qr).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise(e,t);return f(this,Qr).set(e,i),i};const Pm=Symbol("INITIAL_DATA");var Ni,ep,bw;class aM{constructor(){M(this,ep);M(this,Ni,Object.create(null))}get(e,t=null){if(t){const i=P(this,ep,bw).call(this,e);return i.promise.then(()=>t(i.data)),null}const s=f(this,Ni)[e];if(!s||s.data===Pm)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return s.data}has(e){const t=f(this,Ni)[e];return!!t&&t.data!==Pm}resolve(e,t=null){const s=P(this,ep,bw).call(this,e);s.data=t,s.resolve()}clear(){var e;for(const t in f(this,Ni)){const{data:s}=f(this,Ni)[t];(e=s==null?void 0:s.bitmap)==null||e.close()}$(this,Ni,Object.create(null))}*[Symbol.iterator](){for(const e in f(this,Ni)){const{data:t}=f(this,Ni)[e];t!==Pm&&(yield[e,t])}}}Ni=new WeakMap,ep=new WeakSet,bw=function(e){var t;return(t=f(this,Ni))[e]||(t[e]={...Promise.withResolvers(),data:Pm})};var oa;class xZ{constructor(e){M(this,oa,null);$(this,oa,e),this.onContinue=null}get promise(){return f(this,oa).capability.promise}cancel(e=0){f(this,oa).cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=f(this,oa).operatorList;if(!e)return!1;const{annotationCanvasMap:t}=f(this,oa);return e.form||e.canvas&&(t==null?void 0:t.size)>0}}oa=new WeakMap;var aa,jl;const al=class al{constructor({callback:e,params:t,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:o,pageIndex:a,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:u=!1,pageColors:d=null}){M(this,aa,null);this.callback=e,this.params=t,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=a,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new xZ(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){var a,l;if(this.cancelled)return;if(this._canvas){if(f(al,jl).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");f(al,jl).add(this._canvas)}this._pdfBug&&((a=globalThis.StepperManager)!=null&&a.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:r,background:o}=this.params;this.gfx=new ah(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:r,viewport:i,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,(l=this.graphicsReadyCallback)==null||l.call(this)}cancel(e=null,t=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),f(this,aa)&&(window.cancelAnimationFrame(f(this,aa)),$(this,aa,null)),f(al,jl).delete(this._canvas),this.callback(e||new yx(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){var e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(e=this.stepper)==null||e.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?$(this,aa,window.requestAnimationFrame(()=>{$(this,aa,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),f(al,jl).delete(this._canvas),this.callback())))}};aa=new WeakMap,jl=new WeakMap,M(al,jl,new WeakSet);let vw=al;const kZ="4.8.69",AZ="3634dab10";function QA(n){return Math.floor(Math.max(0,Math.min(1,n))*255).toString(16).padStart(2,"0")}function ed(n){return Math.max(0,Math.min(255,255*n))}class eE{static CMYK_G([e,t,s,i]){return["G",1-Math.min(1,.3*e+.59*s+.11*t+i)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return e=ed(e),[e,e,e]}static G_HTML([e]){const t=QA(e);return`#${t}${t}${t}`}static RGB_G([e,t,s]){return["G",.3*e+.59*t+.11*s]}static RGB_rgb(e){return e.map(ed)}static RGB_HTML(e){return`#${e.map(QA).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,s,i]){return["RGB",1-Math.min(1,e+i),1-Math.min(1,s+i),1-Math.min(1,t+i)]}static CMYK_rgb([e,t,s,i]){return[ed(1-Math.min(1,e+i)),ed(1-Math.min(1,s+i)),ed(1-Math.min(1,t+i))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,s]){const i=1-e,r=1-t,o=1-s,a=Math.min(i,r,o);return["CMYK",i,r,o,a]}}class EZ{create(e,t,s=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${e}px`),i.setAttribute("height",`${t}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${e} ${t}`),i}createElement(e){if(typeof e!="string")throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){Et("Abstract method `_createSVG` called.")}}class Ex extends EZ{_createSVG(e){return document.createElementNS(Hr,e)}}class lM{static setupStorage(e,t,s,i,r){const o=i.getValue(t,{value:null});switch(s.name){case"textarea":if(o.value!==null&&(e.textContent=o.value),r==="print")break;e.addEventListener("input",a=>{i.setValue(t,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(o.value===s.attributes.xfaOn?e.setAttribute("checked",!0):o.value===s.attributes.xfaOff&&e.removeAttribute("checked"),r==="print")break;e.addEventListener("change",a=>{i.setValue(t,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(o.value!==null&&e.setAttribute("value",o.value),r==="print")break;e.addEventListener("input",a=>{i.setValue(t,{value:a.target.value})})}break;case"select":if(o.value!==null){e.setAttribute("value",o.value);for(const a of s.children)a.attributes.value===o.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}e.addEventListener("input",a=>{const l=a.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(t,{value:c})});break}}static setAttributes({html:e,element:t,storage:s=null,intent:i,linkService:r}){const{attributes:o}=t,a=e instanceof HTMLAnchorElement;o.type==="radio"&&(o.name=`${o.name}-${i}`);for(const[l,c]of Object.entries(o))if(c!=null)switch(l){case"class":c.length&&e.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",c);break;case"style":Object.assign(e.style,c);break;case"textContent":e.textContent=c;break;default:(!a||l!=="href"&&l!=="newWindow")&&e.setAttribute(l,c)}a&&r.addLinkAttributes(e,o.href,o.newWindow),s&&o.dataId&&this.setupStorage(e,o.dataId,t,s)}static render(e){var u,d;const t=e.annotationStorage,s=e.linkService,i=e.xfaHtml,r=e.intent||"display",o=document.createElement(i.name);i.attributes&&this.setAttributes({html:o,element:i,intent:r,linkService:s});const a=r!=="richText",l=e.div;if(l.append(o),e.viewport){const p=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=p}a&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const p=document.createTextNode(i.value);o.append(p),a&&af.shouldBuildText(i.name)&&c.push(p)}return{textDivs:c}}const h=[[i,-1,o]];for(;h.length>0;){const[p,m,g]=h.at(-1);if(m+1===p.children.length){h.pop();continue}const b=p.children[++h.at(-1)[1]];if(b===null)continue;const{name:y}=b;if(y==="#text"){const v=document.createTextNode(b.value);c.push(v),g.append(v);continue}const w=(u=b==null?void 0:b.attributes)!=null&&u.xmlns?document.createElementNS(b.attributes.xmlns,y):document.createElement(y);if(g.append(w),b.attributes&&this.setAttributes({html:w,element:b,storage:t,intent:r,linkService:s}),((d=b.children)==null?void 0:d.length)>0)h.push([b,-1,w]);else if(b.value){const v=document.createTextNode(b.value);a&&af.shouldBuildText(y)&&c.push(v),w.append(v)}}for(const p of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))p.setAttribute("readOnly",!0);return{textDivs:c}}static update(e){const t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}}const em=1e3,CZ=9,gc=new WeakSet;function So(n){return{width:n[2]-n[0],height:n[3]-n[1]}}class $Z{static create(e){switch(e.data.annotationType){case rn.LINK:return new cM(e);case rn.TEXT:return new TZ(e);case rn.WIDGET:switch(e.data.fieldType){case"Tx":return new PZ(e);case"Btn":return e.data.radioButton?new dM(e):e.data.checkBox?new MZ(e):new IZ(e);case"Ch":return new OZ(e);case"Sig":return new RZ(e)}return new Tc(e);case rn.POPUP:return new _w(e);case rn.FREETEXT:return new yM(e);case rn.LINE:return new LZ(e);case rn.SQUARE:return new DZ(e);case rn.CIRCLE:return new jZ(e);case rn.POLYLINE:return new bM(e);case rn.CARET:return new zZ(e);case rn.INK:return new Cx(e);case rn.POLYGON:return new FZ(e);case rn.HIGHLIGHT:return new vM(e);case rn.UNDERLINE:return new HZ(e);case rn.SQUIGGLY:return new BZ(e);case rn.STRIKEOUT:return new qZ(e);case rn.STAMP:return new wM(e);case rn.FILEATTACHMENT:return new VZ(e);default:return new Xt(e)}}}var Fl,qh,Vh,tp,ww;const ak=class ak{constructor(e,{isRenderable:t=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){M(this,tp);M(this,Fl,null);M(this,qh,!1);M(this,Vh,null);this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:s}){return!!(e!=null&&e.str||t!=null&&t.str||s!=null&&s.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return ak._hasPopupData(this.data)}updateEdited(e){var s;if(!this.container)return;f(this,Fl)||$(this,Fl,{rect:this.data.rect.slice(0)});const{rect:t}=e;t&&P(this,tp,ww).call(this,t),(s=f(this,Vh))==null||s.popup.updateEdited(e)}resetEdited(){var e;f(this,Fl)&&(P(this,tp,ww).call(this,f(this,Fl).rect),(e=f(this,Vh))==null||e.popup.resetEdited(),$(this,Fl,null))}_createContainer(e){const{data:t,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",t.id),this instanceof Tc||(r.tabIndex=em);const{style:o}=r;if(o.zIndex=this.parent.zIndex++,t.alternativeText&&(r.title=t.alternativeText),t.noRotate&&r.classList.add("norotate"),!t.rect||this instanceof _w){const{rotation:g}=t;return!t.hasOwnCanvas&&g!==0&&this.setRotation(g,r),r}const{width:a,height:l}=So(t.rect);if(!e&&t.borderStyle.width>0){o.borderWidth=`${t.borderStyle.width}px`;const g=t.borderStyle.horizontalCornerRadius,b=t.borderStyle.verticalCornerRadius;if(g>0||b>0){const w=`calc(${g}px * var(--scale-factor)) / calc(${b}px * var(--scale-factor))`;o.borderRadius=w}else if(this instanceof dM){const w=`calc(${a}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;o.borderRadius=w}switch(t.borderStyle.style){case Ju.SOLID:o.borderStyle="solid";break;case Ju.DASHED:o.borderStyle="dashed";break;case Ju.BEVELED:He("Unimplemented border style: beveled");break;case Ju.INSET:He("Unimplemented border style: inset");break;case Ju.UNDERLINE:o.borderBottomStyle="solid";break}const y=t.borderColor||null;y?($(this,qh,!0),o.borderColor=Se.makeHexColor(y[0]|0,y[1]|0,y[2]|0)):o.borderWidth=0}const c=Se.normalizeRect([t.rect[0],s.view[3]-t.rect[1]+s.view[1],t.rect[2],s.view[3]-t.rect[3]+s.view[1]]),{pageWidth:h,pageHeight:u,pageX:d,pageY:p}=i.rawDims;o.left=`${100*(c[0]-d)/h}%`,o.top=`${100*(c[1]-p)/u}%`;const{rotation:m}=t;return t.hasOwnCanvas||m===0?(o.width=`${100*a/h}%`,o.height=`${100*l/u}%`):this.setRotation(m,r),r}setRotation(e,t=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:r,height:o}=So(this.data.rect);let a,l;e%180===0?(a=100*r/s,l=100*o/i):(a=100*o/s,l=100*r/i),t.style.width=`${a}%`,t.style.height=`${l}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(t,s,i)=>{const r=i.detail[t],o=r[0],a=r.slice(1);i.target.style[s]=eE[`${o}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:eE[`${o}_rgb`](a)})};return Ge(this,"_commonActions",{display:t=>{const{display:s}=t.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:s}=t.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:t=>{const s=t.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(e,t){const s=this._commonActions;for(const i of Object.keys(t.detail)){const r=e[i]||s[i];r==null||r(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;const s=this._commonActions;for(const[i,r]of Object.entries(t)){const o=s[i];if(o){const a={detail:{[i]:r},target:e};o(a),delete t[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[t,s,i,r]=this.data.rect.map(g=>Math.fround(g));if(e.length===8){const[g,b,y,w]=e.subarray(2,6);if(i===g&&r===b&&t===y&&s===w)return}const{style:o}=this.container;let a;if(f(this,qh)){const{borderColor:g,borderWidth:b}=o;o.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'',``],this.container.classList.add("hasBorder")}const l=i-t,c=r-s,{svgFactory:h}=this,u=h.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0);const d=h.createElement("defs");u.append(d);const p=h.createElement("clipPath"),m=`clippath_${this.data.id}`;p.setAttribute("id",m),p.setAttribute("clipPathUnits","objectBoundingBox"),d.append(p);for(let g=2,b=e.length;g`)}f(this,qh)&&(a.push("')"),o.backgroundImage=a.join("")),this.container.append(u),this.container.style.clipPath=`url(#${m})`}_createPopup(){const{data:e}=this,t=$(this,Vh,new _w({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(t.render())}render(){Et("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[e];if(i)for(const{page:r,id:o,exportValues:a}of i){if(r===-1||o===t)continue;const l=typeof a=="string"?a:null,c=document.querySelector(`[data-element-id="${o}"]`);if(c&&!gc.has(c)){He(`_getElementsByName - element not allowed: ${o}`);continue}s.push({id:o,exportValue:l,domElement:c})}return s}for(const i of document.getElementsByName(e)){const{exportValue:r}=i,o=i.getAttribute("data-element-id");o!==t&&gc.has(i)&&s.push({id:o,exportValue:r,domElement:i})}return s}show(){var e;this.container&&(this.container.hidden=!1),(e=this.popup)==null||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),(e=this.popup)==null||e.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t})})}};Fl=new WeakMap,qh=new WeakMap,Vh=new WeakMap,tp=new WeakSet,ww=function(e){const{container:{style:t},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:o,pageX:a,pageY:l}}}}=this;s==null||s.splice(0,4,...e);const{width:c,height:h}=So(e);t.left=`${100*(e[0]-a)/r}%`,t.top=`${100*(o-e[3]+l)/o}%`,i===0?(t.width=`${100*c/r}%`,t.height=`${100*h/o}%`):this.setRotation(i)};let Xt=ak;var Js,Ka,hM,uM;class cM extends Xt{constructor(t,s=null){super(t,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});M(this,Js);this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let r=!1;return t.url?(s.addLinkAttributes(i,t.url,t.newWindow),r=!0):t.action?(this._bindNamedAction(i,t.action),r=!0):t.attachment?(P(this,Js,hM).call(this,i,t.attachment,t.attachmentDest),r=!0):t.setOCGState?(P(this,Js,uM).call(this,i,t.setOCGState),r=!0):t.dest?(this._bindLink(i,t.dest),r=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),r=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(i,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(i),this.container}_bindLink(t,s){t.href=this.linkService.getDestinationHash(s),t.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&P(this,Js,Ka).call(this)}_bindNamedAction(t,s){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(s),!1),P(this,Js,Ka).call(this)}_bindJSAction(t,s){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const o=i.get(r);o&&(t[o]=()=>{var a;return(a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}t.onclick||(t.onclick=()=>!1),P(this,Js,Ka).call(this)}_bindResetFormAction(t,s){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),P(this,Js,Ka).call(this),!this._fieldObjects){He('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{var u;i==null||i();const{fields:r,refs:o,include:a}=s,l=[];if(r.length!==0||o.length!==0){const d=new Set(o);for(const p of r){const m=this._fieldObjects[p]||[];for(const{id:g}of m)d.add(g)}for(const p of Object.values(this._fieldObjects))for(const m of p)d.has(m.id)===a&&l.push(m)}else for(const d of Object.values(this._fieldObjects))l.push(...d);const c=this.annotationStorage,h=[];for(const d of l){const{id:p}=d;switch(h.push(p),d.type){case"text":{const g=d.defaultValue||"";c.setValue(p,{value:g});break}case"checkbox":case"radiobutton":{const g=d.defaultValue===d.exportValues;c.setValue(p,{value:g});break}case"combobox":case"listbox":{const g=d.defaultValue||"";c.setValue(p,{value:g});break}default:continue}const m=document.querySelector(`[data-element-id="${p}"]`);if(m){if(!gc.has(m)){He(`_bindResetFormAction - element not allowed: ${p}`);continue}}else continue;m.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((u=this.linkService.eventBus)==null||u.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}})),!1}}}Js=new WeakSet,Ka=function(){this.container.setAttribute("data-internal-link","")},hM=function(t,s,i=null){t.href=this.linkService.getAnchorUrl(""),s.description&&(t.title=s.description),t.onclick=()=>{var r;return(r=this.downloadManager)==null||r.openOrDownloadData(s.content,s.filename,i),!1},P(this,Js,Ka).call(this)},uM=function(t,s){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(s),!1),P(this,Js,Ka).call(this)};class TZ extends Xt{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}}class Tc extends Xt{render(){return this.container}showElementAndHideCanvas(e){var t;this.data.hasOwnCanvas&&(((t=e.previousSibling)==null?void 0:t.nodeName)==="CANVAS"&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return fs.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,s,i,r){s.includes("mouse")?e.addEventListener(s,o=>{var a;(a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(o),shift:o.shiftKey,modifier:this._getKeyModifier(o)}})}):e.addEventListener(s,o=>{var a;if(s==="blur"){if(!t.focused||!o.relatedTarget)return;t.focused=!1}else if(s==="focus"){if(t.focused)return;t.focused=!0}r&&((a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(o)}}))})}_setEventListeners(e,t,s,i){var r,o,a;for(const[l,c]of s)(c==="Action"||(r=this.data.actions)!=null&&r[c])&&((c==="Focus"||c==="Blur")&&(t||(t={focused:!1})),this._setEventListener(e,t,l,c,i),c==="Focus"&&!((o=this.data.actions)!=null&&o.Blur)?this._setEventListener(e,t,"blur","Blur",null):c==="Blur"&&!((a=this.data.actions)!=null&&a.Focus)&&this._setEventListener(e,t,"focus","Focus",null))}_setBackgroundColor(e){const t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?"transparent":Se.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){const t=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||CZ,r=e.style;let o;const a=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-a),h=Math.round(c/(bb*i))||1,u=c/h;o=Math.min(i,l(u/bb))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-a);o=Math.min(i,l(c/bb))}r.fontSize=`calc(${o}px * var(--scale-factor))`,r.color=Se.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(r.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class PZ extends Tc{constructor(e){const t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,s,i){const r=this.annotationStorage;for(const o of this._getElementsByName(e.name,e.id))o.domElement&&(o.domElement[t]=s),r.setValue(o.id,{[i]:s})}render(){var i,r;const e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const o=e.getValue(t,{value:this.data.fieldValue});let a=o.value||"";const l=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;l&&a.length>l&&(a=a.slice(0,l));let c=o.formattedValue||((i=this.data.textContent)==null?void 0:i.join(` +`))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const h={userValue:a,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=c??a,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",c??a),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),gc.add(s),s.setAttribute("data-element-id",t),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=em,this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",d=>{e.setValue(t,{value:d.target.value}),this.setPropertyOnSiblings(s,"value",d.target.value,"value"),h.formattedValue=null}),s.addEventListener("resetform",d=>{const p=this.data.defaultFieldValue??"";s.value=h.userValue=p,h.formattedValue=null});let u=d=>{const{formattedValue:p}=h;p!=null&&(d.target.value=p),d.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",p=>{var g;if(h.focused)return;const{target:m}=p;h.userValue&&(m.value=h.userValue),h.lastCommittedValue=m.value,h.commitKey=1,(g=this.data.actions)!=null&&g.Focus||(h.focused=!0)}),s.addEventListener("updatefromsandbox",p=>{this.showElementAndHideCanvas(p.target);const m={value(g){h.userValue=g.detail.value??"",e.setValue(t,{value:h.userValue.toString()}),g.target.value=h.userValue},formattedValue(g){const{formattedValue:b}=g.detail;h.formattedValue=b,b!=null&&g.target!==document.activeElement&&(g.target.value=b),e.setValue(t,{formattedValue:b})},selRange(g){g.target.setSelectionRange(...g.detail.selRange)},charLimit:g=>{var v;const{charLimit:b}=g.detail,{target:y}=g;if(b===0){y.removeAttribute("maxLength");return}y.setAttribute("maxLength",b);let w=h.userValue;!w||w.length<=b||(w=w.slice(0,b),y.value=h.userValue=w,e.setValue(t,{value:w}),(v=this.linkService.eventBus)==null||v.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:w,willCommit:!0,commitKey:1,selStart:y.selectionStart,selEnd:y.selectionEnd}}))}};this._dispatchEventFromSandbox(m,p)}),s.addEventListener("keydown",p=>{var b;h.commitKey=1;let m=-1;if(p.key==="Escape"?m=0:p.key==="Enter"&&!this.data.multiLine?m=2:p.key==="Tab"&&(h.commitKey=3),m===-1)return;const{value:g}=p.target;h.lastCommittedValue!==g&&(h.lastCommittedValue=g,h.userValue=g,(b=this.linkService.eventBus)==null||b.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:g,willCommit:!0,commitKey:m,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}}))});const d=u;u=null,s.addEventListener("blur",p=>{var g,b;if(!h.focused||!p.relatedTarget)return;(g=this.data.actions)!=null&&g.Blur||(h.focused=!1);const{value:m}=p.target;h.userValue=m,h.lastCommittedValue!==m&&((b=this.linkService.eventBus)==null||b.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:m,willCommit:!0,commitKey:h.commitKey,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}})),d(p)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",p=>{var k;h.lastCommittedValue=null;const{data:m,target:g}=p,{value:b,selectionStart:y,selectionEnd:w}=g;let v=y,x=w;switch(p.inputType){case"deleteWordBackward":{const E=b.substring(0,y).match(/\w*[^\w]*$/);E&&(v-=E[0].length);break}case"deleteWordForward":{const E=b.substring(y).match(/^[^\w]*\w*/);E&&(x+=E[0].length);break}case"deleteContentBackward":y===w&&(v-=1);break;case"deleteContentForward":y===w&&(x+=1);break}p.preventDefault(),(k=this.linkService.eventBus)==null||k.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:b,change:m||"",willCommit:!1,selStart:v,selEnd:x}})}),this._setEventListeners(s,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],p=>p.target.value)}if(u&&s.addEventListener("blur",u),this.data.comb){const p=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${p}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class RZ extends Tc{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class MZ extends Tc{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,t=this.data,s=t.id;let i=e.getValue(s,{value:t.exportValue===t.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",e.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return gc.add(r),r.setAttribute("data-element-id",s),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=t.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",t.exportValue),r.tabIndex=em,r.addEventListener("change",o=>{const{name:a,checked:l}=o.target;for(const c of this._getElementsByName(a,s)){const h=l&&c.exportValue===t.exportValue;c.domElement&&(c.domElement.checked=h),e.setValue(c.id,{value:h})}e.setValue(s,{value:l})}),r.addEventListener("resetform",o=>{const a=t.defaultFieldValue||"Off";o.target.checked=a===t.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",o=>{const a={value(l){l.target.checked=l.detail.value!=="Off",e.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(a,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class dM extends Tc{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,t=this.data,s=t.id;let i=e.getValue(s,{value:t.fieldValue===t.buttonValue}).value;if(typeof i=="string"&&(i=i!==t.buttonValue,e.setValue(s,{value:i})),i)for(const o of this._getElementsByName(t.fieldName,s))e.setValue(o.id,{value:!1});const r=document.createElement("input");if(gc.add(r),r.setAttribute("data-element-id",s),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=t.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=em,r.addEventListener("change",o=>{const{name:a,checked:l}=o.target;for(const c of this._getElementsByName(a,s))e.setValue(c.id,{value:!1});e.setValue(s,{value:l})}),r.addEventListener("resetform",o=>{const a=t.defaultFieldValue;o.target.checked=a!=null&&a===t.buttonValue}),this.enableScripting&&this.hasJSActions){const o=t.buttonValue;r.addEventListener("updatefromsandbox",a=>{const l={value:c=>{const h=o===c.detail.value;for(const u of this._getElementsByName(c.target.name)){const d=h&&u.id===s;u.domElement&&(u.domElement.checked=d),e.setValue(u.id,{value:d})}}};this._dispatchEventFromSandbox(l,a)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class IZ extends cM{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),e}}class OZ extends Tc{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,t=this.data.id,s=e.getValue(t,{value:this.data.fieldValue}),i=document.createElement("select");gc.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=em;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",h=>{const u=this.data.defaultFieldValue;for(const d of i.options)d.selected=d.value===u});for(const h of this.data.options){const u=document.createElement("option");u.textContent=h.displayValue,u.value=h.exportValue,s.value.includes(h.exportValue)&&(u.setAttribute("selected",!0),r=!1),i.append(u)}let o=null;if(r){const h=document.createElement("option");h.value=" ",h.setAttribute("hidden",!0),h.setAttribute("selected",!0),i.prepend(h),o=()=>{h.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}const a=h=>{const u=h?"value":"textContent",{options:d,multiple:p}=i;return p?Array.prototype.filter.call(d,m=>m.selected).map(m=>m[u]):d.selectedIndex===-1?null:d[d.selectedIndex][u]};let l=a(!1);const c=h=>{const u=h.target.options;return Array.prototype.map.call(u,d=>({displayValue:d.textContent,exportValue:d.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",h=>{const u={value(d){o==null||o();const p=d.detail.value,m=new Set(Array.isArray(p)?p:[p]);for(const g of i.options)g.selected=m.has(g.value);e.setValue(t,{value:a(!0)}),l=a(!1)},multipleSelection(d){i.multiple=!0},remove(d){const p=i.options,m=d.detail.remove;p[m].selected=!1,i.remove(m),p.length>0&&Array.prototype.findIndex.call(p,b=>b.selected)===-1&&(p[0].selected=!0),e.setValue(t,{value:a(!0),items:c(d)}),l=a(!1)},clear(d){for(;i.length!==0;)i.remove(0);e.setValue(t,{value:null,items:[]}),l=a(!1)},insert(d){const{index:p,displayValue:m,exportValue:g}=d.detail.insert,b=i.children[p],y=document.createElement("option");y.textContent=m,y.value=g,b?b.before(y):i.append(y),e.setValue(t,{value:a(!0),items:c(d)}),l=a(!1)},items(d){const{items:p}=d.detail;for(;i.length!==0;)i.remove(0);for(const m of p){const{displayValue:g,exportValue:b}=m,y=document.createElement("option");y.textContent=g,y.value=b,i.append(y)}i.options.length>0&&(i.options[0].selected=!0),e.setValue(t,{value:a(!0),items:c(d)}),l=a(!1)},indices(d){const p=new Set(d.detail.indices);for(const m of d.target.options)m.selected=p.has(m.index);e.setValue(t,{value:a(!0)}),l=a(!1)},editable(d){d.target.disabled=!d.detail.editable}};this._dispatchEventFromSandbox(u,h)}),i.addEventListener("input",h=>{var p;const u=a(!0),d=a(!1);e.setValue(t,{value:u}),h.preventDefault(),(p=this.linkService.eventBus)==null||p.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:l,change:d,changeEx:u,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],h=>h.target.value)):i.addEventListener("input",function(h){e.setValue(t,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class _w extends Xt{constructor(e){const{data:t,elements:s}=e;super(e,{isRenderable:Xt._hasPopupData(t)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const e=this.popup=new NZ({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(const s of this.elements)s.popup=e,s.container.ariaHasPopup="dialog",t.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",t.map(s=>`${gx}${s}`).join(",")),this.container}}var Uh,Jy,Qy,Wh,zl,zt,eo,Gh,np,sp,Kh,to,Li,no,ip,so,rp,Hl,Bl,ft,Sg,Sw,fM,pM,mM,gM,xg,kg,xw;class NZ{constructor({container:e,color:t,elements:s,titleObj:i,modificationDate:r,contentsObj:o,richText:a,parent:l,rect:c,parentRect:h,open:u}){M(this,ft);M(this,Uh,P(this,ft,mM).bind(this));M(this,Jy,P(this,ft,xw).bind(this));M(this,Qy,P(this,ft,kg).bind(this));M(this,Wh,P(this,ft,xg).bind(this));M(this,zl,null);M(this,zt,null);M(this,eo,null);M(this,Gh,null);M(this,np,null);M(this,sp,null);M(this,Kh,null);M(this,to,!1);M(this,Li,null);M(this,no,null);M(this,ip,null);M(this,so,null);M(this,rp,null);M(this,Hl,null);M(this,Bl,!1);var d;$(this,zt,e),$(this,rp,i),$(this,eo,o),$(this,so,a),$(this,sp,l),$(this,zl,t),$(this,ip,c),$(this,Kh,h),$(this,np,s),$(this,Gh,vx.toDateObject(r)),this.trigger=s.flatMap(p=>p.getElementsToTriggerPopup());for(const p of this.trigger)p.addEventListener("click",f(this,Wh)),p.addEventListener("mouseenter",f(this,Qy)),p.addEventListener("mouseleave",f(this,Jy)),p.classList.add("popupTriggerArea");for(const p of s)(d=p.container)==null||d.addEventListener("keydown",f(this,Uh));f(this,zt).hidden=!0,u&&P(this,ft,xg).call(this)}render(){if(f(this,Li))return;const e=$(this,Li,document.createElement("div"));if(e.className="popup",f(this,zl)){const r=e.style.outlineColor=Se.makeHexColor(...f(this,zl));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?e.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`:e.style.backgroundColor=Se.makeHexColor(...f(this,zl).map(a=>Math.floor(.7*(255-a)+a)))}const t=document.createElement("span");t.className="header";const s=document.createElement("h1");if(t.append(s),{dir:s.dir,str:s.textContent}=f(this,rp),e.append(t),f(this,Gh)){const r=document.createElement("span");r.classList.add("popupDate"),r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:f(this,Gh).valueOf()})),t.append(r)}const i=f(this,ft,Sg);if(i)lM.render({xfaHtml:i,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const r=this._formatContents(f(this,eo));e.append(r)}f(this,zt).append(e)}_formatContents({str:e,dir:t}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=t;const i=e.split(/(?:\r\n?|\n)/);for(let r=0,o=i.length;r{o.key==="Enter"&&(r?o.metaKey:o.ctrlKey)&&P(this,dp,kw).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return f(this,up)}addHighlightArea(){this.container.classList.add("highlightArea")}}up=new WeakMap,dp=new WeakSet,kw=function(){var t;(t=this.downloadManager)==null||t.openOrDownloadData(this.content,this.filename)};var fp,ql,Vl,pp,kc,_M,Aw,jC;let UZ=(jC=class{constructor({div:e,accessibilityManager:t,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:o,structTreeLayer:a}){M(this,kc);M(this,fp,null);M(this,ql,null);M(this,Vl,new Map);M(this,pp,null);this.div=e,$(this,fp,t),$(this,ql,s),$(this,pp,a||null),this.page=r,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return f(this,Vl).size>0}async render(e){var o;const{annotations:t}=e,s=this.div;pc(s,this.viewport);const i=new Map,r={data:null,layer:s,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:e.renderForms!==!1,svgFactory:new Ex,annotationStorage:e.annotationStorage||new _x,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const a of t){if(a.noHTML)continue;const l=a.annotationType===rn.POPUP;if(l){const u=i.get(a.id);if(!u)continue;r.elements=u}else{const{width:u,height:d}=So(a.rect);if(u<=0||d<=0)continue}r.data=a;const c=$Z.create(r);if(!c.isRenderable)continue;if(!l&&a.popupRef){const u=i.get(a.popupRef);u?u.push(c):i.set(a.popupRef,[c])}const h=c.render();a.hidden&&(h.style.visibility="hidden"),await P(this,kc,_M).call(this,h,a.id),c._isEditable&&(f(this,Vl).set(c.data.id,c),(o=this._annotationEditorUIManager)==null||o.renderAnnotationElement(c))}P(this,kc,Aw).call(this)}update({viewport:e}){const t=this.div;this.viewport=e,pc(t,{rotation:e.rotation}),P(this,kc,Aw).call(this),t.hidden=!1}getEditableAnnotations(){return Array.from(f(this,Vl).values())}getEditableAnnotation(e){return f(this,Vl).get(e)}},fp=new WeakMap,ql=new WeakMap,Vl=new WeakMap,pp=new WeakMap,kc=new WeakSet,_M=async function(e,t){var o,a;const s=e.firstChild||e,i=s.id=`${gx}${t}`,r=await((o=f(this,pp))==null?void 0:o.getAriaAttributes(i));if(r)for(const[l,c]of r)s.setAttribute(l,c);this.div.append(e),(a=f(this,fp))==null||a.moveElementInDOM(this.div,e,s,!1)},Aw=function(){if(!f(this,ql))return;const e=this.div;for(const[t,s]of f(this,ql)){const i=e.querySelector(`[data-annotation-id="${t}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:r}=i;r?r.nodeName==="CANVAS"?r.replaceWith(s):r.classList.contains("annotationContent")?r.after(s):r.before(s):i.append(s)}f(this,ql).clear()},jC);const Rm=/\r\n?|\n/g;var Di,Vs,mp,Ul,Us,en,SM,xM,kM,Ag,Ao,Eg,Cg,AM,Cw,EM;const St=class St extends ut{constructor(t){super({...t,name:"freeTextEditor"});M(this,en);M(this,Di);M(this,Vs,"");M(this,mp,`${this.id}-editor`);M(this,Ul,null);M(this,Us);$(this,Di,t.color||St._defaultColor||ut._defaultLineColor),$(this,Us,t.fontSize||St._defaultFontSize)}static get _keyboardManager(){const t=St.prototype,s=o=>o.isEmpty(),i=mc.TRANSLATE_SMALL,r=mc.TRANSLATE_BIG;return Ge(this,"_keyboardManager",new Qp([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-r,0],checker:s}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[r,0],checker:s}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:s}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,r],checker:s}]]))}static initialize(t,s){ut.initialize(t,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,s){switch(t){case Te.FREETEXT_SIZE:St._defaultFontSize=s;break;case Te.FREETEXT_COLOR:St._defaultColor=s;break}}updateParams(t,s){switch(t){case Te.FREETEXT_SIZE:P(this,en,SM).call(this,s);break;case Te.FREETEXT_COLOR:P(this,en,xM).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Te.FREETEXT_SIZE,St._defaultFontSize],[Te.FREETEXT_COLOR,St._defaultColor||ut._defaultLineColor]]}get propertiesToUpdate(){return[[Te.FREETEXT_SIZE,f(this,Us)],[Te.FREETEXT_COLOR,f(this,Di)]]}_translateEmpty(t,s){this._uiManager.translateSelectedEditors(t,s,!0)}getInitialTranslation(){const t=this.parentScale;return[-St._internalPadding*t,-(St._internalPadding+f(this,Us))*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(Ne.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),$(this,Ul,new AbortController);const t=this._uiManager.combinedSignal(f(this,Ul));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){var t;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",f(this,mp)),this._isDraggable=!0,(t=f(this,Ul))==null||t.abort(),$(this,Ul,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var t;this.width||(this.enableEditMode(),this.editorDiv.focus(),(t=this._initialOptions)!=null&&t.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=f(this,Vs),s=$(this,Vs,P(this,en,kM).call(this).trimEnd());if(t===s)return;const i=r=>{if($(this,Vs,r),!r){this.remove();return}P(this,en,Cg).call(this),this._uiManager.rebuild(this),P(this,en,Ag).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(t)},mustExec:!1}),P(this,en,Ag).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){St._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,s;this.width&&(t=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",f(this,mp)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${f(this,Us)}px * var(--scale-factor))`,i.color=f(this,Di),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),fy(this,this.div,["dblclick","keydown"]),this.width){const[r,o]=this.parentDimensions;if(this.annotationElementId){const{position:a}=this._initialData;let[l,c]=this.getInitialTranslation();[l,c]=this.pageTranslationToScreen(l,c);const[h,u]=this.pageDimensions,[d,p]=this.pageTranslation;let m,g;switch(this.rotation){case 0:m=t+(a[0]-d)/h,g=s+this.height-(a[1]-p)/u;break;case 90:m=t+(a[0]-d)/h,g=s-(a[1]-p)/u,[l,c]=[c,-l];break;case 180:m=t-this.width+(a[0]-d)/h,g=s-(a[1]-p)/u,[l,c]=[-l,-c];break;case 270:m=t+(a[0]-d-this.height*u)/h,g=s+(a[1]-p-this.width*h)/u,[l,c]=[-c,l];break}this.setAt(m*r,g*o,l,c)}else this.setAt(t*r,s*o,this.width*r,this.height*o);P(this,en,Cg).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){var m,g,b;const s=t.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;t.preventDefault();const r=P(m=St,Ao,Cw).call(m,s.getData("text")||"").replaceAll(Rm,` +`);if(!r)return;const o=window.getSelection();if(!o.rangeCount)return;this.editorDiv.normalize(),o.deleteFromDocument();const a=o.getRangeAt(0);if(!r.includes(` +`)){a.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),o.collapseToStart();return}const{startContainer:l,startOffset:c}=a,h=[],u=[];if(l.nodeType===Node.TEXT_NODE){const y=l.parentElement;if(u.push(l.nodeValue.slice(c).replaceAll(Rm,"")),y!==this.editorDiv){let w=h;for(const v of this.editorDiv.childNodes){if(v===y){w=u;continue}w.push(P(g=St,Ao,Eg).call(g,v))}}h.push(l.nodeValue.slice(0,c).replaceAll(Rm,""))}else if(l===this.editorDiv){let y=h,w=0;for(const v of this.editorDiv.childNodes)w++===c&&(y=u),y.push(P(b=St,Ao,Eg).call(b,v))}$(this,Vs,`${h.join(` +`)}${r}${u.join(` +`)}`),P(this,en,Cg).call(this);const d=new Range;let p=h.reduce((y,w)=>y+w.length,0);for(const{firstChild:y}of this.editorDiv.childNodes)if(y.nodeType===Node.TEXT_NODE){const w=y.nodeValue.length;if(p<=w){d.setStart(y,p),d.setEnd(y,p);break}p-=w}o.removeAllRanges(),o.addRange(d)}get contentDiv(){return this.editorDiv}static async deserialize(t,s,i){var a;let r=null;if(t instanceof yM){const{data:{defaultAppearanceData:{fontSize:l,fontColor:c},rect:h,rotation:u,id:d,popupRef:p},textContent:m,textPosition:g,parent:{page:{pageNumber:b}}}=t;if(!m||m.length===0)return null;r=t={annotationType:Ne.FREETEXT,color:Array.from(c),fontSize:l,value:m.join(` +`),position:g,pageIndex:b-1,rect:h.slice(0),rotation:u,id:d,deleted:!1,popupRef:p}}const o=await super.deserialize(t,s,i);return $(o,Us,t.fontSize),$(o,Di,Se.makeHexColor(...t.color)),$(o,Vs,P(a=St,Ao,Cw).call(a,t.value)),o.annotationElementId=t.id||null,o._initialData=r,o}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=St._internalPadding*this.parentScale,i=this.getRect(s,s),r=ut._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:f(this,Di)),o={annotationType:Ne.FREETEXT,color:r,fontSize:f(this,Us),value:P(this,en,AM).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!P(this,en,EM).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(t){const s=super.renderAnnotationElement(t);if(this.deleted)return s;const{style:i}=s;i.fontSize=`calc(${f(this,Us)}px * var(--scale-factor))`,i.color=f(this,Di),s.replaceChildren();for(const o of f(this,Vs).split(` +`)){const a=document.createElement("div");a.append(o?document.createTextNode(o):document.createElement("br")),s.append(a)}const r=St._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(r,r),popupContent:f(this,Vs)}),s}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};Di=new WeakMap,Vs=new WeakMap,mp=new WeakMap,Ul=new WeakMap,Us=new WeakMap,en=new WeakSet,SM=function(t){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--scale-factor))`,this.translate(0,-(r-f(this,Us))*this.parentScale),$(this,Us,r),P(this,en,Ag).call(this)},i=f(this,Us);this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Te.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},xM=function(t){const s=r=>{$(this,Di,this.editorDiv.style.color=r)},i=f(this,Di);this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Te.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},kM=function(){var i;const t=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(t.push(P(i=St,Ao,Eg).call(i,r)),s=r);return t.join(` +`)},Ag=function(){const[t,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:r,div:o}=this,a=o.style.display,l=o.classList.contains("hidden");o.classList.remove("hidden"),o.style.display="hidden",r.div.append(this.div),i=o.getBoundingClientRect(),o.remove(),o.style.display=a,o.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/t,this.height=i.height/s):(this.width=i.height/t,this.height=i.width/s),this.fixAndSetPosition()},Ao=new WeakSet,Eg=function(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Rm,"")},Cg=function(){if(this.editorDiv.replaceChildren(),!!f(this,Vs))for(const t of f(this,Vs).split(` +`)){const s=document.createElement("div");s.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(s)}},AM=function(){return f(this,Vs).replaceAll(" "," ")},Cw=function(t){return t.replaceAll(" "," ")},EM=function(t){const{value:s,fontSize:i,color:r,pageIndex:o}=this._initialData;return this._hasBeenMoved||t.value!==s||t.fontSize!==i||t.color.some((a,l)=>a!==r[l])||t.pageIndex!==o},M(St,Ao),ae(St,"_freeTextDefaultContent",""),ae(St,"_internalPadding",0),ae(St,"_defaultColor",null),ae(St,"_defaultFontSize",10),ae(St,"_type","freetext"),ae(St,"_editorType",Ne.FREETEXT);let Ew=St;class CM{toSVGPath(){Et("Abstract method `toSVGPath` must be implemented.")}get box(){Et("Abstract getter `box` must be implemented.")}serialize(e,t){Et("Abstract method `serialize` must be implemented.")}get classNamesForDrawing(){Et("Abstract getter `classNamesForDrawing` must be implemented.")}get classNamesForOutlining(){Et("Abstract getter `classNamesForOutlining` must be implemented.")}get mustRemoveSelfIntersections(){return!1}}var Ws,ji,Zh,Xh,yr,Be,Wl,Gl,gp,yp,Yh,Jh,la,bp,e0,t0,mn,_d,$M,TM,PM,RM,MM,IM;const qr=class qr{constructor({x:e,y:t},s,i,r,o,a=0){M(this,mn);M(this,Ws);M(this,ji,[]);M(this,Zh);M(this,Xh);M(this,yr,[]);M(this,Be,new Float64Array(18));M(this,Wl);M(this,Gl);M(this,gp);M(this,yp);M(this,Yh);M(this,Jh);M(this,la,[]);$(this,Ws,s),$(this,Jh,r*i),$(this,Xh,o),f(this,Be).set([NaN,NaN,NaN,NaN,e,t],6),$(this,Zh,a),$(this,yp,f(qr,bp)*i),$(this,gp,f(qr,t0)*i),$(this,Yh,i),f(this,la).push(e,t)}isEmpty(){return isNaN(f(this,Be)[8])}add({x:e,y:t}){var F;$(this,Wl,e),$(this,Gl,t);const[s,i,r,o]=f(this,Ws);let[a,l,c,h]=f(this,Be).subarray(8,12);const u=e-c,d=t-h,p=Math.hypot(u,d);if(p=6;i-=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);return P(this,mn,TM).call(this,s),s.join(" ")}newFreeDrawOutline(e,t,s,i,r,o){return new OM(e,t,s,i,r,o)}getOutlines(){var u;const e=f(this,yr),t=f(this,ji),s=f(this,Be),[i,r,o,a]=f(this,Ws),l=new Float64Array((((u=f(this,la))==null?void 0:u.length)??0)+2);for(let d=0,p=l.length-2;d=6;d-=6)for(let p=0;p<6;p+=2){if(isNaN(t[d+p])){c[h]=c[h+1]=NaN,h+=2;continue}c[h]=t[d+p],c[h+1]=t[d+p+1],h+=2}return P(this,mn,MM).call(this,c,h),this.newFreeDrawOutline(c,l,f(this,Ws),f(this,Yh),f(this,Zh),f(this,Xh))}};Ws=new WeakMap,ji=new WeakMap,Zh=new WeakMap,Xh=new WeakMap,yr=new WeakMap,Be=new WeakMap,Wl=new WeakMap,Gl=new WeakMap,gp=new WeakMap,yp=new WeakMap,Yh=new WeakMap,Jh=new WeakMap,la=new WeakMap,bp=new WeakMap,e0=new WeakMap,t0=new WeakMap,mn=new WeakSet,_d=function(){const e=f(this,Be).subarray(4,6),t=f(this,Be).subarray(16,18),[s,i,r,o]=f(this,Ws);return[(f(this,Wl)+(e[0]-t[0])/2-s)/r,(f(this,Gl)+(e[1]-t[1])/2-i)/o,(f(this,Wl)+(t[0]-e[0])/2-s)/r,(f(this,Gl)+(t[1]-e[1])/2-i)/o]},$M=function(){const[e,t,s,i]=f(this,Ws),[r,o,a,l]=P(this,mn,_d).call(this);return`M${(f(this,Be)[2]-e)/s} ${(f(this,Be)[3]-t)/i} L${(f(this,Be)[4]-e)/s} ${(f(this,Be)[5]-t)/i} L${r} ${o} L${a} ${l} L${(f(this,Be)[16]-e)/s} ${(f(this,Be)[17]-t)/i} L${(f(this,Be)[14]-e)/s} ${(f(this,Be)[15]-t)/i} Z`},TM=function(e){const t=f(this,ji);e.push(`L${t[4]} ${t[5]} Z`)},PM=function(e){const[t,s,i,r]=f(this,Ws),o=f(this,Be).subarray(4,6),a=f(this,Be).subarray(16,18),[l,c,h,u]=P(this,mn,_d).call(this);e.push(`L${(o[0]-t)/i} ${(o[1]-s)/r} L${l} ${c} L${h} ${u} L${(a[0]-t)/i} ${(a[1]-s)/r}`)},RM=function(e){const t=f(this,Be),[s,i,r,o]=f(this,Ws),[a,l,c,h]=P(this,mn,_d).call(this),u=new Float64Array(36);return u.set([NaN,NaN,NaN,NaN,(t[2]-s)/r,(t[3]-i)/o,NaN,NaN,NaN,NaN,(t[4]-s)/r,(t[5]-i)/o,NaN,NaN,NaN,NaN,a,l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(t[16]-s)/r,(t[17]-i)/o,NaN,NaN,NaN,NaN,(t[14]-s)/r,(t[15]-i)/o],0),this.newFreeDrawOutline(u,e,f(this,Ws),f(this,Yh),f(this,Zh),f(this,Xh))},MM=function(e,t){const s=f(this,ji);return e.set([NaN,NaN,NaN,NaN,s[4],s[5]],t),t+=6},IM=function(e,t){const s=f(this,Be).subarray(4,6),i=f(this,Be).subarray(16,18),[r,o,a,l]=f(this,Ws),[c,h,u,d]=P(this,mn,_d).call(this);return e.set([NaN,NaN,NaN,NaN,(s[0]-r)/a,(s[1]-o)/l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,(i[0]-r)/a,(i[1]-o)/l],t),t+=24},M(qr,bp,8),M(qr,e0,2),M(qr,t0,f(qr,bp)+f(qr,e0));let my=qr;var Qh,Kl,io,vp,Gs,wp,Wt,Ns,Sd,xd,NM;class OM extends CM{constructor(t,s,i,r,o,a){super();M(this,Ns);M(this,Qh);M(this,Kl,null);M(this,io);M(this,vp);M(this,Gs);M(this,wp);M(this,Wt);$(this,Wt,t),$(this,Gs,s),$(this,Qh,i),$(this,wp,r),$(this,io,o),$(this,vp,a),P(this,Ns,NM).call(this,a);const{x:l,y:c,width:h,height:u}=f(this,Kl);for(let d=0,p=t.length;dt[0]-s[0]||t[1]-s[1]||t[2]-s[2]);const e=[];for(const t of f(this,ca))t[3]?(e.push(...P(this,gs,$w).call(this,t)),P(this,gs,DM).call(this,t)):(P(this,gs,jM).call(this,t),e.push(...P(this,gs,$w).call(this,t)));return P(this,gs,LM).call(this,e)}}_p=new WeakMap,ca=new WeakMap,Fi=new WeakMap,gs=new WeakSet,LM=function(e){const t=[],s=new Set;for(const o of e){const[a,l,c]=o;t.push([a,l,o],[a,c,o])}t.sort((o,a)=>o[1]-a[1]||o[0]-a[0]);for(let o=0,a=t.length;o0;){const o=s.values().next().value;let[a,l,c,h,u]=o;s.delete(o);let d=a,p=l;for(r=[a,c],i.push(r);;){let m;if(s.has(h))m=h;else if(s.has(u))m=u;else break;s.delete(m),[a,l,c,h,u]=m,d!==a&&(r.push(d,p,a,p===l?l:c),d=a),p=p===l?c:l}r.push(d,p)}return new WZ(i,f(this,_p))},$g=function(e){const t=f(this,Fi);let s=0,i=t.length-1;for(;s<=i;){const r=s+i>>1,o=t[r][0];if(o===e)return r;o=0;i--){const[r,o]=f(this,Fi)[i];if(r!==e)break;if(r===e&&o===t){f(this,Fi).splice(i,1);return}}},$w=function(e){const[t,s,i]=e,r=[[t,s,i]],o=P(this,gs,$g).call(this,i);for(let a=0;a=l){if(p>c)r[h][1]=c;else{if(u===1)return[];r.splice(h,1),h--,u--}continue}r[h][2]=l,p>c&&r.push([t,c,p])}}}return r};var Sp,eu;class WZ extends CM{constructor(t,s){super();M(this,Sp);M(this,eu);$(this,eu,t),$(this,Sp,s)}toSVGPath(){const t=[];for(const s of f(this,eu)){let[i,r]=s;t.push(`M${i} ${r}`);for(let o=2;o-1?($(this,Cs,!0),P(this,Me,Tg).call(this,t),P(this,Me,Xa).call(this)):f(this,ro)&&($(this,iu,t.anchorNode),$(this,Cp,t.anchorOffset),$(this,$p,t.focusNode),$(this,Tp,t.focusOffset),P(this,Me,Iw).call(this),P(this,Me,Xa).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const t=st.prototype;return Ge(this,"_keyboardManager",new Qp([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:f(this,Cs)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:f(this,ci),methodOfCreation:f(this,Pp)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,s){var i;ut.initialize(t,s),st._defaultColor||(st._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(t,s){switch(t){case Te.HIGHLIGHT_DEFAULT_COLOR:st._defaultColor=s;break;case Te.HIGHLIGHT_THICKNESS:st._defaultThickness=s;break}}translateInPage(t,s){}get toolbarPosition(){return f(this,ou)}updateParams(t,s){switch(t){case Te.HIGHLIGHT_COLOR:P(this,Me,zM).call(this,s);break;case Te.HIGHLIGHT_THICKNESS:P(this,Me,HM).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Te.HIGHLIGHT_DEFAULT_COLOR,st._defaultColor],[Te.HIGHLIGHT_THICKNESS,st._defaultThickness]]}get propertiesToUpdate(){return[[Te.HIGHLIGHT_COLOR,this.color||st._defaultColor],[Te.HIGHLIGHT_THICKNESS,f(this,ci)||st._defaultThickness],[Te.HIGHLIGHT_FREE,f(this,Cs)]]}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&($(this,ru,new gy({editor:this})),t.addColorPicker(f(this,ru))),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(P(this,Me,kd).call(this))}getBaseTranslation(){return[0,0]}getRect(t,s){return super.getRect(t,s,P(this,Me,kd).call(this))}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){P(this,Me,Ow).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(P(this,Me,Xa).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var i;let s=!1;this.parent&&!t?P(this,Me,Ow).call(this):t&&(P(this,Me,Xa).call(this,t),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),s&&this.select()}rotate(t){var r,o,a;const{drawLayer:s}=this.parent;let i;f(this,Cs)?(t=(t-this.rotation+360)%360,i=P(r=st,mi,Uc).call(r,f(this,Bi).box,t)):i=P(o=st,mi,Uc).call(o,this,t),s.rotate(f(this,Jn),t),s.rotate(f(this,ln),t),s.updateBox(f(this,Jn),i),s.updateBox(f(this,ln),P(a=st,mi,Uc).call(a,f(this,li).box,t))}render(){if(this.div)return this.div;const t=super.render();f(this,au)&&(t.setAttribute("aria-label",f(this,au)),t.setAttribute("role","mark")),f(this,Cs)?t.classList.add("free"):this.div.addEventListener("keydown",P(this,Me,qM).bind(this),{signal:this._uiManager._signal});const s=$(this,Yl,document.createElement("div"));t.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=f(this,Xl);const[i,r]=this.parentDimensions;return this.setDims(this.width*i,this.height*r),fy(this,f(this,Yl),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent.drawLayer.addClass(f(this,ln),"hovered")}pointerleave(){this.isSelected||this.parent.drawLayer.removeClass(f(this,ln),"hovered")}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:P(this,Me,Pg).call(this,!0);break;case 1:case 3:P(this,Me,Pg).call(this,!1);break}}select(){var t,s;super.select(),f(this,ln)&&((t=this.parent)==null||t.drawLayer.removeClass(f(this,ln),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(f(this,ln),"selected"))}unselect(){var t;super.unselect(),f(this,ln)&&((t=this.parent)==null||t.drawLayer.removeClass(f(this,ln),"selected"),f(this,Cs)||P(this,Me,Pg).call(this,!1))}get _mustFixPosition(){return!f(this,Cs)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(f(this,Jn),t),this.parent.drawLayer.show(f(this,ln),t))}static startHighlighting(t,s,{target:i,x:r,y:o}){const{x:a,y:l,width:c,height:h}=i.getBoundingClientRect(),u=new AbortController,d=t.combinedSignal(u),p=g=>{g.preventDefault(),g.stopPropagation()},m=g=>{u.abort(),P(this,mi,GM).call(this,t,g)};window.addEventListener("blur",m,{signal:d}),window.addEventListener("pointerup",m,{signal:d}),window.addEventListener("pointerdown",p,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",wi,{signal:d}),i.addEventListener("pointermove",P(this,mi,WM).bind(this,t),{signal:d}),this._freeHighlight=new Tw({x:r,y:o},[a,l,c,h],t.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static async deserialize(t,s,i){var g,b,y,w;let r=null;if(t instanceof vM){const{data:{quadPoints:v,rect:x,rotation:k,id:E,color:T,opacity:O,popupRef:F},parent:{page:{pageNumber:j}}}=t;r=t={annotationType:Ne.HIGHLIGHT,color:Array.from(T),opacity:O,quadPoints:v,boxes:null,pageIndex:j-1,rect:x.slice(0),rotation:k,id:E,deleted:!1,popupRef:F}}else if(t instanceof Cx){const{data:{inkLists:v,rect:x,rotation:k,id:E,color:T,borderStyle:{rawWidth:O},popupRef:F},parent:{page:{pageNumber:j}}}=t;r=t={annotationType:Ne.HIGHLIGHT,color:Array.from(T),thickness:O,inkLists:v,boxes:null,pageIndex:j-1,rect:x.slice(0),rotation:k,id:E,deleted:!1,popupRef:F}}const{color:o,quadPoints:a,inkLists:l,opacity:c}=t,h=await super.deserialize(t,s,i);h.color=Se.makeHexColor(...o),$(h,oo,c||1),l&&$(h,ci,t.thickness),h.annotationElementId=t.id||null,h._initialData=r;const[u,d]=h.pageDimensions,[p,m]=h.pageTranslation;if(a){const v=$(h,ro,[]);for(let x=0;x=0)$(this,Jn,s),$(this,Xl,i),this.parent.drawLayer.finalizeLine(s,t),$(this,ln,this.parent.drawLayer.drawOutline(f(this,li)));else if(this.parent){const p=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(f(this,Jn),t),this.parent.drawLayer.updateBox(f(this,Jn),P(u=st,mi,Uc).call(u,f(this,Bi).box,(p-this.rotation+360)%360)),this.parent.drawLayer.updateLine(f(this,ln),f(this,li)),this.parent.drawLayer.updateBox(f(this,ln),P(d=st,mi,Uc).call(d,f(this,li).box,p))}const{x:o,y:a,width:l,height:c}=t.box;switch(this.rotation){case 0:this.x=o,this.y=a,this.width=l,this.height=c;break;case 90:{const[p,m]=this.parentDimensions;this.x=a,this.y=1-o,this.width=l*m/p,this.height=c*p/m;break}case 180:this.x=1-o,this.y=1-a,this.width=l,this.height=c;break;case 270:{const[p,m]=this.parentDimensions;this.x=1-a,this.y=o,this.width=l*m/p,this.height=c*p/m;break}}const{lastPoint:h}=f(this,li).box;$(this,ou,[(h[0]-o)/l,(h[1]-a)/c])},zM=function(t){const s=(o,a)=>{var l,c,h;this.color=o,(l=this.parent)==null||l.drawLayer.changeColor(f(this,Jn),o),(c=f(this,ru))==null||c.updateColor(o),$(this,oo,a),(h=this.parent)==null||h.drawLayer.changeOpacity(f(this,Jn),a)},i=this.color,r=f(this,oo);this.addCommands({cmd:s.bind(this,t,st._defaultOpacity),undo:s.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Te.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)},HM=function(t){const s=f(this,ci),i=r=>{$(this,ci,r),P(this,Me,BM).call(this,r)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Te.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},BM=function(t){if(!f(this,Cs))return;P(this,Me,Tg).call(this,{highlightOutlines:f(this,Bi).getNewOutline(t/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},Ow=function(){f(this,Jn)===null||!this.parent||(this.parent.drawLayer.remove(f(this,Jn)),$(this,Jn,null),this.parent.drawLayer.remove(f(this,ln)),$(this,ln,null))},Xa=function(t=this.parent){f(this,Jn)===null&&({id:os(this,Jn)._,clipPathId:os(this,Xl)._}=t.drawLayer.draw(f(this,Bi),this.color,f(this,oo)),$(this,ln,t.drawLayer.drawOutline(f(this,li))),f(this,Yl)&&(f(this,Yl).style.clipPath=f(this,Xl)))},mi=new WeakSet,Uc=function({x:t,y:s,width:i,height:r},o){switch(o){case 90:return{x:1-s-r,y:t,width:r,height:i};case 180:return{x:1-t-i,y:1-s-r,width:i,height:r};case 270:return{x:s,y:1-t-i,width:r,height:i}}return{x:t,y:s,width:i,height:r}},qM=function(t){st._keyboardManager.exec(this,t)},Pg=function(t){if(!f(this,iu))return;const s=window.getSelection();t?s.setPosition(f(this,iu),f(this,Cp)):s.setPosition(f(this,$p),f(this,Tp))},kd=function(){return f(this,Cs)?this.rotation:0},VM=function(){if(f(this,Cs))return null;const[t,s]=this.pageDimensions,[i,r]=this.pageTranslation,o=f(this,ro),a=new Float32Array(o.length*8);let l=0;for(const{x:c,y:h,width:u,height:d}of o){const p=c*t+i,m=(1-h-d)*s+r;a[l]=a[l+4]=p,a[l+1]=a[l+3]=m,a[l+2]=a[l+6]=p+u*t,a[l+5]=a[l+7]=m+d*s,l+=8}return a},UM=function(t){return f(this,Bi).serialize(t,P(this,Me,kd).call(this))},WM=function(t,s){this._freeHighlight.add(s)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},GM=function(t,s){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},KM=function(t){const{color:s}=this._initialData;return t.color.some((i,r)=>i!==s[r])},M(st,mi),ae(st,"_defaultColor",null),ae(st,"_defaultOpacity",1),ae(st,"_defaultThickness",12),ae(st,"_type","highlight"),ae(st,"_editorType",Ne.HIGHLIGHT),ae(st,"_freeHighlightId",-1),ae(st,"_freeHighlight",null),ae(st,"_freeHighlightClipId","");let yy=st;var Jl,Ql,br,ao,hi,ec,tc,nc,lo,lu,sc,ic,ua,le,ZM,XM,YM,JM,Lw,QM,Dw,eI,tI,nI,sI,iI,Ya,jw,Fw,zw,Rg,Mg,Wc,Hw,Ig,$o,rI,Bw,oI,aI,qw,Og,Ad;const It=class It extends ut{constructor(t){super({...t,name:"inkEditor"});M(this,le);M(this,Jl,0);M(this,Ql,0);M(this,br,null);M(this,ao,new Path2D);M(this,hi,!1);M(this,ec,null);M(this,tc,!1);M(this,nc,!1);M(this,lo,null);M(this,lu,null);M(this,sc,0);M(this,ic,0);M(this,ua,null);this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(t,s){ut.initialize(t,s)}static updateDefaultParams(t,s){switch(t){case Te.INK_THICKNESS:It._defaultThickness=s;break;case Te.INK_COLOR:It._defaultColor=s;break;case Te.INK_OPACITY:It._defaultOpacity=s/100;break}}updateParams(t,s){switch(t){case Te.INK_THICKNESS:P(this,le,ZM).call(this,s);break;case Te.INK_COLOR:P(this,le,XM).call(this,s);break;case Te.INK_OPACITY:P(this,le,YM).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Te.INK_THICKNESS,It._defaultThickness],[Te.INK_COLOR,It._defaultColor||ut._defaultLineColor],[Te.INK_OPACITY,Math.round(It._defaultOpacity*100)]]}get propertiesToUpdate(){return[[Te.INK_THICKNESS,this.thickness||It._defaultThickness],[Te.INK_COLOR,this.color||It._defaultColor||ut._defaultLineColor],[Te.INK_OPACITY,Math.round(100*(this.opacity??It._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(P(this,le,Rg).call(this),P(this,le,Mg).call(this)),this.isAttachedToDOM||(this.parent.add(this),P(this,le,Wc).call(this)),P(this,le,Ad).call(this)))}remove(){var t;this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,f(this,br)&&(clearTimeout(f(this,br)),$(this,br,null)),(t=f(this,lo))==null||t.disconnect(),$(this,lo,null),super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&t===null&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,s]=this.parentDimensions,i=this.width*t,r=this.height*s;this.setDimensions(i,r)}enableEditMode(){f(this,hi)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,P(this,le,jw).call(this))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),P(this,le,Fw).call(this))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){f(this,hi)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),$(this,hi,!0),this.div.classList.add("disabled"),P(this,le,Ad).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),this.enableEditMode())}canvasPointerdown(t){t.button!==0||!this.isInEditMode()||f(this,hi)||(this.setInForeground(),t.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),P(this,le,QM).call(this,t.offsetX,t.offsetY))}canvasPointermove(t){t.preventDefault(),P(this,le,Dw).call(this,t.offsetX,t.offsetY)}canvasPointerup(t){t.preventDefault(),P(this,le,zw).call(this,t)}canvasPointerleave(t){P(this,le,zw).call(this,t)}get isResizable(){return!this.isEmpty()&&f(this,hi)}render(){if(this.div)return this.div;let t,s;this.width&&(t=this.x,s=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,r,o,a]=P(this,le,JM).call(this);if(this.setAt(i,r,0,0),this.setDims(o,a),P(this,le,Rg).call(this),this.width){const[l,c]=this.parentDimensions;this.setAspectRatio(this.width*l,this.height*c),this.setAt(t*l,s*c,this.width*l,this.height*c),$(this,nc,!0),P(this,le,Wc).call(this),this.setDims(this.width*l,this.height*c),P(this,le,Ya).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return P(this,le,Mg).call(this),this.div}setDimensions(t,s){const i=Math.round(t),r=Math.round(s);if(f(this,sc)===i&&f(this,ic)===r)return;$(this,sc,i),$(this,ic,r),this.canvas.style.visibility="hidden";const[o,a]=this.parentDimensions;this.width=t/o,this.height=s/a,this.fixAndSetPosition(),f(this,hi)&&P(this,le,Hw).call(this,t,s),P(this,le,Wc).call(this),P(this,le,Ya).call(this),this.canvas.style.visibility="visible",this.fixDims()}static async deserialize(t,s,i){var b,y,w;if(t instanceof Cx)return null;const r=await super.deserialize(t,s,i);r.thickness=t.thickness,r.color=Se.makeHexColor(...t.color),r.opacity=t.opacity;const[o,a]=r.pageDimensions,l=r.width*o,c=r.height*a,h=r.parentScale,u=t.thickness/2;$(r,hi,!0),$(r,sc,Math.round(l)),$(r,ic,Math.round(c));const{paths:d,rect:p,rotation:m}=t;for(let{bezier:v}of d){v=P(b=It,$o,oI).call(b,v,p,m);const x=[];r.paths.push(x);let k=h*(v[0]-u),E=h*(v[1]-u);for(let O=2,F=v.length;O{this.thickness=r,P(this,le,Ad).call(this)},i=this.thickness;this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Te.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},XM=function(t){const s=r=>{this.color=r,P(this,le,Ya).call(this)},i=this.color;this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Te.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},YM=function(t){const s=r=>{this.opacity=r,P(this,le,Ya).call(this)};t/=100;const i=this.opacity;this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Te.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},JM=function(){const{parentRotation:t,parentDimensions:[s,i]}=this;switch(t){case 90:return[0,i,i,s];case 180:return[s,i,s,i];case 270:return[s,0,i,s];default:return[0,0,s,i]}},Lw=function(){const{ctx:t,color:s,opacity:i,thickness:r,parentScale:o,scaleFactor:a}=this;t.lineWidth=r*o/a,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${s}${m8(i)}`},QM=function(t,s){this.canvas.addEventListener("contextmenu",wi,{signal:this._uiManager._signal}),P(this,le,Fw).call(this),$(this,ec,new AbortController);const i=this._uiManager.combinedSignal(f(this,ec));this.canvas.addEventListener("pointerleave",this.canvasPointerleave.bind(this),{signal:i}),this.canvas.addEventListener("pointermove",this.canvasPointermove.bind(this),{signal:i}),this.canvas.addEventListener("pointerup",this.canvasPointerup.bind(this),{signal:i}),this.isEditing=!0,f(this,nc)||($(this,nc,!0),P(this,le,Wc).call(this),this.thickness||(this.thickness=It._defaultThickness),this.color||(this.color=It._defaultColor||ut._defaultLineColor),this.opacity??(this.opacity=It._defaultOpacity)),this.currentPath.push([t,s]),$(this,tc,!1),P(this,le,Lw).call(this),$(this,ua,()=>{P(this,le,nI).call(this),f(this,ua)&&window.requestAnimationFrame(f(this,ua))}),window.requestAnimationFrame(f(this,ua))},Dw=function(t,s){const[i,r]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===i&&s===r)return;const o=this.currentPath;let a=f(this,ao);if(o.push([t,s]),$(this,tc,!0),o.length<=2){a.moveTo(...o[0]),a.lineTo(t,s);return}o.length===3&&($(this,ao,a=new Path2D),a.moveTo(...o[0])),P(this,le,sI).call(this,a,...o.at(-3),...o.at(-2),t,s)},eI=function(){if(this.currentPath.length===0)return;const t=this.currentPath.at(-1);f(this,ao).lineTo(...t)},tI=function(t,s){$(this,ua,null),t=Math.min(Math.max(t,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),P(this,le,Dw).call(this,t,s),P(this,le,eI).call(this);let i;if(this.currentPath.length!==1)i=P(this,le,iI).call(this);else{const c=[t,s];i=[[c,c.slice(),c.slice(),c]]}const r=f(this,ao),o=this.currentPath;this.currentPath=[],$(this,ao,new Path2D);const a=()=>{this.allRawPaths.push(o),this.paths.push(i),this.bezierPath2D.push(r),this._uiManager.rebuild(this)},l=()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(P(this,le,Rg).call(this),P(this,le,Mg).call(this)),P(this,le,Ad).call(this))};this.addCommands({cmd:a,undo:l,mustExec:!0})},nI=function(){if(!f(this,tc))return;$(this,tc,!1);const t=Math.ceil(this.thickness*this.parentScale),s=this.currentPath.slice(-3),i=s.map(a=>a[0]),r=s.map(a=>a[1]);Math.min(...i)-t,Math.max(...i)+t,Math.min(...r)-t,Math.max(...r)+t;const{ctx:o}=this;o.save(),o.clearRect(0,0,this.canvas.width,this.canvas.height);for(const a of this.bezierPath2D)o.stroke(a);o.stroke(f(this,ao)),o.restore()},sI=function(t,s,i,r,o,a,l){const c=(s+r)/2,h=(i+o)/2,u=(r+a)/2,d=(o+l)/2;t.bezierCurveTo(c+2*(r-c)/3,h+2*(o-h)/3,u+2*(r-u)/3,d+2*(o-d)/3,u,d)},iI=function(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const s=[];let i,[r,o]=t[0];for(i=1;i{$(this,br,null),this.canvas.removeEventListener("contextmenu",wi)},10)),P(this,le,tI).call(this,t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackground()},Rg=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},Mg=function(){$(this,lo,new ResizeObserver(t=>{const s=t[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),f(this,lo).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var t;(t=f(this,lo))==null||t.disconnect(),$(this,lo,null)},{once:!0})},Wc=function(){if(!f(this,nc))return;const[t,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*s),P(this,le,Ig).call(this)},Hw=function(t,s){const i=P(this,le,Og).call(this),r=(t-i)/f(this,Ql),o=(s-i)/f(this,Jl);this.scaleFactor=Math.min(r,o)},Ig=function(){const t=P(this,le,Og).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)},$o=new WeakSet,rI=function(t){const s=new Path2D;for(let i=0,r=t.length;i`image/${s}`))}static get supportedTypesStr(){return Ge(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,s){s.pasteEditor(Ne.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!!((t=this.altTextData)!=null&&t.altText)}}static computeTelemetryFinalData(t){const s=t.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(t=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:o,height:a}=t||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:r,width:o,height:a,channels:r.length/(o*a)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const c=l.output;return await this.setGuessedAltText(c),s&&!this.hasAltTextData()&&(this.altTextData={alt:c,decorative:!1}),c}remove(){var t,s;f(this,On)&&($(this,Nt,null),this._uiManager.imageManager.deleteId(f(this,On)),(t=f(this,vr))==null||t.remove(),$(this,vr,null),(s=f(this,ho))==null||s.disconnect(),$(this,ho,null),f(this,wr)&&(clearTimeout(f(this,wr)),$(this,wr,null))),super.remove()}rebuild(){if(!this.parent){f(this,On)&&P(this,We,Ng).call(this);return}super.rebuild(),this.div!==null&&(f(this,On)&&f(this,vr)===null&&P(this,We,Ng).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(f(this,da)||f(this,Nt)||f(this,co)||f(this,fa)||f(this,On))}get isResizable(){return!0}render(){if(this.div)return this.div;let t,s;if(this.width&&(t=this.x,s=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),f(this,Nt)?P(this,We,Uw).call(this):P(this,We,Ng).call(this),this.width&&!this.annotationElementId){const[i,r]=this.parentDimensions;this.setAt(t*i,s*r,this.width*i,this.height*r)}return this.div}copyCanvas(t,s,i=!1){var p;t||(t=224);const{width:r,height:o}=f(this,Nt),a=new zv;let l=f(this,Nt),c=r,h=o,u=null;if(s){if(r>s||o>s){const O=Math.min(s/r,s/o);c=Math.floor(r*O),h=Math.floor(o*O)}u=document.createElement("canvas");const m=u.width=Math.ceil(c*a.sx),g=u.height=Math.ceil(h*a.sy);f(this,Ks)||(l=P(this,We,Lg).call(this,m,g));const b=u.getContext("2d");b.filter=this._uiManager.hcmFilter;let y="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":(p=window.matchMedia)!=null&&p.call(window,"(prefers-color-scheme: dark)").matches&&(y="#8f8f9d",w="#42414d");const v=15,x=v*a.sx,k=v*a.sy,E=new OffscreenCanvas(x*2,k*2),T=E.getContext("2d");T.fillStyle=y,T.fillRect(0,0,x*2,k*2),T.fillStyle=w,T.fillRect(0,0,x,k),T.fillRect(x,k,x,k),b.fillStyle=b.createPattern(E,"repeat"),b.fillRect(0,0,m,g),b.drawImage(l,0,0,l.width,l.height,0,0,m,g)}let d=null;if(i){let m,g;if(a.symmetric&&l.widtht||o>t){const w=Math.min(t/r,t/o);m=Math.floor(r*w),g=Math.floor(o*w),f(this,Ks)||(l=P(this,We,Lg).call(this,m,g))}const y=new OffscreenCanvas(m,g).getContext("2d",{willReadFrequently:!0});y.drawImage(l,0,0,l.width,l.height,0,0,m,g),d={width:m,height:g,data:y.getImageData(0,0,m,g).data}}return{canvas:u,width:c,height:h,imageData:d}}getImageForAltText(){return f(this,vr)}static async deserialize(t,s,i){var g;let r=null;if(t instanceof wM){const{data:{rect:b,rotation:y,id:w,structParent:v,popupRef:x},container:k,parent:{page:{pageNumber:E}}}=t,T=k.querySelector("canvas"),O=i.imageManager.getFromCanvas(k.id,T);T.remove();const F=((g=await s._structTree.getAriaAttributes(`${gx}${w}`))==null?void 0:g.get("aria-label"))||"";r=t={annotationType:Ne.STAMP,bitmapId:O.id,bitmap:O.bitmap,pageIndex:E-1,rect:b.slice(0),rotation:y,id:w,deleted:!1,accessibilityData:{decorative:!1,altText:F},isSvg:!1,structParent:v,popupRef:x}}const o=await super.deserialize(t,s,i),{rect:a,bitmap:l,bitmapUrl:c,bitmapId:h,isSvg:u,accessibilityData:d}=t;h&&i.imageManager.isValidId(h)?($(o,On,h),l&&$(o,Nt,l)):$(o,co,c),$(o,Ks,u);const[p,m]=o.pageDimensions;return o.width=(a[2]-a[0])/p,o.height=(a[3]-a[1])/m,o.annotationElementId=t.id||null,d&&(o.altTextData=d),o._initialData=r,$(o,hu,!!r),o}serialize(t=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:Ne.STAMP,bitmapId:f(this,On),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:f(this,Ks),structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=P(this,We,Dg).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:r,altText:o}=this.serializeAltText(!1);if(!r&&o&&(i.accessibilityData={type:"Figure",alt:o}),this.annotationElementId){const l=P(this,We,hI).call(this,i);if(l.isSame)return null;l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,s===null)return i;s.stamps||(s.stamps=new Map);const a=f(this,Ks)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(f(this,On)))s.stamps.set(f(this,On),{area:a,serialized:i}),i.bitmap=P(this,We,Dg).call(this,!1);else if(f(this,Ks)){const l=s.stamps.get(f(this,On));a>l.area&&(l.area=a,l.serialized.bitmap.close(),l.serialized.bitmap=P(this,We,Dg).call(this,!1))}return i}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}};Nt=new WeakMap,On=new WeakMap,da=new WeakMap,co=new WeakMap,fa=new WeakMap,cu=new WeakMap,vr=new WeakMap,ho=new WeakMap,wr=new WeakMap,Ks=new WeakMap,hu=new WeakMap,We=new WeakSet,Ed=function(t,s=!1){if(!t){this.remove();return}$(this,Nt,t.bitmap),s||($(this,On,t.id),$(this,Ks,t.isSvg)),t.file&&$(this,cu,t.file.name),P(this,We,Uw).call(this)},Cd=function(){if($(this,da,null),this._uiManager.enableWaiting(!1),!!f(this,vr)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&f(this,Nt)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&f(this,Nt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Ng=function(){if(f(this,On)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(f(this,On)).then(i=>P(this,We,Ed).call(this,i,!0)).finally(()=>P(this,We,Cd).call(this));return}if(f(this,co)){const i=f(this,co);$(this,co,null),this._uiManager.enableWaiting(!0),$(this,da,this._uiManager.imageManager.getFromUrl(i).then(r=>P(this,We,Ed).call(this,r)).finally(()=>P(this,We,Cd).call(this)));return}if(f(this,fa)){const i=f(this,fa);$(this,fa,null),this._uiManager.enableWaiting(!0),$(this,da,this._uiManager.imageManager.getFromFile(i).then(r=>P(this,We,Ed).call(this,r)).finally(()=>P(this,We,Cd).call(this)));return}const t=document.createElement("input");t.type="file",t.accept=Qd.supportedTypesStr;const s=this._uiManager._signal;$(this,da,new Promise(i=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),P(this,We,Ed).call(this,r)}i()},{signal:s}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>P(this,We,Cd).call(this))),t.click()},Uw=function(){const{div:t}=this;let{width:s,height:i}=f(this,Nt);const[r,o]=this.pageDimensions,a=.75;if(this.width)s=this.width*r,i=this.height*o;else if(s>a*r||i>a*o){const u=Math.min(a*r/s,a*o/i);s*=u,i*=u}const[l,c]=this.parentDimensions;this.setDims(s*l/r,i*c/o),this._uiManager.enableWaiting(!1);const h=$(this,vr,document.createElement("canvas"));h.setAttribute("role","img"),this.addContainer(h),(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),P(this,We,Ww).call(this,s,i),P(this,We,cI).call(this),f(this,hu)||(this.parent.addUndoableEditor(this),$(this,hu,!0)),this._reportTelemetry({action:"inserted_image"}),f(this,cu)&&h.setAttribute("aria-label",f(this,cu))},lI=function(t,s){var a;const[i,r]=this.parentDimensions;this.width=t/i,this.height=s/r,(a=this._initialOptions)!=null&&a.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,f(this,wr)!==null&&clearTimeout(f(this,wr)),$(this,wr,setTimeout(()=>{$(this,wr,null),P(this,We,Ww).call(this,t,s)},200))},Lg=function(t,s){const{width:i,height:r}=f(this,Nt);let o=i,a=r,l=f(this,Nt);for(;o>2*t||a>2*s;){const c=o,h=a;o>2*t&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2)),a>2*s&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const u=new OffscreenCanvas(o,a);u.getContext("2d").drawImage(l,0,0,c,h,0,0,o,a),l=u.transferToImageBitmap()}return l},Ww=function(t,s){const i=new zv,r=Math.ceil(t*i.sx),o=Math.ceil(s*i.sy),a=f(this,vr);if(!a||a.width===r&&a.height===o)return;a.width=r,a.height=o;const l=f(this,Ks)?f(this,Nt):P(this,We,Lg).call(this,r,o),c=a.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(l,0,0,l.width,l.height,0,0,r,o)},Dg=function(t){if(t){if(f(this,Ks)){const r=this._uiManager.imageManager.getSvgUrl(f(this,On));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=f(this,Nt),s.getContext("2d").drawImage(f(this,Nt),0,0),s.toDataURL()}if(f(this,Ks)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*$a.PDF_TO_CSS_UNITS),o=Math.round(this.height*i*$a.PDF_TO_CSS_UNITS),a=new OffscreenCanvas(r,o);return a.getContext("2d").drawImage(f(this,Nt),0,0,f(this,Nt).width,f(this,Nt).height,0,0,r,o),a.transferToImageBitmap()}return structuredClone(f(this,Nt))},cI=function(){this._uiManager._signal&&($(this,ho,new ResizeObserver(t=>{const s=t[0].contentRect;s.width&&s.height&&P(this,We,lI).call(this,s.width,s.height)})),f(this,ho).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var t;(t=f(this,ho))==null||t.disconnect(),$(this,ho,null)},{once:!0}))},hI=function(t){var c;const{rect:s,pageIndex:i,accessibilityData:{altText:r}}=this._initialData,o=t.rect.every((h,u)=>Math.abs(h-s[u])<1),a=t.pageIndex===i,l=(((c=t.accessibilityData)==null?void 0:c.alt)||"")===r;return{isSame:o&&a&&l,isSameAltText:l}},ae(Qd,"_type","stamp"),ae(Qd,"_editorType",Ne.STAMP);let Vw=Qd;var rc,uu,_r,pa,uo,Zs,ma,du,fu,Qn,fo,ke,ga,Bn,uI,Kw,Zw,Xw,jg;const $i=class $i{constructor({uiManager:e,pageIndex:t,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:o,drawLayer:a,textLayer:l,viewport:c,l10n:h}){M(this,Bn);M(this,rc);M(this,uu,!1);M(this,_r,null);M(this,pa,null);M(this,uo,null);M(this,Zs,new Map);M(this,ma,!1);M(this,du,!1);M(this,fu,!1);M(this,Qn,null);M(this,fo,null);M(this,ke);const u=[...f($i,ga).values()];if(!$i._initialized){$i._initialized=!0;for(const d of u)d.initialize(h,e)}e.registerEditorTypes(u),$(this,ke,e),this.pageIndex=t,this.div=s,$(this,rc,r),$(this,_r,o),this.viewport=c,$(this,Qn,l),this.drawLayer=a,this._structTree=i,f(this,ke).addLayer(this)}get isEmpty(){return f(this,Zs).size===0}get isInvisible(){return this.isEmpty&&f(this,ke).getMode()===Ne.NONE}updateToolbar(e){f(this,ke).updateToolbar(e)}updateMode(e=f(this,ke).getMode()){switch(P(this,Bn,jg).call(this),e){case Ne.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Ne.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case Ne.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:t}=this.div;for(const s of f($i,ga).values())t.toggle(`${s._type}Editing`,e===s._editorType);this.div.hidden=!1}hasTextLayer(e){var t;return e===((t=f(this,Qn))==null?void 0:t.div)}addInkEditorIfNeeded(e){if(f(this,ke).getMode()!==Ne.INK)return;if(!e){for(const s of f(this,Zs).values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(e){f(this,ke).setEditingState(e)}addCommands(e){f(this,ke).addCommands(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){var t;(t=f(this,_r))==null||t.div.classList.toggle("disabled",!e)}async enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const e=new Set;for(const s of f(this,Zs).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(f(this,ke).removeChangedExistingAnnotation(s),e.add(s.annotationElementId));if(!f(this,_r))return;const t=f(this,_r).getEditableAnnotations();for(const s of t){if(s.hide(),f(this,ke).isDeletedAnnotationElement(s.data.id)||e.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){var i;$(this,fu,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,t=new Map;for(const r of f(this,Zs).values())if(r.disableEditing(),!!r.annotationElementId){if(r.serialize()!==null){e.set(r.annotationElementId,r);continue}else t.set(r.annotationElementId,r);(i=this.getEditableAnnotation(r.annotationElementId))==null||i.show(),r.remove()}if(f(this,_r)){const r=f(this,_r).getEditableAnnotations();for(const o of r){const{id:a}=o.data;if(f(this,ke).isDeletedAnnotationElement(a))continue;let l=t.get(a);if(l){l.resetAnnotationElement(o),l.show(!1),o.show();continue}l=e.get(a),l&&(f(this,ke).addChangedExistingAnnotation(l),l.renderAnnotationElement(o)&&l.show(!1)),o.show()}}P(this,Bn,jg).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of f($i,ga).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),$(this,fu,!1)}getEditableAnnotation(e){var t;return((t=f(this,_r))==null?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){f(this,ke).getActive()!==e&&f(this,ke).setActiveEditor(e)}enableTextSelection(){var e;if(this.div.tabIndex=-1,(e=f(this,Qn))!=null&&e.div&&!f(this,fo)){$(this,fo,new AbortController);const t=f(this,ke).combinedSignal(f(this,fo));f(this,Qn).div.addEventListener("pointerdown",P(this,Bn,uI).bind(this),{signal:t}),f(this,Qn).div.classList.add("highlighting")}}disableTextSelection(){var e;this.div.tabIndex=0,(e=f(this,Qn))!=null&&e.div&&f(this,fo)&&(f(this,fo).abort(),$(this,fo,null),f(this,Qn).div.classList.remove("highlighting"))}enableClick(){if(f(this,pa))return;$(this,pa,new AbortController);const e=f(this,ke).combinedSignal(f(this,pa));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:e})}disableClick(){var e;(e=f(this,pa))==null||e.abort(),$(this,pa,null)}attach(e){f(this,Zs).set(e.id,e);const{annotationElementId:t}=e;t&&f(this,ke).isDeletedAnnotationElement(t)&&f(this,ke).removeDeletedAnnotationElement(e)}detach(e){var t;f(this,Zs).delete(e.id),(t=f(this,rc))==null||t.removePointerInTextLayer(e.contentDiv),!f(this,fu)&&e.annotationElementId&&f(this,ke).addDeletedAnnotationElement(e)}remove(e){this.detach(e),f(this,ke).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1,f(this,du)||this.addInkEditorIfNeeded(!1)}changeParent(e){var t;e.parent!==this&&(e.parent&&e.annotationElementId&&(f(this,ke).addDeletedAnnotationElement(e.annotationElementId),ut.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),(t=e.parent)==null||t.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(!(e.parent===this&&e.isAttachedToDOM)){if(this.changeParent(e),f(this,ke).addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(),f(this,ke).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var s;if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&!f(this,uo)&&(e._focusEventsAllowed=!1,$(this,uo,setTimeout(()=>{$(this,uo,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:f(this,ke)._signal}),t.focus())},0))),e._structTreeParentId=(s=f(this,rc))==null?void 0:s.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||(e.parent=this),e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){const t=()=>e._uiManager.rebuild(e),s=()=>{e.remove()};this.addCommands({cmd:t,undo:s,mustExec:!1})}getNextId(){return f(this,ke).getId()}combinedSignal(e){return f(this,ke).combinedSignal(e)}canCreateNewEmptyEditor(){var e;return(e=f(this,Bn,Kw))==null?void 0:e.canCreateNewEmptyEditor()}pasteEditor(e,t){f(this,ke).updateToolbar(e),f(this,ke).updateMode(e);const{offsetX:s,offsetY:i}=P(this,Bn,Xw).call(this),r=this.getNextId(),o=P(this,Bn,Zw).call(this,{parent:this,id:r,x:s,y:i,uiManager:f(this,ke),isCentered:!0,...t});o&&this.add(o)}async deserialize(e){var t;return await((t=f($i,ga).get(e.annotationType??e.annotationEditorType))==null?void 0:t.deserialize(e,this,f(this,ke)))||null}createAndAddNewEditor(e,t,s={}){const i=this.getNextId(),r=P(this,Bn,Zw).call(this,{parent:this,id:i,x:e.offsetX,y:e.offsetY,uiManager:f(this,ke),isCentered:t,...s});return r&&this.add(r),r}addNewEditor(){this.createAndAddNewEditor(P(this,Bn,Xw).call(this),!0)}setSelected(e){f(this,ke).setSelected(e)}toggleSelected(e){f(this,ke).toggleSelected(e)}unselect(e){f(this,ke).unselect(e)}pointerup(e){const{isMac:t}=fs.platform;if(!(e.button!==0||e.ctrlKey&&t)&&e.target===this.div&&f(this,ma)){if($(this,ma,!1),!f(this,uu)){$(this,uu,!0);return}if(f(this,ke).getMode()===Ne.STAMP){f(this,ke).unselectAll();return}this.createAndAddNewEditor(e,!1)}}pointerdown(e){if(f(this,ke).getMode()===Ne.HIGHLIGHT&&this.enableTextSelection(),f(this,ma)){$(this,ma,!1);return}const{isMac:t}=fs.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div)return;$(this,ma,!0);const s=f(this,ke).getActive();$(this,uu,!s||s.isEmpty())}findNewParent(e,t,s){const i=f(this,ke).findParent(t,s);return i===null||i===this?!1:(i.changeParent(e),!0)}destroy(){var e,t;((e=f(this,ke).getActive())==null?void 0:e.parent)===this&&(f(this,ke).commitOrRemove(),f(this,ke).setActiveEditor(null)),f(this,uo)&&(clearTimeout(f(this,uo)),$(this,uo,null));for(const s of f(this,Zs).values())(t=f(this,rc))==null||t.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,f(this,Zs).clear(),f(this,ke).removeLayer(this)}render({viewport:e}){this.viewport=e,pc(this.div,e);for(const t of f(this,ke).getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:e}){f(this,ke).commitOrRemove(),P(this,Bn,jg).call(this);const t=this.viewport.rotation,s=e.rotation;if(this.viewport=e,pc(this.div,{rotation:s}),t!==s)for(const i of f(this,Zs).values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return f(this,ke).viewParameters.realScale}};rc=new WeakMap,uu=new WeakMap,_r=new WeakMap,pa=new WeakMap,uo=new WeakMap,Zs=new WeakMap,ma=new WeakMap,du=new WeakMap,fu=new WeakMap,Qn=new WeakMap,fo=new WeakMap,ke=new WeakMap,ga=new WeakMap,Bn=new WeakSet,uI=function(e){f(this,ke).unselectAll();const{target:t}=e;if(t===f(this,Qn).div||(t.getAttribute("role")==="img"||t.classList.contains("endOfContent"))&&f(this,Qn).div.contains(t)){const{isMac:s}=fs.platform;if(e.button!==0||e.ctrlKey&&s)return;f(this,ke).showAllEditors("highlight",!0,!0),f(this,Qn).div.classList.add("free"),this.toggleDrawing(),yy.startHighlighting(this,f(this,ke).direction==="ltr",{target:f(this,Qn).div,x:e.x,y:e.y}),f(this,Qn).div.addEventListener("pointerup",()=>{f(this,Qn).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:f(this,ke)._signal}),e.preventDefault()}},Kw=function(){return f($i,ga).get(f(this,ke).getMode())},Zw=function(e){const t=f(this,Bn,Kw);return t?new t.prototype.constructor(e):null},Xw=function(){const{x:e,y:t,width:s,height:i}=this.div.getBoundingClientRect(),r=Math.max(0,e),o=Math.max(0,t),a=Math.min(window.innerWidth,e+s),l=Math.min(window.innerHeight,t+i),c=(r+a)/2-e,h=(o+l)/2-t,[u,d]=this.viewport.rotation%180===0?[c,h]:[h,c];return{offsetX:u,offsetY:d}},jg=function(){$(this,du,!0);for(const e of f(this,Zs).values())e.isEmpty()&&e.remove();$(this,du,!1)},ae($i,"_initialized",!1),M($i,ga,new Map([Ew,Nw,Vw,yy].map(e=>[e._editorType,e])));let Gw=$i;var Sr,Rp,Qt,po,Mp,Jw,Ac,Qw,dI;const Rn=class Rn{constructor({pageIndex:e}){M(this,Ac);M(this,Sr,null);M(this,Rp,0);M(this,Qt,new Map);M(this,po,new Map);this.pageIndex=e}setParent(e){if(!f(this,Sr)){$(this,Sr,e);return}if(f(this,Sr)!==e){if(f(this,Qt).size>0)for(const t of f(this,Qt).values())t.remove(),e.append(t);$(this,Sr,e)}}static get _svgFactory(){return Ge(this,"_svgFactory",new Ex)}draw(e,t,s,i=!1){const r=os(this,Rp)._++,o=P(this,Ac,Qw).call(this,e.box);o.classList.add(...e.classNamesForDrawing);const a=Rn._svgFactory.createElement("defs");o.append(a);const l=Rn._svgFactory.createElement("path");a.append(l);const c=`path_p${this.pageIndex}_${r}`;l.setAttribute("id",c),l.setAttribute("d",e.toSVGPath()),i&&f(this,po).set(r,l);const h=P(this,Ac,dI).call(this,a,c),u=Rn._svgFactory.createElement("use");return o.append(u),o.setAttribute("fill",t),o.setAttribute("fill-opacity",s),u.setAttribute("href",`#${c}`),f(this,Qt).set(r,o),{id:r,clipPathId:`url(#${h})`}}drawOutline(e){const t=os(this,Rp)._++,s=P(this,Ac,Qw).call(this,e.box);s.classList.add(...e.classNamesForOutlining);const i=Rn._svgFactory.createElement("defs");s.append(i);const r=Rn._svgFactory.createElement("path");i.append(r);const o=`path_p${this.pageIndex}_${t}`;r.setAttribute("id",o),r.setAttribute("d",e.toSVGPath()),r.setAttribute("vector-effect","non-scaling-stroke");let a;if(e.mustRemoveSelfIntersections){const h=Rn._svgFactory.createElement("mask");i.append(h),a=`mask_p${this.pageIndex}_${t}`,h.setAttribute("id",a),h.setAttribute("maskUnits","objectBoundingBox");const u=Rn._svgFactory.createElement("rect");h.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const d=Rn._svgFactory.createElement("use");h.append(d),d.setAttribute("href",`#${o}`),d.setAttribute("stroke","none"),d.setAttribute("fill","black"),d.setAttribute("fill-rule","nonzero"),d.classList.add("mask")}const l=Rn._svgFactory.createElement("use");s.append(l),l.setAttribute("href",`#${o}`),a&&l.setAttribute("mask",`url(#${a})`);const c=l.cloneNode();return s.append(c),l.classList.add("mainOutline"),c.classList.add("secondaryOutline"),f(this,Qt).set(t,s),t}finalizeLine(e,t){const s=f(this,po).get(e);f(this,po).delete(e),this.updateBox(e,t.box),s.setAttribute("d",t.toSVGPath())}updateLine(e,t){f(this,Qt).get(e).firstChild.firstChild.setAttribute("d",t.toSVGPath())}updatePath(e,t){f(this,po).get(e).setAttribute("d",t.toSVGPath())}updateBox(e,t){var s;P(s=Rn,Mp,Jw).call(s,f(this,Qt).get(e),t)}show(e,t){f(this,Qt).get(e).classList.toggle("hidden",!t)}rotate(e,t){f(this,Qt).get(e).setAttribute("data-main-rotation",t)}changeColor(e,t){f(this,Qt).get(e).setAttribute("fill",t)}changeOpacity(e,t){f(this,Qt).get(e).setAttribute("fill-opacity",t)}addClass(e,t){f(this,Qt).get(e).classList.add(t)}removeClass(e,t){f(this,Qt).get(e).classList.remove(t)}getSVGRoot(e){return f(this,Qt).get(e)}remove(e){f(this,po).delete(e),f(this,Sr)!==null&&(f(this,Qt).get(e).remove(),f(this,Qt).delete(e))}destroy(){$(this,Sr,null);for(const e of f(this,Qt).values())e.remove();f(this,Qt).clear(),f(this,po).clear()}};Sr=new WeakMap,Rp=new WeakMap,Qt=new WeakMap,po=new WeakMap,Mp=new WeakSet,Jw=function(e,{x:t=0,y:s=0,width:i=1,height:r=1}={}){const{style:o}=e;o.top=`${100*s}%`,o.left=`${100*t}%`,o.width=`${100*i}%`,o.height=`${100*r}%`},Ac=new WeakSet,Qw=function(e){var s;const t=Rn._svgFactory.create(1,1,!0);return f(this,Sr).append(t),t.setAttribute("aria-hidden",!0),P(s=Rn,Mp,Jw).call(s,t,e),t},dI=function(e,t){const s=Rn._svgFactory.createElement("clipPath");e.append(s);const i=`clip_${t}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=Rn._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${t}`),r.classList.add("clip"),i},M(Rn,Mp);let Yw=Rn;Re.AbortException;Re.AnnotationEditorLayer;Re.AnnotationEditorParamsType;Re.AnnotationEditorType;Re.AnnotationEditorUIManager;var fI=Re.AnnotationLayer,pI=Re.AnnotationMode;Re.ColorPicker;Re.DOMSVGFactory;Re.DrawLayer;Re.FeatureTest;var N0=Re.GlobalWorkerOptions;Re.ImageKind;Re.InvalidPDFException;Re.MissingPDFException;Re.OPS;Re.OutputScale;var KZ=Re.PDFDataRangeTransport;Re.PDFDateString;Re.PDFWorker;Re.PasswordResponses;Re.PermissionFlag;Re.PixelsPerInch;Re.RenderingCancelledException;var mI=Re.TextLayer;Re.UnexpectedResponseException;Re.Util;Re.VerbosityLevel;Re.XfaLayer;Re.build;Re.createValidAbsoluteUrl;Re.fetchData;var gI=Re.getDocument;Re.getFilenameFromUrl;Re.getPdfFilenameFromUrl;Re.getXfaPageViewport;Re.isDataScheme;Re.isPdfFile;Re.noContextMenu;Re.normalizeUnicode;Re.setLayerDimensions;Re.shadow;var e_=Re.version;const ZZ=Object.freeze(Object.defineProperty({__proto__:null,AnnotationLayer:fI,AnnotationMode:pI,GlobalWorkerOptions:N0,PDFDataRangeTransport:KZ,TextLayer:mI,getDocument:gI,version:e_},Symbol.toStringTag,{value:"Module"}));var yn=function(n,e,t){if(t||arguments.length===2)for(var s=0,i=e.length,r;s{pt(this.pdfDocument),pt(e),typeof e=="string"?this.pdfDocument.getDestination(e).then(t):Array.isArray(e)?t(e):e.then(t)}).then(t=>{pt(Array.isArray(t));const s=t[0];new Promise(i=>{pt(this.pdfDocument),s instanceof Object?this.pdfDocument.getPageIndex(s).then(r=>{i(r)}).catch(()=>{pt(!1)}):typeof s=="number"?i(s):pt(!1)}).then(i=>{const r=i+1;pt(this.pdfViewer),pt(r>=1&&r<=this.pagesCount),this.pdfViewer.scrollPageIntoView({dest:t,pageIndex:i,pageNumber:r})})})}navigateTo(e){this.goToDestination(e)}goToPage(e){const t=e-1;pt(this.pdfViewer),pt(e>=1&&e<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:t,pageNumber:e})}addLinkAttributes(e,t,s){e.href=t,e.rel=this.externalLinkRel||bX,e.target=s?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const iE={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},L0=typeof window<"u",vI=L0&&window.location.protocol==="file:";function wX(n){return typeof n<"u"}function qa(n){return wX(n)&&n!==null}function _X(n){return typeof n=="string"}function SX(n){return n instanceof ArrayBuffer}function xX(n){return pt(L0),n instanceof Blob}function t_(n){return _X(n)&&/^data:/.test(n)}function rE(n){pt(t_(n));const[e="",t=""]=n.split(",");return e.split(";").indexOf("base64")!==-1?atob(t):unescape(t)}function kX(){return L0&&window.devicePixelRatio||1}const wI="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function oE(){ss(!vI,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${wI}`)}function AX(){ss(!vI,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${wI}`)}function yc(n){n!=null&&n.cancel&&n.cancel()}function n_(n,e){return Object.defineProperty(n,"width",{get(){return this.view[2]*e},configurable:!0}),Object.defineProperty(n,"height",{get(){return this.view[3]*e},configurable:!0}),Object.defineProperty(n,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(n,"originalHeight",{get(){return this.view[3]},configurable:!0}),n}function EX(n){return n.name==="RenderingCancelledException"}function CX(n){return new Promise((e,t)=>{const s=new FileReader;s.onload=()=>{if(!s.result)return t(new Error("Error while reading a file."));e(s.result)},s.onerror=i=>{if(!i.target)return t(new Error("Error while reading a file."));const{error:r}=i.target;if(!r)return t(new Error("Error while reading a file."));switch(r.code){case r.NOT_FOUND_ERR:return t(new Error("Error while reading a file: File not found."));case r.SECURITY_ERR:return t(new Error("Error while reading a file: Security error."));case r.ABORT_ERR:return t(new Error("Error while reading a file: Aborted."));default:return t(new Error("Error while reading a file."))}},s.readAsArrayBuffer(n)})}function $X(n,e){switch(e.type){case"RESOLVE":return{value:e.value,error:void 0};case"REJECT":return{value:!1,error:e.error};case"RESET":return{value:void 0,error:void 0};default:return n}}function wu(){return V.useReducer($X,{value:void 0,error:void 0})}var TX=function(n,e,t,s){function i(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function a(h){try{c(s.next(h))}catch(u){o(u)}}function l(h){try{c(s.throw(h))}catch(u){o(u)}}function c(h){h.done?r(h.value):i(h.value).then(a,l)}c((s=s.apply(n,e||[])).next())})},aE=function(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i{switch(e){case iE.NEED_PASSWORD:{const t=prompt("Enter the password to open this PDF file.");n(t);break}case iE.INCORRECT_PASSWORD:{const t=prompt("Invalid password. Please try again.");n(t);break}}};function lE(n){return typeof n=="object"&&n!==null&&("data"in n||"range"in n||"url"in n)}const MX=V.forwardRef(function(e,t){var{children:s,className:i,error:r="Failed to load PDF file.",externalLinkRel:o,externalLinkTarget:a,file:l,inputRef:c,imageResourcesPath:h,loading:u="Loading PDF…",noData:d="No PDF file specified.",onItemClick:p,onLoadError:m,onLoadProgress:g,onLoadSuccess:b,onPassword:y=RX,onSourceError:w,onSourceSuccess:v,options:x,renderMode:k,rotate:E}=e,T=aE(e,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[O,F]=wu(),{value:j,error:L}=O,[B,Z]=wu(),{value:q,error:H}=B,se=V.useRef(new vX),Q=V.useRef([]),Y=V.useRef(void 0),ye=V.useRef(void 0);l&&l!==Y.current&&lE(l)&&(ss(!ch(l,Y.current),`File prop passed to changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.`),Y.current=l),x&&x!==ye.current&&(ss(!ch(x,ye.current),`Options prop passed to changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.`),ye.current=x);const z=V.useRef({scrollPageIntoView:ze=>{const{dest:Qe,pageNumber:lt,pageIndex:tt=lt-1}=ze;if(p){p({dest:Qe,pageIndex:tt,pageNumber:lt});return}const Ft=Q.current[tt];if(Ft){Ft.scrollIntoView();return}ss(!1,`An internal link leading to page ${lt} was clicked, but neither was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to and handle navigating by yourself or ensure that all pages are rendered within .`)}});V.useImperativeHandle(t,()=>({linkService:se,pages:Q,viewer:z}),[]);function C(){v&&v()}function I(){L&&(ss(!1,L.toString()),w&&w(L))}function R(){F({type:"RESET"})}V.useEffect(R,[l,F]);const _=V.useCallback(()=>TX(this,void 0,void 0,function*(){if(!l)return null;if(typeof l=="string")return t_(l)?{data:rE(l)}:(oE(),{url:l});if(l instanceof PX)return{range:l};if(SX(l))return{data:l};if(L0&&xX(l))return{data:yield CX(l)};if(pt(typeof l=="object"),pt(lE(l)),"url"in l&&typeof l.url=="string"){if(t_(l.url)){const{url:ze}=l,Qe=aE(l,["url"]),lt=rE(ze);return Object.assign({data:lt},Qe)}oE()}return l}),[l]);V.useEffect(()=>{const ze=tm(_());return ze.promise.then(Qe=>{F({type:"RESOLVE",value:Qe})}).catch(Qe=>{F({type:"REJECT",error:Qe})}),()=>{yc(ze)}},[_,F]),V.useEffect(()=>{if(!(typeof j>"u")){if(j===!1){I();return}C()}},[j]);function A(){q&&(b&&b(q),Q.current=new Array(q.numPages),se.current.setDocument(q))}function N(){H&&(ss(!1,H.toString()),m&&m(H))}V.useEffect(function(){Z({type:"RESET"})},[Z,j]),V.useEffect(function(){if(!j)return;const Qe=x?Object.assign(Object.assign({},j),x):j,lt=gI(Qe);g&&(lt.onProgress=g),y&&(lt.onPassword=y);const tt=lt,Ft=tt.promise.then(qt=>{Z({type:"RESOLVE",value:qt})}).catch(qt=>{tt.destroyed||Z({type:"REJECT",error:qt})});return()=>{Ft.finally(()=>tt.destroy())}},[x,Z,j]),V.useEffect(()=>{if(!(typeof q>"u")){if(q===!1){N();return}A()}},[q]),V.useEffect(function(){se.current.setViewer(z.current),se.current.setExternalLinkRel(o),se.current.setExternalLinkTarget(a)},[o,a]);const W=V.useCallback((ze,Qe)=>{Q.current[ze]=Qe},[]),X=V.useCallback(ze=>{delete Q.current[ze]},[]),he=V.useMemo(()=>({imageResourcesPath:h,linkService:se.current,onItemClick:p,pdf:q,registerPage:W,renderMode:k,rotate:E,unregisterPage:X}),[h,p,q,W,k,E,X]),ie=V.useMemo(()=>yI(T,()=>q),[T,q]);function ge(){return S.jsx(bI.Provider,{value:he,children:s})}function at(){return l?q==null?S.jsx(hh,{type:"loading",children:typeof u=="function"?u():u}):q===!1?S.jsx(hh,{type:"error",children:typeof r=="function"?r():r}):ge():S.jsx(hh,{type:"no-data",children:typeof d=="function"?d():d})}return S.jsx("div",Object.assign({className:s0("react-pdf__Document",i),ref:c,style:{"--scale-factor":"1"}},ie,{children:at()}))});function _I(){return V.useContext(bI)}function SI(){for(var n=[],e=0;eLX(e),[e]),s=V.useMemo(()=>!D0(e)||AI(e)?null:e.children.map((i,r)=>S.jsx(CI,{node:i},r)),[e]);return S.jsx("span",Object.assign({className:n},t,{children:s}))}function j0(){return V.useContext(xI)}function DX(){const n=j0();pt(n);const{onGetStructTreeError:e,onGetStructTreeSuccess:t}=n,[s,i]=wu(),{value:r,error:o}=s,{customTextRenderer:a,page:l}=n;function c(){r&&t&&t(r)}function h(){o&&(ss(!1,o.toString()),e&&e(o))}return V.useEffect(function(){i({type:"RESET"})},[i,l]),V.useEffect(function(){if(a||!l)return;const d=tm(l.getStructTree()),p=d;return d.promise.then(m=>{i({type:"RESOLVE",value:m})}).catch(m=>{i({type:"REJECT",error:m})}),()=>yc(p)},[a,l,i]),V.useEffect(()=>{if(r!==void 0){if(r===!1){h();return}c()}},[r]),r?S.jsx(CI,{className:"react-pdf__Page__structTree structTree",node:r}):null}const cE=pI;function jX(n){const e=j0();pt(e);const t=Object.assign(Object.assign({},e),n),{_className:s,canvasBackground:i,devicePixelRatio:r=kX(),onRenderError:o,onRenderSuccess:a,page:l,renderForms:c,renderTextLayer:h,rotate:u,scale:d}=t,{canvasRef:p}=n;pt(l);const m=V.useRef(null);function g(){l&&a&&a(n_(l,d))}function b(x){EX(x)||(ss(!1,x.toString()),o&&o(x))}const y=V.useMemo(()=>l.getViewport({scale:d*r,rotation:u}),[r,l,u,d]),w=V.useMemo(()=>l.getViewport({scale:d,rotation:u}),[l,u,d]);V.useEffect(function(){if(!l)return;l.cleanup();const{current:k}=m;if(!k)return;k.width=y.width,k.height=y.height,k.style.width=`${Math.floor(w.width)}px`,k.style.height=`${Math.floor(w.height)}px`,k.style.visibility="hidden";const E={annotationMode:c?cE.ENABLE_FORMS:cE.ENABLE,canvasContext:k.getContext("2d",{alpha:!1}),viewport:y};i&&(E.background=i);const T=l.render(E),O=T;return T.promise.then(()=>{k.style.visibility="",g()}).catch(b),()=>yc(O)},[i,l,c,y,w]);const v=V.useCallback(()=>{const{current:x}=m;x&&(x.width=0,x.height=0)},[]);return V.useEffect(()=>v,[v]),S.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:SI(p,m),style:{display:"block",userSelect:"none"},children:h?S.jsx(DX,{}):null})}function FX(n){return"str"in n}function zX(){const n=j0();pt(n);const{customTextRenderer:e,onGetTextError:t,onGetTextSuccess:s,onRenderTextLayerError:i,onRenderTextLayerSuccess:r,page:o,pageIndex:a,pageNumber:l,rotate:c,scale:h}=n;pt(o);const[u,d]=wu(),{value:p,error:m}=u,g=V.useRef(null);ss(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10)===1,"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer");function b(){p&&s&&s(p)}function y(){m&&(ss(!1,m.toString()),t&&t(m))}V.useEffect(function(){d({type:"RESET"})},[o,d]),V.useEffect(function(){if(!o)return;const O=tm(o.getTextContent()),F=O;return O.promise.then(j=>{d({type:"RESOLVE",value:j})}).catch(j=>{d({type:"REJECT",error:j})}),()=>yc(F)},[o,d]),V.useEffect(()=>{if(p!==void 0){if(p===!1){y();return}b()}},[p]);const w=V.useCallback(()=>{r&&r()},[r]),v=V.useCallback(T=>{ss(!1,T.toString()),i&&i(T)},[i]);function x(){const T=g.current;T&&T.classList.add("selecting")}function k(){const T=g.current;T&&T.classList.remove("selecting")}const E=V.useMemo(()=>o.getViewport({scale:h,rotation:c}),[o,c,h]);return V.useLayoutEffect(function(){if(!o||!p)return;const{current:O}=g;if(!O)return;O.innerHTML="";const F=o.streamTextContent({includeMarkedContent:!0}),j={container:O,textContentSource:F,viewport:E},L=new mI(j),B=L;return L.render().then(()=>{const Z=document.createElement("div");Z.className="endOfContent",O.append(Z);const q=O.querySelectorAll('[role="presentation"]');if(e){let H=0;p.items.forEach((se,Q)=>{if(!FX(se))return;const Y=q[H];if(!Y)return;const ye=e(Object.assign({pageIndex:a,pageNumber:l,itemIndex:Q},se));Y.innerHTML=ye,H+=se.str&&se.hasEOL?2:1})}w()}).catch(v),()=>yc(B)},[e,v,w,o,a,l,p,E]),S.jsx("div",{className:s0("react-pdf__Page__textContent","textLayer"),onMouseUp:k,onMouseDown:x,ref:g})}function HX(){const n=_I(),e=j0();pt(e);const t=Object.assign(Object.assign({},n),e),{imageResourcesPath:s,linkService:i,onGetAnnotationsError:r,onGetAnnotationsSuccess:o,onRenderAnnotationLayerError:a,onRenderAnnotationLayerSuccess:l,page:c,pdf:h,renderForms:u,rotate:d,scale:p=1}=t;pt(h),pt(c),pt(i);const[m,g]=wu(),{value:b,error:y}=m,w=V.useRef(null);ss(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10)===1,"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations");function v(){b&&o&&o(b)}function x(){y&&(ss(!1,y.toString()),r&&r(y))}V.useEffect(function(){g({type:"RESET"})},[g,c]),V.useEffect(function(){if(!c)return;const F=tm(c.getAnnotations()),j=F;return F.promise.then(L=>{g({type:"RESOLVE",value:L})}).catch(L=>{g({type:"REJECT",error:L})}),()=>{yc(j)}},[g,c]),V.useEffect(()=>{if(b!==void 0){if(b===!1){x();return}v()}},[b]);function k(){l&&l()}function E(O){ss(!1,`${O}`),a&&a(O)}const T=V.useMemo(()=>c.getViewport({scale:p,rotation:d}),[c,d,p]);return V.useEffect(function(){if(!h||!c||!i||!b)return;const{current:F}=w;if(!F)return;const j=T.clone({dontFlip:!0}),L={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:F,l10n:null,page:c,structTreeLayer:null,viewport:j},B={annotations:b,annotationStorage:h.annotationStorage,div:F,imageResourcesPath:s,linkService:i,page:c,renderForms:u,viewport:j};F.innerHTML="";try{new fI(L).render(B),k()}catch(Z){E(Z)}return()=>{}},[b,s,i,c,h,u,T]),S.jsx("div",{className:s0("react-pdf__Page__annotations","annotationLayer"),ref:w})}var BX=function(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i{if(!ie)return null;let nn=1;const sn=_??hE;if(N||p){const Cn=ie.getViewport({scale:1,rotation:lt});N?nn=N/Cn.width:p&&(nn=p/Cn.height)}return sn*nn},[p,ie,lt,_,N]);V.useEffect(function(){return()=>{qa(ze)&&i&&A&&A(ze)}},[i,Q,ze,A]);function Ft(){if(O){if(!ie||!tt)return;O(n_(ie,tt))}if(i&&Y){if(!qa(ze)||!at.current)return;Y(ze,at.current)}}function qt(){ge&&(ss(!1,ge.toString()),T&&T(ge))}V.useEffect(function(){he({type:"RESET"})},[he,Q,ze]),V.useEffect(function(){if(!Q||!Qe)return;const sn=tm(Q.getPage(Qe)),Cn=sn;return sn.promise.then($n=>{he({type:"RESOLVE",value:$n})}).catch($n=>{he({type:"REJECT",error:$n})}),()=>yc(Cn)},[he,Q,Qe]),V.useEffect(()=>{if(ie!==void 0){if(ie===!1){qt();return}Ft()}},[ie,tt]);const bs=V.useMemo(()=>ie&&qa(ze)&&Qe&&qa(lt)&&qa(tt)?{_className:s,canvasBackground:r,customTextRenderer:h,devicePixelRatio:u,onGetAnnotationsError:y,onGetAnnotationsSuccess:w,onGetStructTreeError:v,onGetStructTreeSuccess:x,onGetTextError:k,onGetTextSuccess:E,onRenderAnnotationLayerError:F,onRenderAnnotationLayerSuccess:j,onRenderError:L,onRenderSuccess:B,onRenderTextLayerError:Z,onRenderTextLayerSuccess:q,page:ie,pageIndex:ze,pageNumber:Qe,renderForms:z,renderTextLayer:I,rotate:lt,scale:tt}:null,[s,r,h,u,y,w,v,x,k,E,F,j,L,B,Z,q,ie,ze,Qe,z,I,lt,tt]),js=V.useMemo(()=>yI(W,()=>ie&&(tt?n_(ie,tt):void 0)),[W,ie,tt]),tn=`${ze}@${tt}/${lt}`;function vs(){switch(C){case"custom":return pt(c),S.jsx(c,{},`${tn}_custom`);case"none":return null;case"canvas":default:return S.jsx(jX,{canvasRef:o},`${tn}_canvas`)}}function ws(){return I?S.jsx(zX,{},`${tn}_text`):null}function Fs(){return ye?S.jsx(HX,{},`${tn}_annotations`):null}function _s(){return S.jsxs(xI.Provider,{value:bs,children:[vs(),ws(),Fs(),a]})}function En(){return Qe?Q===null||ie===void 0||ie===null?S.jsx(hh,{type:"loading",children:typeof g=="function"?g():g}):Q===!1||ie===!1?S.jsx(hh,{type:"error",children:typeof d=="function"?d():d}):_s():S.jsx(hh,{type:"no-data",children:typeof b=="function"?b():b})}return S.jsx("div",Object.assign({className:s0(s,l),"data-page-number":Qe,ref:SI(m,at),style:{"--scale-factor":`${tt}`,backgroundColor:r||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},js,{children:En()}))}AX();N0.workerSrc="pdf.worker.mjs";const VX="/assets/pdf.worker.min-GB3t0DcA.js";N0.workerSrc=VX;function UX(){if(!N0.workerSrc)throw new Error("The bundled PDF worker is not configured.");if(e_!=="4.8.69")throw new Error(`PDF runtime version mismatch (${e_}).`)}const WX=280,GX=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","A"]);function KX({enabled:n,pagesRoot:e,routeId:t,paperVersion:s,numPages:i,onSelect:r,onError:o}){const a=V.useRef(!1),l=V.useRef(!1),c=V.useRef(""),h=V.useRef(0),u=V.useRef(0),d=V.useRef(""),p=V.useRef(r),m=V.useRef(o);p.current=r,m.current=o,V.useEffect(()=>{a.current=!1,l.current=!1,c.current="",d.current="",window.clearTimeout(h.current),cancelAnimationFrame(u.current),u.current=0},[t,s]),V.useEffect(()=>{if(!n){a.current=!1,l.current=!1,window.clearTimeout(h.current),cancelAnimationFrame(u.current),u.current=0;return}const g=()=>{var O,F;const E=NL({selection:window.getSelection(),pagesRoot:e.current,routeId:t,paperVersion:s,numPages:i});if(!E.ok){E.error&&((O=m.current)==null||O.call(m,E.error));return}const T=LL(E.selection);T!==c.current&&(c.current=T,(F=p.current)==null||F.call(p,E.selection))},b=()=>{window.clearTimeout(h.current),cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{u.current=0,g()})},y=E=>{const T=e.current;!T||!E.isPrimary||E.pointerType==="mouse"&&E.button!==0||!(E.target instanceof Node)||!T.contains(E.target)||(a.current=!0,l.current=!1,c.current="",window.clearTimeout(h.current),cancelAnimationFrame(u.current),u.current=0)},w=E=>{!a.current||!E.isPrimary||(a.current=!1,b())},v=E=>{!a.current||!E.isPrimary||(a.current=!1,l.current=!0,d.current="",window.clearTimeout(h.current),cancelAnimationFrame(u.current),u.current=0)},x=E=>{var j,L;const T=e.current;if(!T||a.current||!(E.target instanceof Node&&!!((L=(j=E.target instanceof Element?E.target:E.target.parentElement)==null?void 0:j.closest)!=null&&L.call(j,".textLayer, .reader-web-document")&&T.contains(E.target))))return;const F=(E.key==="a"||E.key==="A")&&(E.metaKey||E.ctrlKey);(E.shiftKey||GX.has(E.key)||F)&&(l.current=!1,c.current="",b())},k=()=>{if(a.current||l.current)return;const E=window.getSelection(),T=E&&E.rangeCount===1?`${E.toString()}\0${E.anchorNode?1:0}\0${E.focusNode?1:0}`:"";d.current=T,window.clearTimeout(h.current),h.current=window.setTimeout(()=>{d.current===T&&g()},WX)};return document.addEventListener("pointerdown",y,!0),document.addEventListener("pointerup",w,!0),document.addEventListener("pointercancel",v,!0),document.addEventListener("keyup",x,!0),document.addEventListener("selectionchange",k),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("pointerup",w,!0),document.removeEventListener("pointercancel",v,!0),document.removeEventListener("keyup",x,!0),document.removeEventListener("selectionchange",k),window.clearTimeout(h.current),cancelAnimationFrame(u.current)}},[n,i,e,s,t])}function uE(n){let e;try{e=new URL(n)}catch{return null}if(!["http:","https:"].includes(e.protocol)||!/^(www\.)?arxiv\.org$/i.test(e.hostname))return null;const t=e.pathname.match(/^\/(?:abs|pdf|html)\/(\d{4}\.\d{4,5}|[a-z-]+(?:\.[A-Z]{2})?\/\d{7})(?:v\d+)?(?:\.pdf)?\/?$/i);return(t==null?void 0:t[1])??null}const ZX=8,XX=12,YX=300,JX=6;function QX(n){const e=n.replace(/^\s*\[[^\]]{1,6}\]\s*/,"").split(/[.?!](?=\s|$|[A-Z])/).map(o=>o.replace(/\s+/g," ").trim()).filter(Boolean),t=o=>o.length<=YX&&o.split(" ").length>=3&&/[a-z]/i.test(o)&&!/https?:\/\//i.test(o)&&!/^arxiv preprint/i.test(o),s=(o,a)=>a.length-o.length,i=e.filter(t).sort(s),r=e.slice(0,-1).map((o,a)=>`${o}. ${e[a+1]}`).filter(t).sort(s);return[...new Set([...i,...r])].slice(0,ZX)}function eY(n){const e=[];let t;for(const s of n){if(!("str"in s))continue;const i=s.transform[5];(!t||Math.abs(i-t.baseline)>1)&&(t={text:"",x:s.transform[4],baseline:i},e.push(t)),t.text+=s.str,s.hasEOL&&(t=void 0)}return e.map(s=>({...s,text:s.text.trim()})).filter(s=>s.text)}function s_([n,e,t,s]){return{x:i=>Math.round((i-n)/(t-n)*1e3),y:i=>Math.round((s-i)/(s-e)*1e3)}}const tY=/\[(\d{1,3}(?:\s*[,;\u2013-]\s*\d{1,3})*)\]/g;function nY(n){return n.split(/[,;]/).flatMap(e=>{const[t,s=t]=e.split(/[\u2013-]/).map(Number);return s>=t&&s-t<50?Array.from({length:s-t+1},(i,r)=>t+r):[t]})}function sY(n,e){const t=s_(e),s=new Map,i=[];let r;for(const o of n)"str"in o&&((!r||Math.abs(o.transform[5]-r.parts[0].item.transform[5])>1)&&(r={text:"",parts:[]},i.push(r)),r.parts.push({start:r.text.length,item:o}),r.text+=o.str,o.hasEOL&&(r=void 0));for(const{text:o,parts:a}of i){const l=h=>a.filter(u=>u.start<=h).pop()??a[0],c=h=>{const{start:u,item:d}=l(h);return d.transform[4]+d.width*Math.min(1,(h-u)/Math.max(d.str.length,1))};for(const h of o.matchAll(tY)){const u=h.index??0,{item:d}=l(u),p=d.transform[5],m=d.height||Math.abs(d.transform[3]),g=[t.x(c(u)),t.y(p+m),t.x(c(u+h[0].length)),t.y(p)+3];for(const b of nY(h[1]))s.set(b,[...s.get(b)??[],g])}}return s}function iY(n,e){let t;const s=new Map,i=new Map,r=new Map;let o,a;const l=x=>{let k=i.get(x);return k||(k=n.getPage(x).then(async E=>({view:E.view,content:await E.getTextContent()})),i.set(x,k)),k},c=x=>{let k=s.get(x);return k||(k=n.getPage(x).then(E=>E.getAnnotations()),s.set(x,k)),k},h=()=>t??(t=(async()=>{var E;const x=await n.getDestinations(),k=[];for(const[T,O]of Object.entries(x)){if(!/^cite[.:]/i.test(T)||((E=O[1])==null?void 0:E.name)!=="XYZ"||typeof O[2]!="number"||typeof O[3]!="number")continue;const F=typeof O[0]=="number"?O[0]+1:await n.getPageIndex(O[0])+1;k.push({name:T,page:F,x:O[2],y:O[3]})}return k.length?k:u()})()),u=async()=>{var E;const x=[];for(let T=Math.max(1,n.numPages-XX+1);T<=n.numPages;T++)x.push(...eY((await l(T)).content.items).map(O=>({...O,page:T})));const k=x.flatMap((T,O)=>/^(?:[\dIVX]+\.?\s*)?(?:references|bibliography)$/i.test(T.text)?[O]:[]);for(const T of k.reverse()){const O=[];let F=0;for(const j of x.slice(T+1)){const L=Number((E=j.text.match(/^\[(\d{1,3})\]/))==null?void 0:E[1]);L>F&&L<=F+3&&(F=L,O.push({name:`text:${L}`,page:j.page,x:j.x,y:j.baseline}))}if(O.length)return O}return[]},d=x=>{let k=r.get(x);return k||(k=(async()=>{const E=await h(),T=E.find(C=>C.name===x);if(!T)return null;const O=E.filter(C=>C.page===T.page),F=O.filter(C=>Math.abs(C.x-T.x)<24),j=Math.max(0,...F.filter(C=>C.yC.y)),L=Math.min(1/0,...O.filter(C=>C.x>T.x+24).map(C=>C.x-4)),B=new Set,Z=(C,I)=>C>=T.x-4&&Cj;for(const C of await c(T.page)){if(!C.url||!C.rect)continue;const I=uE(C.url);if(!I)continue;const[R,_,A,N]=C.rect;Z((R+A)/2,(_+N)/2)&&B.add(I)}const{view:q,content:H}=await l(T.page),se=H.items.filter(C=>"str"in C&&Z(C.transform[4],C.transform[5])),Q=se.map(C=>C.str+(C.hasEOL?" ":"")).join(""),Y=se.filter(C=>C.str.trim()).sort((C,I)=>I.transform[5]-C.transform[5]),ye=Y.findIndex((C,I)=>I>0&&Y[I-1].transform[5]-C.transform[5]>2.5*Math.max(Math.abs(C.transform[3]),1));ye>0&&(Y.length=ye);let z=null;if(Y.length){const{x:C,y:I}=s_(q);z=[C(Math.min(...Y.map(R=>R.transform[4]))),I(Math.max(...Y.map(R=>R.transform[5]+R.height))),C(Math.max(...Y.map(R=>R.transform[4]+R.width))),I(Math.min(...Y.map(R=>R.transform[5])))+3]}for(const C of Q.replace(/\s/g,"").matchAll(/(?:arxiv:|arxiv\.org\/(?:abs|pdf|html)\/)(\d{4}\.\d{4,5}|[a-z-]+(?:\.[A-Z]{2})?\/\d{7})(?:v\d+)?/gi))B.add(C[1]);return{arxivId:B.size===1?[...B][0]:null,titles:QX(Q),box:z}})(),r.set(x,k)),k},p=()=>o??(o=(async()=>{const x=new Map;if(!e)return x;try{const k=await h(),E=[];for(const T of k){const O=await d(T.name);O&&(O.arxivId||O.titles.length)&&E.push({key:T.name,arxiv_id:O.arxivId,titles:O.titles})}return E.length?await e(E):x}catch{return x}})()),m=()=>a??(a=(async()=>{const x=new Map,k=(Z,q,H)=>{const se=x.get(Z)??[],Q=se[se.length-1],Y=Q==null?void 0:Q[Q.length-1];(Y==null?void 0:Y.page)===q&&Math.abs(Y.bbox[1]-H[1])<5&&H[0]>=Y.bbox[0]&&H[0]-Y.bbox[2]<15?Y.bbox=[Y.bbox[0],Math.min(Y.bbox[1],H[1]),Math.max(Y.bbox[2],H[2]),Math.max(Y.bbox[3],H[3])]:(Y==null?void 0:Y.page)===q&&H[1]>Y.bbox[1]&&H[1]-Y.bbox[3]<10&&H[0]{if(O){const{view:Q,content:Y}=await l(Z),ye=Z"str"in z&&z.transform[5]>T.y+1);return[...sY(ye,Q)].flatMap(([z,C])=>C.map(I=>[`text:${z}`,I]))}const q=(await c(Z)).filter(Q=>typeof Q.dest=="string"&&/^cite[.:]/i.test(Q.dest));if(!q.length)return[];const{x:H,y:se}=s_((await n.getPage(Z)).view);return q.flatMap(({dest:Q,rect:Y})=>Y?[[Q,[H(Y[0]),se(Y[3]),H(Y[2]),se(Y[1])]]]:[])},j=O?T.page:n.numPages,L=[],B=Z=>L[Z]??(L[Z]=F(Z).catch(()=>[]));for(let Z=1;Z<=j;Z++){for(let q=Z+1;q<=Math.min(j,Z+JX);q++)B(q);for(const[q,H]of await B(Z))k(q,Z,H)}return x})());e&&p();const g=async x=>{const k=await d(x);return k?k.arxivId??(await p()).get(x)??null:null};return Object.assign(async x=>x.url?uE(x.url):typeof x.dest!="string"||!/^cite[.:]/i.test(x.dest)?null:g(x.dest),{bibliographyLinks:async x=>{const k=(await h()).filter(T=>T.page===x);return(await Promise.all(k.map(async({name:T})=>{const[O,F]=await Promise.all([d(T),g(T)]);return O!=null&&O.box&&F?{name:T,routeId:F,box:O.box}:null}))).filter(T=>T!==null)},citationsOf:async x=>(await m()).get(x)??[],referenceOf:async x=>{var T;const k=(await h()).find(O=>O.name===x),E=k&&((T=await d(x))==null?void 0:T.box);return E?{page:k.page,bbox:E}:null}})}const rY=3,oY=6;function aY(n,e){let t=0,s=0;return n.querySelectorAll(".pdf-outline-tick").forEach((i,r)=>{const o=i.getBoundingClientRect(),a=o.top+o.height/2;(r===0||Math.abs(a-e){if(!i)return;const v=x=>{x.key==="Escape"&&(x.preventDefault(),r(!1))};return window.addEventListener("keydown",v,{capture:!0}),()=>window.removeEventListener("keydown",v,{capture:!0})},[i]);const u=o==null?void 0:o.position;if(V.useEffect(()=>{const v=h.current,x=u===void 0?null:v==null?void 0:v.querySelectorAll("li")[u];!v||!x||(v.scrollTop=x.offsetTop+x.offsetHeight/2-v.clientHeight/2)},[u]),!n.length)return null;const d=v=>{const{position:x,center:k}=aY(v.currentTarget,v.clientY),E=k-v.currentTarget.parentElement.getBoundingClientRect().top;a({position:x,top:E,dragged:c.current})},p=()=>{l.current=null,a(null)},m=v=>{var x,k;c.current=!1,v.pointerType!=="mouse"&&((k=(x=v.currentTarget).setPointerCapture)==null||k.call(x,v.pointerId),l.current=v.clientY,d(v))},g=v=>{if(v.pointerType!=="mouse"){if(l.current===null)return;Math.abs(v.clientY-l.current)>oY&&(c.current=!0)}d(v)},b=v=>{v.pointerType!=="mouse"&&(c.current&&o&&(v.currentTarget.blur(),r(!1),t(n[o.position])),p())},y=v=>o?Math.max(0,1-Math.abs(v-o.position)/rY):0,w=o!=null&&o.dragged&&!i?n[o.position]:null;return S.jsxs("nav",{className:`pdf-outline${i?" is-pinned":""}`,"aria-label":"Paper sections",children:[S.jsx("button",{type:"button",className:"pdf-outline-rail","aria-label":"Table of contents","aria-expanded":i,"aria-controls":s,onClick:()=>{if(c.current){c.current=!1;return}r(v=>!v)},onPointerDown:m,onPointerMove:g,onPointerUp:b,onPointerCancel:()=>{c.current=!1,p()},onPointerLeave:v=>{v.pointerType==="mouse"&&p()},children:n.map((v,x)=>S.jsx("span",{className:`pdf-outline-tick level-${v.level}${v.index===e?" is-active":""}${(o==null?void 0:o.position)===x?" is-scrubbed":""}`,style:{"--pop":y(x)}},v.index))}),w&&S.jsx("span",{className:"pdf-outline-scrub-label",style:{top:o.top},"aria-hidden":"true",children:w.title}),S.jsx("div",{id:s,ref:h,className:"pdf-outline-panel",children:S.jsx("ol",{children:n.map((v,x)=>S.jsx("li",{className:`level-${v.level}`,children:S.jsx("a",{className:(o==null?void 0:o.position)===x?"is-scrubbed":void 0,href:`#pdf-section-${v.index}`,"aria-current":v.index===e?"location":void 0,onClick:k=>{k.preventDefault(),k.currentTarget.blur(),r(!1),t(v)},children:v.title})},v.index))})})]})}function cY({index:n,count:e,onStep:t,onClose:s}){return S.jsxs("div",{className:"pdf-citation-steps",role:"group","aria-label":"Citations of this reference",children:[S.jsxs("span",{role:"status",children:["Citation ",n+1," of ",e]}),S.jsx("button",{type:"button",onClick:()=>t(-1),"aria-label":"Previous citation",title:"Previous citation",children:S.jsx(GC,{size:16,"aria-hidden":"true"})}),S.jsx("button",{type:"button",onClick:()=>t(1),"aria-label":"Next citation",title:"Next citation",children:S.jsx(KC,{size:16,"aria-hidden":"true"})}),S.jsx("button",{type:"button",onClick:s,"aria-label":"Close citations",title:"Close citations",children:S.jsx(n0,{size:16,"aria-hidden":"true"})})]})}function hY({anchor:n,routeId:e,internal:t,dest:s,onShowReference:i}){V.useEffect(()=>{const a=n.style.display;return n.style.display="none",()=>{n.style.display=a}},[n]);const r=n.parentElement;if(!r)return null;const o=()=>{if(!s||!i)return n.click();i(s).then(a=>{a||n.click()})};return kL.createPortal(S.jsx(r0,{routeId:e,to:n.href,target:t?void 0:"_blank",className:"pdf-paper-preview-link",title:/^\d+$/.test(e)?"Preview paper":`Preview arXiv:${e}`,ariaLabel:`${t?"Citation":"arXiv paper"} ${e}`,cardOpensPaper:!0,onClick:t?a=>{a.preventDefault(),o()}:void 0,previewFooter:()=>S.jsxs("div",{className:"pdf-paper-preview-actions",children:[S.jsx("a",{href:`/paper/${encodeURIComponent(e)}`,target:"_blank",rel:"noopener noreferrer",children:"Open paper ↗"}),t&&S.jsx("button",{type:"button",onClick:o,children:"Jump to reference"})]}),children:null}),r)}function uY({routeId:n,box:[e,t,s,i],citations:r=[],onShowCitations:o}){return S.jsx("div",{className:"pdf-bibliography-link",style:{left:`${e/10}%`,top:`${t/10}%`,width:`${(s-e)/10}%`,height:`${(i-t)/10}%`},children:S.jsx(r0,{routeId:n,to:`/paper/${encodeURIComponent(n)}`,target:"_blank",className:"pdf-paper-preview-link",title:/^\d+$/.test(n)?"Preview paper":`Preview arXiv:${n}`,ariaLabel:`Reference ${n}`,cardOpensPaper:!0,previewFooter:()=>S.jsxs("div",{className:"pdf-paper-preview-actions",children:[S.jsx("a",{href:`/paper/${encodeURIComponent(n)}`,target:"_blank",rel:"noopener noreferrer",children:"Open paper ↗"}),r.length>0&&o&&S.jsx("button",{type:"button",onClick:()=>o(r),children:r.length>1?`Jump to citations (${r.length})`:"Jump to citation"})]}),children:null})})}const dY=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function fY({id:n,name:e,avatarUrl:t,box:[s,i,r,o]}){var p,m,g,b;const[a,l]=V.useState(!1),c=`/authors/${encodeURIComponent(n)}`,h=yo({queryKey:["author",n],queryFn:()=>nD.getAuthor(n),enabled:a,staleTime:5*60*1e3,retry:!1}),u=(p=h.data)==null?void 0:p.paper_count,d=(m=h.data)==null?void 0:m.hf_username;return S.jsx("div",{className:"pdf-author-link",style:{left:`${s/10}%`,top:`${i/10}%`,width:`${(r-s)/10}%`,height:`${(o-i)/10}%`},children:S.jsxs(Ip,{open:a,onOpenChange:y=>{(!y||!dY())&&l(y)},openDelay:150,closeDelay:100,children:[S.jsx(Op,{asChild:!0,children:S.jsx(Md,{to:c,target:"_blank",rel:"noopener noreferrer","aria-label":`Author ${e}`,onClick:()=>l(!1)})}),S.jsxs(Np,{className:"paper-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:[S.jsxs(Md,{className:"pdf-author-card",to:c,target:"_blank",rel:"noopener noreferrer",onClick:()=>l(!1),children:[S.jsx(tD,{url:((g=h.data)==null?void 0:g.hf_avatar_url)??t,className:"pdf-author-card-avatar"}),S.jsxs("div",{className:"pdf-author-card-meta",children:[S.jsx("div",{className:"paper-preview-title",children:((b=h.data)==null?void 0:b.full_name)??e}),S.jsxs("div",{className:"paper-preview-auth",children:[u!=null&&`${u.toLocaleString()} ${u===1?"paper":"papers"}`,u!=null&&d&&" · ",d&&`@${d}`]})]})]}),S.jsx("div",{className:"pdf-paper-preview-actions",children:S.jsx(Md,{to:c,target:"_blank",rel:"noopener noreferrer",onClick:()=>l(!1),children:"Open author page ↗"})})]})]})})}const dE=0,pY=1,Gc=2,$d=3,mY=4,gY=2,yY={ł:"l",ø:"o",đ:"d",ð:"d",ı:"i",ß:"ss",æ:"ae",œ:"oe",þ:"th"};function $x(n){return n.normalize("NFKD").toLocaleLowerCase().replace(/[^\p{L}]/gu,"").replace(/[łøđðıßæœþ]/g,e=>yY[e])}function bY(n){return/[\p{M}\p{Sk}'’ʼ\-‐‑]/u.test(n)?pY:/[\s.]/u.test(n)?Gc:$d}function vY(n){const e=n.map(s=>({letters:$x(s),capitalized:new RegExp("^\\P{L}*\\p{Lu}","u").test(s)})).filter(s=>s.letters),t=e.reduce((s,i)=>s+i.letters.length,0);return e.length>=2&&t>=mY?e:null}function wY(n){const e=new Map;for(const t of n){const s=t.name.split(/[\s.]+/).filter(Boolean),i=s.filter((o,a)=>a===0||a===s.length-1||$x(o).length>1),r=new Set;for(const o of[s,i]){const a=vY(o);if(!a)continue;const l=a.map(h=>h.letters).join(" ");if(r.has(l))continue;r.add(l);const c=e.get(l);e.set(l,c===void 0?{authorId:t.id,words:a}:(c==null?void 0:c.authorId)===t.id?c:null)}}return[...e.values()].filter(t=>t!==null)}function _Y(n,e){const t=wY(e);if(!t.length)return[];const s=[],i=[],r=[],o=[],a=[],l=[];let c=$d,h=!1;n.forEach((b,y)=>{y>0&&b.item!==n[y-1].item&&(c=Math.max(c,Gc));for(let w=0;w{if(!u.startsWith(y.letters,b)||y.capitalized&&!i[b])return!1;for(let w=b+1;wr[b]===Gc&&i[b]&&r[b+1]===Gc,m=(b,y)=>{if(r[y]0){if(r[w]===dE||r[w]===$d)return-1;for(let k=0;k=Gc&&!o[w]?w:-1},g=[];for(const b of t){const y=b.words[0].letters;for(let w=u.indexOf(y);w>=0;w=u.indexOf(y,w+1)){const v=m(b,w);v>w&&!g.some(x=>x.authorId===b.authorId&&x.from===w)&&g.push({authorId:b.authorId,start:a[w],end:l[v-1],from:w,to:v})}}return g.filter(b=>!g.some(y=>y.authorId!==b.authorId&&y.from=b.to-b.from)).sort((b,y)=>b.from-y.from).map(({authorId:b,start:y,end:w})=>({authorId:b,start:y,end:w}))}function SY(n,e){const t=n.querySelector(".textLayer");if(!t||!e.length)return[];const s=[],i=[],r=new Map,o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let c=o.nextNode();c;c=o.nextNode()){const h=c.parentElement,u=(h==null?void 0:h.tagName)==="MARK"?h.parentElement:h;u&&(r.has(u)||r.set(u,r.size),s.push(c),i.push({text:c.data,item:r.get(u)}))}const a=n.getBoundingClientRect();if(!a.width||!a.height)return[];const l=(c,h,u)=>Math.round((c-h)/u*1e3);return _Y(i,e).flatMap(({authorId:c,start:h,end:u})=>{const d=document.createRange();d.setStart(s[h.run],h.offset),d.setEnd(s[u.run],u.offset);const p=[];for(const m of d.getClientRects()){if(!m.width||!m.height)continue;const g=p.find(b=>m.top({authorId:c,box:[l(m.left,a.left,a.width),l(m.top,a.top,a.height),l(m.right,a.left,a.width),l(m.bottom,a.top,a.height)]}))})}function xY(n,e,t,s){const i=V.useRef([]),r=V.useRef(0),[o,a]=V.useState([]);V.useEffect(()=>()=>{r.current+=1},[]);const l=V.useCallback(h=>{i.current=h},[]),c=V.useCallback(()=>{var d;const h=++r.current;if(a([]),!t)return;const u=new Map(Array.from(((d=n.current)==null?void 0:d.querySelectorAll("[data-annotation-id] a:not(.pdf-paper-preview-link)"))??[]).map(p=>{var m;return[(m=p.parentElement)==null?void 0:m.dataset.annotationId,p]}));Promise.all(i.current.map(async p=>{const m=u.get(p.id);if(!m)return null;const g=await t(p).catch(()=>null);return g?{anchor:m,routeId:g,internal:!p.url,dest:typeof p.dest=="string"?p.dest:void 0}:null})).then(p=>{if(r.current!==h)return;const m=p.filter(g=>g!==null&&g.anchor.isConnected);m.length&&(s==null||s([...new Set(m.map(g=>g.routeId))])),a(m)})},[s,n,t]);return V.useEffect(()=>{const h=n.current;if(!h||!e||!t)return;let u=requestAnimationFrame(c);const d=new MutationObserver(p=>{p.some(m=>[...m.addedNodes].some(g=>g instanceof Element&&g.matches(".linkAnnotation")))&&(cancelAnimationFrame(u),u=requestAnimationFrame(c))});return d.observe(h,{childList:!0,subtree:!0}),()=>{d.disconnect(),cancelAnimationFrame(u),r.current+=1}},[c,n,t,e]),{paperLinks:o,onAnnotations:l}}const kY=6;function AY(n){const e=new Map,t=i=>{let r=e.get(i);return r||(r=n.getPage(i).then(o=>o.getTextContent()).then(o=>o.items.map(a=>"str"in a?a.str:"").join(" ").toLocaleLowerCase()),r.catch(()=>e.delete(i)),e.set(i,r)),r};async function*s(){for(let i=1;i<=n.numPages;i+=1){const r=Math.min(n.numPages,i+kY);for(let o=i+1;o<=r;o+=1)t(o).catch(()=>{});yield[i,await t(i).catch(()=>"")]}}return{pageText:t,pages:s}}function EY(n,e){let t=0;for(let s=n.indexOf(e);s>=0;s=n.indexOf(e,s+e.length))t+=1;return t}function td(n){return n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e]??e)}function CY(n,e,t){const s=e.trim().toLocaleLowerCase();if(!s)return td(n);const i=n.toLocaleLowerCase(),r=`pdf-search-highlight${t?" is-active":""}`;let o=0,a=i.indexOf(s);if(a<0)return td(n);let l="";for(;a>=0;)l+=td(n.slice(o,a)),l+=`${td(n.slice(a,a+s.length))}`,o=a+s.length,a=i.indexOf(s,o);return l+td(n.slice(o))}function $Y(n,e){const t=V.useRef(),s=V.useRef(0),[i,r]=V.useState(!1),[o,a]=V.useState(""),[l,c]=V.useState(""),[h,u]=V.useState(!1),[d,p]=V.useState([]),[m,g]=V.useState(0),b=V.useCallback(v=>{t.current=AY(v)},[]),y=V.useCallback(()=>{s.current+=1,r(!1),a(""),c(""),p([]),g(0),u(!1)},[]);return V.useEffect(()=>{const v=t.current;if(!i||!v)return;const x=v.pages();(async()=>{for(;t.current===v&&!(await x.next()).done;);})().catch(()=>{})},[n,i]),V.useEffect(()=>{const v=t.current,x=o.trim().toLocaleLowerCase(),k=++s.current;if(!v||!x){c(""),p([]),g(0),u(!1);return}u(!0);const E=window.setTimeout(()=>void(async()=>{c(o.trim()),p([]),g(0);const T=[];for await(const[O,F]of v.pages()){if(s.current!==k)return;const j=EY(F,x);if(j){T.length||e(O);for(let L=0;L{s.current===k&&u(!1)}),120);return()=>window.clearTimeout(E)},[o,n]),{open:i,setOpen:r,query:o,setQuery:a,highlightQuery:l,searching:h,matches:d,activeMatch:m,close:y,navigate:v=>{if(!d.length)return;const x=(m+v+d.length)%d.length;g(x),e(d[x])},indexDocument:b}}const TY=16e6;function PY(n,e){const t=Math.sqrt(TY/(n*n*e));return Math.min(window.devicePixelRatio||1,2,t)}function RY({page:n,width:e,aspect:t,searchQuery:s,activeSearchPage:i,resolveCitation:r,warmPreviews:o,highlightBoxes:a,highlightKey:l,highlightBrief:c,onShowCitations:h,onShowReference:u,authors:d}){const p=V.useRef(null),[m,g]=V.useState(n<=2),{paperLinks:b,onAnnotations:y}=xY(p,m,r,o),[w,v]=V.useState([]);V.useEffect(()=>{if(!m||!r)return;let C=!0;return r.bibliographyLinks(n).then(async I=>{if(!C||(I.length&&(o==null||o([...new Set(I.map(_=>_.routeId))])),v(I),!I.length))return;const R=await Promise.all(I.map(_=>r.citationsOf(_.name)));C&&v(I.map((_,A)=>({..._,citations:R[A]})))}).catch(()=>{}),()=>{C=!1}},[n,r,m,o]);const x=n===i,k=V.useMemo(()=>s?({str:C})=>CY(C,s,x):void 0,[x,s]),[E,T]=V.useState(e);!m&&E!==e&&T(e);const[O,F]=V.useState(0),j=V.useCallback(()=>F(C=>C+1),[]),[L,B]=V.useState([]);V.useEffect(()=>{var I;if(!(d!=null&&d.length))return B([]);const C=(I=p.current)==null?void 0:I.querySelector(".pdf-page-layer:not(.is-pending)");C!=null&&C.querySelector(".textLayer")&&B(SY(C,d))},[d,O]);const Z=E===e?[e]:[E,e],[q,H]=V.useState(),[se,Q]=V.useState(!1);!m&&se&&Q(!1);const Y=V.useRef(),ye=V.useRef(0),z=V.useCallback(C=>{var _;Q(!0);const I=++ye.current,R=(_=p.current)==null?void 0:_.querySelector(`[data-layer-width="${C}"] canvas`);R==null||R.toBlob(A=>{!A||I!==ye.current||(Y.current&&URL.revokeObjectURL(Y.current),Y.current=URL.createObjectURL(A),H(Y.current))},"image/webp",.9)},[]);return V.useEffect(()=>()=>{ye.current+=1,Y.current&&URL.revokeObjectURL(Y.current)},[]),V.useEffect(()=>{const C=p.current;if(!C)return;const I=C.closest(".pdf-scroll"),R=new IntersectionObserver(([A])=>{A.isIntersecting&&g(!0)},{root:I,rootMargin:"250% 0px"}),_=new IntersectionObserver(([A])=>{A.isIntersecting||g(!1)},{root:I,rootMargin:"600% 0px"});return R.observe(C),_.observe(C),()=>{R.disconnect(),_.disconnect()}},[]),S.jsxs("div",{ref:p,className:"pdf-page","data-page":n,style:{minHeight:Math.round(e*t)},children:[m&&Z.map(C=>{const I=C===E,R=I?()=>z(C):()=>{T(C),z(C)};return S.jsx("div",{"data-layer-width":C,className:I?"pdf-page-layer":"pdf-page-layer is-pending",style:I&&C!==e?{"--pdf-layer-scale":e/C}:void 0,"aria-hidden":I?void 0:!0,children:S.jsx(qX,{pageNumber:n,width:C,devicePixelRatio:PY(C,t),renderTextLayer:I,renderAnnotationLayer:I,onGetAnnotationsSuccess:y,onRenderSuccess:R,onRenderError:I?void 0:()=>T(C),onRenderTextLayerSuccess:I&&d?j:void 0,loading:null,customTextRenderer:k})},C)}),q&&!se&&S.jsx("img",{className:"pdf-page-snapshot",src:q,alt:"","aria-hidden":"true"}),m&&b.map(C=>{var I;return S.jsx(hY,{...C,onShowReference:u},(I=C.anchor.parentElement)==null?void 0:I.dataset.annotationId)}),m&&r&&w.map(C=>S.jsx(uY,{...C,onShowCitations:h},C.name)),m&&d&&L.map(({authorId:C,box:I})=>{const R=d.find(_=>_.id===C);return R&&S.jsx(fY,{...R,box:I},`${C}-${I.join(",")}`)}),a==null?void 0:a.map(([C,I,R,_],A)=>S.jsx("div",{className:`pdf-citation-highlight${c?" is-brief":""}`,"aria-hidden":"true",style:{left:`${C/10}%`,top:`${I/10}%`,width:`${(R-C)/10}%`,height:`${(_-I)/10}%`}},`${l}-${A}`))]})}const MY=/^#pdf-section-(\d+)$/,IY=2;function OY(n){const e=MY.exec(n);return e?Number(e[1]):void 0}function NY(n,e){let t=-1;return n.forEach((s,i)=>{s<=e&&(t=i)}),t}async function LY(n,e){return typeof e=="string"?n.getDestination(e):Array.isArray(e)?e:null}async function DY(n,e){const[t,s,,i]=e;let r;if(typeof t=="number")r=t;else if(t&&typeof t=="object"&&"num"in t)r=await n.getPageIndex(t);else return null;if(!Number.isInteger(r)||r<0||r>=n.numPages)return null;const o=r+1;if((s==null?void 0:s.name)!=="XYZ"||typeof i!="number")return{page:o,offset:0};const a=(await n.getPage(o)).view,[,l,,c]=a,h=c-l;return h>0?{page:o,offset:Math.min(1,Math.max(0,(c-i)/h))}:{page:o,offset:0}}async function jY(n){const e=await n.getOutline(),t=[],s=async(i,r)=>{var o;for(const a of i){const l=a.title.replace(/\s+/g," ").trim(),c=await LY(n,a.dest).catch(()=>null),h=c?await DY(n,c).catch(()=>null):null;l&&h&&t.push({index:t.length,title:l,level:r,...h}),r+1{const w=n.current;if(!w)return;const v=()=>{var E;const k=Math.max(240,w.clientWidth-10);u.current=t?k/d:1,t?(E=e.current)==null||E.style.setProperty("--pdf-live-scale",String(u.current)):p(k)};v();const x=new ResizeObserver(v);return x.observe(w),()=>x.disconnect()},[d,e,t,n]),V.useLayoutEffect(()=>{var v;c.current=m,(v=e.current)==null||v.style.setProperty("--pdf-live-scale",String(u.current));const w=n.current;w&&i.current&&fE(w,i.current),i.current=void 0,s.current&&(w&&(w.scrollLeft=Math.max(0,(w.scrollWidth-w.clientWidth)/2)),s.current=!1)},[b,e,t,n,m]);const y=V.useCallback(w=>{window.clearTimeout(l.current);const v=Nv(w(h.current));h.current=v,s.current=v!==c.current,s.current&&n.current&&(i.current=kb(n.current)),g(v)},[n]);return V.useEffect(()=>{const w=n.current;if(!w)return;const v=x=>{x.ctrlKey&&(x.preventDefault(),r.current+=x.deltaY,o.current=x.clientY,!a.current&&(a.current=requestAnimationFrame(()=>{var O;const k=r.current;r.current=0,a.current=0;const E=Nv(h.current*Math.exp(-k*.002));h.current=E;const T=kb(w,o.current);(O=e.current)==null||O.style.setProperty("--pdf-live-scale",String(u.current*E/c.current)),T&&fE(w,T),window.clearTimeout(l.current),l.current=window.setTimeout(()=>{s.current=E!==c.current,s.current&&(i.current=kb(w,o.current)),g(h.current)},180)})))};return w.addEventListener("wheel",v,{passive:!1}),()=>{w.removeEventListener("wheel",v),cancelAnimationFrame(a.current),window.clearTimeout(l.current),a.current=0,l.current=0,r.current=0}},[e,n]),{zoom:m,pageWidth:b,liveResizeScale:u,setZoom:y}}const zY=8,HY=24,BY=72,qY=1.35;function VY(n){const e=n.message.toLowerCase();return e.includes("password")?"This PDF is encrypted and cannot be opened in the reader.":e.includes("worker")?"The PDF renderer could not start.":e.includes("invalid")||e.includes("format")?"The source returned an invalid or unsupported PDF.":e.includes("cors")||e.includes("fetch")||e.includes("network")?"The PDF source could not be loaded in this browser.":"The PDF could not be loaded from its source."}function Ab(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"}function UY({url:n,downloadUrl:e,paperKey:t,initialPage:s,resizeActive:i,selectionEnabled:r,paperVersion:o,documentOptions:a,label:l,loadingLabel:c,toolbar:h,onRetry:u,onPaperSelection:d,onPaperSelectionError:p,onPageChange:m,onClose:g,loadErrorMessage:b,highlight:y,citationLinks:w=!1,sectionHash:v=!1,authors:x}){const k=V.useRef(null),E=V.useRef(null),[T,O]=V.useState(),[F,j]=V.useState();V.useEffect(()=>{O(void 0),j(void 0)},[y==null?void 0:y.nonce,n]);const L=T??y,B=L&&`${T?"jump":"cited"}-${L.nonce}`,[Z,q]=V.useState(),H=T&&Z!==B?void 0:L,se=V.useCallback(ne=>{O(re=>({boxes:ne,nonce:((re==null?void 0:re.nonce)??0)+1}))},[]),Q=V.useCallback(ne=>{j({citations:ne,index:0}),se(ne[0])},[se]),Y=!!(F&&F.citations.length>1),ye=ne=>{if(!F)return;const{citations:re}=F,$e=(F.index+ne+re.length)%re.length;j({citations:re,index:$e}),se(re[$e])},z=V.useRef(null),[C,I]=V.useState(),R=V.useCallback(async ne=>{const re=await(C==null?void 0:C.referenceOf(ne).catch(()=>null));return re&&se([re]),!!re},[C,se]),_=FC(),A=V.useMemo(()=>WL(_),[_]),N=V.useRef(()=>{}),W=V.useRef(()=>{}),[X,he]=V.useState(0),[ie,ge]=V.useState(qY),[at,ze]=V.useState([]),[Qe,lt]=V.useState(-1),[tt,Ft]=V.useState(),[qt,bs]=V.useState(s),[js,tn]=V.useState(),[vs,ws]=V.useState(""),{zoom:Fs,pageWidth:_s,liveResizeScale:En,setZoom:nn}=FY(k,E,i);KX({enabled:r&&!!o,pagesRoot:E,routeId:t,paperVersion:o,numPages:X||void 0,onSelect:d,onError:p}),V.useEffect(()=>{UX()},[]);const sn=V.useCallback(ne=>{const re=Math.max(1,Math.min(X||1,ne));bs(re),m==null||m(re)},[m,X]),Cn=ne=>{var nt,Yt;const re=Math.max(1,Math.min(X||1,ne)),$e=Ab();tn($e==="smooth"?re:void 0),(Yt=(nt=k.current)==null?void 0:nt.querySelector(`[data-page="${re}"]`))==null||Yt.scrollIntoView({block:"start",behavior:$e}),$e==="instant"&&sn(re)},$n=$Y(X,Cn);V.useEffect(()=>{const ne=k.current;if(!ne||!X)return;let re=0,$e=0;const nt=(Un=!1)=>{window.clearTimeout($e),cancelAnimationFrame(re),re=requestAnimationFrame(()=>{const Ss=ne.getBoundingClientRect().top,Qi=Ss+ne.clientHeight/2;let Uu=qt,hm=Number.POSITIVE_INFINITY;const Wu=new Map;ne.querySelectorAll("[data-page]").forEach(Pc=>{const jr=Pc.getBoundingClientRect();Wu.set(Number(Pc.dataset.page),jr);const lk=Qi>=jr.top&&Qi<=jr.bottom?0:Math.min(Math.abs(Qi-jr.top),Math.abs(Qi-jr.bottom));lk{const jr=Wu.get(Pc.page);return jr?jr.top+jr.height*Pc.offset:Number.POSITIVE_INFINITY});lt(NY(vL,Ss+HY))})},Yt=()=>{cancelAnimationFrame(re),window.clearTimeout($e),$e=window.setTimeout(()=>nt(!0),150)},gn=()=>nt(!0);return ne.addEventListener("scroll",Yt,{passive:!0}),ne.addEventListener("scrollend",gn),nt(),()=>{ne.removeEventListener("scroll",Yt),ne.removeEventListener("scrollend",gn),window.clearTimeout($e),cancelAnimationFrame(re)}},[at,qt,_s,X,sn]);const{open:Hu,setOpen:Bu,close:qu}=$n;V.useEffect(()=>{const ne=re=>{re.defaultPrevented||((re.ctrlKey||re.metaKey)&&re.key.toLowerCase()==="f"?(re.preventDefault(),Bu(!0)):re.key==="Escape"&&Hu?(re.preventDefault(),qu()):re.key==="Escape"&&Y?(re.preventDefault(),j(void 0)):re.key==="Escape"&&!re.repeat&&g&&(re.preventDefault(),g()))};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[Y,qu,g,Hu,Bu]),V.useEffect(()=>{const ne=L==null?void 0:L.boxes[0],re=k.current,$e=ne&&(re==null?void 0:re.querySelector(`[data-page="${ne.page}"]`));if(!ne||!re||!$e)return;const nt=Ab(),Yt=$e.getBoundingClientRect(),gn=Yt.top-re.getBoundingClientRect().top+re.scrollTop+Yt.height*ne.bbox[1]/1e3;tn(nt==="smooth"?ne.page:void 0),re.scrollTo({top:Math.max(0,gn-BY),behavior:nt}),nt==="instant"&&sn(ne.page);let Un=0;const Ss=()=>{window.clearTimeout(Un),q(B)},Qi=()=>{window.clearTimeout(Un),Un=window.setTimeout(Ss,150)};return Qi(),re.addEventListener("scroll",Qi,{passive:!0}),re.addEventListener("scrollend",Ss),()=>{window.clearTimeout(Un),re.removeEventListener("scroll",Qi),re.removeEventListener("scrollend",Ss)}},[B,X,ie]);const Vu=(ne,re=Ab())=>{const $e=k.current,nt=$e==null?void 0:$e.querySelector(`[data-page="${ne.page}"]`);if(!$e||!nt)return;const Yt=nt.getBoundingClientRect(),gn=Yt.top-$e.getBoundingClientRect().top+$e.scrollTop+Yt.height*ne.offset;tn(re==="smooth"?ne.page:void 0),Ft(re==="smooth"?ne.index:void 0),$e.scrollTo({top:Math.max(0,gn-zY),behavior:re}),re==="instant"&&sn(ne.page),v&&window.history.replaceState(window.history.state,"",`#pdf-section-${ne.index}`)};V.useLayoutEffect(()=>{N.current=Cn,W.current=Vu});const cm=V.useMemo(()=>Array.from({length:X},(ne,re)=>re+1),[X]),G=ne=>{z.current=ne,$n.indexDocument(ne),w&&I(()=>iY(ne,A.lookup)),he(ne.numPages),ws("");const re=ne.getPage(1).then(Un=>{const[Ss,Qi,Uu,hm]=Un.view,Wu=(hm-Qi)/(Uu-Ss);z.current===ne&&Wu>0&&ge(Wu)},()=>{}),$e=Math.max(1,Math.min(ne.numPages,s)),nt=()=>{var Un,Ss;$e<=1||((Ss=(Un=k.current)==null?void 0:Un.querySelector(`[data-page="${$e}"]`))==null||Ss.scrollIntoView({block:"start"}),bs($e),m==null||m($e))},Yt=Un=>void re.then(()=>{requestAnimationFrame(()=>requestAnimationFrame(()=>{z.current===ne&&Un()}))}),gn=v?OY(window.location.hash):void 0;gn===void 0&&Yt(nt),jY(ne).catch(()=>[]).then(Un=>{if(z.current!==ne||(ze(Un),gn===void 0))return;const Ss=Un[gn];Yt(()=>Ss?W.current(Ss,"instant"):nt())})};return S.jsxs("div",{className:"pdf-viewer",children:[h({page:js??qt,pages:X,zoom:Fs,search:$n,onPage:Cn,onZoom:nn}),S.jsxs("div",{className:"pdf-scroll-frame",children:[S.jsx("div",{ref:k,className:"pdf-scroll",role:"region","aria-label":l,children:vs?S.jsxs("div",{className:"pdf-error",role:"alert",children:[S.jsx("p",{children:vs}),S.jsxs("div",{children:[S.jsx("button",{type:"button",onClick:u,children:"Retry"})," ",S.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:"Open PDF"})]})]}):S.jsx(MX,{file:n,options:a,loading:S.jsx("div",{className:"pdf-loading",role:"status",children:c}),onLoadSuccess:G,onLoadError:ne=>ws(b||VY(ne)),externalLinkTarget:"_blank",onItemClick:({pageNumber:ne})=>N.current(ne),children:S.jsx("div",{ref:E,className:"pdf-pages",style:{"--pdf-live-scale":En.current},children:cm.map(ne=>S.jsx(RY,{page:ne,width:_s,aspect:ie,searchQuery:$n.highlightQuery,activeSearchPage:$n.matches[$n.activeMatch],resolveCitation:C,warmPreviews:A.warm,highlightBoxes:H==null?void 0:H.boxes.filter(re=>re.page===ne).map(re=>re.bbox),highlightKey:B,highlightBrief:!!T,onShowCitations:Q,onShowReference:R,authors:ne===1?x:void 0},ne))})})}),F&&Y&&S.jsx(cY,{index:F.index,count:F.citations.length,onStep:ye,onClose:()=>j(void 0)}),S.jsx(lY,{entries:at,activeIndex:tt??Qe,onSelect:Vu})]})]})}const WY={disableStream:!0,disableAutoFetch:!0},GY={withCredentials:!0};function KY({downloadUrl:n,page:e,pages:t,zoom:s,onPage:i,onZoom:r}){const o=a=>{a.preventDefault();const l=Number(new FormData(a.currentTarget).get("page"));Number.isInteger(l)&&i(l)};return S.jsxs("div",{className:"paper-pdf-toolbar","aria-label":"Paper preview controls",children:[S.jsxs("div",{className:"paper-pdf-toolbar-group",children:[S.jsx("button",{type:"button",onClick:()=>i(e-1),disabled:e<=1,"aria-label":"Previous page",children:"Previous"}),S.jsxs("form",{onSubmit:o,children:[S.jsx("label",{className:"sr-only",htmlFor:"paper-pdf-current-page",children:"Current page"}),S.jsx("input",{id:"paper-pdf-current-page",name:"page",type:"number",min:1,max:t||1,defaultValue:e,"aria-label":`Page ${e} of ${t||"unknown"}`},e)]}),S.jsxs("span",{role:"status","aria-live":"polite",children:["Page ",e," of ",t||"—"]}),S.jsx("button",{type:"button",onClick:()=>i(e+1),disabled:!t||e>=t,"aria-label":"Next page",children:"Next"})]}),S.jsxs("div",{className:"paper-pdf-toolbar-group",children:[S.jsx("button",{type:"button",onClick:()=>r(a=>dy(a,-1)),"aria-label":"Zoom out",children:"−"}),S.jsxs("output",{"aria-live":"polite",children:[Math.round(s*100),"%"]}),S.jsx("button",{type:"button",onClick:()=>r(a=>dy(a,1)),"aria-label":"Zoom in",children:"+"}),S.jsx("button",{type:"button",onClick:()=>r(()=>1),children:"Fit to width"}),S.jsx("a",{href:n,download:!0,children:"Download PDF"})]})]})}function ZY({url:n,downloadUrl:e=n,paperKey:t,paperTitle:s,paperHref:i,resources:r,initialPage:o=1,resizeActive:a=!1,selectionEnabled:l=!1,paperVersion:c="",chrome:h="reader",authors:u,...d}){const[p,m]=V.useState(0),g=h==="reader",b=y=>g?S.jsx(G6,{paperTitle:s,paperHref:i,resources:r,page:y.page,pages:y.pages,zoomPercent:Math.round(y.zoom*100),searchOpen:y.search.open,searchQuery:y.search.query,searchMatch:y.search.activeMatch,searchCount:y.search.matches.length,searching:y.search.searching,onPage:y.onPage,onZoom:w=>y.onZoom(()=>w),onZoomIn:()=>y.onZoom(w=>dy(w,1)),onZoomOut:()=>y.onZoom(w=>dy(w,-1)),onToggleSearch:()=>y.search.open?y.search.close():y.search.setOpen(!0),onCloseSearch:y.search.close,onSearchQuery:y.search.setQuery,onSearch:y.search.navigate}):S.jsx(KY,{downloadUrl:e,...y});return S.jsx(UY,{...d,url:n,downloadUrl:e,paperKey:t,initialPage:o,resizeActive:a,selectionEnabled:l,paperVersion:c,documentOptions:g?WY:GY,label:g?"Paper PDF":`${s} PDF preview`,loadingLabel:g?"Loading paper…":"Loading paper preview…",toolbar:b,onRetry:()=>m(y=>y+1),citationLinks:g,sectionHash:g,authors:g?u:void 0},`${t}-${p}-${o}`)}let i_=[],$I=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(n=$I[s])e=s+1;else return!0;if(e==t)return!1}}function pE(n){return n>=127462&&n<=127487}const mE=8205;function YY(n,e,t=!0,s=!0){return(t?TI:JY)(n,e,s)}function TI(n,e,t){if(e==n.length)return e;e&&PI(n.charCodeAt(e))&&RI(n.charCodeAt(e-1))&&e--;let s=Eb(n,e);for(e+=gE(s);e=0&&pE(Eb(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function JY(n,e,t){for(;e>1;){let s=TI(n,e-2,t);if(s=56320&&n<57344}function RI(n){return n>=55296&&n<56320}function gE(n){return n<65536?1:2}let rt=class MI{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,s){[e,t]=_u(this,e,t);let i=[];return this.decompose(0,e,i,2),s.length&&s.decompose(0,s.length,i,3),this.decompose(t,this.length,i,1),Ar.from(i,this.length-(t-e)+s.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=_u(this,e,t);let s=[];return this.decompose(e,t,s,0),Ar.from(s,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),s=this.length-this.scanIdentical(e,-1),i=new Gd(this),r=new Gd(e);for(let o=t,a=t;;){if(i.next(o),r.next(o),o=0,i.lineBreak!=r.lineBreak||i.done!=r.done||i.value!=r.value)return!1;if(a+=i.value.length,i.done||a>=s)return!0}}iter(e=1){return new Gd(this,e)}iterRange(e,t=this.length){return new II(this,e,t)}iterLines(e,t){let s;if(e==null)s=this.iter();else{t==null&&(t=this.lines+1);let i=this.line(e).from;s=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new OI(s)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?MI.empty:e.length<=32?new Gt(e):Ar.from(Gt.split(e,[]))}};class Gt extends rt{constructor(e,t=QY(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,s,i){for(let r=0;;r++){let o=this.text[r],a=i+o.length;if((t?s:a)>=e)return new e7(i,a,s,o);i=a+1,s++}}decompose(e,t,s,i){let r=e<=0&&t>=this.length?this:new Gt(yE(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(i&1){let o=s.pop(),a=Fg(r.text,o.text.slice(),0,r.length);if(a.length<=32)s.push(new Gt(a,o.length+r.length));else{let l=a.length>>1;s.push(new Gt(a.slice(0,l)),new Gt(a.slice(l)))}}else s.push(r)}replace(e,t,s){if(!(s instanceof Gt))return super.replace(e,t,s);[e,t]=_u(this,e,t);let i=Fg(this.text,Fg(s.text,yE(this.text,0,e)),t),r=this.length+s.length-(t-e);return i.length<=32?new Gt(i,r):Ar.from(Gt.split(i,[]),r)}sliceString(e,t=this.length,s=` +`){[e,t]=_u(this,e,t);let i="";for(let r=0,o=0;r<=t&&oe&&o&&(i+=s),er&&(i+=a.slice(Math.max(0,e-r),t-r)),r=l+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let s=[],i=-1;for(let r of e)s.push(r),i+=r.length+1,s.length==32&&(t.push(new Gt(s,i)),s=[],i=-1);return i>-1&&t.push(new Gt(s,i)),t}}class Ar extends rt{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let s of e)this.lines+=s.lines}lineInner(e,t,s,i){for(let r=0;;r++){let o=this.children[r],a=i+o.length,l=s+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,s,i);i=a+1,s=l+1}}decompose(e,t,s,i){for(let r=0,o=0;o<=t&&r=o){let c=i&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!c?s.push(a):a.decompose(e-o,t-o,s,c)}o=l+1}}replace(e,t,s){if([e,t]=_u(this,e,t),s.lines=r&&t<=a){let l=o.replace(e-r,t-r,s),c=this.lines-o.lines+l.lines;if(l.lines>4&&l.lines>c>>6){let h=this.children.slice();return h[i]=l,new Ar(h,this.length-(t-e)+s.length)}return super.replace(r,a,l)}r=a+1}return super.replace(e,t,s)}sliceString(e,t=this.length,s=` +`){[e,t]=_u(this,e,t);let i="";for(let r=0,o=0;re&&r&&(i+=s),eo&&(i+=a.sliceString(e-o,t-o,s)),o=l+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Ar))return 0;let s=0,[i,r,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,r+=t){if(i==o||r==a)return s;let l=this.children[i],c=e.children[r];if(l!=c)return s+l.scanIdentical(c,t);s+=l.length+1}}static from(e,t=e.reduce((s,i)=>s+i.length+1,-1)){let s=0;for(let p of e)s+=p.lines;if(s<32){let p=[];for(let m of e)m.flatten(p);return new Gt(p,t)}let i=Math.max(32,s>>5),r=i<<1,o=i>>1,a=[],l=0,c=-1,h=[];function u(p){let m;if(p.lines>r&&p instanceof Ar)for(let g of p.children)u(g);else p.lines>o&&(l>o||!l)?(d(),a.push(p)):p instanceof Gt&&l&&(m=h[h.length-1])instanceof Gt&&p.lines+m.lines<=32?(l+=p.lines,c+=p.length+1,h[h.length-1]=new Gt(m.text.concat(p.text),m.length+1+p.length)):(l+p.lines>i&&d(),l+=p.lines,c+=p.length+1,h.push(p))}function d(){l!=0&&(a.push(h.length==1?h[0]:Ar.from(h,c)),c=-1,l=h.length=0)}for(let p of e)u(p);return d(),a.length==1?a[0]:new Ar(a,t)}}rt.empty=new Gt([""],0);function QY(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Fg(n,e,t=0,s=1e9){for(let i=0,r=0,o=!0;r=t&&(l>s&&(a=a.slice(0,s-i)),i0?1:(e instanceof Gt?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let s=this.nodes.length-1,i=this.nodes[s],r=this.offsets[s],o=r>>1,a=i instanceof Gt?i.text.length:i.children.length;if(o==(t>0?a:0)){if(s==0)return this.done=!0,this.value="",this;t>0&&this.offsets[s-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[s]+=t,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(i instanceof Gt){let l=i.text[o+(t<0?-1:0)];if(this.offsets[s]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=i.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[s]+=t):(t<0&&this.offsets[s]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof Gt?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class II{constructor(e,t,s){this.value="",this.done=!1,this.cursor=new Gd(e,t>s?-1:1),this.pos=t>s?e.length:0,this.from=Math.min(t,s),this.to=Math.max(t,s)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let s=t<0?this.pos-this.from:this.to-this.pos;e>s&&(e=s),s-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=s?i:t<0?i.slice(i.length-s):i.slice(0,s),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class OI{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:s,value:i}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):s?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(rt.prototype[Symbol.iterator]=function(){return this.iter()},Gd.prototype[Symbol.iterator]=II.prototype[Symbol.iterator]=OI.prototype[Symbol.iterator]=function(){return this});class e7{constructor(e,t,s,i){this.from=e,this.to=t,this.number=s,this.text=i}get length(){return this.to-this.from}}function _u(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function kn(n,e,t=!0,s=!0){return YY(n,e,t,s)}function t7(n){return n>=56320&&n<57344}function n7(n){return n>=55296&&n<56320}function NI(n,e){let t=n.charCodeAt(e);if(!n7(t)||e+1==n.length)return t;let s=n.charCodeAt(e+1);return t7(s)?(t-55296<<10)+(s-56320)+65536:t}function s7(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function LI(n){return n<65536?1:2}const r_=/\r\n?|\n/;var Qs=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(Qs||(Qs={}));class Or{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-i);r+=a}else{if(s!=Qs.Simple&&c>=e&&(s==Qs.TrackDel&&ie||s==Qs.TrackBefore&&ie))return null;if(c>e||c==e&&t<0&&!a)return e==i||t<0?r:r+l;r+=l}i=c}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return r}touchesRange(e,t=e){for(let s=0,i=0;s=0&&i<=t&&a>=e)return it?"cover":!0;i=a}return!1}toString(){let e="";for(let t=0;t=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Or(e)}static create(e){return new Or(e)}}class un extends Or{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return o_(this,(t,s,i,r,o)=>e=e.replace(i,i+(s-t),o),!1),e}mapDesc(e,t=!1){return a_(this,e,t,!0)}invert(e){let t=this.sections.slice(),s=[];for(let i=0,r=0;i=0){t[i]=a,t[i+1]=o;let l=i>>1;for(;s.length0&&_a(s,t,r.text),r.forward(h),a+=h}let c=e[o++];for(;a>1].toJSON()))}return e}static of(e,t,s){let i=[],r=[],o=0,a=null;function l(h=!1){if(!h&&!i.length)return;od||u<0||d>t)throw new RangeError(`Invalid change range ${u} to ${d} (in doc of length ${t})`);let m=p?typeof p=="string"?rt.of(p.split(s||r_)):p:rt.empty,g=m.length;if(u==d&&g==0)return;uo&&ns(i,u-o,-1),ns(i,d-u,g),_a(r,i,m),o=d}}return c(e),l(!a),a}static empty(e){return new un(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],s=[];for(let i=0;ia&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;s.length=0&&t<=0&&t==n[i+1]?n[i]+=e:i>=0&&e==0&&n[i]==0?n[i+1]+=t:s?(n[i]+=e,n[i+1]+=t):n.push(e,t)}function _a(n,e,t){if(t.length==0)return;let s=e.length-2>>1;if(s>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)a=n.sections[o++],l=n.sections[o++];e(i,c,r,h,u),i=c,r=h}}}function a_(n,e,t,s=!1){let i=[],r=s?[]:null,o=new lf(n),a=new lf(e);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let c=Math.min(o.len,a.len);ns(i,c,-1),o.forward(c),a.forward(c)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len=0&&l=0){let c=0,h=o.len;for(;h;)if(a.ins==-1){let u=Math.min(h,a.len);c+=u,h-=u,a.forward(u)}else if(a.ins==0&&a.lenl||o.ins>=0&&o.len>l)&&(a||s.length>c),r.forward2(l),o.forward(l)}}}}class lf{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?rt.empty:e[t]}textBit(e){let{inserted:t}=this.set,s=this.i-2>>1;return s>=t.length&&!e?rt.empty:t[s].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Bo{constructor(e,t,s,i){this.from=e,this.to=t,this.flags=s,this.goalColumn=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let s,i;return this.empty?s=i=e.mapPos(this.from,t):(s=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),s==this.from&&i==this.to?this:new Bo(s,i,this.flags,this.goalColumn)}extend(e,t=e,s=0){if(e<=this.anchor&&t>=this.anchor)return te.range(e,t,void 0,void 0,s);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return te.range(this.anchor,i,void 0,void 0,s)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return te.range(e.anchor,e.head)}static create(e,t,s,i){return new Bo(e,t,s,i)}}class te{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:te.create(this.ranges.map(s=>s.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let s=0;se.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new te(e.ranges.map(t=>Bo.fromJSON(t)),e.main)}static single(e,t=e){return new te([te.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let s=0,i=0;ii.from-r.from),t=e.indexOf(s);for(let i=1;ir.head?te.range(l,a):te.range(a,l))}}return new te(e,t)}}function jI(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Tx=0;class ve{constructor(e,t,s,i,r){this.combine=e,this.compareInput=t,this.compare=s,this.isStatic=i,this.id=Tx++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new ve(e.combine||(t=>t),e.compareInput||((t,s)=>t===s),e.compare||(e.combine?(t,s)=>t===s:Px),!!e.static,e.enables)}of(e){return new zg([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new zg(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new zg(e,this,2,t)}from(e,t){return t||(t=s=>s),this.compute([e],s=>t(s.field(e)))}}function Px(n,e){return n==e||n.length==e.length&&n.every((t,s)=>t===e[s])}class zg{constructor(e,t,s,i){this.dependencies=e,this.facet=t,this.type=s,this.value=i,this.id=Tx++}dynamicSlot(e){var t;let s=this.value,i=this.facet.compareInput,r=this.id,o=e[r]>>1,a=this.type==2,l=!1,c=!1,h=[];for(let u of this.dependencies)u=="doc"?l=!0:u=="selection"?c=!0:((t=e[u.id])!==null&&t!==void 0?t:1)&1||h.push(e[u.id]);return{create(u){return u.values[o]=s(u),1},update(u,d){if(l&&d.docChanged||c&&(d.docChanged||d.selection)||l_(u,h)){let p=s(u);if(a?!bE(p,u.values[o],i):!i(p,u.values[o]))return u.values[o]=p,1}return 0},reconfigure:(u,d)=>{let p,m=d.config.address[r];if(m!=null){let g=vy(d,m);if(this.dependencies.every(b=>b instanceof ve?d.facet(b)===u.facet(b):b instanceof Dr?d.field(b,!1)==u.field(b,!1):!0)||(a?bE(p=s(u),g,i):i(p=s(u),g)))return u.values[o]=g,0}else p=s(u);return u.values[o]=p,1}}}get extension(){return this}}function bE(n,e,t){if(n.length!=e.length)return!1;for(let s=0;sn[l.id]),i=t.map(l=>l.type),r=s.filter(l=>!(l&1)),o=n[e.id]>>1;function a(l){let c=[];for(let h=0;hs===i),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Mm).find(s=>s.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:s=>(s.values[t]=this.create(s),1),update:(s,i)=>{let r=s.values[t],o=this.updateF(r,i);return this.compareF(r,o)?0:(s.values[t]=o,1)},reconfigure:(s,i)=>{let r=s.facet(Mm),o=i.facet(Mm),a;return(a=r.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(s.values[t]=a.create(s),1):i.config.address[this.id]!=null?(s.values[t]=i.field(this),0):(s.values[t]=this.create(s),1)}}}init(e){return[this,Mm.of({field:this,create:e})]}get extension(){return this}}const rl={lowest:4,low:3,default:2,high:1,highest:0};function nd(n){return e=>new FI(e,n)}const F0={highest:nd(rl.highest),high:nd(rl.high),default:nd(rl.default),low:nd(rl.low),lowest:nd(rl.lowest)};class FI{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class nm{of(e){return new c_(this,e)}reconfigure(e){return nm.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class c_{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class by{constructor(e,t,s,i,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=s,this.address=i,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,s){let i=[],r=Object.create(null),o=new Map;for(let d of r7(e,t,o))d instanceof Dr?i.push(d):(r[d.facet.id]||(r[d.facet.id]=[])).push(d);let a=Object.create(null),l=[],c=[];for(let d of i)a[d.id]=c.length<<1,c.push(p=>d.slot(p));let h=s==null?void 0:s.config.facets;for(let d in r){let p=r[d],m=p[0].facet,g=h&&h[d]||[];if(p.every(b=>b.type==0))if(a[m.id]=l.length<<1|1,Px(g,p))l.push(s.facet(m));else{let b=m.combine(p.map(y=>y.value));l.push(s&&m.compare(b,s.facet(m))?s.facet(m):b)}else{for(let b of p)b.type==0?(a[b.id]=l.length<<1|1,l.push(b.value)):(a[b.id]=c.length<<1,c.push(y=>b.dynamicSlot(y)));a[m.id]=c.length<<1,c.push(b=>i7(b,m,p))}}let u=c.map(d=>d(a));return new by(e,o,u,a,l,r)}}function r7(n,e,t){let s=[[],[],[],[],[]],i=new Map;function r(o,a){let l=i.get(o);if(l!=null){if(l<=a)return;let c=s[l].indexOf(o);c>-1&&s[l].splice(c,1),o instanceof c_&&t.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let c of o)r(c,a);else if(o instanceof c_){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),r(c,a)}else if(o instanceof FI)r(o.inner,o.prec);else if(o instanceof Dr)s[a].push(o),o.provides&&r(o.provides,a);else if(o instanceof zg)s[a].push(o),o.facet.extensions&&r(o.facet.extensions,rl.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(c==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(c,a)}}return r(n,rl.default),s.reduce((o,a)=>o.concat(a))}function Kd(n,e){if(e&1)return 2;let t=e>>1,s=n.status[t];if(s==4)throw new Error("Cyclic dependency between fields and/or facets");if(s&2)return s;n.status[t]=4;let i=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|i}function vy(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const zI=ve.define(),h_=ve.define({combine:n=>n.some(e=>e),static:!0}),HI=ve.define({combine:n=>n.length?n[0]:void 0,static:!0}),BI=ve.define(),qI=ve.define(),VI=ve.define(),UI=ve.define({combine:n=>n.length?n[0]:!1});class Da{constructor(e,t){this.type=e,this.value=t}static define(){return new o7}}class o7{of(e){return new Da(this,e)}}class a7{constructor(e){this.map=e}of(e){return new bt(this,e)}}class bt{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new bt(this.type,t)}is(e){return this.type==e}static define(e={}){return new a7(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let s=[];for(let i of e){let r=i.map(t);r&&s.push(r)}return s}}bt.reconfigure=bt.define();bt.appendConfig=bt.define();class pn{constructor(e,t,s,i,r,o){this.startState=e,this.changes=t,this.selection=s,this.effects=i,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,s&&jI(s,t.newLength),r.some(a=>a.type==pn.time)||(this.annotations=r.concat(pn.time.of(Date.now())))}static create(e,t,s,i,r,o){return new pn(e,t,s,i,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(pn.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}pn.time=Da.define();pn.userEvent=Da.define();pn.addToHistory=Da.define();pn.remote=Da.define();function l7(n,e){let t=[];for(let s=0,i=0;;){let r,o;if(s=n[s]))r=n[s++],o=n[s++];else if(i=0;i--){let r=s[i](n);r instanceof pn?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof pn?n=r[0]:n=GI(e,uh(r),!1)}return n}function h7(n){let e=n.startState,t=e.facet(VI),s=n;for(let i=t.length-1;i>=0;i--){let r=t[i](n);r&&Object.keys(r).length&&(s=WI(s,u_(e,r,n.changes.newLength),!0))}return s==n?n:pn.create(e,n.changes,n.selection,s.effects,s.annotations,s.scrollIntoView)}const u7=[];function uh(n){return n==null?u7:Array.isArray(n)?n:[n]}var Zt=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(Zt||(Zt={}));const d7=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let d_;try{d_=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function f7(n){if(d_)return d_.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||d7.test(t)))return!0}return!1}function p7(n){return e=>{if(!/\S/.test(e))return Zt.Space;if(f7(e))return Zt.Word;for(let t=0;t-1)return Zt.Word;return Zt.Other}}class it{constructor(e,t,s,i,r,o){this.config=e,this.doc=t,this.selection=s,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let a=0;ai.set(c,l)),t=null),i.set(a.value.compartment,a.value.extension)):a.is(bt.reconfigure)?(t=null,s=a.value):a.is(bt.appendConfig)&&(t=null,s=uh(s).concat(a.value));let r;t?r=e.startState.values.slice():(t=by.resolve(s,i,this),r=new it(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let o=e.startState.facet(h_)?e.newSelection:e.newSelection.asSingle();new it(t,e.newDoc,o,r,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:te.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,s=e(t.ranges[0]),i=this.changes(s.changes),r=[s.range],o=uh(s.effects);for(let a=1;ao.spec.fromJSON(a,l)))}}return it.create({doc:e.doc,selection:te.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=by.resolve(e.extensions||[],new Map),s=e.doc instanceof rt?e.doc:rt.of((e.doc||"").split(t.staticFacet(it.lineSeparator)||r_)),i=e.selection?e.selection instanceof te?e.selection:te.single(e.selection.anchor,e.selection.head):te.single(0);return jI(i,s.length),t.staticFacet(h_)||(i=i.asSingle()),new it(t,s,i,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(it.tabSize)}get lineBreak(){return this.facet(it.lineSeparator)||` +`}get readOnly(){return this.facet(UI)}phrase(e,...t){for(let s of this.facet(it.phrases))if(Object.prototype.hasOwnProperty.call(s,e)){e=s[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(s,i)=>{if(i=="$")return"$";let r=+(i||1);return!r||r>t.length?s:t[r-1]})),e}languageDataAt(e,t,s=-1){let i=[];for(let r of this.facet(zI))for(let o of r(this,t,s))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return p7(t.length?t[0]:"")}wordAt(e){let{text:t,from:s,length:i}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-s,a=e-s;for(;o>0;){let l=kn(t,o,!1);if(r(t.slice(l,o))!=Zt.Word)break;o=l}for(;an.length?n[0]:4});it.lineSeparator=HI;it.readOnly=UI;it.phrases=ve.define({compare(n,e){let t=Object.keys(n),s=Object.keys(e);return t.length==s.length&&t.every(i=>n[i]==e[i])}});it.languageData=zI;it.changeFilter=BI;it.transactionFilter=qI;it.transactionExtender=VI;nm.reconfigure=bt.define();function ju(n,e,t={}){let s={};for(let i of n)for(let r of Object.keys(i)){let o=i[r],a=s[r];if(a===void 0)s[r]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(t,r))s[r]=t[r](a,o);else throw new Error("Config merge conflict for field "+r)}for(let i in e)s[i]===void 0&&(s[i]=e[i]);return s}class bc{eq(e){return this==e}range(e,t=e){return f_.create(e,t,this)}}bc.prototype.startSide=bc.prototype.endSide=0;bc.prototype.point=!1;bc.prototype.mapMode=Qs.TrackDel;function Rx(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let f_=class KI{constructor(e,t,s){this.from=e,this.to=t,this.value=s}static create(e,t,s){return new KI(e,t,s)}};function p_(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class Mx{constructor(e,t,s,i){this.from=e,this.to=t,this.value=s,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,t,s,i=0){let r=s?this.to:this.from;for(let o=i,a=r.length;;){if(o==a)return o;let l=o+a>>1,c=r[l]-e||(s?this.value[l].endSide:this.value[l].startSide)-t;if(l==o)return c>=0?o:a;c>=0?a=l:o=l+1}}between(e,t,s,i){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(s,1e9,!1,r);rp||d==p&&c.startSide>0&&c.endSide<=0)continue;(p-d||c.endSide-c.startSide)<0||(o<0&&(o=d),c.point&&(a=Math.max(a,p-d)),s.push(c),i.push(d-o),r.push(p-o))}return{mapped:s.length?new Mx(i,r,s,a):null,pos:o}}}class et{constructor(e,t,s,i){this.chunkPos=e,this.chunk=t,this.nextLayer=s,this.maxPoint=i}static create(e,t,s,i){return new et(e,t,s,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:s=!1,filterFrom:i=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(s&&(t=t.slice().sort(p_)),this.isEmpty)return t.length?et.of(t):this;let a=new ZI(this,null,-1).goto(0),l=0,c=[],h=new cf;for(;a.value||l=0){let u=t[l++];h.addInner(u.from,u.to,u.value)||c.push(u)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||ra.to||r=r&&e<=r+o.length&&o.between(r,e-r,t-r,s)===!1)return}this.nextLayer.between(e,t,s)}}iter(e=0){return hf.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return hf.from(e).goto(t)}static compare(e,t,s,i,r=-1){let o=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=r),a=t.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=r),l=vE(o,a,s),c=new sd(o,l,r),h=new sd(a,l,r);s.iterGaps((u,d,p)=>wE(c,u,h,d,p,i)),s.empty&&s.length==0&&wE(c,0,h,0,0,i)}static eq(e,t,s=0,i){i==null&&(i=999999999);let r=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0),o=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let a=vE(r,o),l=new sd(r,a,0).goto(s),c=new sd(o,a,0).goto(s);for(;;){if(l.to!=c.to||!m_(l.active,c.active)||l.point&&(!c.point||!Rx(l.point,c.point)))return!1;if(l.to>i)return!0;l.next(),c.next()}}static spans(e,t,s,i,r=-1){let o=new sd(e,null,r).goto(t),a=t,l=o.openStart;for(;;){let c=Math.min(o.to,s);if(o.point){let h=o.activeForPoint(o.to),u=o.pointFroma&&(i.span(a,c,o.active,l),l=o.openEnd(c));if(o.to>s)return l+(o.point&&o.to>s?1:0);a=o.to,o.next()}}static of(e,t=!1){let s=new cf;for(let i of e instanceof f_?[e]:t?m7(e):e)s.add(i.from,i.to,i.value);return s.finish()}static join(e){if(!e.length)return et.empty;let t=e[e.length-1];for(let s=e.length-2;s>=0;s--)for(let i=e[s];i!=et.empty;i=i.nextLayer)t=new et(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}et.empty=new et([],[],null,-1);function m7(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(p_);e=s}return n}et.empty.nextLayer=et.empty;class cf{finishChunk(e){this.chunks.push(new Mx(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,s){this.addInner(e,t,s)||(this.nextLayer||(this.nextLayer=new cf)).add(e,t,s)}addInner(e,t,s){let i=e-this.lastTo||s.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||s.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=s,this.lastFrom=e,this.lastTo=t,this.value.push(s),s.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let s=t.value.length-1;return this.last=t.value[s],this.lastFrom=t.from[s]+e,this.lastTo=t.to[s]+e,!0}finish(){return this.finishInner(et.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=et.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function vE(n,e,t){let s=new Map;for(let r of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=s&&i.push(new ZI(o,t,s,r));return i.length==1?i[0]:new hf(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let s of this.heap)s.goto(e,t);for(let s=this.heap.length>>1;s>=0;s--)Cb(this.heap,s);return this.next(),this}forward(e,t){for(let s of this.heap)s.forward(e,t);for(let s=this.heap.length>>1;s>=0;s--)Cb(this.heap,s);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Cb(this.heap,0)}}}function Cb(n,e){for(let t=n[e];;){let s=(e<<1)+1;if(s>=n.length)break;let i=n[s];if(s+1=0&&(i=n[s+1],s++),t.compare(i)<0)break;n[s]=t,n[e]=i,e=s}}class sd{constructor(e,t,s){this.minPoint=s,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=hf.from(e,t,s)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Im(this.active,e),Im(this.activeTo,e),Im(this.activeRank,e),this.minActive=_E(this.active,this.activeTo)}addActive(e){let t=0,{value:s,to:i,rank:r}=this.cursor;for(;t0;)t++;Om(this.active,t,s),Om(this.activeTo,t,i),Om(this.activeRank,t,r),e&&Om(e,t,this.cursor.from),this.minActive=_E(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let s=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),s&&Im(s,i)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(s),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&s[i]=0&&!(this.activeRank[s]e||this.activeTo[s]==e&&this.active[s].endSide>=this.point.endSide)&&t.push(this.active[s]);return t.reverse()}openEnd(e){let t=0;for(let s=this.activeTo.length-1;s>=0&&this.activeTo[s]>e;s--)t++;return t}}function wE(n,e,t,s,i,r){n.goto(e),t.goto(s);let o=s+i,a=s,l=s-e,c=!!r.boundChange;for(let h=!1;;){let u=n.to+l-t.to,d=u||n.endSide-t.endSide,p=d<0?n.to+l:t.to,m=Math.min(p,o);if(n.point||t.point?(n.point&&t.point&&Rx(n.point,t.point)&&m_(n.activeForPoint(n.to),t.activeForPoint(t.to))||r.comparePoint(a,m,n.point,t.point),h=!1):(h&&r.boundChange(a),m>a&&!m_(n.active,t.active)&&r.compareRange(a,m,n.active,t.active),c&&mo)break;a=p,d<=0&&n.next(),d>=0&&t.next()}}function m_(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;s--)n[s+1]=n[s];n[e]=t}function _E(n,e){let t=-1,s=1e9;for(let i=0;i=e)return i;if(i==n.length)break;r+=n.charCodeAt(i)==9?t-r%t:1,i=kn(n,i)}return n.length}const g_="ͼ",SE=typeof Symbol>"u"?"__"+g_:Symbol.for(g_),y_=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),xE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Su{constructor(e,t){this.rules=[];let{finish:s}=t||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,a,l,c){let h=[],u=/^@(\w+)\b/.exec(o[0]),d=u&&u[1]=="keyframes";if(u&&a==null)return l.push(o[0]+";");for(let p in a){let m=a[p];if(/&/.test(p))r(p.split(/,\s*/).map(g=>o.map(b=>g.replace(/&/,b))).reduce((g,b)=>g.concat(b)),m,l);else if(m&&typeof m=="object"){if(!u)throw new RangeError("The value of a property ("+p+") should be a primitive value.");r(i(p),m,h,d)}else m!=null&&h.push(p.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+m+";")}(h.length||d)&&l.push((s&&!u&&!c?o.map(s):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)r(i(o),e[o],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=xE[SE]||1;return xE[SE]=e+1,g_+e.toString(36)}static mount(e,t,s){let i=e[y_],r=s&&s.nonce;i?r&&i.setNonce(r):i=new y7(e,r),i.mount(Array.isArray(t)?t:[t],e)}}let kE=new Map;class y7{constructor(e,t){let s=e.ownerDocument||e,i=s.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let r=kE.get(s);if(r)return e[y_]=r;this.sheet=new i.CSSStyleSheet,kE.set(s,this)}else this.styleTag=s.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[y_]=this}mount(e,t){let s=this.sheet,i=0,r=0;for(let o=0;o-1&&(this.modules.splice(l,1),r--,l=-1),l==-1){if(this.modules.splice(r++,0,a),s)for(let c=0;c",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},b7=typeof navigator<"u"&&/Mac/.test(navigator.platform),v7=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Fn=0;Fn<10;Fn++)Pa[48+Fn]=Pa[96+Fn]=String(Fn);for(var Fn=1;Fn<=24;Fn++)Pa[Fn+111]="F"+Fn;for(var Fn=65;Fn<=90;Fn++)Pa[Fn]=String.fromCharCode(Fn+32),uf[Fn]=String.fromCharCode(Fn);for(var $b in Pa)uf.hasOwnProperty($b)||(uf[$b]=Pa[$b]);function w7(n){var e=b7&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||v7&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?uf:Pa)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function xn(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s)){var i=t[s];typeof i=="string"?n.setAttribute(s,i):i!=null&&(n[s]=i)}e++}for(;e2);var de={mac:CE||/Mac/.test(us.platform),windows:/Win/.test(us.platform),linux:/Linux|X11/.test(us.platform),ie:H0,ie_version:YI?b_.documentMode||6:w_?+w_[1]:v_?+v_[1]:0,gecko:AE,gecko_version:AE?+(/Firefox\/(\d+)/.exec(us.userAgent)||[0,0])[1]:0,chrome:!!Tb,chrome_version:Tb?+Tb[1]:0,ios:CE,android:/Android\b/.test(us.userAgent),webkit:EE,webkit_version:EE?+(/\bAppleWebKit\/(\d+)/.exec(us.userAgent)||[0,0])[1]:0,safari:__,safari_version:__?+(/\bVersion\/(\d+(\.\d+)?)/.exec(us.userAgent)||[0,0])[1]:0,tabSize:b_.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Ix(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const wy=Object.create(null);function Ox(n,e,t){if(n==e)return!0;n||(n=wy),e||(e=wy);let s=Object.keys(n),i=Object.keys(e);if(s.length-0!=i.length-0)return!1;for(let r of s)if(r!=t&&(i.indexOf(r)==-1||n[r]!==e[r]))return!1;return!0}function _7(n,e){for(let t=n.attributes.length-1;t>=0;t--){let s=n.attributes[t].name;e[s]==null&&n.removeAttribute(s)}for(let t in e){let s=e[t];t=="style"?n.style.cssText=s:n.getAttribute(t)!=s&&n.setAttribute(t,s)}}function $E(n,e,t){let s=!1;if(e)for(let i in e)t&&i in t||(s=!0,i=="style"?n.style.cssText="":n.removeAttribute(i));if(t)for(let i in t)e&&e[i]==t[i]||(s=!0,i=="style"?n.style.cssText=t[i]:n.setAttribute(i,t[i]));return s}function S7(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new vc(e,t,t,s,e.widget||null,!1)}static replace(e){let t=!!e.block,s,i;if(e.isBlockGap)s=-5e8,i=4e8;else{let{start:r,end:o}=JI(e,t);s=(r?t?-3e8:-1:5e8)-1,i=(o?t?2e8:1:-6e8)+1}return new vc(e,s,i,t,e.widget||null,!0)}static line(e){return new im(e)}static set(e,t=!1){return et.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Ze.none=et.empty;class sm extends Ze{constructor(e){let{start:t,end:s}=JI(e);super(t?-1:5e8,s?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Ix(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||wy}eq(e){return this==e||e instanceof sm&&this.tagName==e.tagName&&Ox(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}sm.prototype.point=!1;class im extends Ze{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof im&&this.spec.class==e.spec.class&&Ox(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}im.prototype.mapMode=Qs.TrackBefore;im.prototype.point=!0;class vc extends Ze{constructor(e,t,s,i,r,o){super(t,s,r,e),this.block=i,this.isReplace=o,this.mapMode=i?t<=0?Qs.TrackBefore:Qs.TrackAfter:Qs.TrackDel}get type(){return this.startSide!=this.endSide?Hn.WidgetRange:this.startSide<=0?Hn.WidgetBefore:Hn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof vc&&x7(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}vc.prototype.point=!0;function JI(n,e=!1){let{inclusiveStart:t,inclusiveEnd:s}=n;return t==null&&(t=n.inclusive),s==null&&(s=n.inclusive),{start:t??e,end:s??e}}function x7(n,e){return n==e||!!(n&&e&&n.compare(e))}function dh(n,e,t,s=0){let i=t.length-1;i>=0&&t[i]+s>=n?t[i]=Math.max(t[i],e):t.push(n,e)}class df extends bc{constructor(e,t,s){super(),this.tagName=e,this.attributes=t,this.rank=s}eq(e){return e==this||e instanceof df&&this.tagName==e.tagName&&Ox(this.attributes,e.attributes)}static create(e){return new df(e.tagName,e.attributes||wy,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return et.of(e,t)}}df.prototype.startSide=df.prototype.endSide=-1;function ff(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function S_(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Zd(n,e){if(!e.anchorNode)return!1;try{return S_(n,e.anchorNode)}catch{return!1}}function Hg(n){return n.nodeType==3?pf(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function Xd(n,e,t,s){return t?TE(n,e,t,s,-1)||TE(n,e,t,s,1):!1}function Ra(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function _y(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function TE(n,e,t,s,i){for(;;){if(n==t&&e==s)return!0;if(e==(i<0?0:Eo(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||r.nodeType!=1)return!1;e=Ra(n)+(i<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=i<0?Eo(n):0}else return!1}}function Eo(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Sy(n,e){let{left:t,right:s}=n;if(t==s)return n;let i=e?t:s;return{left:i,right:i,top:n.top,bottom:n.bottom}}function k7(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function QI(n,e){let t=e.width/n.offsetWidth,s=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(s>.995&&s<1.005||!isFinite(s)||Math.abs(e.height-n.offsetHeight)<1)&&(s=1),{scaleX:t,scaleY:s}}function A7(n,e,t,s,i,r,o,a){let l=n.ownerDocument,c=l.defaultView||window;for(let h=n,u=!1;h&&!u;)if(h.nodeType==1){let d,p=h==l.body,m=1,g=1;if(p)d=k7(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let w=h.getBoundingClientRect();({scaleX:m,scaleY:g}=QI(h,w)),d={left:w.left,right:w.left+h.clientWidth*m,top:w.top,bottom:w.top+h.clientHeight*g}}let b=0,y=0;if(i=="nearest")e.top0&&e.bottom>d.bottom+y&&(y=e.bottom-d.bottom+o)):e.bottom>d.bottom-o&&(y=e.bottom-d.bottom+o,t<0&&e.top-y0&&e.right>d.right+b&&(b=e.right-d.right+r)):e.right>d.right-r&&(b=e.right-d.right+r,t<0&&e.leftd.bottom||e.leftd.right)&&(e={left:Math.max(e.left,d.left),right:Math.min(e.right,d.right),top:Math.max(e.top,d.top),bottom:Math.min(e.bottom,d.bottom)}),h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function eO(n,e=!0){let t=n.ownerDocument,s=null,i=null;for(let r=n.parentNode;r&&!(r==t.body||(!e||s)&&i);)if(r.nodeType==1)!i&&r.scrollHeight>r.clientHeight&&(i=r),e&&!s&&r.scrollWidth>r.clientWidth&&(s=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:s,y:i}}class E7{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:s}=e;this.set(t,Math.min(e.anchorOffset,t?Eo(t):0),s,Math.min(e.focusOffset,s?Eo(s):0))}set(e,t,s,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=s,this.focusOffset=i}}function tO(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function nO(n,e=!0){for(let{node:t,left:s,top:i}of n)e&&t.scrollTop!=i&&(t.scrollTop=i),t.scrollLeft!=s&&(t.scrollLeft=s)}let Ja=null;de.safari&&de.safari_version>=26&&(Ja=!1);function sO(n){if(n.setActive)return n.setActive();if(Ja)return n.focus(Ja);let e=tO(n);n.focus(Ja==null?{get preventScroll(){return Ja={preventScroll:!0},!0}}:void 0),Ja||(Ja=!1,nO(e))}let PE;function pf(n,e,t=e){let s=PE||(PE=document.createRange());return s.setEnd(n,t),s.setStart(n,e),s}function fh(n,e,t,s){let i={key:e,code:e,keyCode:t,which:t,cancelable:!0};s&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=s);let r=new KeyboardEvent("keydown",i);r.synthetic=!0,n.dispatchEvent(r);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,n.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function C7(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function $7(n,e){let t=e.focusNode,s=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=s)return!1;for(s=Math.min(s,Eo(t));;)if(s){if(t.nodeType!=1)return!1;let i=t.childNodes[s-1];i.contentEditable=="false"?s--:(t=i,s=Eo(t))}else{if(t==n)return!0;s=Ra(t),t=t.parentNode}}function iO(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function rO(n,e){for(let t=n,s=e;;){if(t.nodeType==3&&s>0)return{node:t,offset:s};if(t.nodeType==1&&s>0){if(t.contentEditable=="false")return null;t=t.childNodes[s-1],s=Eo(t)}else if(t.parentNode&&!_y(t))s=Ra(t),t=t.parentNode;else return null}}function oO(n,e){for(let t=n,s=e;;){if(t.nodeType==3&&s=t){if(a.level==s)return o;(r<0||(i!=0?i<0?a.fromt:e[r].level>a.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function cO(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;g-=3)if(tr[g+1]==-p){let b=tr[g+2],y=b&2?i:b&4?b&1?r:i:0;y&&(yt[u]=yt[tr[g]]=y),a=g;break}}else{if(tr.length==189)break;tr[a++]=u,tr[a++]=d,tr[a++]=l}else if((m=yt[u])==2||m==1){let g=m==i;l=g?0:1;for(let b=a-3;b>=0;b-=3){let y=tr[b+2];if(y&2)break;if(g)tr[b+2]|=2;else{if(y&4)break;tr[b+2]|=4}}}}}function O7(n,e,t,s){for(let i=0,r=s;i<=t.length;i++){let o=i?t[i-1].to:n,a=il;)m==b&&(m=t[--g].from,b=g?t[g-1].to:n),yt[--m]=p;l=h}else r=c,l++}}}function k_(n,e,t,s,i,r,o){let a=s%2?2:1;if(s%2==i%2)for(let l=e,c=0;ll&&o.push(new Tr(l,g.from,p));let b=g.direction==wc!=!(p%2);A_(n,b?s+1:s,i,g.inner,g.from,g.to,o),l=g.to}m=g.to}else{if(m==t||(h?yt[m]!=a:yt[m]==a))break;m++}d?k_(n,l,m,s+1,i,d,o):le;){let h=!0,u=!1;if(!c||l>r[c-1].to){let g=yt[l-1];g!=a&&(h=!1,u=g==16)}let d=!h&&a==1?[]:null,p=h?s:s+1,m=l;e:for(;;)if(c&&m==r[c-1].to){if(u)break e;let g=r[--c];if(!h)for(let b=g.from,y=c;;){if(b==e)break e;if(y&&r[y-1].to==b)b=r[--y].from;else{if(yt[b-1]==a)break e;break}}if(d)d.push(g);else{g.toyt.length;)yt[yt.length]=256;let s=[],i=e==wc?0:1;return A_(n,i,i,t,0,n.length,s),s}function hO(n){return[new Tr(0,n,0)]}let uO="";function L7(n,e,t,s,i){var r;let o=s.head-n.from,a=Tr.find(e,o,(r=s.bidiLevel)!==null&&r!==void 0?r:-1,s.assoc),l=e[a],c=l.side(i,t);if(o==c){let d=a+=i?1:-1;if(d<0||d>=e.length)return null;l=e[a=d],o=l.side(!i,t),c=l.side(i,t)}let h=kn(n.text,o,l.forward(i,t));(hl.to)&&(h=c),uO=n.text.slice(Math.min(o,h),Math.max(o,h));let u=a==(i?e.length-1:0)?null:e[a+(i?1:-1)];return u&&h==c&&u.level+(i?0:1)n.some(e=>e)}),vO=ve.define({combine:n=>n.some(e=>e)}),wO=ve.define();class ph{constructor(e,t,s,i,r,o=!1){this.range=e,this.y=t,this.x=s,this.yMargin=i,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new ph(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ph(te.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Nm=bt.define({map:(n,e)=>n.map(e)}),_O=bt.define();function Pr(n,e,t){let s=n.facet(mO);s.length?s[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const go=ve.define({combine:n=>n.length?n[0]:!0});let j7=0;const eh=ve.define({combine(n){return n.filter((e,t)=>{for(let s=0;s{let l=[];return o&&l.push(q0.of(c=>{let h=c.plugin(a);return h?o(h):Ze.none})),r&&l.push(r(a)),l})}static fromClass(e,t){return ti.define((s,i)=>new e(s,i),t)}}class Pb{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(s){if(Pr(t.state,s,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Pr(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(s){Pr(e.state,s,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const SO=ve.define(),jx=ve.define(),q0=ve.define(),xO=ve.define(),Fx=ve.define(),rm=ve.define(),kO=ve.define();function RE(n,e){let t=n.state.facet(kO);if(!t.length)return t;let s=t.map(r=>r instanceof Function?r(n):r),i=[];return et.spans(s,e.from,e.to,{point(){},span(r,o,a,l){let c=r-e.from,h=o-e.from,u=i;for(let d=a.length-1;d>=0;d--,l--){let p=a[d].spec.bidiIsolate,m;if(p==null&&(p=D7(e.text,c,h)),l>0&&u.length&&(m=u[u.length-1]).to==c&&m.direction==p)m.to=h,u=m.inner;else{let g={from:c,to:h,direction:p,inner:[]};u.push(g),u=g.inner}}}}),i}const AO=ve.define();function EO(n){let e=0,t=0,s=0,i=0;for(let r of n.state.facet(AO)){let o=r(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(s=Math.max(s,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:e,right:t,top:s,bottom:i}}const Td=ve.define();class gi{constructor(e,t,s,i){this.fromA=e,this.toA=t,this.fromB=s,this.toB=i}join(e){return new gi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,s=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>s.toA)){if(i.toAi.push(new gi(r,o,a,l))),this.changedRanges=i}static create(e,t,s){return new xy(e,t,s)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const F7=[];class Bt{constructor(e,t,s=0){this.dom=e,this.length=t,this.flags=s,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return F7}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&_7(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let s=t;for(let i of this.children){if(i==e)return s;s+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,s){return null}domPosFor(e,t){let s=Ra(this.dom),i=this.length?e>0:t>0;return new Wi(this.parent.dom,s+(i?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof U0)return e;return null}static get(e){return e.cmTile}}class V0 extends Bt{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,s=null,i,r=(e==null?void 0:e.node)==t?e:null,o=0;for(let a of this.children){if(a.sync(e),o+=a.length+a.breakAfter,i=s?s.nextSibling:t.firstChild,r&&i!=a.dom&&(r.written=!0),a.dom.parentNode==t)for(;i&&i!=a.dom;)i=ME(i);else t.insertBefore(a.dom,i);s=a.dom}for(i=s?s.nextSibling:t.firstChild,r&&i&&(r.written=!0);i;)i=ME(i);this.length=o}}function ME(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class U0 extends V0{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Bt.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],s=this,i=0,r=0;;)if(i==s.children.length){if(!t.length)return;s=s.parent,s.breakAfter&&r++,i=t.pop()}else{let o=s.children[i++];if(o instanceof xo)t.push(i),s=o,i=0;else{let a=r+o.length,l=e(o,r);if(l!==void 0)return l;r=a+o.breakAfter}}}resolveBlock(e,t){let s,i=-1,r,o=-1;if(this.blockTiles((a,l)=>{let c=l+a.length;if(e>=l&&e<=c){if(a.isWidget()&&t>=-1&&t<=1){if(a.flags&32)return!0;a.flags&16&&(s=void 0)}(le||e==l&&(t>1?a.length:a.covers(-1)))&&(!r||!a.isWidget()&&r.isWidget())&&(r=a,o=e-l)}}),!s&&!r)throw new Error("No tile at position "+e);return s&&t<0||!r?{tile:s,offset:i}:{tile:r,offset:o}}}class xo extends V0{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let s=new xo(t||document.createElement(e.tagName),e);return t||(s.flags|=4),s}}class xu extends V0{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,s){let i=new xu(t||document.createElement("div"),e);return(!t||!s)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,s){let i=null,r=-1,o=null,a=-1;function l(h,u){for(let d=0,p=0;d=u&&(m.isComposite()?l(m,u-p):(!o||o.isHidden&&(t>0&&!(o.flags&32)||s&&H7(o,m)))&&(g>u||m.flags&32&&t<=1)?(o=m,a=u-p):(p=-1)&&(i=m,r=u-p)),p=g}}l(this,e);let c=(t<0?i:o)||i||o;return c?{tile:c,offset:c==i?r:a}:null}coordsIn(e,t,s){let i=this.resolveInline(e,t,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),t,s):z7(this)}domIn(e,t){let s=this.resolveInline(e,t);if(s){let{tile:i,offset:r}=s;if(this.dom.contains(i.dom))return i.isText()?new Wi(i.dom,Math.min(i.dom.nodeValue.length,r)):i.domPosFor(r,i.flags&16?1:i.flags&32?-1:t);let o=s.tile.parent,a=!1;for(let l of o.children){if(a)return new Wi(l.dom,0);l==s.tile&&(a=!0)}}return new Wi(this.dom,0)}}function z7(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=Hg(e);return t[t.length-1]||null}function H7(n,e){let t=n.coordsIn(0,1),s=e.coordsIn(0,1);return t&&s&&s.topi&&(e=i);let r=e,o=e,a=0;e==0&&t<0||e==i&&t>=0?de.chrome||de.gecko||(e?(r--,a=1):o=0)?0:l.length-1];return de.safari&&!a&&c.width==0&&(c=Array.prototype.find.call(l,h=>h.width)||c),s==null?c:Sy(c,(a?a>0:t<0)==s)}static of(e,t){let s=new cl(t||document.createTextNode(e),e);return t||(s.flags|=2),s}}class _c extends Bt{constructor(e,t,s,i){super(e,t,i),this.widget=s}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,s){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;if(s)return Sy(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let a=this.flags&16?!0:this.flags&32?!1:e>0;for(let l=a?r.length-1:0;o=r[l],!(e>0?l==0:l==r.length-1||o.top0==s)}}class B7{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,s){let{tile:i,index:r,beforeBreak:o,parents:a}=this;for(;e||t>0;)if(i.isComposite())if(o){if(!e)break;s&&s.break(),e--,o=!1}else if(r==i.children.length){if(!e&&!a.length)break;s&&s.leave(i),o=!!i.breakAfter,{tile:i,index:r}=a.pop(),r++}else{let l=i.children[r],c=l.breakAfter;(t>0?l.length<=e:l.length=0;a--){let l=t.marks[a],c=i.lastChild;if(c instanceof Is&&c.mark.eq(l.mark))c.dom!=l.dom&&c.setDOM(Rb(l.dom)),i=c;else{if(this.cache.reused.get(l)){let u=Bt.get(l.dom);u&&u.setDOM(Rb(l.dom))}let h=Is.of(l.mark,l.dom);i.append(h),i=h}this.cache.reused.set(l,2)}let r=Bt.get(e.text);r&&this.cache.reused.set(r,2);let o=new cl(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,i.append(o)}addInlineWidget(e,t,s){let i=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);i||this.flushBuffer();let r=this.ensureMarks(t,s);!i&&!(e.flags&16)&&r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,s){this.flushBuffer(),this.ensureMarks(t,s).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var s;e||(e=CO);let i=xu.start(e,t||((s=this.cache.find(xu))===null||s===void 0?void 0:s.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var s;let i=this.curLine;for(let r=e.length-1;r>=0;r--){let o=e[r],a;if(t>0&&(a=i.lastChild)&&a instanceof Is&&a.mark.eq(o))i=a,t--;else{let l=Is.of(o,(s=this.cache.find(Is,c=>c.mark.eq(o)))===null||s===void 0?void 0:s.dom);i.append(l),i=l,t=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!IE(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(de.ios&&IE(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Mb,0,32)||new _c(Mb.toDOM(),0,Mb,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=e.rank*102+e.value.rank,s=new q7(e.from,e.to,e.value,t),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-s.rank||this.wrappers[i-1].to-s.to)<0;)i--;this.wrappers.splice(i,0,s)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let s of this.wrappers){let i=t.lastChild;if(s.fromo.wrapper.eq(s.wrapper)))===null||e===void 0?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),s=this.cache.find(ky,void 0,1);return s&&(s.flags=t),s||new ky(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class U7{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:i,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=i;let a=this.textOff=Math.min(e,i.length);return r?null:i.slice(0,a)}let t=Math.min(this.text.length,this.textOff+e),s=this.text.slice(this.textOff,t);return this.textOff=t,s}}const Ay=[_c,xu,cl,Is,ky,xo,U0];for(let n=0;n[]),this.index=Ay.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,s=this.buckets[t];s.length<6?s.push(e):s[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,s=2){let i=e.bucket,r=this.buckets[i],o=this.index[i];for(let a=0;a{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let s=t&&this.getCompositionContext(t.text);for(let i=0,r=0,o=0;;){let a=oi){let c=l-i;this.preserve(c,!o,!a),i=l,r+=c}if(!a)break;t&&a.fromA<=t.range.fromA&&a.toA>=t.range.toA?(this.forward(a.fromA,t.range.fromA,t.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(l-a);else{let c=l>0||a{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Is&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=r=0):o instanceof Is&&(i.shift(),r=Math.min(r,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let s=null,i=this.builder,r=-1,o=et.spans(this.decorations,e,t,{point:(a,l,c,h,u,d)=>{if(c instanceof vc){if(this.disallowBlockEffectsFor[d]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(l>this.view.state.doc.lineAt(a).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=h.length,u>h.length)i.continueWidget(l-a);else{let p=c.widget||(c.block?ku.block:ku.inline),m=K7(c),g=this.cache.findWidget(p,l-a,m)||_c.of(p,this.view,l-a,m);c.block?(c.startSide>0&&i.addLineStartIfNotCovered(s),i.addBlockWidget(g)):(i.ensureLine(s),i.addInlineWidget(g,h,u))}s=null}else s=Z7(s,c);l>a&&this.text.skip(l-a)},span:(a,l,c,h)=>{for(let u=a;u-1&&(this.openWidget=o>r),this.openWidget||i.addLineStartIfNotCovered(s),this.openMarks=o}forward(e,t,s=1){t-e<=10?this.old.advance(t-e,s,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,s,this.reuseWalker))}getCompositionContext(e){let t=[],s=null;for(let i=e.parentNode;;i=i.parentNode){let r=Bt.get(i);if(i==this.view.contentDOM)break;r instanceof Is?t.push(r):r!=null&&r.isLine()?s=r:r instanceof xo||(i.nodeName=="DIV"&&!s&&i!=this.view.contentDOM?s=new xu(i,CO):s||t.push(Is.of(new sm({tagName:i.nodeName.toLowerCase(),attributes:S7(i)}),i)))}return{line:s,marks:t}}}function IE(n,e){let t=s=>{for(let i of s.children)if((e?i.isText():i.length)||t(i))return!0;return!1};return t(n)}function K7(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const CO={class:"cm-line"};function Z7(n,e){let t=e.spec.attributes,s=e.spec.class;return!t&&!s||(n||(n={class:"cm-line"}),t&&Ix(t,n),s&&(n.class+=" "+s)),n}function X7(n){let e=[];for(let t=n.parents.length;t>1;t--){let s=t==n.parents.length?n.tile:n.parents[t].tile;s instanceof Is&&e.push(s.mark)}return e}function Rb(n){let e=Bt.get(n);return e&&e.setDOM(n.cloneNode()),n}class ku extends B0{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}ku.inline=new ku("span");ku.block=new ku("div");const Mb=new class extends B0{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class OE{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Ze.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new U0(e,e.contentDOM),this.updateInner([new gi(0,0,0,e.state.doc.length)],null)}update(e){var t;let s=e.changedRanges;this.minWidth>0&&s.length&&(s.every(({fromA:h,toA:u})=>uthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?i=this.domChanged.newSel.head:!rJ(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let r=i>-1?J7(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:h,to:u}=this.hasComposition;s=new gi(h,u,e.changes.mapPos(h,-1),e.changes.mapPos(u,1)).addToSet(s.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(de.ie||de.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,a=this.blockWrappers;this.updateDeco();let l=tJ(o,this.decorations,e.changes);l.length&&(s=gi.extendWithRanges(s,l));let c=sJ(a,this.blockWrappers,e.changes);return c.length&&(s=gi.extendWithRanges(s,c)),r&&!s.some(h=>h.fromA<=r.range.fromA&&h.toA>=r.range.toA)&&(s=r.range.addToSet(s.slice())),this.tile.flags&2&&s.length==0?!1:(this.updateInner(s,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:s}=this.view;s.ignore(()=>{if(t||e.length){let o=this.tile,a=new G7(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Bt.get(t.text)&&a.cache.reused.set(Bt.get(t.text),2),this.tile=a.run(e,t),C_(o,a.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=de.chrome||de.ios?{node:s.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||s.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Zd(s,this.view.observer.selectionRange)&&!(i&&s.contains(i));if(!(r||t||o))return;let a=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,c,h;if(l.empty?h=c=this.inlineDOMNearPos(l.anchor,l.assoc||1):(h=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),c=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),de.gecko&&l.empty&&!this.hasComposition&&Y7(c)){let d=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(d,c.node.childNodes[c.offset]||null)),c=h=new Wi(d,0),a=!0}let u=this.view.observer.selectionRange;(a||!u.focusNode||(!Xd(c.node,c.offset,u.anchorNode,u.anchorOffset)||!Xd(h.node,h.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,l))&&(this.view.observer.ignore(()=>{de.android&&de.chrome&&s.contains(u.focusNode)&&iJ(u.focusNode,s)&&(s.blur(),s.focus({preventScroll:!0}));let d=ff(this.view.root);if(d)if(l.empty){if(de.gecko){let p=Q7(c.node,c.offset);if(p&&p!=3){let m=(p==1?rO:oO)(c.node,c.offset);m&&(c=new Wi(m.node,m.offset))}}d.collapse(c.node,c.offset),l.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=l.bidiLevel)}else if(d.extend){d.collapse(c.node,c.offset);try{d.extend(h.node,h.offset)}catch{}}else{let p=document.createRange();l.anchor>l.head&&([c,h]=[h,c]),p.setEnd(h.node,h.offset),p.setStart(c.node,c.offset),d.removeAllRanges(),d.addRange(p)}o&&this.view.root.activeElement==s&&(s.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(c,h)),this.impreciseAnchor=c.precise?null:new Wi(u.anchorNode,u.anchorOffset),this.impreciseHead=h.precise?null:new Wi(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Xd(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,s=ff(e.root),{anchorNode:i,anchorOffset:r}=e.observer.selectionRange;if(!s||!t.empty||!t.assoc||!s.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let a=o.posAtStart;if(t.head==a||t.head==a+o.length)return;let l=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!l||!c||l.bottom>c.top)return;let h=this.domAtPos(t.head+t.assoc,t.assoc);s.collapse(h.node,h.offset),s.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&s.collapse(i,r)}posFromDOM(e,t){let s=this.tile.nearest(e);if(!s)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let i=s.posAtStart;if(s.isComposite()){let r;if(e==s.dom)r=s.dom.childNodes[t];else{let o=Eo(e)==0?0:t==0?-1:1;for(;;){let a=e.parentNode;if(a==s.dom)break;o==0&&a.firstChild!=a.lastChild&&(e==a.firstChild?o=-1:o=1),e=a}o<0?r=e:r=e.nextSibling}if(r==s.dom.firstChild)return i;for(;r&&!Bt.get(r);)r=r.nextSibling;if(!r)return i+s.length;for(let o=0,a=i;;o++){let l=s.children[o];if(l.dom==r)return a;a+=l.length+l.breakAfter}}else return s.isText()?e==s.dom?i+t:i+(t?s.length:0):i}domAtPos(e,t){let{tile:s,offset:i}=this.tile.resolveBlock(e,t);return s.isWidget()?s.domPosFor(i,t):s.domIn(i,t)}inlineDOMNearPos(e,t){let s,i=-1,r=!1,o,a=-1,l=!1;return this.tile.blockTiles((c,h)=>{if(c.isWidget()){if(c.flags&32&&h>=e)return!0;c.flags&16&&(r=!0)}else{let u=h+c.length;if(h<=e&&(s=c,i=e-h,r=u=e&&!o&&(o=c,a=e-h,l=h>e),h>e&&o)return!0}}),!s&&!o?this.domAtPos(e,t):(r&&o?s=null:l&&s&&(o=null),s&&t<0||!o?s.domIn(i,t):o.domIn(a,t))}coordsAt(e,t,s){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof Ib?null:i.coordsInWidget(r,t,!0):i.coordsIn(r,t,s)}lineAt(e,t){let{tile:s}=this.tile.resolveBlock(e,t);return s.isLine()?s:null}coordsForChar(e){let{tile:t,offset:s}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function i(r,o){if(r.isComposite())for(let a of r.children){if(a.length>=o){let l=i(a,o);if(l)return l}if(o-=a.length,o<0)break}else if(r.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==Pt.LTR,c=0,h=(u,d,p)=>{for(let m=0;mi);m++){let g=u.children[m],b=d+g.length,y=g.dom.getBoundingClientRect(),{height:w}=y;if(p&&!m&&(c+=y.top-p.top),g instanceof xo)b>s&&h(g,d,y);else if(d>=s&&(c>0&&t.push(-c),t.push(w+c),c=0,o)){let v=g.dom.lastChild,x=v?Hg(v):[];if(x.length){let k=x[x.length-1],E=l?k.right-y.left:y.right-k.left;E>a&&(a=E,this.minWidth=r,this.minWidthFrom=d,this.minWidthTo=b)}}p&&m==u.children.length-1&&(c+=p.bottom-y.bottom),d=b+g.breakAfter}};return h(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?Pt.RTL:Pt.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let a=0,l;for(let c of o.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let h=Hg(c.dom);if(h.length!=1)return;a+=h[0].width,l=h[0].height}if(a)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:a/o.length,textHeight:l}}});if(e)return e;let t=document.createElement("div"),s,i,r;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=Hg(t.firstChild)[0];s=t.getBoundingClientRect().height,i=o&&o.width?o.width/27:7,r=o&&o.height?o.height:s,t.remove()}),{lineHeight:s,charWidth:i,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let s=0,i=0;;i++){let r=i==t.viewports.length?null:t.viewports[i],o=r?r.from-1:this.view.state.doc.length;if(o>s){let a=(t.lineBlockAt(o).bottom-t.lineBlockAt(s).top)/this.view.scaleY;e.push(Ze.replace({widget:new Ib(a),block:!0,inclusive:!0,isBlockGap:!0}).range(s,o))}if(!r)break;s=r.to+1}return Ze.set(e)}updateDeco(){let e=1,t=this.view.state.facet(q0).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),s=!1,i=this.view.state.facet(Fx).map((r,o)=>{let a=typeof r=="function";return a&&(s=!0),a?r(this.view):r});for(i.length&&(this.dynamicDecorationMap[e++]=s,t.push(et.join(i))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof r=="function"?r(this.view):r)}scrollIntoView(e){if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(wO))try{if(c(this.view,e.range,e))return!0}catch(h){Pr(this.view.state,h,"scroll handler")}let{range:t}=e,s=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),i;if(!s)return;!t.empty&&(i=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(s={left:Math.min(s.left,i.left),top:Math.min(s.top,i.top),right:Math.max(s.right,i.right),bottom:Math.max(s.bottom,i.bottom)});let r=EO(this.view),o={left:s.left-r.left,top:s.top-r.top,right:s.right+r.right,bottom:s.bottom+r.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;if(A7(this.view.scrollDOM,o,t.head1&&(s.top>window.visualViewport.offsetTop+window.visualViewport.height||s.bottoms.isWidget()||s.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){C_(this.tile)}}function C_(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let s of n.children)C_(s,e)}}function Y7(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function $O(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let s=rO(t.focusNode,t.focusOffset),i=oO(t.focusNode,t.focusOffset),r=s||i;if(i&&s&&i.node!=s.node){let a=Bt.get(i.node);if(!a||a.isText()&&a.text!=i.node.nodeValue)r=i;else if(n.docView.lastCompositionAfterCursor){let l=Bt.get(s.node);!l||l.isText()&&l.text!=s.node.nodeValue||(r=i)}}if(n.docView.lastCompositionAfterCursor=r!=s,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function J7(n,e,t){let s=$O(n,t);if(!s)return null;let{node:i,from:r,to:o}=s,a=i.nodeValue;if(/[\n\r]/.test(a)||n.state.doc.sliceString(s.from,s.to)!=a)return null;let l=e.invertedDesc;return{range:new gi(l.mapPos(r),l.mapPos(o),r,o),text:i}}function Q7(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{se.from&&(t=!0)}),t}class Ib extends B0{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function oJ(n,e,t=1){let s=n.charCategorizer(e),i=n.doc.lineAt(e),r=e-i.from;if(i.length==0)return te.cursor(e);r==0?t=1:r==i.length&&(t=-1);let o=r,a=r;t<0?o=kn(i.text,r,!1):a=kn(i.text,r);let l=s(i.text.slice(o,a));for(;o>0;){let c=kn(i.text,o,!1);if(s(i.text.slice(c,o))!=l)break;o=c}for(;an.defaultLineHeight*1.5){let a=n.viewState.heightOracle.textHeight,l=Math.floor((i-t.top-(n.defaultLineHeight-a)*.5)/a);r+=l*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+g7(o,r,n.state.tabSize)}function $_(n,e,t){let s=n.lineBlockAt(e);if(Array.isArray(s.type)){let i;for(let r of s.type){if(r.from>e)break;if(!(r.toe)return r;(!i||r.type==Hn.Text&&(i.type!=r.type||(t<0?r.frome)))&&(i=r)}}return i||s}return s}function lJ(n,e,t,s){let i=$_(n,e.head,e.assoc||-1),r=!s||i.type!=Hn.Text||!(n.lineWrapping||i.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(r){let o=n.dom.getBoundingClientRect(),a=n.textDirectionAt(i.from),l=n.posAtCoords({x:t==(a==Pt.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(l!=null)return te.cursor(l,t?-1:1)}return te.cursor(t?i.to:i.from,t?-1:1)}function NE(n,e,t,s){let i=n.state.doc.lineAt(e.head),r=n.bidiSpans(i),o=n.textDirectionAt(i.from);for(let a=e,l=null;;){let c=L7(i,r,o,a,t),h=uO;if(!c){if(i.number==(t?n.state.doc.lines:1))return a;h=` +`,i=n.state.doc.line(i.number+(t?1:-1)),r=n.bidiSpans(i),c=n.visualLineSide(i,!t)}if(l){if(!l(h))return a}else{if(!s)return c;l=s(h)}a=c}}function cJ(n,e,t){let s=n.state.charCategorizer(e),i=s(t);return r=>{let o=s(r);return i==Zt.Space&&(i=o),i==o}}function hJ(n,e,t,s){let i=e.head,r=t?1:-1;if(i==(t?n.state.doc.length:0))return te.cursor(i,e.assoc);let o=e.goalColumn,a,l=n.contentDOM.getBoundingClientRect(),c=n.coordsAtPos(i,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),h=n.documentTop;if(c)o==null&&(o=c.left-l.left),a=r<0?c.top:c.bottom;else{let m=n.viewState.lineBlockAt(i);o==null&&(o=Math.min(l.right-l.left,n.defaultCharacterWidth*(i-m.from))),a=(r<0?m.top:m.bottom)+h}let u=l.left+o,d=n.viewState.heightOracle.textHeight>>1,p=s??d;for(let m=0;;m+=d){let g=a+(p+m)*r,b=T_(n,{x:u,y:g},!1,r);if(t?g>l.bottom:ga:w{if(e>r&&ei(n)),t.from,e.head>t.from?-1:1);return s==t.from?t:te.cursor(s,sn.viewState.docHeight)return new Er(n.state.doc.length,-1);if(c=n.elementAtHeight(l),s==null)break;if(c.type==Hn.Text){if(s<0?c.ton.viewport.to)break;let d=n.docView.coordsAt(s<0?c.from:c.to,s>0?-1:1);if(d&&(s<0?d.top<=l+r:d.bottom>=l+r))break}let u=n.viewState.heightOracle.textHeight/2;l=s>0?c.bottom+u:c.top-u}if(n.viewport.from>=c.to||n.viewport.to<=c.from){if(t)return null;if(c.type==Hn.Text){let u=aJ(n,i,c,o,a);return new Er(u,u==c.from?1:-1)}}if(c.type!=Hn.Text)return l<(c.top+c.bottom)/2?new Er(c.from,1):new Er(c.to,-1);let h=n.docView.lineAt(c.from,2);return(!h||h.length!=c.length)&&(h=n.docView.lineAt(c.from,-2)),new uJ(n,o,a,n.textDirectionAt(c.from)).scanTile(h,c.from)}class uJ{constructor(e,t,s,i){this.view=e,this.x=t,this.y=s,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||s.length&&(s[0].level!=this.baseDir||s[0].to+i.from>1;t:if(o.has(g)){for(let w=1;w=r&&(v-=m),!o.has(v)){g=v;break t}}break e}o.add(g);let b=t(g),y=0;if(b)for(let w=0;w1))if(v.bottomthis.y)(!c||c.top>v.top)&&(c=v),y=-1;else{let x=v.left>this.x?this.x-v.left:v.right(m+m+g)/3)return this.y=l.bottom-1,this.scan(e,t,!0);if(c&&c.top<(m+g+g)/3)return this.y=c.top+1,this.scan(e,t,!0)}let p=(a?this.dirAt(e[h],1):this.baseDir)==Pt.LTR;return{i:h,after:this.x>(d.left+d.right)/2==p}}scanText(e,t){let s=[];for(let r=0;r{let o=s[r]-t,a=s[r+1]-t;return pf(e.dom,o,a).getClientRects()});return i.after?new Er(s[i.i+1],-1):new Er(s[i.i],1)}scanTile(e,t){if(!e.length)return new Er(t,1);if(e.children.length==1){let a=e.children[0];if(a.isText())return this.scanText(a,t);if(a.isComposite())return this.scanTile(a,t)}let s=[t];for(let a=0,l=t;a{let l=e.children[a];return l.flags&48?null:(l.dom.nodeType==1?l.dom:pf(l.dom,0,l.length)).getClientRects()}),r=e.children[i.i],o=s[i.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):i.after?new Er(s[i.i+1],-1):new Er(o,1)}}const Kc="￿";class dJ{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(it.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Kc}readRange(e,t){if(!e)return this;let s=e.parentNode;for(let i=e;;){this.findPointBefore(s,i);let r=this.text.length;this.readNode(i);let o=Bt.get(i),a=i.nextSibling;if(a==t){o!=null&&o.breakAfter&&!a&&s!=this.view.contentDOM&&this.lineBreak();break}let l=Bt.get(a);(o&&l?o.breakAfter:(o?o.breakAfter:_y(i))||_y(a)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>r)&&!pJ(a,t)&&this.lineBreak(),i=a}return this.findPointBefore(s,t),this}readTextNode(e){let t=e.nodeValue;for(let s of this.points)s.node==e&&(s.pos=this.text.length+Math.min(s.offset,t.length));for(let s=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,a;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,s),o=this.lineSeparator.length):(a=i.exec(t))&&(r=a.index,o=a[0].length),this.append(t.slice(s,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=o-1);s=r+o}}readNode(e){let t=Bt.get(e),s=t&&t.overrideDOMText;if(s!=null){this.findPointInside(e,s.length);for(let i=s.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let s of this.points)s.node==e&&e.childNodes[s.offset]==t&&(s.pos=this.text.length)}findPointInside(e,t){for(let s of this.points)(e.nodeType==3?s.node==e:e.contains(s.node))&&(s.pos=this.text.length+(fJ(e,s.node,s.offset)?t:0))}}function fJ(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView,a=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=PO(e.docView.tile,t,s,0))){let l=r||o?[]:yJ(e),c=new dJ(l,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=bJ(l,this.bounds.from)}else{let l=e.observer.selectionRange,c=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!S_(e.contentDOM,l.focusNode)?a.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!S_(e.contentDOM,l.anchorNode)?a.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),u=e.viewport;if((de.ios||de.chrome)&&c!=h&&Math.min(c,h)<=a.main.from&&Math.max(c,h)>=a.main.to&&(u.from>0||u.to-1&&a.ranges.length>1)this.newSel=a.replaceRange(te.range(h,c));else if(e.lineWrapping&&h==c&&!(a.main.empty&&a.main.head==c)&&e.inputState.lastTouchTime>Date.now()-100){let d=e.coordsAtPos(c,-1),p=0;d&&(p=e.inputState.lastTouchY<=d.bottom?-1:1),this.newSel=te.create([te.cursor(c,p)])}else this.newSel=te.single(h,c)}}}function PO(n,e,t,s){if(n.isComposite()){let i=-1,r=-1,o=-1,a=-1;for(let l=0,c=s,h=s;lt)return PO(u,e,t,c);if(d>=e&&i==-1&&(i=l,r=c),c>t&&u.dom.parentNode==n.dom){o=l,a=h;break}h=d,c=d+u.breakAfter}return{from:r,to:a<0?s+n.length:a,startDOM:(i?n.children[i-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o=0?n.children[o].dom:null}}else return n.isText()?{from:s,to:s+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function RO(n,e){let t,{newSel:s}=e,{state:i}=n,r=i.selection.main,o=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:l}=e.bounds,c=r.from,h=null;(o===8||de.android&&e.text.length=a&&r.to<=l&&(e.typeOver||u!=e.text)&&u.slice(0,r.from-a)==e.text.slice(0,r.from-a)&&u.slice(r.to-a)==e.text.slice(d=e.text.length-(u.length-(r.to-a)))?t={from:r.from,to:r.to,insert:rt.of(e.text.slice(r.from-a,d).split(Kc))}:(p=MO(u,e.text,c-a,h))&&(de.chrome&&o==13&&p.toB==p.from+2&&e.text.slice(p.from,p.toB)==Kc+Kc&&p.toB--,t={from:a+p.from,to:a+p.toA,insert:rt.of(e.text.slice(p.from,p.toB).split(Kc))})}else s&&(!n.hasFocus&&i.facet(go)||Ey(s,r))&&(s=null);if(!t&&!s)return!1;if((de.mac||de.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(s&&t.insert.length==2&&(s=te.single(s.main.anchor-1,s.main.head-1)),t={from:t.from,to:t.to,insert:rt.of([t.insert.toString().replace("."," ")])}):i.doc.lineAt(r.from).toDate.now()-50?t={from:r.from,to:r.to,insert:i.toText(n.inputState.insertingText)}:de.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==` + `&&n.lineWrapping&&(s&&(s=te.single(s.main.anchor-1,s.main.head-1)),t={from:r.from,to:r.to,insert:rt.of([" "])}),t)return zx(n,t,s,o);if(s&&!Ey(s,r)){let a=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(a=!0),l=n.inputState.lastSelectionOrigin,l=="select.pointer"&&(s=TO(i.facet(rm).map(c=>c(n)),s))),n.dispatch({selection:s,scrollIntoView:a,userEvent:l}),!0}else return!1}function zx(n,e,t,s=-1){if(de.ios&&n.inputState.flushIOSKey(e))return!0;let i=n.state.selection.main;if(de.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&n.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&fh(n.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||s==8&&e.insert.lengthi.head)&&fh(n.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&fh(n.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,a=()=>o||(o=gJ(n,e,t));return n.state.facet(gO).some(l=>l(n,e.from,e.to,r,a))||n.dispatch(a()),!0}function gJ(n,e,t){let s,i=n.state,r=i.selection.main,o=-1;if(e.from==e.to&&e.fromr.to){let l=e.fromu(n)),c,l);e.from==h&&(o=h)}if(o>-1)s={changes:e,selection:te.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=r.frome.to?i.sliceDoc(e.to,r.to):"";s=i.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+c))}else{let l=i.changes(e),c=t&&t.main.to<=l.newLength?t.main:void 0;if(i.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=r.to+10&&e.to>=r.to-10){let h=n.state.sliceDoc(e.from,e.to),u,d=t&&$O(n,t.main.head);if(d){let m=e.insert.length-(e.to-e.from);u={from:d.from,to:d.to-m}}else u=n.state.doc.lineAt(r.head);let p=r.to-e.to;s=i.changeByRange(m=>{if(m.from==r.from&&m.to==r.to)return{changes:l,range:c||m.map(l)};let g=m.to-p,b=g-h.length;if(n.state.sliceDoc(b,g)!=h||g>=u.from&&b<=u.to)return{range:m};let y=i.changes({from:b,to:g,insert:e.insert}),w=m.to-r.to;return{changes:y,range:c?te.range(Math.max(0,c.anchor+w),Math.max(0,c.head+w)):m.map(y)}})}else s={changes:l,selection:c&&i.selection.replaceRange(c)}}let a="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,a+=".compose",n.inputState.compositionFirstChange&&(a+=".start",n.inputState.compositionFirstChange=!1)),i.update(s,{userEvent:a,scrollIntoView:!0})}function MO(n,e,t,s){let i=Math.min(n.length,e.length),r=0;for(;r0&&a>0&&n.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(s=="end"){let l=Math.max(0,r-Math.min(o,a));t-=o+l-r}if(o=o?r-t:0;r-=l,a=r+(a-o),o=r}else if(a=a?r-t:0;r-=l,o=r+(o-a),a=r}return{from:r,toA:o,toB:a}}function yJ(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:s,focusNode:i,focusOffset:r}=n.observer.selectionRange;return t&&(e.push(new LE(t,s)),(i!=t||r!=s)&&e.push(new LE(i,r))),e}function bJ(n,e){if(n.length==0)return null;let t=n[0].pos,s=n.length==2?n[1].pos:t;return t>-1&&s>-1?te.single(t+e,s+e):null}function Ey(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}class vJ{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,de.safari&&e.contentDOM.addEventListener("input",()=>null),de.gecko&&NJ(e.contentDOM.ownerDocument)}handleEvent(e){!$J(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let s=this.handlers[e];if(s){for(let i of s.observers)i(this.view,t);for(let i of s.handlers){if(t.defaultPrevented)break;if(i(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=_J(e),s=this.handlers,i=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,a=s[r];a&&o!=!a.handlers.length&&(i.removeEventListener(r,this.handleEvent),a=null),a||i.addEventListener(r,this.handleEvent,{passive:o})}for(let r in s)r!="scroll"&&!t[r]&&i.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&OO.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),de.android&&de.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(de.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(IO.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||SJ.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&de.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&wJ(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:de.safari&&!de.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function wJ(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function DE(n,e){return(t,s)=>{try{return e.call(n,s,t)}catch(i){Pr(t.state,i)}}}function _J(n){let e=Object.create(null);function t(s){return e[s]||(e[s]={observers:[],handlers:[]})}for(let s of n){let i=s.spec,r=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(r)for(let a in r){let l=r[a];l&&t(a).handlers.push(DE(s.value,l))}if(o)for(let a in o){let l=o[a];l&&t(a).observers.push(DE(s.value,l))}}for(let s in Xi)t(s).handlers.push(Xi[s]);for(let s in ys)t(s).observers.push(ys[s]);return e}const IO=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],SJ="dthko",OO=[16,17,18,20,91,92,224,225],Lm=6;function Dm(n){return Math.max(0,n)*.7+8}function xJ(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class kJ{constructor(e,t,s,i){this.view=e,this.startEvent=t,this.style=s,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=eO(e.contentDOM),this.atoms=e.state.facet(rm).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(it.allowMultipleSelections)&&AJ(e,t),this.dragging=CJ(e,t)&&DO(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&xJ(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,s=0,i=0,r=0,o=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=EO(this.view);e.clientX-l.left<=i+Lm?t=-Dm(i-e.clientX):e.clientX+l.right>=o-Lm&&(t=Dm(e.clientX-o)),e.clientY-l.top<=r+Lm?s=-Dm(r-e.clientY):e.clientY+l.bottom>=a-Lm&&(s=Dm(e.clientY-a)),this.setScrollSpeed(t,s)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,s=TO(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!s.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:s,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function AJ(n,e){let t=n.state.facet(dO);return t.length?t[0](e):de.mac?e.metaKey:e.ctrlKey}function EJ(n,e){let t=n.state.facet(fO);return t.length?t[0](e):de.mac?!e.altKey:!e.ctrlKey}function CJ(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let s=ff(n.root);if(!s||s.rangeCount==0)return!0;let i=s.getRangeAt(0).getClientRects();for(let r=0;r=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function $J(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,s;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(s=Bt.get(t))&&s.isWidget()&&!s.isHidden&&s.widget.ignoreEvent(e))return!1;return!0}const Xi=Object.create(null),ys=Object.create(null),NO=de.ie&&de.ie_version<15||de.ios&&de.webkit_version<604;function TJ(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),LO(n,t.value)},50)}function W0(n,e,t){for(let s of n.facet(e))t=s(t,n);return t}function LO(n,e){e=W0(n.state,Lx,e);let{state:t}=n,s,i=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(P_!=null&&t.selection.ranges.every(l=>l.empty)&&P_==r.toString()){let l=-1;s=t.changeByRange(c=>{let h=t.doc.lineAt(c.from);if(h.from==l)return{range:c};l=h.from;let u=t.toText((o?r.line(i++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:u},range:te.cursor(c.from+u.length)}})}else o?s=t.changeByRange(l=>{let c=r.line(i++);return{changes:{from:l.from,to:l.to,insert:c.text},range:te.cursor(l.from+c.length)}}):s=t.replaceSelection(r);n.dispatch(s,{userEvent:"input.paste",scrollIntoView:!0})}ys.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,de.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};ys.wheel=ys.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};Xi.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);ys.touchstart=(n,e)=>{let t=n.inputState,s=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),s&&(t.lastTouchX=s.clientX,t.lastTouchY=s.clientY),t.setSelectionOrigin("select.pointer")};ys.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};ys.touchend=(n,e)=>{n.inputState.touchActive=!1};Xi.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let s of n.state.facet(pO))if(t=s(n,e),t)break;if(!t&&e.button==0&&(t=RJ(n,e)),t){let s=!n.hasFocus;n.inputState.startMouseSelection(new kJ(n,e,t,s)),s&&n.observer.ignore(()=>{sO(n.contentDOM);let r=n.root.activeElement;r&&!r.contains(n.contentDOM)&&r.blur()});let i=n.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function jE(n,e,t,s){if(s==1)return te.cursor(e,t);if(s==2)return oJ(n.state,e,t);{let i=n.docView.lineAt(e,t),r=n.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:r.from,a=i?i.posAtEnd:r.to;return aDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(zE+1)%3:1}function RJ(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),s=DO(e),i=n.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),i=i.map(r.changes))},get(r,o,a){let l=n.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),c,h=jE(n,l.pos,l.assoc,s);if(t.pos!=l.pos&&!o){let u=jE(n,t.pos,t.assoc,s),d=Math.min(u.from,h.from),p=Math.max(u.to,h.to);h=d1&&(c=MJ(i,l.pos))?c:a?i.addRange(h):te.create([h])}}}function MJ(n,e){for(let t=0;t=e)return te.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}Xi.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let i=n.docView.tile.nearest(e.target);if(i&&i.isWidget()){let r=i.posAtStart,o=r+i.length;(r>=t.to||o<=t.from)&&(t=te.undirectionalRange(r,o))}}let{inputState:s}=n;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",W0(n.state,Dx,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Xi.dragend=n=>(n.inputState.draggedContent=null,!1);function BE(n,e,t,s){if(t=W0(n.state,Lx,t),!t)return;let i=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=n.inputState,o=s&&r&&EJ(n,e)?{from:r.from,to:r.to}:null,a={from:i,insert:t},l=n.state.changes(o?[o,a]:a);n.focus(),n.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Xi.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let s=Array(t.length),i=0,r=()=>{++i==t.length&&BE(n,e,s.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(s[o]=a.result),r()},a.readAsText(t[o])}return!0}else{let s=e.dataTransfer.getData("Text");if(s)return BE(n,e,s,!0),!0}return!1};Xi.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=NO?null:e.clipboardData;return t?(LO(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(TJ(n),!1)};function IJ(n,e){let t=n.dom.parentNode;if(!t)return;let s=t.appendChild(document.createElement("textarea"));s.style.cssText="position: fixed; left: -10000px; top: 10px",s.value=e,s.focus(),s.selectionEnd=e.length,s.selectionStart=0,setTimeout(()=>{s.remove(),n.focus()},50)}function OJ(n){let e=[],t=[],s=!1;for(let i of n.selection.ranges)i.empty||(e.push(n.sliceDoc(i.from,i.to)),t.push(i));if(!e.length){let i=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>i&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),i=o.number}s=!0}return{text:W0(n,Dx,e.join(n.lineBreak)),ranges:t,linewise:s}}let P_=null;Xi.copy=Xi.cut=(n,e)=>{if(!Zd(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:s,linewise:i}=OJ(n.state);if(!t&&!i)return!1;P_=i?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:s,scrollIntoView:!0,userEvent:"delete.cut"});let r=NO?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(IJ(n,t),!1)};const jO=Da.define();function FO(n,e){let t=[];for(let s of n.facet(yO)){let i=s(n,e);i&&t.push(i)}return t.length?n.update({effects:t,annotations:jO.of(!0)}):null}function zO(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=FO(n.state,e);t?n.dispatch(t):n.update([])}},10)}ys.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),zO(n)};ys.blur=n=>{n.observer.clearSelectionRange(),zO(n)};ys.compositionstart=ys.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};ys.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,de.chrome&&de.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};ys.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Xi.beforeinput=(n,e)=>{var t,s;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let a=o[0],l=n.posAtDOM(a.startContainer,a.startOffset),c=n.posAtDOM(a.endContainer,a.endOffset);return zx(n,{from:l,to:c,insert:n.state.toText(r)},null),!0}}let i;if(de.chrome&&de.android&&(i=IO.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let r=((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return de.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),de.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>ys.compositionend(n,e),20),!1};const qE=new Set;function NJ(n){qE.has(n)||(qE.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const VE=["pre-wrap","normal","pre-line","break-spaces"];let Au=!1;function UE(){Au=!1}class LJ{constructor(e){this.lineWrapping=e,this.doc=rt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let s=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(s+=Math.max(0,Math.ceil((t-e-s*this.lineLength*.5)/this.lineLength))),this.lineHeight*s}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return VE.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let s=0;s-1,l=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=s,this.textHeight=i,this.lineLength=r,l){this.heightSamples={};for(let c=0;c0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Bg&&(Au=!0),this.height=e)}replace(e,t,s){return ps.of(s)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,s,i){let r=this,o=s.doc;for(let a=i.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:h,toB:u}=i[a],d=r.lineAt(l,xt.ByPosNoHeight,s.setDoc(t),0,0),p=d.to>=c?d:r.lineAt(c,xt.ByPosNoHeight,s,0,0);for(u+=p.to-c,c=p.to;a>0&&d.from<=i[a-1].toA;)l=i[a-1].fromA,h=i[a-1].fromB,a--,lr*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),s+=1+a.break,i-=a.size}else if(r>i*2){let a=e[s];a.break?e.splice(s,1,a.left,null,a.right):e.splice(s,1,a.left,a.right),s+=2+a.break,r-=a.size}else break;else if(i=r&&o(this.lineAt(0,xt.ByPos,s,i,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,s=!1,i){return i&&i.from<=t&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Ys extends HO{constructor(e,t,s){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=s}mainBlock(e,t){return new Ui(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,s){let i=s[0];return s.length==1&&(i instanceof Ys||i instanceof Nn&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Nn?i=new Ys(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):ps.of(s)}updateHeight(e,t=0,s=!1,i){return i&&i.from<=t&&i.more?this.setMeasuredHeight(i):(s||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Nn extends ps{constructor(e){super(e,0)}heightMetrics(e,t){let s=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,r=i-s+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*r);o=l/r,this.length>r+1&&(a=(this.height-l)/(this.length-r-1))}else o=this.height/r;return{firstLine:s,lastLine:i,perLine:o,perChar:a}}blockAt(e,t,s,i){let{firstLine:r,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(t,i);if(t.lineWrapping){let c=i+(e0){let r=s[s.length-1];r instanceof Nn?s[s.length-1]=new Nn(r.length+i):s.push(null,new Nn(i-1))}if(e>0){let r=s[0];r instanceof Nn?s[0]=new Nn(e+r.length):s.unshift(new Nn(e-1),null)}return ps.of(s)}decomposeLeft(e,t){t.push(new Nn(e-1),null)}decomposeRight(e,t){t.push(null,new Nn(this.length-e-1))}updateHeight(e,t=0,s=!1,i){let r=t+this.length;if(i&&i.from<=t+this.length&&i.more){let o=[],a=Math.max(t,i.from),l=-1;for(i.from>t&&o.push(new Nn(i.from-t-1).updateHeight(e,t));a<=r&&i.more;){let h=e.doc.lineAt(a).length;o.length&&o.push(null);let u=i.heights[i.index++],d=0;u<0&&(d=-u,u=i.heights[i.index++]),l==-1?l=u:Math.abs(u-l)>=Bg&&(l=-2);let p=new Ys(h,u,d);p.outdated=!1,o.push(p),a+=h+1}a<=r&&o.push(null,new Nn(r-a).updateHeight(e,a));let c=ps.of(o);return(l<0||Math.abs(c.height-this.height)>=Bg||Math.abs(l-this.heightMetrics(e,t).perLine)>=Bg)&&(Au=!0),Cy(this,c)}else(s||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class FJ extends ps{constructor(e,t,s){super(e.length+t+s.length,e.height+s.height,t|(e.outdated||s.outdated?2:0)),this.left=e,this.right=s,this.size=e.size+s.size}get break(){return this.flags&1}blockAt(e,t,s,i){let r=s+this.left.height;return ea))return c;let h=t==xt.ByPosNoHeight?xt.ByPosNoHeight:xt.ByPos;return l?c.join(this.right.lineAt(a,h,s,o,a)):this.left.lineAt(a,h,s,i,r).join(c)}forEachLine(e,t,s,i,r,o){let a=i+this.left.height,l=r+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,t,s,a,l,o);else{let c=this.lineAt(l,xt.ByPos,s,i,r);e=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,s,a,l,o)}}replace(e,t,s){let i=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,s));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let a of s)r.push(a);if(e>0&&WE(r,o-1),t=s&&t.push(null)),e>s&&this.right.decomposeLeft(e-s,t)}decomposeRight(e,t){let s=this.left.length,i=s+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e2*t.size||t.size>2*e.size?ps.of(this.break?[e,null,t]:[e,t]):(this.left=Cy(this.left,e),this.right=Cy(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,s=!1,i){let{left:r,right:o}=this,a=t+r.length+this.break,l=null;return i&&i.from<=t+r.length&&i.more?l=r=r.updateHeight(e,t,s,i):r.updateHeight(e,t,s),i&&i.from<=a+o.length&&i.more?l=o=o.updateHeight(e,a,s,i):o.updateHeight(e,a,s),l?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function WE(n,e){let t,s;n[e]==null&&(t=n[e-1])instanceof Nn&&(s=n[e+1])instanceof Nn&&n.splice(e-1,3,new Nn(t.length+1+s.length))}const zJ=5;class Hx{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let s=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Ys?i.length+=s-this.pos:(s>this.pos||!this.isCovered)&&this.nodes.push(new Ys(s-this.pos,-1,0)),this.writtenTo=s,t>s&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,s){if(e=zJ)&&this.addLineDeco(i,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new Ys(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let s=new Nn(t-e);return this.oracle.doc.lineAt(e).to==t&&(s.flags|=4),s}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ys)return e;let t=new Ys(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,s){let i=this.ensureLine();i.length+=s,i.collapsed+=s,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+s}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ys)&&!this.isCovered?this.nodes.push(new Ys(0,-1,0)):(this.writtenToh.clientHeight||h.scrollWidth>h.clientWidth)&&u.overflow!="visible"){let d=h.getBoundingClientRect();r=Math.max(r,d.left),o=Math.min(o,d.right),a=Math.max(a,d.top),l=Math.min(c==n.parentNode?i.innerHeight:l,d.bottom)}c=u.position=="absolute"||u.position=="fixed"?h.offsetParent:h.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function VJ(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function UJ(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Nb{constructor(e,t,s,i){this.from=e,this.to=t,this.size=s,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let s=0;stypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new LJ(s),this.stateDeco=ZE(t),this.heightMap=ps.empty().applyChanges(this.stateDeco,rt.empty,this.heightOracle.setDoc(t.doc),[new gi(0,0,0,t.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Ze.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let s=0;s<=1;s++){let i=s?t.head:t.anchor;if(!e.some(({from:r,to:o})=>i>=r&&i<=o)){let{from:r,to:o}=this.lineBlockAt(i);e.push(new jm(r,o))}}return this.viewports=e.sort((s,i)=>s.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?KE:new Bx(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Pd(e,this.scaler))})}update(e,t=null){this.state=e.state;let s=this.stateDeco;this.stateDeco=ZE(this.state);let i=e.changedRanges,r=gi.extendWithRanges(i,HJ(s,this.stateDeco,e?e.changes:un.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);UE(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||Au)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let l=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(vO)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,s=window.getComputedStyle(t),i=this.heightOracle,r=s.whiteSpace;this.defaultTextDirection=s.direction=="rtl"?Pt.RTL:Pt.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",a=t.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,h=0;if(a.width&&a.height){let{scaleX:k,scaleY:E}=QI(t,a);(k>.005&&Math.abs(this.scaleX-k)>.005||E>.005&&Math.abs(this.scaleY-E)>.005)&&(this.scaleX=k,this.scaleY=E,c|=16,o=l=!0)}let u=(parseInt(s.paddingTop)||0)*this.scaleY,d=(parseInt(s.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let p=eO(this.view.contentDOM,!1).y;p!=this.scrollParent&&(this.scrollParent=p,this.scrollAnchorHeight=-1,this.scrollOffset=0);let m=this.getScrollOffset();this.scrollOffset!=m&&(this.scrollAnchorHeight=-1,this.scrollOffset=m),this.scrolledToBottom=iO(this.scrollParent||e.win);let g=(this.printing?UJ:qJ)(t,this.paddingTop),b=g.top-this.pixelViewport.top,y=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(l=!0)),!this.inView&&!this.scrollTarget&&!VJ(e.dom))return 0;let v=a.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let k=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(k)&&(o=!0),o||i.lineWrapping&&Math.abs(v-this.contentDOMWidth)>i.charWidth){let{lineHeight:E,charWidth:T,textHeight:O}=e.docView.measureTextSize();o=E>0&&i.refresh(r,E,T,O,Math.max(5,v/T),k),o&&(e.docView.minWidth=0,c|=16)}b>0&&y>0?h=Math.max(b,y):b<0&&y<0&&(h=Math.min(b,y)),UE();for(let E of this.viewports){let T=E.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(E);this.heightMap=(o?ps.empty().applyChanges(this.stateDeco,rt.empty,this.heightOracle,[new gi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new DJ(E.from,T))}Au&&(c|=2)}let x=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return x&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),c|=this.updateForViewport()),(c&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let s=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new jm(i.lineAt(o-s*1e3,xt.ByHeight,r,0,0).from,i.lineAt(a+(1-s)*1e3,xt.ByHeight,r,0,0).to);if(t){let{head:c}=t.range;if(cl.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=i.lineAt(c,xt.ByPos,r,0,0),d;t.y=="center"?d=(u.top+u.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&c=a+Math.max(10,Math.min(s,250)))&&i>o-2*1e3&&r>1,o=i<<1;if(this.defaultTextDirection!=Pt.LTR&&!s)return[];let a=[],l=(h,u,d,p)=>{if(u-hh&&yy.from>=d.from&&y.to<=d.to&&Math.abs(y.from-h)y.fromw));if(!b){if(uv.from<=u&&v.to>=u)){let v=t.moveToLineBoundary(te.cursor(u),!1,!0).head;v>h&&(u=v)}let y=this.gapSize(d,h,u,p),w=s||y<2e6?y:2e6;b=new Nb(h,u,y,w)}a.push(b)},c=h=>{if(h.length2e6)for(let E of e)E.from>=h.from&&E.fromh.from&&l(h.from,p,h,u),mt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let s=[];et.spans(t,this.viewport.from,this.viewport.to,{span(r,o){s.push({from:r,to:o})},point(){}},20);let i=0;if(s.length!=this.visibleRanges.length)i=12;else for(let r=0;r=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Pd(this.heightMap.lineAt(e,xt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Pd(this.heightMap.lineAt(this.scaler.fromDOM(e),xt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Pd(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class jm{constructor(e,t){this.from=e,this.to=t}}function GJ(n,e,t){let s=[],i=n,r=0;return et.spans(t,n,e,{span(){},point(o,a){o>i&&(s.push({from:i,to:o}),r+=o-i),i=a}},20),i=1)return e[e.length-1].to;let s=Math.floor(n*t);for(let i=0;;i++){let{from:r,to:o}=e[i],a=o-r;if(s<=a)return r+s;s-=a}}function zm(n,e){let t=0;for(let{from:s,to:i}of n.ranges){if(e<=i){t+=e-s;break}t+=i-s}return t/n.total}function KJ(n,e){for(let t of n)if(e(t))return t}const KE={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function ZE(n){let e=n.facet(q0).filter(s=>typeof s!="function"),t=n.facet(Fx).filter(s=>typeof s!="function");return t.length&&e.push(et.join(t)),e}class Bx{constructor(e,t,s){let i=0,r=0,o=0;this.viewports=s.map(({from:a,to:l})=>{let c=t.lineAt(a,xt.ByPos,e,0,0).top,h=t.lineAt(l,xt.ByPos,e,0,0).bottom;return i+=h-c,{from:a,to:l,top:c,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(t.height-i);for(let a of this.viewports)a.domTop=o+(a.top-r)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),r=a.bottom}toDOM(e){for(let t=0,s=0,i=0;;t++){let r=tt.from==e.viewports[s].from&&t.to==e.viewports[s].to):!1}}function Pd(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),s=e.toDOM(n.bottom);return new Ui(n.from,n.length,t,s-t,Array.isArray(n._content)?n._content.map(i=>Pd(i,e)):n._content)}const Hm=ve.define({combine:n=>n.join(" ")}),R_=ve.define({combine:n=>n.indexOf(!0)>-1}),M_=Su.newName(),BO=Su.newName(),qO=Su.newName(),VO={"&light":"."+BO,"&dark":"."+qO};function I_(n,e,t){return new Su(e,{finish(s){return/&/.test(s)?s.replace(/&\w*/,i=>{if(i=="&")return n;if(!t||!t[i])throw new RangeError(`Unsupported selector: ${i}`);return t[i]}):n+" "+s}})}const ZJ=I_("."+M_,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},VO),XJ={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Lb=de.ie&&de.ie_version<=11;class YJ{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new E7,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let s of t)this.queue.push(s);(de.ie&&de.ie_version<=11||de.ios&&e.composing)&&t.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&de.android&&e.constructor.EDIT_CONTEXT!==!1&&!(de.chrome&&de.chrome_version<126)&&(this.editContext=new QJ(e),e.state.facet(go)&&(e.contentDOM.editContext=this.editContext.editContext)),Lb&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,s)=>t!=e[s]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:s}=this,i=this.selectionRange;if(s.state.facet(go)?s.root.activeElement!=this.dom:!Zd(this.dom,i))return;let r=i.anchorNode&&s.docView.tile.nearest(i.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(de.ie&&de.ie_version<=11||de.android&&de.chrome)&&!s.state.selection.main.empty&&i.focusNode&&Xd(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=ff(e.root);if(!t)return!1;let s=de.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&JJ(this.view,t)||t;if(!s||this.selectionRange.eq(s))return!1;let i=Zd(this.dom,s);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&fh(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,s=-1,i=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(i=!0),t==-1?{from:t,to:s}=o:(t=Math.min(o.from,t),s=Math.max(o.to,s)))}return{from:t,to:s,typeOver:i}}readChange(){let{from:e,to:t,typeOver:s}=this.processRecords(),i=this.selectionChanged&&Zd(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new mJ(this.view,e,t,s);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let s=this.view.state,i=RO(this.view,t);return this.view.state==s&&(t.domChanged||t.newSel&&!Ey(this.view.state.selection,t.newSel.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let s=XE(t,e.previousSibling||e.target.previousSibling,-1),i=XE(t,e.nextSibling||e.target.nextSibling,1);return{from:s?t.posAfter(s):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(go)!=e.state.facet(go)&&(e.view.contentDOM.editContext=e.state.facet(go)?this.editContext.editContext:null))}destroy(){var e,t,s;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(s=this.resizeScroll)===null||s===void 0||s.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function XE(n,e,t){for(;e;){let s=Bt.get(e);if(s&&s.parent==n)return s;let i=e.parentNode;e=i!=n.dom?i:t>0?e.nextSibling:e.previousSibling}return null}function YE(n,e){let t=e.startContainer,s=e.startOffset,i=e.endContainer,r=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return Xd(o.node,o.offset,i,r)&&([t,s,i,r]=[i,r,t,s]),{anchorNode:t,anchorOffset:s,focusNode:i,focusOffset:r}}function JJ(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return YE(n,i)}let t=null;function s(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",s,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",s,!0),t?YE(n,t):null}class QJ{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=s=>{let i=e.state.selection.main,{anchor:r,head:o}=i,a=this.toEditorPos(s.updateRangeStart),l=this.toEditorPos(s.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:s.updateRangeStart,editorBase:a,drifted:!1});let c=l-a>s.text.length;a==this.from&&rthis.to&&(l=r);let h=MO(e.state.sliceDoc(a,l),s.text,(c?i.from:i.to)-a,c?"end":null);if(!h){let d=te.single(this.toEditorPos(s.selectionStart),this.toEditorPos(s.selectionEnd));Ey(d,i)||e.dispatch({selection:d,userEvent:"select"});return}let u={from:h.from+a,to:h.toA+a,insert:rt.of(s.text.slice(h.from,h.toB).split(` +`))};if((de.mac||de.android)&&u.from==o-1&&/^\. ?$/.test(s.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:a,to:l,insert:rt.of([s.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let d=this.to-this.from+(u.to-u.from+u.insert.length);zx(e,u,te.single(this.toEditorPos(s.selectionStart,d),this.toEditorPos(s.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,s.updateRangeStart-1),Math.min(t.text.length,s.updateRangeStart+1)))&&this.handlers.compositionend(s)},this.handlers.characterboundsupdate=s=>{let i=[],r=null;for(let o=this.toEditorPos(s.rangeStart),a=this.toEditorPos(s.rangeEnd);o{let i=[];for(let r of s.getTextFormats()){let o=r.underlineStyle,a=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(a)){let l=this.toEditorPos(r.rangeStart),c=this.toEditorPos(r.rangeEnd);if(l{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:s}=this.composing;this.composing=null,s&&this.reset(e.state)}};for(let s in this.handlers)t.addEventListener(s,this.handlers[s]);this.measureReq={read:s=>{let i=ff(s.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,s=!1,i=this.pendingContextChange;return e.changes.iterChanges((r,o,a,l,c)=>{if(s)return;let h=c.length-(o-r);if(i&&o>=i.to)if(i.from==r&&i.to==o&&i.insert.eq(c)){i=this.pendingContextChange=null,t+=h,this.to+=h;return}else i=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=h,this.to+=h;else if(rthis.to||this.to-this.from+c.length>3e4){s=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),c.toString()),this.to+=h}t+=h}),i&&!s&&this.revertPending(e.state),!s}update(e){let t=this.pendingContextChange,s=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(s.from,s.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,s=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);(this.editContext.selectionStart!=s||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(s,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let s=this.composing;return s&&s.drifted?s.editorBase+(e-s.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class xe{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:s}=e;this.dispatchTransactions=e.dispatchTransactions||s&&(i=>i.forEach(r=>s(r,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||C7(e.parent)||document,this.viewState=new GE(this,e.state||it.create(e)),e.scrollTo&&e.scrollTo.is(Nm)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(eh).map(i=>new Pb(i));for(let i of this.plugins)i.update(this);this.observer=new YJ(this),this.inputState=new vJ(this),this.inputState.ensureHandlers(this.plugins),this.docView=new OE(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof pn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,s=!1,i,r=this.state;for(let d of e){if(d.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=d.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,a=0,l=null;e.some(d=>d.annotation(jO))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=FO(r,o),l||(a=1));let c=this.observer.delayedAndroidKey,h=null;if(c?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet(it.phrases)!=this.state.facet(it.phrases))return this.setState(r);i=xy.create(this,r,e),i.flags|=a;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(u&&(u=u.map(d.changes)),d.scrollIntoView){let{main:p}=d.state.selection,{x:m,y:g}=this.state.facet(xe.cursorScrollMargin);u=new ph(p.empty?p:te.cursor(p.head,p.head>p.anchor?-1:1),"nearest","nearest",g,m)}for(let p of d.effects)p.is(Nm)&&(u=p.value.clip(this.state))}this.viewState.update(i,u),this.bidiCache=$y.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),t=this.docView.update(i),this.state.facet(Td)!=this.styleModules&&this.mountStyles(),s=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Hm)!=i.state.facet(Hm)&&(this.viewState.mustMeasureContent=!0),(t||s||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(E_))try{d(i)}catch(p){Pr(this.state,p,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!RO(this,h)&&c.force&&fh(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let s of this.plugins)s.destroy(this);this.viewState=new GE(this,e),this.plugins=e.facet(eh).map(s=>new Pb(s)),this.pluginMap.clear();for(let s of this.plugins)s.update(this);this.docView.destroy(),this.docView=new OE(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(eh),s=e.state.facet(eh);if(t!=s){let i=[];for(let r of s){let o=t.indexOf(r);if(o<0)i.push(new Pb(r));else{let a=this.plugins[o];a.mustUpdate=e,i.push(a)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,s=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(iO(s||this.win))r=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(i);r=p.from,o=p.top}this.updateState=1;let l=this.viewState.measure();if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let h=c.map(p=>{try{return p.read(this)}catch(m){return Pr(this.state,m),JE}}),u=xy.create(this,this.state,[]),d=!1;u.flags|=l,t?t.flags|=l:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let p=0;p1||m<-1)&&!(de.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(s==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+m,s?r<0?s.scrollTop=s.scrollHeight:s.scrollTop+=m:this.win.scrollBy(0,m),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(E_))a(t)}get themeClasses(){return M_+" "+(this.state.facet(R_)?qO:BO)+" "+this.state.facet(Hm)}updateAttrs(){let e=QE(this,SO,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(go)?"true":"false",class:"cm-content",style:`${de.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),QE(this,jx,t);let s=this.observer.ignore(()=>{let i=$E(this.contentDOM,this.contentAttrs,t),r=$E(this.dom,this.editorAttrs,e);return i||r});return this.editorAttrs=e,this.contentAttrs=t,s}showAnnouncements(e){let t=!0;for(let s of e)for(let i of s.effects)if(i.is(xe.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Td);let e=this.state.facet(xe.cspNonce);Su.mount(this.root,this.styleModules.concat(ZJ).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ts.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,s){return Ob(this,e,NE(this,e,t,s))}moveByGroup(e,t){return Ob(this,e,NE(this,e,t,s=>cJ(this,e.head,s)))}visualLineSide(e,t){let s=this.bidiSpans(e),i=this.textDirectionAt(e.from),r=s[t?s.length-1:0];return te.cursor(r.side(t,i)+e.from,r.forward(!t,i)?1:-1)}moveToLineBoundary(e,t,s=!0){return lJ(this,e,t,s)}moveVertically(e,t,s){return Ob(this,e,hJ(this,e,t,s))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let s=T_(this,e,t);return s&&s.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),T_(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let s=this.state.doc.lineAt(e),i=this.bidiSpans(s),r=i[Tr.find(i,e-s.from,-1,t)];return this.docView.coordsAt(e,t,r.dir==Pt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(bO)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>eQ)return hO(e.length);let t=this.textDirectionAt(e.from),s;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||cO(r.isolates,s=RE(this,e))))return r.order;s||(s=RE(this,e));let i=N7(e.text,t,s);return this.bidiCache.push(new $y(e.from,e.to,t,s,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||de.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{sO(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var s,i,r,o;return Nm.of(new ph(typeof e=="number"?te.cursor(e):e,(s=t.y)!==null&&s!==void 0?s:"nearest",(i=t.x)!==null&&i!==void 0?i:"nearest",(r=t.yMargin)!==null&&r!==void 0?r:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,s=this.viewState.scrollAnchorAt(e);return Nm.of(new ph(te.cursor(s.from),"start","start",s.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return ti.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ti.define(()=>({}),{eventObservers:e})}static theme(e,t){let s=Su.newName(),i=[Hm.of(s),Td.of(I_(`.${s}`,e))];return t&&t.dark&&i.push(R_.of(!0)),i}static baseTheme(e){return F0.lowest(Td.of(I_("."+M_,e,VO)))}static findFromDOM(e){var t;let s=e.querySelector(".cm-content"),i=s&&Bt.get(s)||Bt.get(e);return((t=i==null?void 0:i.root)===null||t===void 0?void 0:t.view)||null}}xe.styleModule=Td;xe.inputHandler=gO;xe.clipboardInputFilter=Lx;xe.clipboardOutputFilter=Dx;xe.scrollHandler=wO;xe.focusChangeEffect=yO;xe.perLineTextDirection=bO;xe.exceptionSink=mO;xe.updateListener=E_;xe.editable=go;xe.mouseSelectionStyle=pO;xe.dragMovesSelection=fO;xe.clickAddsSelectionRange=dO;xe.decorations=q0;xe.blockWrappers=xO;xe.outerDecorations=Fx;xe.atomicRanges=rm;xe.bidiIsolatedRanges=kO;xe.cursorScrollMargin=ve.define({combine:n=>{let e=5,t=5;for(let s of n)typeof s=="number"?e=t=s:{x:e,y:t}=s;return{x:e,y:t}}});xe.scrollMargins=AO;xe.darkTheme=R_;xe.cspNonce=ve.define({combine:n=>n.length?n[0]:""});xe.contentAttributes=jx;xe.editorAttributes=SO;xe.lineWrapping=xe.contentAttributes.of({class:"cm-lineWrapping"});xe.announce=bt.define();const eQ=4096,JE={};class $y{constructor(e,t,s,i,r,o){this.from=e,this.to=t,this.dir=s,this.isolates=i,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let s=[],i=e.length?e[e.length-1].dir:Pt.LTR;for(let r=Math.max(0,e.length-10);r=0;i--){let r=s[i],o=typeof r=="function"?r(n):r;o&&Ix(o,t)}return t}const tQ=de.mac?"mac":de.windows?"win":de.linux?"linux":"key";function nQ(n,e){const t=n.split(/-(?!$)/);let s=t[t.length-1];s=="Space"&&(s=" ");let i,r,o,a;for(let l=0;ls.concat(i),[]))),t}function iQ(n,e,t){return GO(WO(n.state),e,n,t)}let qo=null;const rQ=4e3;function oQ(n,e=tQ){let t=Object.create(null),s=Object.create(null),i=(o,a)=>{let l=s[o];if(l==null)s[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,a,l,c,h)=>{var u,d;let p=t[o]||(t[o]=Object.create(null)),m=a.split(/ (?!$)/).map(y=>nQ(y,e));for(let y=1;y{let x=qo={view:v,prefix:w,scope:o};return setTimeout(()=>{qo==x&&(qo=null)},rQ),!0}]})}let g=m.join(" ");i(g,!1);let b=p[g]||(p[g]={preventDefault:!1,stopPropagation:!1,run:((d=(u=p._any)===null||u===void 0?void 0:u.run)===null||d===void 0?void 0:d.slice())||[]});l&&b.run.push(l),c&&(b.preventDefault=!0),h&&(b.stopPropagation=!0)};for(let o of n){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of a){let h=t[c]||(t[c]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=o;for(let d in h)h[d].run.push(p=>u(p,O_))}let l=o[e]||o.key;if(l)for(let c of a)r(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return t}let O_=null;function GO(n,e,t,s){O_=e;let i=w7(e),r=NI(i,0),o=LI(r)==i.length&&i!=" ",a="",l=!1,c=!1,h=!1;qo&&qo.view==t&&qo.scope==s&&(a=qo.prefix+" ",OO.indexOf(e.keyCode)<0&&(c=!0,qo=null));let u=new Set,d=b=>{if(b){for(let y of b.run)if(!u.has(y)&&(u.add(y),y(t)))return b.stopPropagation&&(h=!0),!0;b.preventDefault&&(b.stopPropagation&&(h=!0),c=!0)}return!1},p=n[s],m,g;return p&&(d(p[a+Bm(i,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(de.windows&&e.ctrlKey&&e.altKey)&&!(de.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(m=Pa[e.keyCode])&&m!=i?(d(p[a+Bm(m,e,!0)])||e.shiftKey&&(g=uf[e.keyCode])!=i&&g!=m&&d(p[a+Bm(g,e,!1)]))&&(l=!0):o&&e.shiftKey&&d(p[a+Bm(i,e,!0)])&&(l=!0),!l&&d(p._any)&&(l=!0)),c&&(l=!0),l&&h&&e.stopPropagation(),O_=null,l}class oc{constructor(e,t,s,i,r){this.className=e,this.left=t,this.top=s,this.width=i,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,s){if(s.empty){let i=e.coordsAtPos(s.head,s.assoc||1);if(!i)return[];let r=KO(e);return[new oc(t,i.left-r.left,i.top-r.top,null,i.bottom-i.top)]}else return aQ(e,t,s)}}function KO(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==Pt.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function tC(n,e,t,s){let i=n.coordsAtPos(e,t*2);if(!i)return s;let r=n.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,a=n.posAtCoords({x:r.left+1,y:o}),l=n.posAtCoords({x:r.right-1,y:o});return a==null||l==null?s:{from:Math.max(s.from,Math.min(a,l)),to:Math.min(s.to,Math.max(a,l))}}function aQ(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let s=Math.max(t.from,n.viewport.from),i=Math.min(t.to,n.viewport.to),r=n.textDirection==Pt.LTR,o=n.contentDOM,a=o.getBoundingClientRect(),l=KO(n),c=o.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),d=a.right-(h?parseInt(h.paddingRight):0),p=$_(n,s,1),m=$_(n,i,-1),g=p.type==Hn.Text?p:null,b=m.type==Hn.Text?m:null;if(g&&(n.lineWrapping||p.widgetLineBreaks)&&(g=tC(n,s,1,g)),b&&(n.lineWrapping||m.widgetLineBreaks)&&(b=tC(n,i,-1,b)),g&&b&&g.from==b.from&&g.to==b.to)return w(v(t.from,t.to,g));{let k=g?v(t.from,null,g):x(p,!1),E=b?v(null,t.to,b):x(m,!0),T=[];return(g||p).to<(b||m).from-(g&&b?1:0)||p.widgetLineBreaks>1&&k.bottom+n.defaultLineHeight/2B&&q.from=se)break;z>H&&L(Math.max(ye,H),k==null&&ye<=B,Math.min(z,se),E==null&&z>=Z,Y.dir)}if(H=Q.to+1,H>=se)break}return j.length==0&&L(B,k==null,Z,E==null,n.textDirection),{top:O,bottom:F,horizontal:j}}function x(k,E){let T=a.top+(E?k.top:k.bottom);return{top:T,bottom:T,horizontal:[]}}}function lQ(n,e){return n.constructor==e.constructor&&n.eq(e)}class cQ{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(qg)!=e.state.facet(qg)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,s=e.facet(qg);for(;t!lQ(t,this.drawn[s]))){let t=this.dom.firstChild,s=0;for(let i of e)i.update&&t&&i.constructor&&this.drawn[s].constructor&&i.update(t,this.drawn[s])?(t=t.nextSibling,s++):this.dom.insertBefore(i.draw(),t);for(;t;){let i=t.nextSibling;t.remove(),t=i}this.drawn=e,de.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const qg=ve.define();function ZO(n){return[ti.define(e=>new cQ(e,n)),qg.of(n)]}const Eu=ve.define({combine(n){return ju(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function hQ(n={}){return[Eu.of(n),uQ,dQ,pQ,vO.of(!0)]}function XO(n){return n.startState.facet(Eu)!=n.state.facet(Eu)}const uQ=ZO({above:!0,markers(n){let{state:e}=n,t=e.facet(Eu),s=[];for(let i of e.selection.ranges){let r=i==e.selection.main;if(i.empty||t.drawRangeCursor&&!(r&&de.ios&&t.iosSelectionHandles)){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=i.empty?i:te.cursor(i.head,i.assoc);for(let l of oc.forRange(n,o,a))s.push(l)}}return s},update(n,e){n.transactions.some(s=>s.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=XO(n);return t&&nC(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){nC(e.state,n)},class:"cm-cursorLayer"});function nC(n,e){e.style.animationDuration=n.facet(Eu).cursorBlinkRate+"ms"}const dQ=ZO({above:!1,markers(n){let e=[],{main:t,ranges:s}=n.state.selection;for(let i of s)if(!i.empty)for(let r of oc.forRange(n,"cm-selectionBackground",i))e.push(r);if(de.ios&&!t.empty&&n.state.facet(Eu).iosSelectionHandles){for(let i of oc.forRange(n,"cm-selectionHandle cm-selectionHandle-start",te.cursor(t.from,1)))e.push(i);for(let i of oc.forRange(n,"cm-selectionHandle cm-selectionHandle-end",te.cursor(t.to,1)))e.push(i)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||XO(n)},class:"cm-selectionLayer"}),fQ=de.gecko&&de.gecko_version==153?"#ffffff01":"transparent",pQ=F0.highest(xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${fQ} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function mQ(){return yQ}const gQ=Ze.line({class:"cm-activeLine"}),yQ=ti.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let s of n.state.selection.ranges){let i=n.lineBlockAt(s.head);i.from>e&&(t.push(gQ.range(i.from)),e=i.from)}return Ze.set(t)}},{decorations:n=>n.decorations}),sC=ve.define({combine(n){let e,t;for(let s of n)e=e||s.topContainer,t=t||s.bottomContainer;return{topContainer:e,bottomContainer:t}}});function YO(n,e){let t=n.plugin(JO),s=t?t.specs.indexOf(e):-1;return s>-1?t.panels[s]:null}const JO=ti.fromClass(class{constructor(n){this.input=n.state.facet(Ty),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(sC);this.top=new qm(n,!0,e.topContainer),this.bottom=new qm(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(sC);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new qm(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new qm(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Ty);if(t!=this.input){let s=t.filter(l=>l),i=[],r=[],o=[],a=[];for(let l of s){let c=this.specs.indexOf(l),h;c<0?(h=l(n.view),a.push(h)):(h=this.panels[c],h.update&&h.update(n)),i.push(h),(h.top?r:o).push(h)}this.specs=s,this.panels=i,this.top.sync(r),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let s of this.panels)s.update&&s.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>xe.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class qm{constructor(e,t,s){this.view=e,this.top=t,this.container=s,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=iC(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=iC(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function iC(n){let e=n.nextSibling;return n.remove(),e}const Ty=ve.define({enables:JO});function bQ(n,e){let t,s=new Promise(o=>t=o),i=o=>vQ(o,e,t);n.state.field(Db,!1)?n.dispatch({effects:QO.of(i)}):n.dispatch({effects:bt.appendConfig.of(Db.init(()=>[i]))});let r=eN.of(i);return{close:r,result:s.then(o=>((n.win.queueMicrotask||(l=>n.win.setTimeout(l,10)))(()=>{n.state.field(Db).indexOf(i)>-1&&n.dispatch({effects:r})}),o))}}const Db=Dr.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(QO)?n=[t.value].concat(n):t.is(eN)&&(n=n.filter(s=>s!=t.value));return n},provide:n=>Ty.computeN([n],e=>e.field(n))}),QO=bt.define(),eN=bt.define();function vQ(n,e,t){let s=e.content?e.content(n,()=>o(null)):null;if(!s){if(s=xn("form"),e.input){let a=xn("input",e.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),s.appendChild(xn("label",(e.label||"")+": ",a))}else s.appendChild(document.createTextNode(e.label||""));s.appendChild(document.createTextNode(" ")),s.appendChild(xn("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let i=s.nodeName=="FORM"?[s]:s.querySelectorAll("form");for(let a=0;a{c.keyCode==27?(c.preventDefault(),o(null)):c.keyCode==13&&(c.preventDefault(),o(l))}),l.addEventListener("submit",c=>{c.preventDefault(),o(l)})}let r=xn("div",s,xn("button",{onclick:()=>o(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");function o(a){r.contains(r.ownerDocument.activeElement)&&n.focus(),t(a)}return{dom:r,top:e.top,mount:()=>{if(e.focus){let a;typeof e.focus=="string"?a=s.querySelector(e.focus):a=s.querySelector("input")||s.querySelector("button"),a&&"select"in a?a.select():a&&"focus"in a&&a.focus()}}}}class Sc extends bc{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Sc.prototype.elementClass="";Sc.prototype.toDOM=void 0;Sc.prototype.mapMode=Qs.TrackBefore;Sc.prototype.startSide=Sc.prototype.endSide=-1;Sc.prototype.point=!0;const jb=ve.define(),wQ=ve.define(),Vg=ve.define(),rC=ve.define({combine:n=>n.some(e=>e)});function _Q(n){return[SQ]}const SQ=ti.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(Vg).map(e=>new aC(n,e)),this.fixed=!n.state.facet(rC);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,s=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(s<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(rC)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=et.iter(this.view.state.facet(jb),this.view.viewport.from),s=[],i=this.gutters.map(r=>new xQ(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(r.type)){let o=!0;for(let a of r.type)if(a.type==Hn.Text&&o){N_(t,s,a.from);for(let l of i)l.line(this.view,a,s);o=!1}else if(a.widget)for(let l of i)l.widget(this.view,a)}else if(r.type==Hn.Text){N_(t,s,r.from);for(let o of i)o.line(this.view,r,s)}else if(r.widget)for(let o of i)o.widget(this.view,r);for(let r of i)r.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(Vg),t=n.state.facet(Vg),s=n.docChanged||n.heightChanged||n.viewportChanged||!et.eq(n.startState.facet(jb),n.state.facet(jb),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let i of this.gutters)i.update(n)&&(s=!0);else{s=!0;let i=[];for(let r of t){let o=e.indexOf(r);o<0?i.push(new aC(this.view,r)):(this.gutters[o].update(n),i.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),i.indexOf(r)<0&&r.destroy();for(let r of i)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=i}return s}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>xe.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let s=t.dom.offsetWidth*e.scaleX,i=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Pt.LTR?{left:s,right:i}:{right:s,left:i}})});function oC(n){return Array.isArray(n)?n:[n]}function N_(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class xQ{constructor(e,t,s){this.gutter=e,this.height=s,this.i=0,this.cursor=et.iter(e.markers,t.from)}addElement(e,t,s){let{gutter:i}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==i.elements.length){let a=new tN(e,o,r,s);i.elements.push(a),i.dom.appendChild(a.dom)}else i.elements[this.i].update(e,o,r,s);this.height=t.bottom,this.i++}line(e,t,s){let i=[];N_(this.cursor,i,t.from),s.length&&(i=i.concat(s));let r=this.gutter.config.lineMarker(e,t,i);r&&i.unshift(r);let o=this.gutter;i.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,i)}widget(e,t){let s=this.gutter.config.widgetMarker(e,t.widget,t),i=s?[s]:null;for(let r of e.state.facet(wQ)){let o=r(e,t.widget,t);o&&(i||(i=[])).push(o)}i&&this.addElement(e,t,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class aC{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let s in t.domEventHandlers)this.dom.addEventListener(s,i=>{let r=i.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let l=r.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=i.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[s](e,a,i)&&i.preventDefault()});this.markers=oC(t.markers(e)),t.initialSpacer&&(this.spacer=new tN(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=oC(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],e);i!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[i])}let s=e.view.viewport;return!et.eq(this.markers,t,s.from,s.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class tN{constructor(e,t,s,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,s,i)}update(e,t,s,i){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=s&&(this.dom.style.marginTop=(this.above=s)?s+"px":""),kQ(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,t){let s="cm-gutterElement",i=this.dom.firstChild;for(let r=0,o=0;;){let a=o,l=rr(a,l,c)||o(a,l,c):o}return s}})}});class Fb extends Sc{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function zb(n,e){return n.state.facet(th).formatNumber(e,n.state)}const CQ=Vg.compute([th],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(AQ)},lineMarker(e,t,s){return s.some(i=>i.toDOM)?null:new Fb(zb(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,s)=>{for(let i of e.state.facet(EQ)){let r=i(e,t,s);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(th)!=e.state.facet(th),initialSpacer(e){return new Fb(zb(e,lC(e.state.doc.lines)))},updateSpacer(e,t){let s=zb(t.view,lC(t.view.state.doc.lines));return s==e.number?e:new Fb(s)},domEventHandlers:n.facet(th).domEventHandlers,side:"before"}));function $Q(n={}){return[th.of(n),_Q(),CQ]}function lC(n){let e=9;for(;e{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ls.match(e)),t=>{let s=e(t);return s===void 0?null:[this,s]}}}Je.closedBy=new Je({deserialize:n=>n.split(" ")});Je.openedBy=new Je({deserialize:n=>n.split(" ")});Je.group=new Je({deserialize:n=>n.split(" ")});Je.isolate=new Je({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});Je.contextHash=new Je({perNode:!0});Je.lookAhead=new Je({perNode:!0});Je.mounted=new Je({perNode:!0});class Jd{constructor(e,t,s,i=!1){this.tree=e,this.overlay=t,this.parser=s,this.bracketed=i}static get(e){return e&&e.props&&e.props[Je.mounted.id]}}const RQ=Object.create(null);class Ls{constructor(e,t,s,i=0){this.name=e,this.props=t,this.id=s,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):RQ,s=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Ls(e.name||"",t,e.id,s);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(i)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(Je.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let s in e)for(let i of s.split(" "))t[i]=e[s];return s=>{for(let i=s.prop(Je.group),r=-1;r<(i?i.length:0);r++){let o=t[r<0?s.name:i[r]];if(o)return o}}}}Ls.none=new Ls("",Object.create(null),0,8);class qx{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(o|Kt.IncludeAnonymous);;){let c=!1;if(l.from<=r&&l.to>=i&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&s&&(a||!l.type.isAnonymous)&&s(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Wx(Ls.none,this.children,this.positions,0,this.children.length,0,this.length,(t,s,i)=>new Rt(this.type,t,s,i,this.propValues),e.makeTree||((t,s,i)=>new Rt(Ls.none,t,s,i)))}static build(e){return NQ(e)}}Rt.empty=new Rt(Ls.none,[],[],0);class Vx{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Vx(this.buffer,this.index)}}class Ma{constructor(e,t,s){this.buffer=e,this.length=t,this.set=s}get type(){return Ls.none}toString(){let e=[];for(let t=0;t0));l=o[l+3]);return a}slice(e,t,s){let i=this.buffer,r=new Uint16Array(t-e),o=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&s>e;case 2:return s>e;case 4:return!0}}function mf(n,e,t,s){for(var i;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?a.length:-1;e!=c;e+=t){let h=a[e],u=l[e]+o.from,d;if(!(!(r&Kt.EnterBracketed&&h instanceof Rt&&(d=Jd.get(h))&&!d.overlay&&d.bracketed&&s>=u&&s<=u+h.length)&&!nN(i,s,u,u+h.length))){if(h instanceof Ma){if(r&Kt.ExcludeBuffers)continue;let p=h.findChild(0,h.buffer.length,t,s-u,i);if(p>-1)return new Sa(new MQ(o,h,e,u),null,p)}else if(r&Kt.IncludeAnonymous||!h.type.isAnonymous||Ux(h)){let p;if(!(r&Kt.IgnoreMounts)&&(p=Jd.get(h))&&!p.overlay)return new bi(p.tree,u,e,o);let m=new bi(h,u,e,o);return r&Kt.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(t<0?h.children.length-1:0,t,s,i,r)}}}if(r&Kt.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,s=0){let i;if(!(s&Kt.IgnoreOverlays)&&(i=Jd.get(this._tree))&&i.overlay){let r=e-this.from,o=s&Kt.EnterBracketed&&i.bracketed;for(let{from:a,to:l}of i.overlay)if((t>0||o?a<=r:a=r:l>r))return new bi(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,s)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function hC(n,e,t,s){let i=n.cursor(),r=[];if(!i.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=i.type.is(t),!i.nextSibling())return r}for(;;){if(s!=null&&i.type.is(s))return r;if(i.type.is(e)&&r.push(i.node),!i.nextSibling())return s==null?r:[]}}function L_(n,e,t=e.length-1){for(let s=n;t>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(e[t]&&e[t]!=s.name)return!1;t--}}return!0}class MQ{constructor(e,t,s,i){this.parent=e,this.buffer=t,this.index=s,this.start=i}}class Sa extends sN{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,s){super(),this.context=e,this._parent=t,this.index=s,this.type=e.buffer.set.types[e.buffer.buffer[s]]}child(e,t,s){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,s);return r<0?null:new Sa(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,s=0){if(s&Kt.ExcludeBuffers)return null;let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new Sa(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Sa(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Sa(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:s}=this.context,i=this.index+4,r=s.buffer[this.index+3];if(r>i){let o=s.buffer[this.index+1];e.push(s.slice(i,r,o)),t.push(0)}return new Rt(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function iN(n){if(!n.length)return null;let e=0,t=n[0];for(let r=1;rt.from||o.to=e){let a=new bi(o.tree,o.overlay[0].from+r.from,-1,r);(i||(i=[s])).push(mf(a,e,t,!1))}}return i?iN(i):s}class D_{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Kt.EnterBracketed,e instanceof bi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let s=e._parent;s;s=s._parent)this.stack.unshift(s.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:s,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=s+i.buffer[e+1],this.to=s+i.buffer[e+2],!0}yield(e){return e?e instanceof bi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,s){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,s,this.mode));let{buffer:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,s);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,s=this.mode){return this.buffer?s&Kt.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,s))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Kt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Kt.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,s=this.stack.length-1;if(e<0){let i=s<0?0:this.stack[s]+4;if(this.index!=i)return this.yieldBuf(t.findChild(i,this.index,-1,0,4))}else{let i=t.buffer[this.index+3];if(i<(s<0?t.buffer.length:t.buffer[this.stack[s]+3]))return this.yieldBuf(i)}return s<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,s,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let r=t+e,o=e<0?-1:s._tree.children.length;r!=o;r+=e){let a=s._tree.children[r];if(this.mode&Kt.IncludeAnonymous||a instanceof Ma||!a.type.isAnonymous||Ux(a))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;t=o,s=r+1;break e}i=this.stack[--r]}for(let i=s;i=0;r--){if(r<0)return L_(this._tree,e,i);let o=s[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function Ux(n){return n.children.some(e=>e instanceof Ma||!e.type.isAnonymous||Ux(e))}function NQ(n){var e;let{buffer:t,nodeSet:s,maxBufferLength:i=TQ,reused:r=[],minRepeatType:o=s.types.length}=n,a=Array.isArray(t)?new Vx(t,t.length):t,l=s.types,c=0,h=0;function u(k,E,T,O,F,j){let{id:L,start:B,end:Z,size:q}=a,H=h,se=c;if(q<0)if(a.next(),q==-1){let C=r[L];T.push(C),O.push(B-k);return}else if(q==-3){c=L;return}else if(q==-4){h=L;return}else throw new RangeError(`Unrecognized record size: ${q}`);let Q=l[L],Y,ye,z=B-k;if(Z-B<=i&&(ye=b(a.pos-E,F))){let C=new Uint16Array(ye.size-ye.skip),I=a.pos-ye.size,R=C.length;for(;a.pos>I;)R=y(ye.start,C,R);Y=new Ma(C,Z-ye.start,s),z=ye.start-k}else{let C=a.pos-q;a.next();let I=[],R=[],_=L>=o?L:-1,A=0,N=Z;for(;a.pos>C;)_>=0&&a.id==_&&a.size>=0?(a.end<=N-i&&(m(I,R,B,A,a.end,N,_,H,se),A=I.length,N=a.end),a.next()):j>2500?d(B,C,I,R):u(B,C,I,R,_,j+1);if(_>=0&&A>0&&A-1&&A>0){let W=p(Q,se);Y=Wx(Q,I,R,0,I.length,0,Z-B,W,W)}else Y=g(Q,I,R,Z-B,H-Z,se)}T.push(Y),O.push(z)}function d(k,E,T,O){let F=[],j=0,L=-1;for(;a.pos>E;){let{id:B,start:Z,end:q,size:H}=a;if(H>4)a.next();else{if(L>-1&&Z=0;q-=3)B[H++]=F[q],B[H++]=F[q+1]-Z,B[H++]=F[q+2]-Z,B[H++]=H;T.push(new Ma(B,F[2]-Z,s)),O.push(Z-k)}}function p(k,E){return(T,O,F)=>{let j=0,L=T.length-1,B,Z;if(L>=0&&(B=T[L])instanceof Rt){if(!L&&B.type==k&&B.length==F)return B;(Z=B.prop(Je.lookAhead))&&(j=O[L]+B.length+Z)}return g(k,T,O,F,j,E)}}function m(k,E,T,O,F,j,L,B,Z){let q=[],H=[];for(;k.length>O;)q.push(k.pop()),H.push(E.pop()+T-F);k.push(g(s.types[L],q,H,j-F,B-j,Z)),E.push(F-T)}function g(k,E,T,O,F,j,L){if(j){let B=[Je.contextHash,j];L=L?[B].concat(L):[B]}if(F>25){let B=[Je.lookAhead,F];L=L?[B].concat(L):[B]}return new Rt(k,E,T,O,L)}function b(k,E){let T=a.fork(),O=0,F=0,j=0,L=T.end-i,B={size:0,start:0,skip:0};e:for(let Z=T.pos-k;T.pos>Z;){let q=T.size;if(T.id==E&&q>=0){B.size=O,B.start=F,B.skip=j,j+=4,O+=4,T.next();continue}let H=T.pos-q;if(q<0||H=o?4:0,Q=T.start;for(T.next();T.pos>H;){if(T.size<0)if(T.size==-3||T.size==-4)se+=4;else break e;else T.id>=o&&(se+=4);T.next()}F=Q,O+=q,j+=se}return(E<0||O==k)&&(B.size=O,B.start=F,B.skip=j),B.size>4?B:void 0}function y(k,E,T){let{id:O,start:F,end:j,size:L}=a;if(a.next(),L>=0&&O4){let Z=a.pos-(L-4);for(;a.pos>Z;)T=y(k,E,T)}E[--T]=B,E[--T]=j-k,E[--T]=F-k,E[--T]=O}else L==-3?c=O:L==-4&&(h=O);return T}let w=[],v=[];for(;a.pos>0;)u(n.start||0,n.bufferStart||0,w,v,-1,0);let x=(e=n.length)!==null&&e!==void 0?e:w.length?v[0]+w[0].length:0;return new Rt(l[n.topID],w.reverse(),v.reverse(),x)}const uC=new WeakMap;function Ug(n,e){if(!n.isAnonymous||e instanceof Ma||e.type!=n)return 1;let t=uC.get(e);if(t==null){t=1;for(let s of e.children){if(s.type!=n||!(s instanceof Rt)){t=1;break}t+=Ug(n,s)}uC.set(e,t)}return t}function Wx(n,e,t,s,i,r,o,a,l){let c=0;for(let m=s;m=h)break;E+=T}if(v==x+1){if(E>h){let T=m[x];p(T.children,T.positions,0,T.children.length,g[x]+w);continue}u.push(m[x])}else{let T=g[v-1]+m[v-1].length-k;u.push(Wx(n,m,g,x,v,k,T,null,l))}d.push(k+w-r)}}return p(e,t,s,i,0),(a||l)(u,d,o)}class ac{constructor(e,t,s,i,r=!1,o=!1){this.from=e,this.to=t,this.tree=s,this.offset=i,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],s=!1){let i=[new ac(0,e.length,e,0,!1,s)];for(let r of t)r.to>e.length&&i.push(r);return i}static applyChanges(e,t,s=128){if(!t.length)return e;let i=[],r=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let h=a=s)for(;o&&o.from=d.from||u<=d.to||c){let p=Math.max(d.from,l)-c,m=Math.min(d.to,u)-c;d=p>=m?null:new ac(p,m,d.tree,d.offset+c,a>0,!!h)}if(d&&i.push(d),o.to>u)break;o=rnew Hb(i.from,i.to)):[new Hb(0,0)]:[new Hb(0,e.length)],this.createParse(e,t||[],s)}parse(e,t,s){let i=this.startParse(e,t,s);for(;;){let r=i.advance();if(r)return r}}}class LQ{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new Je({perNode:!0});let DQ=0;class fi{constructor(e,t,s,i){this.name=e,this.set=t,this.base=s,this.modified=i,this.id=DQ++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let s=typeof e=="string"?e:"?";if(e instanceof fi&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let i=new fi(s,[],null,[]);if(i.set.push(i),t)for(let r of t.set)i.set.push(r);return i}static defineModifier(e){let t=new Py(e);return s=>s.modified.indexOf(t)>-1?s:Py.get(s.base||s,s.modified.concat(t).sort((i,r)=>i.id-r.id))}}let jQ=0;class Py{constructor(e){this.name=e,this.instances=[],this.id=jQ++}static get(e,t){if(!t.length)return e;let s=t[0].instances.find(a=>a.base==e&&FQ(t,a.modified));if(s)return s;let i=[],r=new fi(e.name,i,e,t);for(let a of t)a.instances.push(r);let o=zQ(t);for(let a of e.set)if(!a.modified.length)for(let l of o)i.push(Py.get(a,l));return r}}function FQ(n,e){return n.length==e.length&&n.every((t,s)=>t==e[s])}function zQ(n){let e=[[]];for(let t=0;ts.length-t.length)}function HQ(n){let e=Object.create(null);for(let t in n){let s=n[t];Array.isArray(s)||(s=[s]);for(let i of t.split(" "))if(i){let r=[],o=2,a=i;for(let u=0;;){if(a=="..."&&u>0&&u+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!d)throw new RangeError("Invalid path: "+i);if(r.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),u+=d[0].length,u==i.length)break;let p=i[u++];if(u==i.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+i);a=i.slice(u)}let l=r.length-1,c=r[l];if(!c)throw new RangeError("Invalid path: "+i);let h=new Ry(s,o,l>0?r.slice(0,l):null);e[c]=h.sort(e[c])}}return BQ.add(e)}const BQ=new Je({combine(n,e){let t,s,i;for(;n||e;){if(!n||e&&n.depth>=e.depth?(i=e,e=e.next):(i=n,n=n.next),t&&t.mode==i.mode&&!i.context&&!t.context)continue;let r=new Ry(i.tags,i.mode,i.context);t?t.next=r:s=r,t=r}return s}});class Ry{constructor(e,t,s,i){this.tags=e,this.mode=t,this.context=s,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=i;for(let a of r)for(let l of a.set){let c=t[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:s}}const ce=fi.define,Um=ce(),Do=ce(),dC=ce(Do),fC=ce(Do),jo=ce(),Wm=ce(jo),Bb=ce(jo),ir=ce(),Va=ce(ir),nr=ce(),sr=ce(),j_=ce(),id=ce(j_),Gm=ce(),De={comment:Um,lineComment:ce(Um),blockComment:ce(Um),docComment:ce(Um),name:Do,variableName:ce(Do),typeName:dC,tagName:ce(dC),propertyName:fC,attributeName:ce(fC),className:ce(Do),labelName:ce(Do),namespace:ce(Do),macroName:ce(Do),literal:jo,string:Wm,docString:ce(Wm),character:ce(Wm),attributeValue:ce(Wm),number:Bb,integer:ce(Bb),float:ce(Bb),bool:ce(jo),regexp:ce(jo),escape:ce(jo),color:ce(jo),url:ce(jo),keyword:nr,self:ce(nr),null:ce(nr),atom:ce(nr),unit:ce(nr),modifier:ce(nr),operatorKeyword:ce(nr),controlKeyword:ce(nr),definitionKeyword:ce(nr),moduleKeyword:ce(nr),operator:sr,derefOperator:ce(sr),arithmeticOperator:ce(sr),logicOperator:ce(sr),bitwiseOperator:ce(sr),compareOperator:ce(sr),updateOperator:ce(sr),definitionOperator:ce(sr),typeOperator:ce(sr),controlOperator:ce(sr),punctuation:j_,separator:ce(j_),bracket:id,angleBracket:ce(id),squareBracket:ce(id),paren:ce(id),brace:ce(id),content:ir,heading:Va,heading1:ce(Va),heading2:ce(Va),heading3:ce(Va),heading4:ce(Va),heading5:ce(Va),heading6:ce(Va),contentSeparator:ce(ir),list:ce(ir),quote:ce(ir),emphasis:ce(ir),strong:ce(ir),link:ce(ir),monospace:ce(ir),strikethrough:ce(ir),inserted:ce(),deleted:ce(),changed:ce(),invalid:ce(),meta:Gm,documentMeta:ce(Gm),annotation:ce(Gm),processingInstruction:ce(Gm),definition:fi.defineModifier("definition"),constant:fi.defineModifier("constant"),function:fi.defineModifier("function"),standard:fi.defineModifier("standard"),local:fi.defineModifier("local"),special:fi.defineModifier("special")};for(let n in De){let e=De[n];e instanceof fi&&(e.name=n)}qQ([{tag:De.link,class:"tok-link"},{tag:De.heading,class:"tok-heading"},{tag:De.emphasis,class:"tok-emphasis"},{tag:De.strong,class:"tok-strong"},{tag:De.keyword,class:"tok-keyword"},{tag:De.atom,class:"tok-atom"},{tag:De.bool,class:"tok-bool"},{tag:De.url,class:"tok-url"},{tag:De.labelName,class:"tok-labelName"},{tag:De.inserted,class:"tok-inserted"},{tag:De.deleted,class:"tok-deleted"},{tag:De.literal,class:"tok-literal"},{tag:De.string,class:"tok-string"},{tag:De.number,class:"tok-number"},{tag:[De.regexp,De.escape,De.special(De.string)],class:"tok-string2"},{tag:De.variableName,class:"tok-variableName"},{tag:De.local(De.variableName),class:"tok-variableName tok-local"},{tag:De.definition(De.variableName),class:"tok-variableName tok-definition"},{tag:De.special(De.variableName),class:"tok-variableName2"},{tag:De.definition(De.propertyName),class:"tok-propertyName tok-definition"},{tag:De.typeName,class:"tok-typeName"},{tag:De.namespace,class:"tok-namespace"},{tag:De.className,class:"tok-className"},{tag:De.macroName,class:"tok-macroName"},{tag:De.propertyName,class:"tok-propertyName"},{tag:De.operator,class:"tok-operator"},{tag:De.comment,class:"tok-comment"},{tag:De.meta,class:"tok-meta"},{tag:De.invalid,class:"tok-invalid"},{tag:De.punctuation,class:"tok-punctuation"}]);var qb;const Rd=new Je;function VQ(n){return ve.define({combine:n?e=>e.concat(n):void 0})}const UQ=new Je;class Rr{constructor(e,t,s=[],i=""){this.data=e,this.name=i,it.prototype.hasOwnProperty("tree")||Object.defineProperty(it.prototype,"tree",{get(){return Ia(this)}}),this.parser=t,this.extension=[Tu.of(this),it.languageData.of((r,o,a)=>{let l=pC(r,o,a),c=l.type.prop(Rd);if(!c)return[];let h=r.facet(c),u=l.type.prop(UQ);if(u){let d=l.resolve(o-l.from,a);for(let p of u)if(p.test(d,r)){let m=r.facet(p.facet);return p.type=="replace"?m:m.concat(h)}}return h})].concat(s)}isActiveAt(e,t,s=-1){return pC(e,t,s).type.prop(Rd)==this.data}findRegions(e){let t=e.facet(Tu);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let s=[],i=(r,o)=>{if(r.prop(Rd)==this.data){s.push({from:o,to:o+r.length});return}let a=r.prop(Je.mounted);if(a){if(a.tree.prop(Rd)==this.data){if(a.overlay)for(let l of a.overlay)s.push({from:l.from+o,to:l.to+o});else s.push({from:o,to:o+r.length});return}else if(a.overlay){let l=s.length;if(i(a.tree,a.overlay[0].from+o),s.length>l)return}}for(let l=0;l=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-s,t-s)}}let rd=null;class Cu{constructor(e,t,s=[],i,r,o,a,l){this.parser=e,this.state=t,this.fragments=s,this.tree=i,this.treeLen=r,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,s){return new Cu(e,t,[],Rt.empty,0,s,[],null)}startParse(){return this.parser.startParse(new WQ(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Rt.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var s;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(ac.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=rd;rd=this;try{return e()}finally{rd=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=mC(e,t.from,t.to);return e}changes(e,t){let{fragments:s,tree:i,treeLen:r,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,h,u,d)=>l.push({fromA:c,toA:h,fromB:u,toB:d})),s=ac.applyChanges(s,l),i=Rt.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let h=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);he.from&&(this.fragments=mC(this.fragments,i,r),this.skipped.splice(s--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends rN{createParse(t,s,i){let r=i[0].from,o=i[i.length-1].to;return{parsedPos:r,advance(){let l=rd;if(l){for(let c of i)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new Rt(Ls.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return rd}}function mC(n,e,t){return ac.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class $u{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),s=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,s)||t.takeTree(),new $u(t)}static init(e){let t=Math.min(3e3,e.doc.length),s=Cu.create(e.facet(Tu).parser,e,{from:0,to:t});return s.work(20,t)||s.takeTree(),new $u(s)}}Rr.state=Dr.define({create:$u.init,update(n,e){for(let t of e.effects)if(t.is(Rr.setState))return t.value;return e.startState.facet(Tu)!=e.state.facet(Tu)?$u.init(e.state):n.apply(e)}});let oN=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(oN=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Vb=typeof navigator<"u"&&(!((qb=navigator.scheduling)===null||qb===void 0)&&qb.isInputPending)?()=>navigator.scheduling.isInputPending():null,GQ=ti.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Rr.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Rr.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=oN(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndi+1e3,l=r.context.work(()=>Vb&&Vb()||Date.now()>o,i+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Rr.setState.of(new $u(r.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Pr(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Tu=ve.define({combine(n){return n.length?n[0]:null},enables:n=>[Rr.state,GQ,xe.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),KQ=ve.define(),Gx=ve.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function xc(n){let e=n.facet(Gx);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function My(n,e){let t="",s=n.tabSize,i=n.facet(Gx)[0];if(i==" "){for(;e>=s;)t+=" ",e-=s;i=" "}for(let r=0;r=e?ZQ(n,t,e):null}class G0{constructor(e,t={}){this.state=e,this.options=t,this.unit=xc(e)}lineAt(e,t=1){let s=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:r}=this.options;return i!=null&&i>=s.from&&i<=s.to?r&&i==e?{text:"",from:e}:(t<0?i-1&&(r+=o-this.countColumn(s,s.search(/\S|$/))),r}countColumn(e,t=e.length){return z0(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:s,from:i}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(i);if(o>-1)return o}return this.countColumn(s,s.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const lN=new Je;function ZQ(n,e,t){let s=e.resolveStack(t),i=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(i!=s.node){let r=[];for(let o=i;o&&!(o.froms.node.to||o.from==s.node.from&&o.type==s.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)s={node:r[o],next:s}}return cN(s,n,t)}function cN(n,e,t){for(let s=n;s;s=s.next){let i=YQ(s.node);if(i)return i(Kx.create(e,t,s))}return 0}function XQ(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function YQ(n){let e=n.type.prop(lN);if(e)return e;let t=n.firstChild,s;if(t&&(s=t.type.prop(Je.closedBy))){let i=n.lastChild,r=i&&s.indexOf(i.name)>-1;return o=>tee(o,!0,1,void 0,r&&!XQ(o)?i.from:void 0)}return n.parent==null?JQ:null}function JQ(){return 0}class Kx extends G0{constructor(e,t,s){super(e.state,e.options),this.base=e,this.pos=t,this.context=s}get node(){return this.context.node}static create(e,t,s){return new Kx(e,t,s)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let s=e.resolve(t.from);for(;s.parent&&s.parent.from==s.from;)s=s.parent;if(QQ(s,e))break;t=this.state.doc.lineAt(s.from)}return this.lineIndent(t.from)}continue(){return cN(this.context.next,this.base,this.pos)}}function QQ(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function eee(n){let e=n.node,t=e.childAfter(e.from),s=e.lastChild;if(!t)return null;let i=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=i==null||i<=r.from?r.to:Math.min(r.to,i);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==s)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+c}}a=l.to}}function tee(n,e,t,s,i){let r=n.textAfter,o=r.match(/^\s*/)[0].length,a=s&&r.slice(o,o+s.length)==s||i==n.pos+o,l=eee(n);return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*t)}const nee=xe.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),hN=1e4,uN="()[]{}",dN=ve.define({combine(n){return ju(n,{afterCursor:!0,brackets:uN,maxScanDistance:hN,renderMatch:ree})}}),see=Ze.mark({class:"cm-matchingBracket"}),iee=Ze.mark({class:"cm-nonmatchingBracket"});function ree(n){let e=[],t=n.matched?see:iee;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function gC(n){let e=[],t=n.facet(dN);for(let s of n.selection.ranges){if(!s.empty)continue;let i=Mr(n,s.head,-1,t)||s.head>0&&Mr(n,s.head-1,1,t)||t.afterCursor&&(Mr(n,s.head,1,t)||s.headn.decorations}),aee=[oee,nee];function lee(n={}){return[dN.of(n),aee]}const cee=new Je;function F_(n,e,t){let s=n.prop(e<0?Je.openedBy:Je.closedBy);if(s)return s;if(n.name.length==1){let i=t.indexOf(n.name);if(i>-1&&i%2==(e<0?1:0))return[t[i+e]]}return null}function z_(n){let e=n.type.prop(cee);return e?e(n.node):n}function Mr(n,e,t,s={}){let i=s.maxScanDistance||hN,r=s.brackets||uN,o=Ia(n),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=F_(l.type,t,r);if(c&&l.from0?e>=h.from&&eh.from&&e<=h.to))return hee(n,e,t,l,h,c,r)}}return uee(n,e,t,o,a.type,i,r)}function hee(n,e,t,s,i,r,o){let a=s.parent,l={from:i.from,to:i.to},c=0,h=a==null?void 0:a.cursor();if(h&&(t<0?h.childBefore(s.from):h.childAfter(s.to)))do if(t<0?h.to<=s.from:h.from>=s.to){if(c==0&&r.indexOf(h.type.name)>-1&&h.from0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},h=n.doc.iterRange(e,t>0?n.doc.length:0),u=0;for(let d=0;!h.next().done&&d<=r;){let p=h.value;t<0&&(d+=p.length);let m=e+d*t;for(let g=t>0?0:p.length-1,b=t>0?p.length:-1;g!=b;g+=t){let y=o.indexOf(p[g]);if(!(y<0||s.resolveInner(m+g,1).type!=i))if(y%2==0==t>0)u++;else{if(u==1)return{start:c,end:{from:m+g,to:m+g+1},matched:y>>1==l>>1};u--}}t>0&&(d+=p.length)}return h.done?{start:c,matched:!1}:null}function yC(n,e,t,s=0,i=0){e==null&&(e=n.search(/[^\s\u00a0]/),e==-1&&(e=n.length));let r=i;for(let o=s;o=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.post}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPoss?o.toLowerCase():o,r=this.string.substr(this.pos,e.length);return i(r)==i(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let i=this.string.slice(this.pos).match(e);return i&&i.index>0?null:(i&&t!==!1&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function dee(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||fee,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||Yx,mergeTokens:n.mergeTokens!==!1}}function fee(n){if(typeof n!="object")return n;let e={};for(let t in n){let s=n[t];e[t]=s instanceof Array?s.slice():s}return e}const bC=new WeakMap;class Zx extends Rr{constructor(e){let t=VQ(e.languageData),s=dee(e),i,r=new class extends rN{createParse(o,a,l){return new mee(i,o,a,l)}};super(t,r,[],e.name),this.topNode=bee(t,this),i=this,this.streamParser=s,this.stateAfter=new Je({perNode:!0}),this.tokenTable=e.tokenTable?new yN(s.tokenTable):yee}static define(e){return new Zx(e)}getIndent(e){let t,{overrideIndentation:s}=e.options;s&&(t=bC.get(e.state),t!=null&&t1e4)return null;for(;r=s&&t+e.length<=i&&e.prop(n.stateAfter);if(r)return{state:n.streamParser.copyState(r),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let a=e.children[o],l=t+e.positions[o],c=a instanceof Rt&&l=e.length)return e;!i&&t==0&&e.type==n.topNode&&(i=!0);for(let r=e.children.length-1;r>=0;r--){let o=e.positions[r],a=e.children[r],l;if(ot&&Xx(n,r.tree,0-r.offset,t,a),c;if(l&&l.pos<=s&&(c=pN(n,r.tree,t+r.offset,l.pos+r.offset,!1)))return{state:l.state,tree:c}}return{state:n.streamParser.startState(i?xc(i):4),tree:Rt.empty}}class mee{constructor(e,t,s,i){this.lang=e,this.input=t,this.fragments=s,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let r=Cu.get(),o=i[0].from,{state:a,tree:l}=pee(e,s,o,this.to,r==null?void 0:r.state);this.state=a,this.parsedPos=this.chunkStart=o+l.length;for(let c=0;cc.from<=r.viewport.from&&c.to>=r.viewport.from)&&(this.state=this.lang.streamParser.startState(xc(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let e=Cu.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),s=Math.min(t,this.chunkStart+512);for(e&&(s=Math.min(s,e.viewport.to));this.parsedPos=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==` +`&&(t="");else{let s=t.indexOf(` +`);s>-1&&(t=t.slice(0,s))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),s=e+t.length;for(let i=this.rangeIndex;;){let r=this.ranges[i].to;if(r>=s||(t=t.slice(0,r-(s-t.length)),i++,i==this.ranges.length))break;let o=this.ranges[i].from,a=this.lineAfter(o);t+=a,s=o+a.length}return{line:t,end:s}}skipGapsTo(e,t,s){for(;;){let i=this.ranges[this.rangeIndex].to,r=e+t;if(s>0?i>r:i>=r)break;let o=this.ranges[++this.rangeIndex].from;t+=o-i}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to1){i=this.skipGapsTo(t,i,1),t+=i;let a=this.chunk.length;i=this.skipGapsTo(s,i,-1),s+=i,r+=this.chunk.length-a}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&r==4&&o>=0&&this.chunk[o]==e&&this.chunk[o+2]==t?this.chunk[o+2]=s:this.chunk.push(e,t,s,r),i}parseLine(e){let{line:t,end:s}=this.nextLine(),i=0,{streamParser:r}=this.lang,o=new fN(t,e?e.state.tabSize:4,e?xc(e.state):2);if(o.eol())r.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let a=mN(r.token,o,this.state);if(a&&(i=this.emitToken(this.lang.tokenTable.resolve(a),this.parsedPos+o.start,this.parsedPos+o.pos,i)),o.start>1e4)break}this.parsedPos=s,this.moveRangeIndex(),this.parsedPose.start)return i}throw new Error("Stream parser failed to advance stream.")}const Yx=Object.create(null),gf=[Ls.none],gee=new qx(gf),vC=[],wC=Object.create(null),gN=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])gN[n]=bN(Yx,e);class yN{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),gN)}resolve(e){return e?this.table[e]||(this.table[e]=bN(this.extra,e)):0}}const yee=new yN(Yx);function Ub(n,e){vC.indexOf(n)>-1||(vC.push(n),console.warn(e))}function bN(n,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let h=n[c]||De[c];h?typeof h=="function"?l.length?l=l.map(h):Ub(c,`Modifier ${c} used at start of tag`):l.length?Ub(c,`Tag ${c} used as modifier`):l=Array.isArray(h)?h:[h]:Ub(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let s=e.replace(/ /g,"_"),i=s+" "+t.map(a=>a.id),r=wC[i];if(r)return r.id;let o=wC[i]=Ls.define({id:gf.length,name:s,props:[HQ({[s]:t})]});return gf.push(o),o.id}function bee(n,e){let t=Ls.define({id:gf.length,name:"Document",props:[Rd.add(()=>n),lN.add(()=>s=>e.getIndent(s))],top:!0});return gf.push(t),t}Pt.RTL,Pt.LTR;const vee=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),s=Qx(n.state,t.from);return s.line?wee(n):s.block?See(n):!1};function Jx(n,e){return({state:t,dispatch:s})=>{if(t.readOnly)return!1;let i=n(e,t);return i?(s(t.update(i)),!0):!1}}const wee=Jx(Aee,0),_ee=Jx(vN,0),See=Jx((n,e)=>vN(n,e,kee(e)),0);function Qx(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const od=50;function xee(n,{open:e,close:t},s,i){let r=n.sliceDoc(s-od,s),o=n.sliceDoc(i,i+od),a=/\s*$/.exec(r)[0].length,l=/^\s*/.exec(o)[0].length,c=r.length-a;if(r.slice(c-e.length,c)==e&&o.slice(l,l+t.length)==t)return{open:{pos:s-a,margin:a&&1},close:{pos:i+l,margin:l&&1}};let h,u;i-s<=2*od?h=u=n.sliceDoc(s,i):(h=n.sliceDoc(s,s+od),u=n.sliceDoc(i-od,i));let d=/^\s*/.exec(h)[0].length,p=/\s*$/.exec(u)[0].length,m=u.length-p-t.length;return h.slice(d,d+e.length)==e&&u.slice(m,m+t.length)==t?{open:{pos:s+d+e.length,margin:/\s/.test(h.charAt(d+e.length))?1:0},close:{pos:i-p-t.length,margin:/\s/.test(u.charAt(m-1))?1:0}}:null}function kee(n){let e=[];for(let t of n.selection.ranges){let s=n.doc.lineAt(t.from),i=t.to<=s.to?s:n.doc.lineAt(t.to);i.from>s.from&&i.from==t.to&&(i=t.to==s.to+1?s:n.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>s.from?e[r].to=i.to:e.push({from:s.from+/^\s*/.exec(s.text)[0].length,to:i.to})}return e}function vN(n,e,t=e.selection.ranges){let s=t.map(r=>Qx(e,r.from).block);if(!s.every(r=>r))return null;let i=t.map((r,o)=>xee(e,s[o],r.from,r.to));if(n!=2&&!i.every(r=>r))return{changes:e.changes(t.map((r,o)=>i[o]?[]:[{from:r.from,insert:s[o].open+" "},{from:r.to,insert:" "+s[o].close}]))};if(n!=1&&i.some(r=>r)){let r=[];for(let o=0,a;oi&&(r==o||o>u.from)){i=u.from;let d=/^\s*/.exec(u.text)[0].length,p=d==u.length,m=u.text.slice(d,d+c.length)==c?d:-1;dr.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:a,token:l,indent:c,empty:h,single:u}of s)(u||!h)&&r.push({from:a.from+c,insert:l+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&s.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:a,token:l}of s)if(a>=0){let c=o.from+a,h=c+l.length;o.text[h-o.from]==" "&&h++,r.push({from:c,to:h})}return{changes:r}}return null}const H_=Da.define(),Eee=Da.define(),Cee=ve.define(),wN=ve.define({combine(n){return ju(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(s,i)=>e(s,i)||t(s,i)})}}),_N=Dr.define({create(){return Ir.empty},update(n,e){let t=e.state.facet(wN),s=e.annotation(H_);if(s){let l=Os.fromTransaction(e,s.selection),c=s.side,h=c==0?n.undone:n.done;return l?h=Iy(h,h.length,t.minDepth,l):h=kN(h,e.startState.selection),new Ir(c==0?s.rest:h,c==0?h:s.rest)}let i=e.annotation(Eee);if((i=="full"||i=="before")&&(n=n.isolate()),e.annotation(pn.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=Os.fromTransaction(e),o=e.annotation(pn.time),a=e.annotation(pn.userEvent);return r?n=n.addChanges(r,o,a,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,a,t.newGroupDelay)),(i=="full"||i=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new Ir(n.done.map(Os.fromJSON),n.undone.map(Os.fromJSON))}});function $ee(n={}){return[_N,wN.of(n),xe.domEventHandlers({beforeinput(e,t){let s=e.inputType=="historyUndo"?SN:e.inputType=="historyRedo"?B_:null;return s?(e.preventDefault(),s(t)):!1}})]}function K0(n,e){return function({state:t,dispatch:s}){if(!e&&t.readOnly)return!1;let i=t.field(_N,!1);if(!i)return!1;let r=i.pop(n,t,e);return r?(s(r),!0):!1}}const SN=K0(0,!1),B_=K0(1,!1),Tee=K0(0,!0),Pee=K0(1,!0);class Os{constructor(e,t,s,i,r){this.changes=e,this.effects=t,this.mapped=s,this.startSelection=i,this.selectionsAfter=r}setSelAfter(e){return new Os(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,s;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(s=this.startSelection)===null||s===void 0?void 0:s.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new Os(e.changes&&un.fromJSON(e.changes),[],e.mapped&&Or.fromJSON(e.mapped),e.startSelection&&te.fromJSON(e.startSelection),e.selectionsAfter.map(te.fromJSON))}static fromTransaction(e,t){let s=yi;for(let i of e.startState.facet(Cee)){let r=i(e);r.length&&(s=s.concat(r))}return!s.length&&e.changes.empty?null:new Os(e.changes.invert(e.startState.doc),s,void 0,t||e.startState.selection,yi)}static selection(e){return new Os(void 0,yi,void 0,void 0,e)}}function Iy(n,e,t,s){let i=e+1>t+20?e-t-1:0,r=n.slice(i,e);return r.push(s),r}function Ree(n,e){let t=[],s=!1;return n.iterChangedRanges((i,r)=>t.push(i,r)),e.iterChangedRanges((i,r,o,a)=>{for(let l=0;l=c&&o<=h&&(s=!0)}}),s}function Mee(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,s)=>t.empty!=e.ranges[s].empty).length===0}function xN(n,e){return n.length?e.length?n.concat(e):n:e}const yi=[],Iee=200;function kN(n,e){if(n.length){let t=n[n.length-1],s=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Iee));return s.length&&s[s.length-1].eq(e)?n:(s.push(e),Iy(n,n.length-1,1e9,t.setSelAfter(s)))}else return[Os.selection([e])]}function Oee(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Wb(n,e){if(!n.length)return n;let t=n.length,s=yi;for(;t;){let i=Nee(n[t-1],e,s);if(i.changes&&!i.changes.empty||i.effects.length){let r=n.slice(0,t);return r[t-1]=i,r}else e=i.mapped,t--,s=i.selectionsAfter}return s.length?[Os.selection(s)]:yi}function Nee(n,e,t){let s=xN(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):yi,t);if(!n.changes)return Os.selection(s);let i=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new Os(i,bt.mapEffects(n.effects,e),o,n.startSelection.map(r),s)}const Lee=/^(input\.type|delete)($|\.)/;class Ir{constructor(e,t,s=0,i=void 0){this.done=e,this.undone=t,this.prevTime=s,this.prevUserEvent=i}isolate(){return this.prevTime?new Ir(this.done,this.undone):this}addChanges(e,t,s,i,r){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!s||Lee.test(s))&&(!a.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):Z0(t,e))}function rs(n){return n.textDirectionAt(n.state.selection.main.head)==Pt.LTR}const EN=n=>AN(n,!rs(n)),CN=n=>AN(n,rs(n));function $N(n,e){return Ji(n,t=>t.empty?n.moveByGroup(t,e):Z0(t,e))}const jee=n=>$N(n,!rs(n)),Fee=n=>$N(n,rs(n));function zee(n,e,t){if(e.type.prop(t))return!0;let s=e.to-e.from;return s&&(s>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function X0(n,e,t){let s=Ia(n).resolveInner(e.head),i=t?Je.closedBy:Je.openedBy;for(let l=e.head;;){let c=t?s.childAfter(l):s.childBefore(l);if(!c)break;zee(n,c,i)?s=c:l=t?c.to:c.from}let r=s.type.prop(i),o,a;return r&&(o=t?Mr(n,s.from,1):Mr(n,s.to,-1))&&o.matched?a=t?o.end.to:o.end.from:a=t?s.to:s.from,te.cursor(a,t?-1:1)}const Hee=n=>Ji(n,e=>X0(n.state,e,!rs(n))),Bee=n=>Ji(n,e=>X0(n.state,e,rs(n)));function TN(n,e){return Ji(n,t=>{if(!t.empty)return Z0(t,e);let s=n.moveVertically(t,e);return s.head!=t.head?s:n.moveToLineBoundary(t,e)})}const PN=n=>TN(n,!1),RN=n=>TN(n,!0);function MN(n){let e=n.scrollDOM.clientHeighto.empty?n.moveVertically(o,e,t.height):Z0(o,e));if(i.eq(s.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(s.selection.main.head),a=n.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;o&&o.top>l&&o.bottomIN(n,!1),q_=n=>IN(n,!0);function ja(n,e,t){let s=n.lineBlockAt(e.head),i=n.moveToLineBoundary(e,t);if(i.head==e.head&&i.head!=(t?s.to:s.from)&&(i=n.moveToLineBoundary(e,t,!1)),!t&&i.head==s.from&&s.length){let r=/^\s*/.exec(n.state.sliceDoc(s.from,Math.min(s.from+100,s.to)))[0].length;r&&e.head!=s.from+r&&(i=te.cursor(s.from+r))}return i}const qee=n=>Ji(n,e=>ja(n,e,!0)),Vee=n=>Ji(n,e=>ja(n,e,!1)),Uee=n=>Ji(n,e=>ja(n,e,!rs(n))),Wee=n=>Ji(n,e=>ja(n,e,rs(n))),Gee=n=>Ji(n,e=>te.cursor(n.lineBlockAt(e.head).from,1)),Kee=n=>Ji(n,e=>te.cursor(n.lineBlockAt(e.head).to,-1));function Zee(n,e,t){let s=!1,i=Fu(n.selection,r=>{let o=Mr(n,r.head,-1)||Mr(n,r.head,1)||r.head>0&&Mr(n,r.head-1,1)||r.headZee(n,e);function xi(n,e,t){let s=Fu(n.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=te.range(i.head,i.anchor));let r=t(i);return te.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return s.eq(n.state.selection)?!1:(n.dispatch(Yi(n.state,s)),!0)}function ON(n,e){return xi(n,e,t=>n.moveByChar(t,e))}const NN=n=>ON(n,!rs(n)),LN=n=>ON(n,rs(n));function DN(n,e){return xi(n,e,t=>n.moveByGroup(t,e))}const Yee=n=>DN(n,!rs(n)),Jee=n=>DN(n,rs(n)),Qee=n=>{let e=!rs(n);return xi(n,e,t=>X0(n.state,t,e))},ete=n=>{let e=rs(n);return xi(n,e,t=>X0(n.state,t,e))};function jN(n,e){return xi(n,e,t=>n.moveVertically(t,e))}const FN=n=>jN(n,!1),zN=n=>jN(n,!0);function HN(n,e){return xi(n,e,t=>n.moveVertically(t,e,MN(n).height))}const SC=n=>HN(n,!1),xC=n=>HN(n,!0),tte=n=>xi(n,!0,e=>ja(n,e,!0)),nte=n=>xi(n,!1,e=>ja(n,e,!1)),ste=n=>{let e=!rs(n);return xi(n,e,t=>ja(n,t,e))},ite=n=>{let e=rs(n);return xi(n,e,t=>ja(n,t,e))},rte=n=>xi(n,!1,e=>te.cursor(n.lineBlockAt(e.head).from)),ote=n=>xi(n,!0,e=>te.cursor(n.lineBlockAt(e.head).to)),kC=({state:n,dispatch:e})=>(e(Yi(n,{anchor:0})),!0),AC=({state:n,dispatch:e})=>(e(Yi(n,{anchor:n.doc.length})),!0),EC=({state:n,dispatch:e})=>(e(Yi(n,{anchor:n.selection.main.anchor,head:0})),!0),CC=({state:n,dispatch:e})=>(e(Yi(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),ate=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),lte=({state:n,dispatch:e})=>{let t=Y0(n).map(({from:s,to:i})=>te.undirectionalRange(s,Math.min(i+1,n.doc.length)));return e(n.update({selection:te.create(t),userEvent:"select"})),!0},cte=({state:n,dispatch:e})=>{let t=Fu(n.selection,s=>{let i=Ia(n),r=i.resolveStack(s.from,1);if(s.empty){let o=i.resolveStack(s.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:a}=o;if((a.from=s.to||a.to>s.to&&a.from<=s.from)&&o.next)return te.undirectionalRange(a.from,a.to)}return s});return t.eq(n.selection)?!1:(e(Yi(n,t)),!0)};function BN(n,e){let{state:t}=n,s=t.selection,i=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to0)for(let a=r;;){let l=n.moveVertically(a,e);if(l.heado.to){i.some(c=>c.head==l.head)||i.push(l);break}else{if(l.head==a.head)break;a=l}}}return i.length==s.ranges.length?!1:(n.dispatch(Yi(t,te.create(i,i.length-1))),!0)}const hte=n=>BN(n,!1),ute=n=>BN(n,!0),dte=({state:n,dispatch:e})=>{let t=n.selection,s=null;return t.ranges.length>1?s=te.create([t.main]):t.main.empty||(s=te.create([te.cursor(t.main.head)])),s?(e(Yi(n,s)),!0):!1};function om(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:s}=n,i=s.changeByRange(r=>{let{from:o,to:a}=r;if(o==a){let l=e(r);lo&&(t="delete.forward",l=Km(n,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=Km(n,o,!1),a=Km(n,a,!0);return o==a?{range:r}:{changes:{from:o,to:a},range:te.cursor(o,oi(n)))s.between(e,e,(i,r)=>{ie&&(e=t?r:i)});return e}const qN=(n,e,t)=>om(n,s=>{let i=s.from,{state:r}=n,o=r.doc.lineAt(i),a,l;if(t&&!e&&i>o.from&&iqN(n,!1,!0),VN=n=>qN(n,!0,!1),UN=(n,e)=>om(n,t=>{let s=t.head,{state:i}=n,r=i.doc.lineAt(s),o=i.charCategorizer(s);for(let a=null;;){if(s==(e?r.to:r.from)){s==t.head&&r.number!=(e?i.doc.lines:1)&&(s+=e?1:-1);break}let l=kn(r.text,s-r.from,e)+r.from,c=r.text.slice(Math.min(s,l)-r.from,Math.max(s,l)-r.from),h=o(c);if(a!=null&&h!=a)break;(c!=" "||s!=t.head)&&(a=h),s=l}return s}),WN=n=>UN(n,!1),fte=n=>UN(n,!0),pte=n=>om(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headom(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),gte=n=>om(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(s=>({changes:{from:s.from,to:s.to,insert:rt.of(["",""])},range:te.cursor(s.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},bte=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(s=>{if(!s.empty||s.from==0||s.from==n.doc.length)return{range:s};let i=s.from,r=n.doc.lineAt(i),o=i==r.from?i-1:kn(r.text,i-r.from,!1)+r.from,a=i==r.to?i+1:kn(r.text,i-r.from,!0)+r.from;return{changes:{from:o,to:a,insert:n.doc.slice(i,a).append(n.doc.slice(o,i))},range:te.cursor(a)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Y0(n){let e=[],t=-1;for(let s of n.selection.ranges){let i=n.doc.lineAt(s.from),r=n.doc.lineAt(s.to);if(!s.empty&&s.to==r.from&&(r=n.doc.lineAt(s.to-1)),t>=i.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(s)}else e.push({from:i.from,to:r.to,ranges:[s]});t=r.number+1}return e}function GN(n,e,t){if(n.readOnly)return!1;let s=[],i=[];for(let r of Y0(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),a=o.length+1;if(t){s.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let l of r.ranges)i.push(te.range(Math.min(n.doc.length,l.anchor+a),Math.min(n.doc.length,l.head+a)))}else{s.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let l of r.ranges)i.push(te.range(l.anchor-a,l.head-a))}}return s.length?(e(n.update({changes:s,scrollIntoView:!0,selection:te.create(i,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const vte=({state:n,dispatch:e})=>GN(n,e,!1),wte=({state:n,dispatch:e})=>GN(n,e,!0);function KN(n,e,t){if(n.readOnly)return!1;let s=[];for(let r of Y0(n))t?s.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):s.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});let i=n.changes(s);return e(n.update({changes:i,selection:n.selection.map(i,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const _te=({state:n,dispatch:e})=>KN(n,e,!1),Ste=({state:n,dispatch:e})=>KN(n,e,!0),xte=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Y0(e).map(({from:i,to:r})=>(i>0?i--:r{let r;if(n.lineWrapping){let o=n.lineBlockAt(i.head),a=n.coordsAtPos(i.head,i.assoc||1);a&&(r=o.bottom+n.documentTop-a.bottom+n.defaultLineHeight/2)}return n.moveVertically(i,!0,r)}).map(t);return n.dispatch({changes:t,selection:s,scrollIntoView:!0,userEvent:"delete.line"}),!0};function kte(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Ia(n).resolveInner(e),s=t.childBefore(e),i=t.childAfter(e),r;return s&&i&&s.to<=e&&i.from>=e&&(r=s.type.prop(Je.closedBy))&&r.indexOf(i.name)>-1&&n.doc.lineAt(s.to).from==n.doc.lineAt(i.from).from&&!/\S/.test(n.sliceDoc(s.to,i.from))?{from:s.to,to:i.from}:null}const $C=ZN(!1),Ate=ZN(!0);function ZN(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let s=e.changeByRange(i=>{let{from:r,to:o}=i,a=e.doc.lineAt(r),l=!n&&r==o&&kte(e,r);n&&(r=o=(o<=a.to?a:e.doc.lineAt(o)).to);let c=new G0(e,{simulateBreak:r,simulateDoubleBreak:!!l}),h=aN(c,r);for(h==null&&(h=z0(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));oa.from&&r{let i=[];for(let o=s.from;o<=s.to;){let a=n.doc.lineAt(o);a.number>t&&(s.empty||s.to>a.from)&&(e(a,i,s),t=a.number),o=a.to+1}let r=n.changes(i);return{changes:i,range:te.range(r.mapPos(s.anchor,1),r.mapPos(s.head,1))}})}const Ete=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),s=new G0(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),i=ek(n,(r,o,a)=>{let l=aN(s,r.from);if(l==null)return;/\S/.test(r.text)||(l=0);let c=/^\s*/.exec(r.text)[0],h=My(n,l);(c!=h||a.fromn.readOnly?!1:(e(n.update(ek(n,(t,s)=>{s.push({from:t.from,insert:n.facet(Gx)})}),{userEvent:"input.indent"})),!0),YN=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(ek(n,(t,s)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let r=z0(i,n.tabSize),o=0,a=My(n,Math.max(0,r-xc(n)));for(;o(n.setTabFocusMode(),!0),$te=[{key:"Ctrl-b",run:EN,shift:NN,preventDefault:!0},{key:"Ctrl-f",run:CN,shift:LN},{key:"Ctrl-p",run:PN,shift:FN},{key:"Ctrl-n",run:RN,shift:zN},{key:"Ctrl-a",run:Gee,shift:rte},{key:"Ctrl-e",run:Kee,shift:ote},{key:"Ctrl-d",run:VN},{key:"Ctrl-h",run:V_},{key:"Ctrl-k",run:pte},{key:"Ctrl-Alt-h",run:WN},{key:"Ctrl-o",run:yte},{key:"Ctrl-t",run:bte},{key:"Ctrl-v",run:q_}],Tte=[{key:"ArrowLeft",run:EN,shift:NN,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:jee,shift:Yee,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Uee,shift:ste,preventDefault:!0},{key:"ArrowRight",run:CN,shift:LN,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Fee,shift:Jee,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Wee,shift:ite,preventDefault:!0},{key:"ArrowUp",run:PN,shift:FN,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kC,shift:EC},{mac:"Ctrl-ArrowUp",run:_C,shift:SC},{key:"ArrowDown",run:RN,shift:zN,preventDefault:!0},{mac:"Cmd-ArrowDown",run:AC,shift:CC},{mac:"Ctrl-ArrowDown",run:q_,shift:xC},{key:"PageUp",run:_C,shift:SC},{key:"PageDown",run:q_,shift:xC},{key:"Home",run:Vee,shift:nte,preventDefault:!0},{key:"Mod-Home",run:kC,shift:EC},{key:"End",run:qee,shift:tte,preventDefault:!0},{key:"Mod-End",run:AC,shift:CC},{key:"Enter",run:$C,shift:$C},{key:"Mod-a",run:ate},{key:"Backspace",run:V_,shift:V_,preventDefault:!0},{key:"Delete",run:VN,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:WN,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:fte,preventDefault:!0},{mac:"Mod-Backspace",run:mte,preventDefault:!0},{mac:"Mod-Delete",run:gte,preventDefault:!0}].concat($te.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Pte=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Hee,shift:Qee},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Bee,shift:ete},{key:"Alt-ArrowUp",run:vte},{key:"Shift-Alt-ArrowUp",run:_te},{key:"Alt-ArrowDown",run:wte},{key:"Shift-Alt-ArrowDown",run:Ste},{key:"Mod-Alt-ArrowUp",run:hte},{key:"Mod-Alt-ArrowDown",run:ute},{key:"Escape",run:dte},{key:"Mod-Enter",run:Ate},{key:"Alt-l",mac:"Ctrl-l",run:lte},{key:"Mod-i",run:cte,preventDefault:!0},{key:"Mod-[",run:YN},{key:"Mod-]",run:XN},{key:"Mod-Alt-\\",run:Ete},{key:"Shift-Mod-k",run:xte},{key:"Shift-Mod-\\",run:Xee},{key:"Mod-/",run:vee},{key:"Alt-A",mac:"Ctrl-A",run:_ee},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Cte}].concat(Tte),Rte={key:"Tab",run:XN,shift:YN};function JN(n){function e(u,d){u.cmdState.push(d)}function t(u){return u.cmdState.length>0?u.cmdState[u.cmdState.length-1]:null}function s(u){var d=u.cmdState.pop();d&&d.closeBracket()}function i(u){for(var d=u.cmdState,p=d.length-1;p>=0;p--){var m=d[p];if(m.name!="DEFAULT")return m}return{styleIdentifier:function(){return null}}}function r(u,d,p){return function(){this.name=u,this.bracketNo=0,this.style=d,this.styles=p,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var o={};o.importmodule=r("importmodule","tag",["string","builtin"]),o.documentclass=r("documentclass","tag",["","atom"]),o.usepackage=r("usepackage","tag",["atom"]),o.begin=r("begin","tag",["atom"]),o.end=r("end","tag",["atom"]),o.label=r("label","tag",["atom"]),o.ref=r("ref","tag",["atom"]),o.eqref=r("eqref","tag",["atom"]),o.cite=r("cite","tag",["atom"]),o.bibitem=r("bibitem","tag",["atom"]),o.Bibitem=r("Bibitem","tag",["atom"]),o.RBibitem=r("RBibitem","tag",["atom"]),o.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function a(u,d){u.f=d}function l(u,d){var p;if(u.match(/^\\[a-zA-Z@\xc0-\u1fff\u2060-\uffff]+/)){var m=u.current().slice(1);return p=o.hasOwnProperty(m)?o[m]:o.DEFAULT,p=new p,e(d,p),a(d,h),p.style}if(u.match(/^\\[$&%#{}_]/)||u.match(/^\\[,;!\/\\]/))return"tag";if(u.match("\\["))return a(d,function(b,y){return c(b,y,"\\]")}),"keyword";if(u.match("\\("))return a(d,function(b,y){return c(b,y,"\\)")}),"keyword";if(u.match("$$"))return a(d,function(b,y){return c(b,y,"$$")}),"keyword";if(u.match("$"))return a(d,function(b,y){return c(b,y,"$")}),"keyword";var g=u.next();if(g=="%")return u.skipToEnd(),"comment";if(g=="}"||g=="]"){if(p=t(d),p)p.closeBracket(g),a(d,h);else return"error";return"bracket"}else return g=="{"||g=="["?(p=o.DEFAULT,p=new p,e(d,p),"bracket"):/\d/.test(g)?(u.eatWhile(/[\w.%]/),"atom"):(u.eatWhile(/[\w\-_]/),p=i(d),p.name=="begin"&&(p.argument=u.current()),p.styleIdentifier())}function c(u,d,p){if(u.eatSpace())return null;if(p&&u.match(p))return a(d,l),"keyword";if(u.match(/^\\[a-zA-Z@]+/))return"tag";if(u.match(/^[a-zA-Z]+/))return"variableName.special";if(u.match(/^\\[$&%#{}_]/)||u.match(/^\\[,;!\/]/)||u.match(/^[\^_&]/))return"tag";if(u.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(u.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var m=u.next();return m=="{"||m=="}"||m=="["||m=="]"||m=="("||m==")"?"bracket":m=="%"?(u.skipToEnd(),"comment"):"error"}function h(u,d){var p=u.peek(),m;return p=="{"||p=="["?(m=t(d),m.openBracket(p),u.eat(p),a(d,l),"bracket"):/[ \t\r]/.test(p)?(u.eat(p),null):(a(d,l),s(d),l(u,d))}return{name:"stex",startState:function(){var u=n?function(d,p){return c(d,p)}:l;return{cmdState:[],f:u}},copyState:function(u){return{cmdState:u.cmdState.slice(),f:u.f}},token:function(u,d){return d.f(u,d)},blankLine:function(u){u.f=l,u.cmdState.length=0},languageData:{commentTokens:{line:"%"}}}}const Mte=JN(!1);JN(!0);const TC=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class Pu{constructor(e,t,s=0,i=e.length,r,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(s,i),this.bufferStart=s,this.normalize=r?a=>r(TC(a)):TC,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return NI(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=s7(e),s=this.bufferStart+this.bufferPos;this.bufferPos+=LI(e);let i=this.normalize(t);if(i.length)for(let r=0,o=s,a=!0;;r++){let l=i.charCodeAt(r),c=this.match(l,o,a,this.bufferPos+this.bufferStart,r==i.length-1);if(c)return this.value=c,this;if(r==i.length-1)break;a&&rthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let s=this.curLineStart+t.index,i=s+t[0].length;if(this.matchPos=Oy(this.text,i+(s==i?1:0)),s==this.curLineStart+this.curLine.length&&this.nextLine(),(sthis.value.to)&&(!this.test||this.test(s,i,t)))return this.value={from:s,to:i,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=s||i.to<=t){let a=new mh(t,e.sliceString(t,s));return Gb.set(e,a),a}if(i.from==t&&i.to==s)return i;let{text:r,from:o}=i;return o>t&&(r=e.sliceString(t,o)+r,o=t),i.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let s=this.flat.from+t.index,i=s+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(s,i,t)))return this.value={from:s,to:i,precise:!0,match:t},this.matchPos=Oy(this.text,i+(s==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=mh.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(eL.prototype[Symbol.iterator]=tL.prototype[Symbol.iterator]=function(){return this});function Ite(n){try{return new RegExp(n,tk),!0}catch{return!1}}function Oy(n,e){if(e>=n.length)return e;let t=n.lineAt(e),s;for(;e=56320&&s<57344;)e++;return e}const Ote=n=>{let{state:e}=n,t=String(e.doc.lineAt(n.state.selection.main.head).number),{close:s,result:i}=bQ(n,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return i.then(r=>{let o=r&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(r.elements.line.value);if(!o){n.dispatch({effects:s});return}let a=e.doc.lineAt(e.selection.main.head),[,l,c,h,u]=o,d=h?+h.slice(1):0,p=c?+c:a.number;if(c&&u){let b=p/100;l&&(b=b*(l=="-"?-1:1)+a.number/e.doc.lines),p=Math.round(e.doc.lines*b)}else c&&l&&(p=p*(l=="-"?-1:1)+a.number);let m=e.doc.line(Math.max(1,Math.min(e.doc.lines,p))),g=te.cursor(m.from+Math.max(0,Math.min(d,m.length)));n.dispatch({effects:[s,xe.scrollIntoView(g.from,{y:"center"})],selection:g})}),!0},Nte={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Lte=ve.define({combine(n){return ju(n,Nte,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Dte(n){return[Bte,Hte]}const jte=Ze.mark({class:"cm-selectionMatch"}),Fte=Ze.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function PC(n,e,t,s){return(t==0||n(e.sliceDoc(t-1,t))!=Zt.Word)&&(s==e.doc.length||n(e.sliceDoc(s,s+1))!=Zt.Word)}function zte(n,e,t,s){return n(e.sliceDoc(t,t+1))==Zt.Word&&n(e.sliceDoc(s-1,s))==Zt.Word}const Hte=ti.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(Lte),{state:t}=n,s=t.selection;if(s.ranges.length>1)return Ze.none;let i=s.main,r,o=null;if(i.empty){if(!e.highlightWordAroundCursor)return Ze.none;let l=t.wordAt(i.head);if(!l)return Ze.none;o=t.charCategorizer(i.head),r=t.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l200)return Ze.none;if(e.wholeWords){if(r=t.sliceDoc(i.from,i.to),o=t.charCategorizer(i.head),!(PC(o,t,i.from,i.to)&&zte(o,t,i.from,i.to)))return Ze.none}else if(r=t.sliceDoc(i.from,i.to),!r)return Ze.none}let a=[];for(let l of n.visibleRanges){let c=new Pu(t.doc,r,l.from,l.to);for(;!c.next().done;){let{from:h,to:u}=c.value;if((!o||PC(o,t,h,u))&&(i.empty&&h<=i.from&&u>=i.to?a.push(Fte.range(h,u)):(h>=i.to||u<=i.from)&&a.push(jte.range(h,u)),a.length>e.maxMatches))return Ze.none}}return Ze.set(a)}},{decorations:n=>n.decorations}),Bte=xe.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),qte=({state:n,dispatch:e})=>{let{selection:t}=n,s=te.create(t.ranges.map(i=>n.wordAt(i.head)||te.cursor(i.head)),t.mainIndex);return s.eq(t)?!1:(e(n.update({selection:s})),!0)};function Vte(n,e){let{main:t,ranges:s}=n.selection,i=n.wordAt(t.head),r=i&&i.from==t.from&&i.to==t.to;for(let o=!1,a=new Pu(n.doc,e,s[s.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new Pu(n.doc,e,0,Math.max(0,s[s.length-1].from-1)),o=!0}else{if(o&&s.some(l=>l.from==a.value.from))continue;if(r){let l=n.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}const Ute=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return qte({state:n,dispatch:e});let s=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=s))return!1;let i=Vte(n,s);return i?(e(n.update({selection:n.selection.addRange(te.range(i.from,i.to),!1),effects:xe.scrollIntoView(i.to)})),!0):!1},zu=ve.define({combine(n){return ju(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new rne(e),scrollToMatch:e=>xe.scrollIntoView(e)})}});class nL{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Ite(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,s)=>s=="n"?` +`:s=="r"?"\r":s=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Yte(this):new Kte(this)}getCursor(e,t=0,s){let i=e.doc?e:it.create({doc:e});return s==null&&(s=i.doc.length),this.regexp?Xc(this,i,t,s):Zc(this,i,t,s)}}class sL{constructor(e){this.spec=e}}function Wte(n,e,t){return(s,i,r,o)=>{if(t&&!t(s,i,r,o))return!1;let a=s>=o&&i<=o+r.length?r.slice(s-o,i-o):e.doc.sliceString(s,i);return n(a,e,s,i)}}function Zc(n,e,t,s){let i;return n.wholeWord&&(i=Gte(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(i=Wte(n.test,e,i)),new Pu(e.doc,n.unquoted,t,s,n.caseSensitive?void 0:r=>r.toLowerCase(),i)}function Gte(n,e){return(t,s,i,r)=>((r>t||r+i.length=t)return null;i.push(s.value)}return i}highlight(e,t,s,i){let r=Zc(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(s+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}function Zte(n,e,t){return(s,i,r)=>(!t||t(s,i,r))&&n(r[0],e,s,i)}function Xc(n,e,t,s){let i;return n.wholeWord&&(i=Xte(e.charCategorizer(e.selection.main.head))),n.test&&(i=Zte(n.test,e,i)),new eL(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:i},t,s)}function Ny(n,e){return n.slice(kn(n,e,!1),e)}function Ly(n,e){return n.slice(e,kn(n,e))}function Xte(n){return(e,t,s)=>!s[0].length||(n(Ny(s.input,s.index))!=Zt.Word||n(Ly(s.input,s.index))!=Zt.Word)&&(n(Ly(s.input,s.index+s[0].length))!=Zt.Word||n(Ny(s.input,s.index+s[0].length))!=Zt.Word)}class Yte extends sL{nextMatch(e,t,s){let i=Xc(this.spec,e,s,e.doc.length).next();return i.done&&(i=Xc(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,s){for(let i=1;;i++){let r=Math.max(t,s-i*1e4),o=Xc(this.spec,e,r,s),a=null;for(;!o.next().done;)a=o.value;if(a&&(r==t||a.from>r+10))return a;if(r==t)return null}}prevMatch(e,t,s){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,s,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,s)=>{if(s=="&")return e.match[0];if(s=="$")return"$";for(let i=s.length;i>0;i--){let r=+s.slice(0,i);if(r>0&&r=t)return null;i.push(s.value)}return i}highlight(e,t,s,i){let r=Xc(this.spec,e,Math.max(0,t-250),Math.min(s+250,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}const yf=bt.define(),nk=bt.define(),Aa=Dr.define({create(n){return new Kb(U_(n).create(),null)},update(n,e){for(let t of e.effects)t.is(yf)?n=new Kb(t.value.create(),n.panel):t.is(nk)&&(n=new Kb(n.query,t.value?sk:null));return n},provide:n=>Ty.from(n,e=>e.panel)});class Kb{constructor(e,t){this.query=e,this.panel=t}}const Jte=Ze.mark({class:"cm-searchMatch"}),Qte=Ze.mark({class:"cm-searchMatch cm-searchMatch-selected"}),ene=ti.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Aa))}update(n){let e=n.state.field(Aa);(e!=n.startState.field(Aa)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return Ze.none;let{view:t}=this,s=new cf;for(let i=0,r=t.visibleRanges,o=r.length;ir[i+1].from-2*250;)l=r[++i].to;n.highlight(t.state,a,l,(c,h)=>{let u=t.state.selection.ranges.some(d=>d.from==c&&d.to==h);s.add(c,h,u?Qte:Jte)})}return s.finish()}},{decorations:n=>n.decorations});function am(n){return e=>{let t=e.state.field(Aa,!1);return t&&t.query.spec.valid?n(e,t):oL(e)}}const Dy=am((n,{query:e})=>{let{to:t}=n.state.selection.main,s=e.nextMatch(n.state,t,t);if(!s)return!1;let i=te.single(s.from,s.to),r=n.state.facet(zu);return n.dispatch({selection:i,effects:[ik(n,s),r.scrollToMatch(i.main,n)],userEvent:"select.search"}),rL(n),!0}),jy=am((n,{query:e})=>{let{state:t}=n,{from:s}=t.selection.main,i=e.prevMatch(t,s,s);if(!i)return!1;let r=te.single(i.from,i.to),o=n.state.facet(zu);return n.dispatch({selection:r,effects:[ik(n,i),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),rL(n),!0}),tne=am((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:te.create(t.map(s=>te.range(s.from,s.to))),userEvent:"select.search.matches"}),!0)}),nne=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:s,to:i}=t.main,r=[],o=0;for(let a=new Pu(n.doc,n.sliceDoc(s,i));!a.next().done;){if(r.length>1e3)return!1;a.value.from==s&&(o=r.length),r.push(te.range(a.value.from,a.value.to))}return e(n.update({selection:te.create(r,o),userEvent:"select.search.matches"})),!0},RC=am((n,{query:e})=>{let{state:t}=n,{from:s,to:i}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,s,s);if(!r)return!1;let o=r,a=[],l,c,h=[];o.precise?o.from==s&&o.to==i&&(c=t.toText(e.getReplacement(o)),a.push({from:o.from,to:o.to,insert:c}),o=e.nextMatch(t,o.from,o.to),h.push(xe.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(s).number)+"."))):o=e.nextMatch(t,o.from,o.to);let u=n.state.changes(a);return o&&(l=te.single(o.from,o.to).map(u),h.push(ik(n,o)),h.push(t.facet(zu).scrollToMatch(l.main,n))),n.dispatch({changes:u,selection:l,effects:h,userEvent:"input.replace"}),!0}),sne=am((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let i of e.matchAll(n.state,1e9)){let{from:r,to:o,precise:a}=i;a&&t.push({from:r,to:o,insert:e.getReplacement(i)})}if(!t.length)return!1;let s=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:xe.announce.of(s),userEvent:"input.replace.all"}),!0});function sk(n){return n.state.facet(zu).createPanel(n)}function U_(n,e){var t,s,i,r,o;let a=n.selection.main,l=a.empty||a.to>a.from+100?"":n.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=n.facet(zu);return new nL({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(s=e==null?void 0:e.caseSensitive)!==null&&s!==void 0?s:c.caseSensitive,literal:(i=e==null?void 0:e.literal)!==null&&i!==void 0?i:c.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function iL(n){let e=YO(n,sk);return e&&e.dom.querySelector("[main-field]")}function rL(n){let e=iL(n);e&&e==n.root.activeElement&&e.select()}const oL=n=>{let e=n.state.field(Aa,!1);if(e&&e.panel){let t=iL(n);if(t&&t!=n.root.activeElement){let s=U_(n.state,e.query.spec);s.valid&&n.dispatch({effects:yf.of(s)}),t.focus(),t.select()}}else n.dispatch({effects:[nk.of(!0),e?yf.of(U_(n.state,e.query.spec)):bt.appendConfig.of(ane)]});return!0},aL=n=>{let e=n.state.field(Aa,!1);if(!e||!e.panel)return!1;let t=YO(n,sk);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:nk.of(!1)}),!0},ine=[{key:"Mod-f",run:oL,scope:"editor search-panel"},{key:"F3",run:Dy,shift:jy,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Dy,shift:jy,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:aL,scope:"editor search-panel"},{key:"Mod-Shift-l",run:nne},{key:"Mod-Alt-g",run:Ote},{key:"Mod-d",run:Ute,preventDefault:!0}];class rne{constructor(e){this.view=e;let t=this.query=e.state.field(Aa).query.spec;this.commit=this.commit.bind(this),this.searchField=xn("input",{value:t.search,placeholder:Hs(e,"Find"),"aria-label":Hs(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=xn("input",{value:t.replace,placeholder:Hs(e,"Replace"),"aria-label":Hs(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=xn("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=xn("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=xn("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function s(i,r,o){return xn("button",{class:"cm-button",name:i,onclick:r,type:"button"},o)}this.dom=xn("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,s("next",()=>Dy(e),[Hs(e,"next")]),s("prev",()=>jy(e),[Hs(e,"previous")]),s("select",()=>tne(e),[Hs(e,"all")]),xn("label",null,[this.caseField,Hs(e,"match case")]),xn("label",null,[this.reField,Hs(e,"regexp")]),xn("label",null,[this.wordField,Hs(e,"by word")]),...e.state.readOnly?[]:[xn("br"),this.replaceField,s("replace",()=>RC(e),[Hs(e,"replace")]),s("replaceAll",()=>sne(e),[Hs(e,"replace all")])],xn("button",{name:"close",onclick:()=>aL(e),"aria-label":Hs(e,"close"),type:"button"},["×"])])}commit(){let e=new nL({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:yf.of(e)}))}keydown(e){iQ(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?jy:Dy)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),RC(this.view))}update(e){for(let t of e.transactions)for(let s of t.effects)s.is(yf)&&!s.value.eq(this.query)&&this.setQuery(s.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(zu).top}}function Hs(n,e){return n.state.phrase(e)}const Zm=30,Xm=/[\s\.,:;?!]/;function ik(n,{from:e,to:t}){let s=n.state.doc.lineAt(e),i=n.state.doc.lineAt(t).to,r=Math.max(s.from,e-Zm),o=Math.min(i,t+Zm),a=n.state.sliceDoc(r,o);if(r!=s.from){for(let l=0;la.length-Zm;l--)if(!Xm.test(a[l-1])&&Xm.test(a[l])){a=a.slice(0,l);break}}return xe.announce.of(`${n.state.phrase("current match")}. ${a} ${n.state.phrase("on line")} ${s.number}.`)}const one=xe.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),ane=[Aa,F0.low(ene),one],lne=({path:n,value:e,readOnly:t,onChange:s})=>{const i=ee.useRef(null),r=ee.useRef(null),o=ee.useRef(new nm),a=ee.useRef(s);return a.current=s,ee.useEffect(()=>{if(!i.current)return;const l=it.create({doc:e,extensions:[$Q(),hQ(),mQ(),$ee(),Dte(),lee(),Zx.define(Mte),UO.of([...Pte,...Dee,...ine,Rte]),xe.contentAttributes.of({"aria-label":`Editing ${n}`,class:"ph-no-capture","data-ph-no-autocapture":"true","data-ph-no-capture":"true"}),o.current.of(xe.editable.of(!t)),xe.updateListener.of(c=>{c.docChanged&&a.current(c.state.doc.toString())})]});return r.current=new xe({state:l,parent:i.current}),()=>{var c;return(c=r.current)==null?void 0:c.destroy()}},[n]),ee.useEffect(()=>{const l=r.current;!l||l.state.doc.toString()===e||l.dispatch({changes:{from:0,to:l.state.doc.length,insert:e}})},[e]),ee.useEffect(()=>{var l;(l=r.current)==null||l.dispatch({effects:o.current.reconfigure(xe.editable.of(!t))})},[t]),S.jsx("div",{className:"latex-source-editor ph-no-capture","data-ph-no-autocapture":"true","data-ph-no-capture":"true","data-testid":"latex-source-editor",ref:i})},cne="pwc:artifact-navigation";function xse(){return typeof window>"u"?!0:window.dispatchEvent(new Event(cne,{cancelable:!0}))}const lL=()=>({open:!1,selectedKey:null,selected:null,selectedVersionId:null,tab:"preview",sourceFile:null,panelPercent:55,requestNonce:0,registry:{},autoOpened:{},manuallyClosed:{}});function hne(n,e){if(e.type==="reset")return{...lL(),panelPercent:n.panelPercent};if(e.type==="register"){const t=n.registry[e.key];if(t&&JSON.stringify(t)===JSON.stringify(e.block))return n;const s={...n.registry,[e.key]:e.block},i=n.selectedKey===e.key?e.block:n.selected,r=(t==null?void 0:t.status)==="generating"&&e.block.status==="ready",o=e.autoOpenOnMount&&!t&&e.block.status==="ready"&&!Object.values(n.autoOpened).some(Boolean);return(r||o)&&!n.autoOpened[e.key]&&!n.manuallyClosed[e.key]?{...n,registry:s,open:!0,selectedKey:e.key,selected:e.block,selectedVersionId:e.block.version_id??null,tab:"preview",sourceFile:null,requestNonce:n.requestNonce+1,autoOpened:{...n.autoOpened,[e.key]:!0}}:{...n,registry:s,selected:i}}return e.type==="unregister"?n:e.type==="open"?{...n,open:!0,selectedKey:e.key,selected:e.block,selectedVersionId:e.block.version_id??null,tab:"preview",sourceFile:null,requestNonce:n.requestNonce+1,manuallyClosed:{...n.manuallyClosed,[e.key]:!1}}:e.type==="close"?{...n,open:!1,manuallyClosed:n.selectedKey?{...n.manuallyClosed,[n.selectedKey]:!0}:n.manuallyClosed}:e.type==="tab"?{...n,tab:e.tab}:e.type==="source"?{...n,sourceFile:e.path}:e.type==="version"?{...n,selectedVersionId:e.versionId,tab:"preview",sourceFile:null}:{...n,panelPercent:e.percent}}function W_(n){return n.publication_id||n.public_capability||n.version_id||`${n.scope}:${n.identifier}:${n.version??"pending"}`}const cL=ee.createContext(null),kse=({children:n,workspaceKey:e,autoOpenOnMount:t=!1,onAskAiFix:s})=>{const[i,r]=ee.useReducer(hne,void 0,lL),o=ee.useRef(null),a=ee.useRef(e);ee.useEffect(()=>{a.current!==e&&(a.current=e,o.current=null,r({type:"reset"}))},[e]);const l=ee.useCallback(()=>{r({type:"close"}),window.setTimeout(()=>{var v;(v=o.current)!=null&&v.isConnected&&o.current.focus()},0)},[]),c=ee.useCallback(v=>r({type:"register",key:W_(v),block:v,autoOpenOnMount:t}),[t]),h=ee.useCallback(v=>r({type:"unregister",key:v}),[]),u=ee.useCallback((v,x)=>{const k=document.activeElement;o.current=x??(k instanceof HTMLElement&&k!==document.body?k:null),r({type:"open",key:W_(v),block:v})},[]),d=ee.useCallback(v=>r({type:"tab",tab:v}),[]),p=ee.useCallback(v=>r({type:"source",path:v}),[]),m=ee.useCallback(v=>r({type:"version",versionId:v}),[]),g=ee.useCallback(v=>r({type:"width",percent:v}),[]),b=ee.useCallback(v=>s==null?void 0:s(v),[s]),y=ee.useCallback(()=>r({type:"reset"}),[]),w=ee.useMemo(()=>({state:i,autoOpenOnMount:t,register:c,unregister:h,open:u,close:l,setTab:d,setSourceFile:p,setVersion:m,setPanelPercent:g,askAiToFix:b,reset:y}),[b,t,l,u,c,y,g,p,d,m,i,h]);return S.jsx(cL.Provider,{value:w,children:n})};function lm(){const n=ee.useContext(cL);if(!n)throw new Error("Poster artifacts require an ArtifactPanelProvider");return n}function Zb(n,e){if(!(n instanceof AL))return n instanceof Error?n.message:e;const t=n.detail;return typeof t=="object"&&t!==null&&"message"in t&&typeof t.message=="string"?t.message:e}function Ym(n){return`pwc:latex-paper-draft:${n}`}function une(n,e){const t=Object.keys(n).sort(),s=Object.keys(e).sort();return t.length===s.length&&t.every((i,r)=>i===s[r]&&n[i]===e[i])}function MC(n){return!n.includes("\\")&&/^(?!\/)(?!.*(?:^|\/)\.\.?\/)[^\0]{1,300}\.(?:tex|bib)$/iu.test(n)}function dne(n){var s,i;const e=((s=n.provenance)==null?void 0:s.action)??(n.actor_type==="restore"?"restore":n.actor_type==="ai"?"ai_draft":"human_save"),t={human_save:"Human save",ai_draft:"AI draft",ai_repair:"AI repair",restore:"Restore"}[e];return(i=n.provenance)!=null&&i.model_identity?`${t} · ${n.provenance.model_identity}`:t}const fne=({artifactId:n,title:e,forceDialog:t=!1})=>{var nn,sn,Cn,$n,Hu,Bu,qu,Vu,cm;const s=lm(),i=FC(),r=s.close,[o,a]=ee.useState(()=>{var G;return typeof window<"u"&&((G=window.matchMedia)==null?void 0:G.call(window,"(max-width: 760px)").matches)}),[l,c]=ee.useState({}),[h,u]=ee.useState({}),[d,p]=ee.useState(null),[m,g]=ee.useState(!1),[b,y]=ee.useState(!1),[w,v]=ee.useState(null),[x,k]=ee.useState(!1),[E,T]=ee.useState(null),O=ee.useRef(null),F=ee.useRef(null),j=ee.useRef(!1),L=t||o,B=d!==null&&!une(l,h);ee.useEffect(()=>{var re,$e;const G=(re=window.matchMedia)==null?void 0:re.call(window,"(max-width: 760px)");if(!G)return;const ne=()=>a(G.matches);return ne(),($e=G.addEventListener)==null||$e.call(G,"change",ne),()=>{var nt;return(nt=G.removeEventListener)==null?void 0:nt.call(G,"change",ne)}},[]),ee.useEffect(()=>{var re,$e;if(!L)return;($e=(re=F.current)==null?void 0:re.querySelector("[data-artifact-close]"))==null||$e.focus(),window.history.pushState({...window.history.state,pwcArtifactPanel:!0},""),j.current=!0;const G=()=>{if(B&&!window.confirm("Leave this view? Unsaved paper edits remain in this browser.")){window.history.pushState({...window.history.state,pwcArtifactPanel:!0},""),j.current=!0;return}j.current=!1,r()},ne=nt=>{nt.key==="Escape"&&(nt.preventDefault(),!(B&&!window.confirm("Leave this view? Unsaved paper edits remain in this browser."))&&(r(),j.current&&(j.current=!1,window.history.back())))};return window.addEventListener("popstate",G),document.addEventListener("keydown",ne),()=>{window.removeEventListener("popstate",G),document.removeEventListener("keydown",ne)}},[r,L,B]),ee.useEffect(()=>{if(!L)return;const G=ne=>{if(ne.key!=="Tab"||!F.current)return;const re=[...F.current.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), [contenteditable="true"], [tabindex]:not([tabindex="-1"])')];if(!re.length)return;const $e=re[0],nt=re.at(-1);ne.shiftKey&&document.activeElement===$e?(ne.preventDefault(),nt.focus()):!ne.shiftKey&&document.activeElement===nt&&(ne.preventDefault(),$e.focus())};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[L]),ee.useEffect(()=>{const G=ne=>{B&&(ne.preventDefault(),ne.returnValue="")};return window.addEventListener("beforeunload",G),()=>window.removeEventListener("beforeunload",G)},[B]),ee.useEffect(()=>{const G=ne=>{B&&!window.confirm("Leave this view? Unsaved paper edits remain in this browser.")&&ne.preventDefault()};return window.addEventListener("pwc:artifact-navigation",G),()=>window.removeEventListener("pwc:artifact-navigation",G)},[B]);const Z=yo({queryKey:ri.latexPaper(n),queryFn:()=>ts.getLatexPaper(n),staleTime:5e3}),q=Z.data,H=q==null?void 0:q.source_head,se=q==null?void 0:q.preview_head,Q=yo({queryKey:ri.history(n,E),queryFn:()=>ts.getLatexPaperHistory(n,E),enabled:x,staleTime:Number.POSITIVE_INFINITY}),Y=H==null?void 0:H.version_id,ye=s.state.tab==="files"?Y:void 0,z=yo({queryKey:ri.manifest(n,Y),queryFn:ye?()=>ts.getLatexPaperManifest(n,ye):Id,staleTime:Number.POSITIVE_INFINITY}),C=((nn=z.data)==null?void 0:nn.files.filter(G=>G.media_type==="text/x-tex"||G.media_type==="application/x-bibtex"))??[],I=((sn=z.data)==null?void 0:sn.files.filter(G=>G.media_type==="image/png"||G.media_type==="image/jpeg"||G.media_type==="application/pdf"))??[],R=yo({queryKey:ri.sourceFiles(n,Y),queryFn:ye&&C.length?async()=>Object.fromEntries(await Promise.all(C.map(async G=>[G.path,await ts.getArtifactSource(n,ye,G.path)]))):Id,staleTime:Number.POSITIVE_INFINITY});ee.useEffect(()=>{g(!1)},[H==null?void 0:H.version_id]),ee.useEffect(()=>{var nt;if(!(H!=null&&H.version_id)||!R.data||O.current===H.version_id)return;const G=R.data;let ne=G,re=!1,$e=H.version_id;try{const Yt=window.localStorage.getItem(Ym(n)),gn=Yt?JSON.parse(Yt):null;gn!=null&&gn.files&&typeof gn.files=="object"&&(ne=gn.files,re=gn.parentVersionId!==H.version_id,$e=gn.parentVersionId)}catch{}O.current=H.version_id,c(ne),u(G),p($e),y(re),g(!0),re&&v("This local draft is based on an older paper version. Copy or discard it before saving the latest version."),(!s.state.sourceFile||!ne[s.state.sourceFile])&&s.setSourceFile(((nt=z.data)==null?void 0:nt.root_document)??null)},[n,(Cn=z.data)==null?void 0:Cn.root_document,s,H==null?void 0:H.version_id,R.data]),ee.useEffect(()=>{if(!d)return;const G=Ym(n);if(!B){window.localStorage.removeItem(G);return}window.localStorage.setItem(G,JSON.stringify({parentVersionId:d,files:l}))},[n,B,d,l]);const _=G=>{i.setQueryData(ri.latexPaper(n),G),i.invalidateQueries({queryKey:ri.manifest(n)}),i.invalidateQueries({queryKey:ri.sourceFiles(n)})},A=ad({mutationFn:()=>{if(!(H!=null&&H.version_id))throw new Error("Paper source is not ready to save");return ts.saveLatexPaper(n,H.version_id,l)},onSuccess:G=>{var ne,re;_(G),O.current=((ne=G.source_head)==null?void 0:ne.version_id)??null,u(l),p(((re=G.source_head)==null?void 0:re.version_id)??null),window.localStorage.removeItem(Ym(n)),v(null),y(!1),s.setTab("preview")},onError:G=>v(Zb(G,"Could not save paper"))}),N=ad({mutationFn:G=>{if(!(H!=null&&H.version_id))throw new Error("Paper source is not ready to restore");return ts.restoreLatexPaperVersion(n,G,H.version_id)},onSuccess:G=>{_(G),i.invalidateQueries({queryKey:ri.history(n)}),O.current=null,g(!1),T(null),v(null),s.setTab("preview")},onError:G=>v(Zb(G,"Could not restore paper version"))}),W=ad({mutationFn:G=>{if(!(H!=null&&H.version_id))throw new Error("Paper source is not ready to upload a figure");if(B)throw new Error("Save or discard text edits before uploading a figure");return ts.uploadLatexPaperFigure(n,H.version_id,G)},onSuccess:G=>{_(G),v(null)},onError:G=>v(Zb(G,"Could not upload figure"))}),he=ad({mutationFn:()=>ts.refreshLatexPaperCompile(n),onSuccess:G=>i.setQueryData(ri.latexPaper(n),G)}).mutate,ie=H==null?void 0:H.compile_status;ee.useEffect(()=>{if(!Y||!["queued","compiling"].includes(ie??""))return;const G=window.setTimeout(()=>he(),2e3);return()=>window.clearTimeout(G)},[he,ie,Y]);const ge=s.state.sourceFile??(($n=z.data)==null?void 0:$n.root_document)??null,at=(q==null?void 0:q.editing_enabled)===!0&&!!(H!=null&&H.version_id)&&m&&!b&&!A.isPending,ze=new Map(((Hu=Q.data)==null?void 0:Hu.items.map(G=>[G.version_id,G.version]))??[]),Qe=se?zo.preview(n,se.version_id):null,lt=!!(H&&se&&H.version_id!==se.version_id),tt=()=>!B||window.confirm("Leave this view? Unsaved paper edits remain in this browser."),Ft=G=>G!==s.state.tab&&!tt()?!1:(s.setTab(G),!0),qt=G=>{var re,$e;if(!["ArrowLeft","ArrowRight","Home","End"].includes(G.key))return;G.preventDefault();const ne=G.key==="ArrowLeft"||G.key==="Home"?"preview":"files";Ft(ne)&&(($e=(re=G.currentTarget.parentElement)==null?void 0:re.querySelector(`#paper-${ne}-tab`))==null||$e.focus())},bs=G=>{G!==ge&&B&&!window.confirm("Switch files? Unsaved edits stay in this browser.")||s.setSourceFile(G)},js=()=>{const G=window.prompt("New TeX or BibTeX file name","section.tex");if(G){if(!MC(G)||l[G]){v("Choose a new safe .tex or .bib filename.");return}if(Object.keys(l).length>=100){v("A paper can contain at most 100 files.");return}c({...l,[G]:""}),v(null),s.setSourceFile(G)}},tn=()=>{var re;if(!ge||ge===((re=z.data)==null?void 0:re.root_document))return;const G=window.prompt("Rename file",ge);if(!G||G===ge)return;if(!MC(G)||l[G]){v("Choose a new safe .tex or .bib filename.");return}const ne={...l,[G]:l[ge]};delete ne[ge],c(ne),s.setSourceFile(G)},vs=()=>{var ne,re;if(!ge||ge===((ne=z.data)==null?void 0:ne.root_document)||!window.confirm(`Delete ${ge}?`))return;const G={...l};delete G[ge],c(G),s.setSourceFile(((re=z.data)==null?void 0:re.root_document)??null)},ws=()=>{!b||!window.confirm("Discard this stale local draft?")||(window.localStorage.removeItem(Ym(n)),c(h),p((H==null?void 0:H.version_id)??null),y(!1),v(null))},Fs=()=>{tt()&&(r(),L&&j.current&&(j.current=!1,window.history.back()))},_s=()=>{if(!H||H.compile_status!=="failed"||H.repair_exhausted)return;const G=(H.compile_diagnostics??[]).slice(0,20).map(ne=>`${ne.file??"project"}${ne.line?`:${ne.line}`:""}: ${ne.message}`).join(` +`);s.askAiToFix(`Repair the failed paper source version ${H.version_id}. Use pwc-paper to inspect and repair it; make no more than three attempts. Compiler diagnostics: +${G||"No compiler diagnostic was available."}`)},En=G=>{!G||!Ft("files")||s.setSourceFile(G)};return S.jsxs("section",{ref:F,className:`chat-artifact-panel${L?" is-dialog":" is-docked"}`,role:L?"dialog":"complementary","aria-modal":L?!0:void 0,"aria-labelledby":"latex-paper-title","data-testid":"latex-paper-panel",children:[S.jsxs("header",{children:[S.jsxs("div",{children:[S.jsx("span",{children:"Private paper"}),S.jsx("h2",{id:"latex-paper-title",children:e}),S.jsxs("p",{className:"chat-paper-status",role:"status","aria-live":"polite",children:[H?`Source v${H.version} · ${H.compile_status}`:"Preparing paper source",lt?" · Preview out of date":""]}),S.jsx("p",{className:"chat-paper-privacy-note",children:"This paper is private to this chat. Source, figures, and PDFs are stored privately; AI-authored text needs your review."})]}),S.jsxs("div",{className:"chat-artifact-header-actions",children:[S.jsx("button",{type:"button","aria-expanded":x,"aria-controls":"paper-version-history",onClick:()=>{T(null),k(!x)},children:"Version history"}),S.jsx("button",{type:"button","data-artifact-close":!0,"aria-label":L?"Back to conversation":"Close paper",onClick:Fs,children:S.jsx(n0,{})})]})]}),S.jsxs("nav",{"aria-label":"Paper views",role:"tablist",children:[S.jsx("button",{type:"button",id:"paper-preview-tab",role:"tab","aria-selected":s.state.tab==="preview","aria-controls":"paper-preview-panel",tabIndex:s.state.tab==="preview"?0:-1,className:s.state.tab==="preview"?"active":"",onClick:()=>Ft("preview"),onKeyDown:qt,children:"Preview"}),S.jsx("button",{type:"button",id:"paper-files-tab",role:"tab","aria-selected":s.state.tab==="files","aria-controls":"paper-files-panel",tabIndex:s.state.tab==="files"?0:-1,className:s.state.tab==="files"?"active":"",onClick:()=>Ft("files"),onKeyDown:qt,children:"Files"})]}),S.jsxs("div",{id:s.state.tab==="preview"?"paper-preview-panel":"paper-files-panel",role:"tabpanel","aria-labelledby":s.state.tab==="preview"?"paper-preview-tab":"paper-files-tab",className:"chat-artifact-panel-body",children:[s.state.tab==="preview"?Z.isError?S.jsxs("div",{role:"alert",children:["Could not load paper details. ",S.jsx("button",{type:"button",onClick:()=>void Z.refetch(),children:"Retry paper details"})]}):Qe?S.jsx(ZY,{url:Qe,downloadUrl:zo.pdfExport(n),paperKey:`${n}:${se==null?void 0:se.version_id}`,paperTitle:e,paperHref:"/chat",chrome:"canvas"},se==null?void 0:se.version_id):H?H.compile_status==="failed"?S.jsx("p",{role:"alert",children:"No compiled preview is available for this failed source version. Review the diagnostics or fix the paper in Files."}):["queued","compiling"].includes(H.compile_status)?S.jsx("p",{role:"status",children:"Preview is compiling. The stored source is available in Files."}):S.jsx("p",{role:"alert",children:"No compiled preview is available for this source version."}):S.jsx("p",{role:"status",children:"Paper source and compiled preview are not available yet."}):S.jsxs("div",{className:"chat-artifact-source-workspace",children:[S.jsxs("nav",{"aria-label":"Paper source files",children:[C.map(G=>S.jsx("button",{type:"button","aria-pressed":ge===G.path,onClick:()=>bs(G.path),children:G.path},G.path)),at&&S.jsxs("button",{type:"button",className:"latex-file-action","aria-label":"Add TeX file",onClick:js,children:[S.jsx(iD,{})," Add file"]}),at&&S.jsxs("label",{className:"latex-file-action",children:["Upload figure",S.jsx("input",{"aria-label":"Upload figure",type:"file",accept:"image/png,image/jpeg,application/pdf,.png,.jpg,.jpeg,.pdf",disabled:W.isPending,onChange:G=>{var re;const ne=(re=G.currentTarget.files)==null?void 0:re[0];G.currentTarget.value="",ne&&W.mutate(ne)}})]}),I.map(G=>H&&S.jsx("a",{href:zo.file(n,H.version_id,"figures",G.path),download:!0,children:G.path},G.path))]}),S.jsxs("div",{className:"latex-editor-column",children:[ge&&l[ge]!==void 0?S.jsx(lne,{path:ge,value:l[ge],readOnly:!at,onChange:G=>c({...l,[ge]:G})}):S.jsx("p",{children:R.isError?"Source could not be loaded.":"Loading source…"}),at&&ge&&ge!==((Bu=z.data)==null?void 0:Bu.root_document)&&S.jsxs("div",{className:"latex-file-buttons",children:[S.jsxs("button",{type:"button",onClick:tn,children:[S.jsx(ZC,{})," Rename"]}),S.jsxs("button",{type:"button",onClick:vs,children:[S.jsx(qL,{})," Delete"]})]})]})]}),x&&S.jsxs("section",{id:"paper-version-history",className:"chat-artifact-history","aria-label":"Paper version history",children:[S.jsx("h3",{children:"Version history"}),Q.isLoading&&S.jsx("p",{children:"Loading history…"}),Q.isError&&S.jsx("p",{role:"alert",children:"Paper history could not be loaded."}),(qu=Q.data)==null?void 0:qu.items.map(G=>{var ne,re,$e,nt;return S.jsxs("article",{children:[S.jsxs("strong",{children:["v",G.version," · ",G.compile_status]}),S.jsx("span",{children:dne(G)}),G.created_at&&S.jsx("time",{dateTime:G.created_at,children:G.created_at}),G.parent_version_id&&S.jsxs("span",{children:["Parent ",ze.has(G.parent_version_id)?`v${ze.get(G.parent_version_id)}`:G.parent_version_id]}),(ne=G.provenance)!=null&&ne.changed_files.length?S.jsxs("span",{children:["Changed: ",G.provenance.changed_files.join(", ")]}):null,((re=G.provenance)==null?void 0:re.restored_from_version_id)&&S.jsxs("span",{children:["Restored from ",G.provenance.restored_from_version_id]}),(($e=G.provenance)==null?void 0:$e.change_summary)&&S.jsx("p",{children:G.provenance.change_summary}),(nt=G.provenance)==null?void 0:nt.reference_changes.map(Yt=>S.jsx("p",{children:Yt},Yt)),S.jsx("a",{href:zo.sourceZip(n,G.version_id),download:!0,children:"Source ZIP"}),(q==null?void 0:q.editing_enabled)&&(H==null?void 0:H.version_id)&&G.version_id!==H.version_id&&S.jsxs("button",{type:"button",disabled:N.isPending||B,onClick:()=>N.mutate(G.version_id),children:["Restore version ",G.version]})]},G.version_id)}),((Vu=Q.data)==null?void 0:Vu.next_cursor)&&S.jsx("button",{type:"button",onClick:()=>{var G;return T(((G=Q.data)==null?void 0:G.next_cursor)??null)},children:"Load older versions"})]})]}),S.jsxs("footer",{children:[S.jsxs("div",{className:"chat-artifact-metadata","aria-live":"polite",children:[lt&&S.jsx("strong",{children:"Out of date"}),(cm=H==null?void 0:H.compile_diagnostics)==null?void 0:cm.map((G,ne)=>S.jsxs("button",{type:"button",onClick:()=>En(G.file),className:"latex-compile-diagnostic",children:[G.file?`${G.file}${G.line?`:${G.line}`:""}: `:"",G.message]},`${G.file??"global"}:${G.line??""}:${ne}`)),w&&S.jsx("span",{role:"alert",children:w}),b&&S.jsx("button",{type:"button",onClick:ws,children:"Discard stale local draft"})]}),S.jsxs("div",{className:"chat-artifact-actions",children:[(H==null?void 0:H.compile_status)==="failed"&&!H.repair_exhausted&&S.jsx("button",{type:"button",onClick:_s,children:"Ask AI to fix"}),(H==null?void 0:H.compile_status)==="failed"&&H.repair_exhausted&&S.jsx("span",{role:"status",children:"AI repair attempts exhausted"}),s.state.tab==="files"&&at&&S.jsxs("button",{type:"button",disabled:!B,onClick:()=>A.mutate(),children:[S.jsx(aD,{}),A.isPending?"Saving…":"Save & Compile"]}),H&&S.jsxs("a",{href:zo.sourceZip(n,H.version_id),download:!0,children:[S.jsx(Z_,{})," Source ZIP"]})]})]})]})},pne="https://github.com/Chenruishuo/posterly/tree/b9f42e5578a49a27525a68f85376bb3bb25af86f";function mne(){if(typeof window>"u")return null;const n=window.location.pathname.match(/^\/share\/([^/]+)/u);return n?decodeURIComponent(n[1]):null}function hL(n){if(n.scope==="public"){const i=mne();if(!i||!n.public_capability)return null;const r=zo.sharedRoot(i,n.public_capability);return{preview:`${r}/preview`,png:`${r}/download/png`,pdf:`${r}/download/pdf`,owner:null}}const{artifact_id:e,version_id:t}=n;if(!e||!t)return null;const s=(i,r)=>zo.file(e,t,i,r);return{preview:zo.preview(e,t),png:s("download","poster.png"),pdf:null,owner:{artifactId:e,versionId:t,source:i=>s("source",i),download:i=>s("download",i)}}}const uL=n=>({passed:"Passed",warnings:"Passed with warnings",failed:"Draft—checks failed"})[n??"passed"];function gne(){const[n,e]=ee.useState(()=>{var t;return typeof window<"u"&&((t=window.matchMedia)==null?void 0:t.call(window,"(max-width: 760px)").matches)});return ee.useEffect(()=>{var i,r;const t=(i=window.matchMedia)==null?void 0:i.call(window,"(max-width: 760px)");if(!t)return;const s=()=>e(t.matches);return s(),(r=t.addEventListener)==null||r.call(t,"change",s),()=>{var o;return(o=t.removeEventListener)==null?void 0:o.call(t,"change",s)}},[]),n}const yne=({forceDialog:n=!1,readerFallback:e=!1})=>{var T,O,F;const t=lm(),s=t.close,{state:i}=t,r=i.selected,o=gne(),a=n||o,l=ee.useRef(null),c=ee.useRef(!1),h=i.open&&(r==null?void 0:r.scope)==="owner"?r.artifact_id:void 0,u=yo({queryKey:ri.posterVersions(h),queryFn:h?()=>ts.getPosterVersions(h):Id,staleTime:Number.POSITIVE_INFINITY}),d=(T=u.data)==null?void 0:T.find(j=>j.version_id===i.selectedVersionId),p=r&&d?{...r,version_id:d.version_id,version:d.version,gate_status:d.gate_status,total_bytes:d.total_bytes}:r,m=p?hL(p):null,g=i.open?(m==null?void 0:m.owner)??null:null,y=yo({queryKey:ri.manifest(g==null?void 0:g.artifactId,g==null?void 0:g.versionId),queryFn:g?()=>ts.getPosterManifest(g.artifactId,g.versionId):Id,staleTime:Number.POSITIVE_INFINITY}).data,w=i.sourceFile??(y==null?void 0:y.entrypoint)??null,v=yo({queryKey:ri.source(g==null?void 0:g.artifactId,g==null?void 0:g.versionId,w),queryFn:g&&i.tab==="source"&&w?()=>ts.getArtifactSource(g.artifactId,g.versionId,w):Id,staleTime:Number.POSITIVE_INFINITY});if(ee.useEffect(()=>{var L,B;if(!i.open||!a)return;(B=(L=l.current)==null?void 0:L.querySelector("[data-artifact-close]"))==null||B.focus(),window.history.pushState({...window.history.state,pwcArtifactPanel:!0},""),c.current=!0;const j=()=>{c.current=!1,s()};return window.addEventListener("popstate",j),()=>window.removeEventListener("popstate",j)},[s,a,i.open]),ee.useEffect(()=>{if(!i.open||!a)return;const j=L=>{if(L.key==="Escape"){L.preventDefault(),s(),c.current&&(c.current=!1,window.history.back());return}if(L.key!=="Tab"||!l.current)return;const B=[...l.current.querySelectorAll('button:not([disabled]), a[href], select:not([disabled]), [tabindex]:not([tabindex="-1"])')];if(!B.length)return;const Z=B[0],q=B.at(-1);L.shiftKey&&document.activeElement===Z?(L.preventDefault(),q.focus()):!L.shiftKey&&document.activeElement===q&&(L.preventDefault(),Z.focus())};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[s,a,i.open]),!i.open||!p||!m)return null;const x=()=>{s(),a&&c.current&&(c.current=!1,window.history.back())},k=(O=y==null?void 0:y.downloads[0])==null?void 0:O.path,E=p.scope==="public"?m.pdf:k&&m.owner?m.owner.download(k):null;return S.jsxs("section",{ref:l,className:`chat-artifact-panel${a?" is-dialog":" is-docked"}${e?" is-reader-fallback":""}`,role:a?"dialog":"complementary","aria-modal":a?!0:void 0,"aria-label":p.title,"data-testid":"artifact-panel",children:[S.jsxs("header",{children:[S.jsxs("div",{children:[S.jsx("span",{children:"Posterly artifact"}),S.jsx("h2",{children:p.title})]}),(((F=u.data)==null?void 0:F.length)??0)>1&&S.jsxs("label",{className:"chat-artifact-version",children:["Version",S.jsx("select",{"aria-label":"Poster version",value:p.version_id,onChange:j=>t.setVersion(j.target.value),children:[...u.data??[]].reverse().map(j=>S.jsxs("option",{value:j.version_id,children:["v",j.version]},j.version_id))})]}),S.jsx("button",{type:"button","data-artifact-close":!0,"aria-label":a?"Back to conversation":"Close poster",onClick:x,children:S.jsx(n0,{})})]}),S.jsxs("nav",{"aria-label":"Poster views",children:[S.jsx("button",{type:"button","aria-pressed":i.tab==="preview",className:i.tab==="preview"?"active":"",onClick:()=>t.setTab("preview"),children:"Preview"}),p.scope==="owner"&&S.jsx("button",{type:"button","aria-pressed":i.tab==="source",className:i.tab==="source"?"active":"",onClick:()=>t.setTab("source"),children:"Source"})]}),S.jsx("div",{className:"chat-artifact-panel-body",children:i.tab==="preview"?S.jsx("img",{src:m.preview,alt:`Full preview of ${p.title}`}):S.jsxs("div",{className:"chat-artifact-source-workspace",children:[(y==null?void 0:y.source_files)&&y.source_files.length>1&&S.jsx("nav",{"aria-label":"Poster source files",children:y.source_files.map(j=>S.jsx("button",{type:"button","aria-pressed":w===j,onClick:()=>t.setSourceFile(j),children:j},j))}),S.jsx("pre",{children:S.jsx("code",{children:v.isError?"Source could not be loaded.":v.data??"Loading source…"})})]})}),S.jsxs("footer",{children:[S.jsxs("div",{className:"chat-artifact-metadata",children:[S.jsx("strong",{children:uL(p.gate_status)}),y&&S.jsxs("span",{children:[y.canvas.width," × ",y.canvas.height," ",y.canvas.unit," · ",y.canvas.orientation," · ",y.direction]}),y==null?void 0:y.gate_summary.map(j=>S.jsx("span",{children:j},j))]}),S.jsxs("div",{className:"chat-artifact-actions",children:[S.jsxs("a",{href:m.png,download:!0,children:[S.jsx(hk,{})," PNG"]}),p.gate_status!=="failed"&&E&&S.jsxs("a",{href:E,download:!0,children:[S.jsx(hk,{})," PDF"]}),p.scope==="owner"&&y&&m.owner&&S.jsxs("a",{href:m.owner.source(y.entrypoint),download:!0,children:[S.jsx(Z_,{})," HTML"]}),p.scope==="owner"&&y&&m.owner&&S.jsx("a",{href:m.owner.source(y.gate_report),download:!0,children:"Gate report"}),S.jsxs("a",{href:pne,target:"_blank",rel:"noreferrer",children:[S.jsx(WC,{})," Posterly source · AGPL-3.0"]})]})]})]})},IC=n=>{const{state:e}=lm(),t=e.selected;return(t==null?void 0:t.artifact_kind)==="latex_paper"&&t.artifact_id?S.jsx(fne,{artifactId:t.artifact_id,title:t.title,...n}):S.jsx(yne,{...n})},bne=({block:n})=>{const e=lm(),t=e.register,s=e.unregister,i=W_(n);if(ee.useEffect(()=>{t(n)},[n,t]),ee.useEffect(()=>()=>s(i),[i,s]),n.status==="generating")return S.jsxs("div",{className:"chat-artifact-card chat-artifact-generating",role:"status",children:[S.jsx("span",{className:"chat-artifact-pulse","aria-hidden":"true"}),S.jsxs("span",{children:[S.jsx("strong",{children:n.title}),S.jsx("small",{children:"Publishing Posterly preview…"})]})]});if(n.status==="error")return S.jsxs("div",{className:"chat-artifact-card chat-artifact-error",role:"alert",children:[S.jsx(Z_,{"aria-hidden":"true"}),S.jsxs("span",{children:[S.jsx("strong",{children:n.title}),S.jsx("small",{children:n.error_message??"Poster publication failed."})]})]});const r=hL(n);if(!r)return null;const o=e.state.open&&e.state.selectedKey===i;return S.jsxs("button",{type:"button",className:`chat-artifact-card${o?" is-selected":""}`,"aria-pressed":o,onClick:a=>e.open(n,a.currentTarget),children:[S.jsx("img",{src:r.preview,alt:`Preview of ${n.title}`}),S.jsxs("span",{className:"chat-artifact-card-copy",children:[S.jsxs("span",{className:"chat-artifact-kicker",children:[S.jsx(rD,{"aria-hidden":"true"})," Posterly · v",n.version]}),S.jsx("strong",{children:n.title}),S.jsx("small",{className:`chat-artifact-gate chat-artifact-gate-${n.gate_status}`,children:uL(n.gate_status)})]})]})};function vne(n){if(!n.authors.length)return"";const e=n.authors.slice(0,3).map(t=>t.name).join(", ");return n.authors.length>3?`${e}, et al.`:e}function wne(n){var t;if(n.conference)return n.conference;const e=(t=n.published)==null?void 0:t.slice(0,4);if(n.arxiv_id)return e?`arXiv ${e}`:"arXiv";if(n.source_url)try{return new URL(n.source_url).hostname.replace(/^www\./,"")}catch{}return e??"external"}function _ne(n,e=240){const t=n.content.trim();return t.length<=e?t:`${t.slice(0,e).trimEnd()}…`}const dL=()=>S.jsx("span",{className:"chat-caret"}),Sne=n=>{var t;if(!n.streaming)return!1;const e=(t=n.blocks)==null?void 0:t.at(-1);return e?e.kind==="reasoning"?!e.active:e.kind==="tool"?e.status!=="running":!1:!0},xne=n=>{var p,m;const e=n.currentTarget,t=e.ownerDocument,s=(p=t.caretPositionFromPoint)==null?void 0:p.call(t,n.clientX,n.clientY),i=s?null:(m=t.caretRangeFromPoint)==null?void 0:m.call(t,n.clientX,n.clientY),r=(s==null?void 0:s.offsetNode)??(i==null?void 0:i.startContainer),o=(s==null?void 0:s.offset)??(i==null?void 0:i.startOffset);if(!(r instanceof Text)||o===void 0||!e.contains(r))return;const a=r.data,l=/[\p{L}\p{M}\p{N}_'-]/u;let c=Math.min(o,a.length),h=c;for(;c>0&&l.test(a[c-1]);)c-=1;for(;h"]+/gi,OC=/[.,;:!?'"\]}>*_]+$/,Ane=n=>{let e=n.replace(OC,"");for(;e.endsWith(")")&&e.split("(").length{const t=[];let s=0;for(const i of n.matchAll(kne)){const r=Ane(i[0]);r.endsWith("://")||(t.push(n.slice(s,i.index)),t.push(S.jsx("a",{className:"chat-user-link",href:r,target:"_blank",rel:"noopener noreferrer",children:r},`${e}-${i.index}`)),s=i.index+r.length)}return t.push(n.slice(s)),t},Ene=({text:n,mentions:e})=>{const t=[];let s=0;for(const i of[...e].sort((r,o)=>r.start-o.start)){const r=n.slice(i.start,i.end);i.startn.length||r!==i.title&&r!==`@${i.title}`||(t.push(...NC(n.slice(s,i.start),`text-${s}`)),t.push(S.jsxs("span",{className:"chat-inline-paper-mention",children:[S.jsx(UC,{size:13,"aria-hidden":"true"}),S.jsx(r0,{routeId:i.route_id,className:"chat-inline-paper-link",children:r.startsWith("@")?r.slice(1):r})]},i.key)),s=i.end)}return t.push(...NC(n.slice(s),`text-${s}`)),S.jsx(S.Fragment,{children:t})},Cne=({block:n,papers:e,citations:t,webCitations:s,onToggle:i})=>n.active?S.jsxs("div",{className:"chat-reason-live",children:[S.jsxs("div",{className:"chat-reason-live-head",children:[S.jsx(K_,{})," ",S.jsx("span",{children:"Thinking…"})]}),S.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[S.jsx(Xb,{text:n.text,streaming:!0,papers:e,citations:t,webCitations:s}),S.jsx(dL,{})]})]}):S.jsxs("div",{className:"chat-reason-done",children:[S.jsxs("button",{type:"button",className:"chat-reason-done-head",onClick:i,"aria-expanded":n.open,children:[S.jsx(DL,{}),S.jsx("span",{children:"Thought for a few seconds"}),S.jsx(qC,{open:n.open})]}),n.open&&S.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:S.jsx(Xb,{text:n.text,papers:e,citations:t,webCitations:s})})]}),$ne=({block:n,papers:e,onToggle:t})=>{var d,p,m,g;const s=n.status==="running",i=s&&n.argumentState==="streaming",r=n.schema_version===2||!!n.content,o=n.status==="error"||n.status==="denied",a=typeof n.args.query=="string"?n.args.query:"",l=typeof n.args.command=="string"?n.args.command:typeof n.args.file_path=="string"?n.args.file_path:a,c=n.name.startsWith("pwc_")?Object.entries(n.args).filter(([,b])=>b!=null&&b!=="").map(([b,y])=>`${b}=${typeof y=="string"?y:JSON.stringify(y)}`).join(" · "):r?l:`("${a}")`,h=((d=n.content)==null?void 0:d.map(b=>b.text).join(""))??"",u=i?"streaming arguments…":s?"running…":r?`${n.status} · ${n.took_ms??0} ms`:`${n.hits} results · ${n.took_ms} ms`;return S.jsxs("div",{className:`chat-tool${s?" chat-tool-running":""}${o?" chat-tool-failed":""}`,children:[S.jsxs("button",{type:"button",className:"chat-tool-head",onClick:t,"aria-expanded":n.open,children:[S.jsxs("span",{className:"chat-tool-head-left",children:[s?S.jsx(K_,{}):S.jsx(jL,{}),S.jsx("code",{className:"chat-tool-name",children:n.name}),S.jsx("span",{className:"chat-tool-query",title:c,children:c})]}),S.jsxs("span",{className:"chat-tool-head-right",children:[S.jsx("span",{className:"chat-tool-status",children:u}),S.jsx(qC,{open:n.open})]})]}),n.open&&S.jsxs("div",{className:"chat-tool-body",children:[S.jsxs("div",{className:"chat-tool-args",children:[S.jsxs("span",{className:"chat-tool-label",children:["arguments",n.arguments_redacted?" · redacted":""]}),S.jsx("pre",{children:n.argumentState==="streaming"&&!n.arguments_redacted&&n.argumentText||JSON.stringify(n.args,null,2)})]}),!s&&r?S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"chat-tool-output-head",children:[S.jsx("span",{className:"chat-tool-label",children:"result"}),S.jsx("button",{type:"button",className:"chat-tool-copy",onClick:()=>void navigator.clipboard.writeText(h),children:"Copy"})]}),S.jsx("pre",{className:"chat-tool-output",children:S.jsx("code",{children:h})}),((p=n.metadata)==null?void 0:p.output_truncated)&&S.jsx("div",{className:"chat-tool-truncated",children:"Output was truncated."})]}):s?null:S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"chat-tool-label chat-tool-results-label",children:["returned ",((m=n.results)==null?void 0:m.length)??0," papers"]}),S.jsx("ol",{className:"chat-tool-results",children:(g=n.results)==null?void 0:g.map(b=>S.jsxs("li",{className:"chat-hit",children:[S.jsx("div",{className:"chat-hit-top",children:S.jsx(QC,{routeId:b.route_id,paper:e[b.route_id],className:"chat-hit-title",children:b.title})}),S.jsx("div",{className:"chat-hit-meta",children:[vne(b.metadata),wne(b.metadata)].filter(Boolean).join(" · ")}),S.jsxs("div",{className:"chat-hit-snippet",children:[_ne(b),b.content_truncated&&S.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},b.route_id))})]})]})]})},Tne=({block:n,papers:e,citations:t,webCitations:s,streaming:i})=>S.jsxs("div",{className:"chat-answer",children:[S.jsx(Xb,{text:n.text,streaming:i,papers:e,citations:t,webCitations:s}),i&&!!n.text.trim()&&S.jsx(dL,{})]}),Pne=({block:n})=>S.jsx(q6,{block:n}),fL=n=>{const e=ee.useRef(null),t=ee.useCallback(()=>{const s=e.current;if(!s)return;s.style.height="auto";const i=Math.max(120,window.innerHeight*.4);s.style.height=`${Math.min(s.scrollHeight,i)}px`,s.style.overflowY=s.scrollHeight>i?"auto":"hidden"},[]);return ee.useLayoutEffect(()=>{var s,i;(s=e.current)==null||s.focus(),(i=e.current)==null||i.setSelectionRange(n.length,n.length),t()},[t,n.length]),{textareaRef:e,resize:t}},pL=(n,e,t)=>{n.key==="Escape"?(n.preventDefault(),e==null||e()):n.key==="Enter"&&!n.shiftKey&&!n.nativeEvent.isComposing&&(n.preventDefault(),t())},mL=({editNotice:n,canSend:e,onCancel:t,onSend:s})=>S.jsxs(S.Fragment,{children:[n&&S.jsx("div",{className:"chat-inline-editor-notice",children:n}),S.jsxs("div",{className:"chat-inline-editor-actions",children:[S.jsx("button",{type:"button",onClick:t,children:"Cancel"}),S.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!e,onClick:s,children:"Send"})]})]}),gL=(n,e,{onResend:t,onResendDraft:s})=>{const[i,r]=ee.useState(!1);return{resend:()=>{if(!n||i)return;r(!0);const a=e();((s==null?void 0:s(a))??(t==null?void 0:t(a.text))??!1)||r(!1)},canSend:n&&!i}},Rne=({id:n,text:e,paperSelection:t,editNotice:s,onCancel:i,onResend:r,onResendDraft:o})=>{const[a,l]=ee.useState(e),[c,h]=ee.useState(t),{textareaRef:u,resize:d}=fL(e);ee.useLayoutEffect(d,[d,a]);const{resend:p,canSend:m}=gL(!!a.trim()&&a.length<=8e3,()=>({text:a,paperMentions:[],...c?{paperSelection:c}:{}}),{onResend:r,onResendDraft:o});return S.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":n,children:S.jsxs("div",{className:"chat-inline-editor",children:[c&&S.jsx(a0,{selection:c,editable:!0,onRemove:()=>h(void 0)}),S.jsx("textarea",{ref:u,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:a,maxLength:8e3,onChange:g=>l(g.target.value),onKeyDown:g=>pL(g,i,p)}),S.jsx(mL,{editNotice:s,canSend:m,onCancel:i,onSend:p})]})})},Mne=({id:n,text:e,paperMentions:t,paperSelection:s,enabled:i,editNotice:r,onCancel:o,onResend:a,onResendDraft:l})=>{const[c,h]=ee.useState({text:e,paperMentions:t,...s?{paperSelection:s}:{}}),[u,d]=ee.useState(0),{textareaRef:p,resize:m}=fL(e),g=zC({draft:c,onChange:h,enabled:i,textareaRef:p});ee.useLayoutEffect(m,[m,c.text]);const{resend:b,canSend:y}=gL(!!c.text.trim()&&c.text.length<=8e3&&(i||c.paperMentions.length===0),()=>c,{onResend:a,onResendDraft:l});return S.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":n,children:S.jsxs("div",{className:"chat-inline-editor",children:[c.paperSelection&&S.jsx(a0,{selection:c.paperSelection,editable:!0,onRemove:()=>h({text:c.text,paperMentions:c.paperMentions})}),S.jsxs("div",{className:"chat-inline-editor-textarea-wrap",children:[S.jsx(HC,{text:c.text,mentions:c.paperMentions,scrollTop:u,variant:"editor"}),S.jsx("textarea",{ref:p,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:c.text,maxLength:8e3,role:"combobox","aria-autocomplete":"list","aria-expanded":g.open,"aria-controls":g.open?g.pickerId:void 0,"aria-activedescendant":g.open&&g.results.length?`${g.optionIdPrefix}-${g.activeIndex}`:void 0,onChange:w=>g.updateText(w.target.value,w.target.selectionStart),onSelect:w=>g.refresh(w.currentTarget.selectionStart),onScroll:w=>d(w.currentTarget.scrollTop),onKeyDown:w=>{g.keyDown(w)||pL(w,o,b)}}),S.jsx(BC,{open:g.open,query:g.query,results:g.results,activeIndex:g.activeIndex,loading:g.loading,error:g.error,onSelect:g.select,id:g.pickerId,optionIdPrefix:g.optionIdPrefix})]}),!i&&c.paperMentions.length>0&&S.jsx("div",{className:"chat-inline-editor-notice",role:"status",children:"Paper mentions are currently disabled. Remove them before sending."}),S.jsx(mL,{editNotice:r,canSend:y,onCancel:o,onSend:b})]})})},Ase=({id:n,text:e,paperMentions:t=[],paperSelection:s,paperMentionsEnabled:i=!1,editingAllowed:r=!1,editing:o=!1,editNotice:a,onEdit:l,onCancel:c,onResend:h,onResendDraft:u})=>{const[d,p]=ee.useState(!1),m=ee.useRef(null);ee.useEffect(()=>()=>{m.current!==null&&window.clearTimeout(m.current)},[]);const g=async()=>{var b;if((b=navigator.clipboard)!=null&&b.writeText)try{await navigator.clipboard.writeText(e),p(!0),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>p(!1),1500)}catch{}};return o?!i&&t.length===0?S.jsx(Rne,{id:n,text:e,paperSelection:s,editNotice:a,onCancel:c,onResend:h,onResendDraft:u}):S.jsx(Mne,{id:n,text:e,paperMentions:t,paperSelection:s,enabled:i,editNotice:a,onCancel:c,onResend:h,onResendDraft:u}):S.jsx("div",{className:"chat-msg chat-msg-user","data-message-id":n,children:S.jsxs("div",{className:"chat-user-message-wrap",children:[s&&S.jsx(a0,{selection:s}),S.jsx("div",{className:"chat-bubble",onDoubleClick:xne,children:S.jsx(Ene,{text:e,mentions:t})}),S.jsxs("div",{className:"chat-user-actions",children:[S.jsx("button",{type:"button",className:"chat-user-action","aria-label":d?"Message copied":"Copy message",title:d?"Copied":"Copy",onClick:()=>void g(),children:d?S.jsx(EL,{"aria-hidden":"true"}):S.jsx(YL,{"aria-hidden":"true"})}),r&&S.jsx("button",{type:"button",className:"chat-user-action","aria-label":"Edit message",title:"Edit",onClick:l,children:S.jsx(ZC,{"aria-hidden":"true"})})]})]})})},Ine=n=>({citations:Object.fromEntries(n.filter(e=>(e.kind==="catalog_paper"||e.kind==="paper"||!e.kind&&e.route_id)&&e.route_id).map(e=>[e.route_id,e])),webCitations:Object.fromEntries(n.filter(e=>(e.kind==="external_source"||e.kind==="web")&&e.url).map(e=>[e.url,e]))}),Ese=({msg:n,papers:e,onToggleBlock:t,onRetryCompaction:s,onRetryWithLuna:i,onArchiveOldChats:r,onArchiveOldestChats:o,archivePending:a=null,hfBilling:l=null,openRouterFallbackEnabled:c=!1,feedbackEnabled:h=!1})=>{var d,p,m;const u=h&&!n.streaming&&!n.error&&!!((d=n.blocks)!=null&&d.some(g=>g.kind==="answer"&&g.text.trim()));return S.jsx("div",{className:"chat-msg chat-msg-assistant",children:S.jsxs("div",{className:"chat-msg-blocks",children:[(p=n.blocks)==null?void 0:p.map((g,b)=>{var x;const y=`${n.id}-${b}`,{citations:w,webCitations:v}=Ine("citations"in g&&g.citations!==void 0?g.citations:n.citations??[]);return g.kind==="reasoning"?S.jsx(Cne,{block:g,papers:e,citations:w,webCitations:v,onToggle:()=>t(n.id,b)},y):g.kind==="tool"?S.jsx($ne,{block:g,papers:e,onToggle:()=>t(n.id,b)},y):g.kind==="app"?S.jsx(Pne,{block:g},g.instance_id||y):g.kind==="artifact"?S.jsx(bne,{block:g},g.publication_id||g.version_id||y):S.jsx(Tne,{block:g,papers:e,citations:w,webCitations:v,streaming:!!(n.streaming&&b===(((x=n.blocks)==null?void 0:x.length)??0)-1)},y)}),n.streaming&&n.compacting&&S.jsx(hD,{}),!n.compacting&&Sne(n)&&S.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:S.jsx("span",{className:"chat-thinking",children:(((m=n.blocks)==null?void 0:m.length)??0)===0?n.status??"Thinking…":"Thinking…"})}),n.error&&S.jsx(mD,{msg:{...n,error:n.error},onRetryCompaction:s,onRetryWithLuna:i,onArchiveOldChats:r,onArchiveOldestChats:o,archivePending:a,hfBilling:l,openRouterFallbackEnabled:c}),!n.streaming&&n.finishReason&&!["success","scope_blocked"].includes(n.finishReason)&&S.jsx("div",{className:"chat-finish-note",children:["tool_limit","max_turns"].includes(n.finishReason)?"The assistant stopped at the execution limit.":`The assistant stopped early (${n.finishReason.replace(/_/g," ")}).`}),u&&S.jsx(KD,{messageId:n.id})]})})},One={chat:{breakpoint:760,left:360,right:360},shared:{breakpoint:760,left:360,right:360},reader:{breakpoint:1260,left:840,right:420}};function Ua(n,e,t,s){if(!n)return Math.max(25,Math.min(75,e));const i=Math.max(25,s/n*100),r=Math.min(75,(n-t)/n*100);return Math.max(i,Math.min(r,e))}const Cse=({children:n,variant:e})=>{var w;const t=lm(),s=One[e],i=ee.useRef(null),r=ee.useRef(null),o=ee.useRef(null),a=ee.useRef(null),[l,c]=ee.useState(0),h=ee.useRef(!1),u=ee.useRef(t.state.panelPercent);ee.useLayoutEffect(()=>{const v=i.current;if(!v)return;const x=()=>c(v.clientWidth||window.innerWidth);if(x(),typeof ResizeObserver>"u")return;const k=new ResizeObserver(x);return k.observe(v),()=>k.disconnect()},[]);const d=t.state.open&&l>=s.breakpoint,p=Ua(l,t.state.panelPercent,s.left,s.right),m=((w=t.state.selected)==null?void 0:w.artifact_kind)==="latex_paper"?"paper":"poster",g=v=>{var k;const x=Ua(l,v,s.left,s.right);u.current=x,r.current&&(r.current.style.width=`${100-x}%`),o.current&&(o.current.style.width=`${x}%`),(k=a.current)==null||k.setAttribute("aria-valuenow",String(Math.round(x)))},b=v=>{var k;const x=(k=i.current)==null?void 0:k.getBoundingClientRect();x!=null&&x.width&&g((x.right-v)/x.width*100)},y=()=>{h.current&&(h.current=!1,t.setPanelPercent(u.current))};return S.jsxs("div",{ref:i,className:`chat-artifact-workspace chat-artifact-workspace-${e}${d?" has-docked-artifact":""}`,"data-artifact-layout":d?"split":t.state.open?"dialog":"closed",children:[S.jsx("div",{ref:r,className:"chat-artifact-workspace-content",style:d?{width:`${100-p}%`}:void 0,children:n}),d&&S.jsxs(S.Fragment,{children:[S.jsx("div",{ref:a,className:"chat-artifact-resize-handle",role:"separator","aria-label":`Resize conversation and ${m} panels`,"aria-orientation":"vertical","aria-valuemin":Math.ceil(Ua(l,0,s.left,s.right)),"aria-valuemax":Math.floor(Ua(l,100,s.left,s.right)),"aria-valuenow":Math.round(p),tabIndex:0,onPointerDown:v=>{h.current=!0,v.currentTarget.setPointerCapture(v.pointerId),b(v.clientX)},onPointerMove:v=>{h.current&&b(v.clientX)},onPointerUp:y,onPointerCancel:y,onLostPointerCapture:y,onDoubleClick:()=>t.setPanelPercent(55),onKeyDown:v=>{(v.key==="ArrowLeft"||v.key==="ArrowRight")&&(v.preventDefault(),t.setPanelPercent(Ua(l,p+(v.key==="ArrowLeft"?2:-2),s.left,s.right))),v.key==="Home"&&t.setPanelPercent(Ua(l,25,s.left,s.right)),v.key==="End"&&t.setPanelPercent(Ua(l,75,s.left,s.right))}}),S.jsx("div",{ref:o,className:"chat-artifact-workspace-pane",style:{width:`${p}%`},children:S.jsx(IC,{})})]}),t.state.open&&!d&&S.jsx(IC,{forceDialog:!0,readerFallback:e==="reader"})]})},yL="Preparing research workspace…",bL={preparing_workspace:"Preparing secure workspace…",starting_agent:"Starting research agent…",connecting_model:"Connecting to model…"},_t=(n,e=null,t=null)=>({presentation:n,workspaceStatus:e,terminal:t}),$se={stream_start:_t("silent"),sandbox_start:_t("silent","arm"),sandbox_ready:_t("silent","clear"),workspace_ready:_t("silent","clear"),lifecycle:_t("structural","clear"),compaction_status:_t("structural"),session_title_start:_t("silent"),session_title_delta:_t("silent"),session_title_done:_t("silent"),reasoning_start:_t("structural","clear"),reasoning_delta:_t("delta","clear"),reasoning_end:_t("structural"),tool_call:_t("structural","clear"),tool_call_start:_t("structural","clear"),tool_call_arguments_delta:_t("delta","clear"),tool_call_arguments_done:_t("structural","clear"),tool_result:_t("structural"),app_start:_t("structural","clear"),app_result:_t("structural","clear"),artifact_start:_t("structural","clear"),artifact_ready:_t("structural","clear"),artifact_error:_t("structural","clear"),paper_artifact:_t("structural"),answer_delta:_t("delta","clear"),done:_t("structural","clear","complete"),error:_t("structural","clear","error")},Nne=()=>({messages:[],sessionId:null,title:""});function LC(n,e){for(let t=n.length-1;t>=0;t-=1)if(e(n[t]))return t;return-1}function Fo(n){if(n.status!==yL&&!Object.values(bL).includes(n.status))return n;const{status:e,...t}=n;return t}function es(n,e){if(!n.length)return n;const t=n.slice();return t[t.length-1]=e(t[t.length-1]),t}function Wa(n,e,t){return es(n,s=>{const i=Fo(s),r=i.blocks??[];return{...i,blocks:r.map((o,a)=>e(o,a,r)?t(o):o)}})}function Lne(n,e){switch(e.type){case"stream_start":return e.session_id?{...n,sessionId:e.session_id}:n;case"sandbox_start":case"sandbox_ready":case"workspace_ready":return n;case"lifecycle":return{...n,messages:es(n.messages,t=>{var s;return t.role==="assistant"&&t.streaming&&(((s=t.blocks)==null?void 0:s.length)??0)===0?{...t,status:bL[e.phase]}:t})};case"session_title_start":return{...n,title:""};case"session_title_delta":return{...n,title:`${n.title}${e.text}`.replace(/\s+/g," ").slice(0,80)};case"session_title_done":return{...n,title:e.title};case"compaction_status":return{...n,messages:es(n.messages,t=>({...t,compacting:!!(t.streaming&&e.state==="started")}))};case"reasoning_start":return{...n,messages:es(n.messages,t=>{const s=Fo(t);return{...s,blocks:[...(s.blocks??[]).map(i=>i.kind==="reasoning"&&i.active?{...i,active:!1,open:!1}:i),{kind:"reasoning",text:"",active:!0,open:!0}]}})};case"reasoning_delta":return{...n,messages:Wa(n.messages,(t,s,i)=>t.kind==="reasoning"&&LC(i,r=>r.kind==="reasoning")===s,t=>t.kind==="reasoning"?{...t,text:t.text+e.text}:t)};case"reasoning_end":return{...n,messages:es(n.messages,t=>{const s=t.blocks??[],i=LC(s,a=>a.kind==="reasoning"&&a.active);if(i<0)return t;const r=s[i];if(r.kind!=="reasoning")return t;const o=s[i-1];return(o==null?void 0:o.kind)==="reasoning"&&o.text===r.text?{...t,blocks:s.filter((a,l)=>l!==i)}:{...t,blocks:s.map((a,l)=>l===i?{...r,active:!1,open:!1}:a)}})};case"tool_call":return{...n,messages:es(n.messages,t=>{const s=Fo(t);return{...s,blocks:[...s.blocks??[],{kind:"tool",id:e.id,name:e.name,args:e.args,status:"running",open:!1}]}})};case"tool_call_start":return{...n,messages:es(n.messages,t=>{const s=Fo(t);return{...s,blocks:[...s.blocks??[],{kind:"tool",schema_version:2,id:e.id,name:e.name,args:{},argumentText:"",argumentState:"streaming",arguments_redacted:e.redacted,status:"running",open:!1}]}})};case"tool_call_arguments_delta":return{...n,messages:Wa(n.messages,t=>t.kind==="tool"&&t.id===e.id,t=>t.kind==="tool"?{...t,args:e.partial_args,argumentText:e.snapshot?e.delta:`${t.argumentText??""}${e.delta}`,arguments_redacted:t.arguments_redacted||e.redacted}:t)};case"tool_call_arguments_done":return{...n,messages:Wa(n.messages,t=>t.kind==="tool"&&t.id===e.id,t=>t.kind==="tool"?{...t,args:e.args,argumentText:JSON.stringify(e.args),argumentState:"done",arguments_redacted:t.arguments_redacted||e.redacted}:t)};case"app_start":return{...n,messages:es(n.messages,t=>{const s=Fo(t);return{...s,blocks:[...s.blocks??[],{kind:"app",schema_version:1,instance_id:e.instance_id,provider:e.provider,server:e.server,tool:e.tool,resource_uri:e.resource_uri,status:"loading",input:e.input,result:{content:[],structuredContent:{},isError:!1},csp:{},permissions:{clipboardWrite:!0},height:525}]}})};case"app_result":return{...n,messages:Wa(n.messages,t=>t.kind==="app"&&t.instance_id===e.id,t=>t.kind==="app"?{...t,status:e.status,result:e.result}:t)};case"tool_result":return{...n,messages:Wa(n.messages,t=>t.kind==="tool"&&t.id===e.id,t=>t.kind!=="tool"?t:e.status?{...t,schema_version:2,status:e.status,took_ms:e.took_ms,content:e.content,metadata:e.metadata,open:e.status!=="success"}:{...t,status:"done",hits:e.hits,took_ms:e.took_ms,results:e.results})};case"artifact_start":return{...n,messages:es(n.messages,t=>{const s=Fo(t);return{...s,blocks:[...s.blocks??[],{kind:"artifact",schema_version:1,scope:"owner",publication_id:e.publication_id,identifier:e.identifier,artifact_kind:"posterly",title:e.title,status:"generating",phase:"publishing_poster"}]}})};case"artifact_ready":return{...n,messages:Wa(n.messages,t=>t.kind==="artifact"&&t.publication_id===e.publication_id,t=>t.kind==="artifact"?{...t,artifact_id:e.artifact_id,version_id:e.version_id,identifier:e.identifier,version:e.version,title:e.title,status:"ready",preview_mime:e.preview_mime,source_language:e.source_language,gate_status:e.gate_status,total_bytes:e.total_bytes,phase:void 0}:t)};case"artifact_error":return{...n,messages:Wa(n.messages,t=>t.kind==="artifact"&&t.publication_id===e.publication_id,t=>t.kind==="artifact"?{...t,status:"error",phase:void 0,error_code:e.code,error_message:e.message}:t)};case"answer_delta":return{...n,messages:es(n.messages,t=>{const s=Fo(t),i=s.blocks??[],r=i.at(-1);return(r==null?void 0:r.kind)==="answer"&&!r.done?{...s,blocks:[...i.slice(0,-1),{...r,text:r.text+e.text}]}:{...s,blocks:[...i,{kind:"answer",text:e.text,done:!1}]}})};case"done":return{...n,messages:es(n.messages,t=>({...t,streaming:!1,compacting:!1,followups:e.followups,finishReason:e.finish_reason,citations:e.citations,blocks:(t.blocks??[]).map(s=>s.kind==="answer"?{...s,done:!0}:s.kind==="reasoning"&&s.active?{...s,active:!1,open:!1}:s)}))};case"error":return{...n,messages:es(n.messages,t=>({...t,streaming:!1,compacting:!1,error:e.message,errorCode:e.code,blocks:(t.blocks??[]).map(s=>s.kind==="reasoning"&&s.active?{...s,active:!1,open:!1}:s.kind==="tool"&&s.status==="running"?{...s,status:"error",open:!0}:s)}))};default:return n}}function Dne(n){return es(n,e=>{if(e.role!=="assistant")return e;const t=(e.blocks??[]).flatMap(s=>s.kind==="tool"&&s.status==="running"?[{...s,status:"error",open:!0}]:s.kind==="reasoning"&&s.active?s.text?[{...s,active:!1,open:!1}]:[]:s.kind==="answer"?[{...s,done:!0}]:[s]);return{...e,blocks:t,streaming:!1,compacting:!1,finishReason:"stopped"}})}function Tse(n,e){switch(e.type){case"start":return{messages:e.messages,sessionId:e.sessionId,title:""};case"event":return Lne(n,e.event);case"load":return{messages:e.messages,sessionId:e.sessionId,title:n.title};case"workspace_status":return{...n,messages:es(n.messages,t=>{var s;return t.role==="assistant"&&t.streaming&&(((s=t.blocks)==null?void 0:s.length)??0)===0&&!t.error?{...t,status:yL}:t})};case"clear_workspace_status":return{...n,messages:es(n.messages,Fo)};case"settle":return{...n,messages:es(n.messages,t=>t.streaming?{...t,streaming:!1,compacting:!1}:t)};case"stop":return{...n,messages:Dne(n.messages)};case"toggle_block":return{...n,messages:jne(n.messages,e.messageId,e.blockIndex)};case"reset":return Nne()}}function jne(n,e,t){return n.map(s=>{var i;return s.id!==e?s:{...s,blocks:(i=s.blocks)==null?void 0:i.map((r,o)=>o===t&&(r.kind==="reasoning"||r.kind==="tool")?{...r,open:!r.open}:r)}})}export{kse as A,lse as C,$se as E,ZY as P,W6 as R,Ase as U,Cse as a,Ese as b,lm as c,cse as d,RD as e,xse as f,W_ as g,gse as h,lR as i,Nne as j,Tse as k,LC as l,yse as m,pse as n,mse as o,jne as t,KX as u}; diff --git a/assets/ArtifactWorkspace-Lr_OJaUk.css b/assets/chatLifecycle-Lr_OJaUk.css similarity index 100% rename from assets/ArtifactWorkspace-Lr_OJaUk.css rename to assets/chatLifecycle-Lr_OJaUk.css diff --git a/assets/chatSessions-9VEG8seW.js b/assets/chatSessions-9VEG8seW.js new file mode 100644 index 0000000000000000000000000000000000000000..bd1738d383c43ba8ac97871e34b0fd8075955a68 --- /dev/null +++ b/assets/chatSessions-9VEG8seW.js @@ -0,0 +1,14 @@ +import{j as p,V as f,b as oe,A as Ce,ab as xe}from"./index-CjdUkE4w.js";import{c as k}from"./chat-B1EBF720.js";import{p as Re}from"./papers-DgZwjF3K.js";const et=({light:e})=>p.jsx("span",{className:`chat-spinner${e?" chat-spinner-light":""}`}),tt=({open:e})=>p.jsx("svg",{className:`chat-chev${e?" chat-chev-open":""}`,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:p.jsx("path",{d:"m6 9 6 6 6-6"})}),rt=()=>p.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[p.jsx("circle",{cx:"12",cy:"12",r:"9"}),p.jsx("path",{d:"m9 12 2 2 4-4"})]}),nt=({size:e=14})=>p.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[p.jsx("circle",{cx:"11",cy:"11",r:"7"}),p.jsx("path",{d:"m21 21-4.3-4.3"})]}),ot=()=>p.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",children:p.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})}),at=()=>p.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:p.jsx("path",{d:"M12 5v14M5 12h14"})}),st=()=>p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[p.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),p.jsx("path",{d:"M9 4v16"})]}),it=()=>p.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:p.jsx("path",{d:"M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2M6 6l1 14a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-14"})}),ct=({text:e,mentions:t,scrollTop:r=0,variant:n="composer",completion:o=""})=>{const s=[];let i=0;for(const a of[...t].sort((u,d)=>u.start-d.start)){const u=e.slice(a.start,a.end),d=u===a.title||u===`@${a.title}`;a.starte.length||!d||(s.push(e.slice(i,a.start)),s.push(p.jsx("span",{className:`chat-paper-inline-highlight${a.unavailable?" is-unavailable":""}`,"data-paper-route-id":a.route_id,children:u},a.key)),i=a.end)}return s.push(e.slice(i)),o&&s.push(p.jsx("span",{className:"chat-prompt-completion",children:o},"completion")),e.endsWith(` +`)&&s.push("​"),p.jsx("div",{"aria-hidden":"true",className:`chat-paper-highlight-layer chat-paper-highlight-layer-${n}`,children:p.jsx("div",{style:{transform:`translateY(-${r}px)`},children:s})})},lt=({open:e,query:t,results:r,activeIndex:n,loading:o,error:s,onSelect:i,id:a="chat-paper-picker",optionIdPrefix:u="chat-paper-option"})=>{if(!e)return null;const d=t.trim()?o?"Searching papers…":s?"Paper search is unavailable":r.length?`${r.length} paper${r.length===1?"":"s"} found`:"No papers found":"Type to search papers";return p.jsxs("div",{className:"chat-paper-picker",id:a,role:"listbox","aria-label":"Paper results",children:[p.jsx("div",{className:"chat-paper-picker-status",role:"status","aria-live":"polite",children:d}),r.map((h,l)=>{const O=h.arxiv_id||h.id,L=h.arxiv_id||(()=>{try{return h.source_url?new URL(h.source_url).hostname:"External resource"}catch{return"External resource"}})();return p.jsxs("button",{type:"button",id:`${u}-${l}`,role:"option","aria-selected":l===n,className:`chat-paper-option${l===n?" is-active":""}`,onMouseDown:Y=>{Y.preventDefault(),i(h)},children:[p.jsx("span",{className:"chat-paper-option-title",children:h.title}),p.jsx("span",{className:"chat-paper-option-meta",children:L})]},O)})]})},ke=["What are decision models?","Find relevant papers on RLVR","What's the state-of-the-art for real-time object detection?"],ut=["Summarize the main contributions","Explain in simple terms","Identify the main limitations"],Ae=[...ke,"What are the latest papers on ","Which benchmarks are used for ","Which methods work best for ","How does ","Explain how ","Compare ","Summarize the key contributions of "],De=3,Ie=4,Le=new Set(["about","all","and","are","best","can","compare","does","explain","find","for","from","give","how","into","latest","list","method","methods","model","models","new","paper","papers","recent","show","state","summarize","task","tasks","the","this","use","what","when","where","which","who","why","with","work"]),Me=new RegExp(`(?:^|(?<=[\\s("'“‘]))(?=\\S)`,"g"),Pe=e=>{const t=e.toLowerCase(),r=Ae.find(n=>n.length>e.length&&n.toLowerCase().startsWith(t));return r?r.slice(e.length):""},Ne=(e,t)=>{const r=[...e.matchAll(Me)].map(n=>n.index??0);for(const n of r.slice(-4)){const o=e.slice(n),s=o.toLowerCase(),i=/\s/.test(o);if(o.length<(i?De:Ie)||!i&&Le.has(s))continue;const a=t.find(u=>u.length>o.length&&u.toLowerCase().startsWith(s));if(a)return a.slice(o.length)}return""},Ye=(e,t)=>!e.trim()||/\s$/.test(e)?"":Pe(e)||Ne(e,t);function dt(e,t=!1){var h;const r=e.text,[n,o]=f.useState(null),s=oe({queryKey:["chatAutocompleteVocabulary"],queryFn:()=>k.getAutocompleteVocabulary(),enabled:r.length>0,staleTime:1/0,gcTime:1/0,retry:!1}),i=(n==null?void 0:n.text)===r?n.atEnd:!0,a=e.paperMentions.some(l=>l.end===r.length);return{completion:!t&&i&&!a?Ye(r,((h=s.data)==null?void 0:h.names)??[]):"",trackCaret:l=>o({text:l.value,atEnd:l.selectionStart===l.selectionEnd&&l.selectionEnd===l.value.length})}}const pt=e=>e.key==="Tab"&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.nativeEvent.isComposing,ht=e=>{var r;const t=(r=e.parentElement)==null?void 0:r.querySelector(".chat-paper-highlight-layer");return Math.max(e.scrollHeight,(t==null?void 0:t.scrollHeight)??0)},ae=8e3,se=16384,ie=1e4,C={crossPage:"Select text within one PDF page.",outside:"Select text from the paper, not the surrounding interface.",tooLarge:"Select a shorter passage (maximum 8,000 characters)."};function ce(e){return new TextEncoder().encode(e).length}function le(e){return e.replace(/\r\n/g,` +`).replace(/\r/g,` +`).replace(/\u00a0/g," ").replace(/[^\S\n]+/g," ").trim()}function ft(e){return`${e.routeId}\0${e.paperVersion}\0${e.page}\0${e.text}`}function mt(e){return{route_id:e.routeId,paper_version:e.paperVersion,page:e.page,text:e.text}}function N(e="",t){return t?{text:e,paperMentions:[],paperSelection:t}:{text:e,paperMentions:[]}}function K(e,t,r){return e.paperSelection?{text:t,paperMentions:r,paperSelection:e.paperSelection}:{text:t,paperMentions:r}}function Fe(e){if(!e||typeof e!="object")return;const t=e;if(typeof t.routeId!="string"||!t.routeId.trim()||typeof t.paperVersion!="string"||!t.paperVersion.trim())return;const r=t.page;if(typeof r!="number"||!Number.isInteger(r)||r<1||r>ie||typeof t.text!="string")return;const n=le(t.text);if(n&&!(n.length>ae)&&!(ce(n)>se))return{routeId:t.routeId.trim(),paperVersion:t.paperVersion.trim(),page:r,text:n}}function je(e,t){if(typeof e=="string")return N(e);if(!e||typeof e!="object")return t===void 0?null:N(t);const r=e;if(typeof r.text!="string"||!Array.isArray(r.paperMentions))return t===void 0?null:N(t);const n=Fe(r.paperSelection);return n?{text:r.text,paperMentions:r.paperMentions,paperSelection:n}:{text:r.text,paperMentions:r.paperMentions}}function ue(e){return e?e instanceof Element?e:e.parentElement:null}function G(e,t){const r=ue(e);if(!r||!t.contains(r)||!r.closest(".textLayer, .reader-web-document"))return null;const n=r.closest(".pdf-page[data-page], .reader-web-document[data-page]");if(!n||!t.contains(n))return null;const o=Number(n.dataset.page);return!Number.isInteger(o)||o<1||o>ie?null:o}function gt(e){const{selection:t,pagesRoot:r,routeId:n,paperVersion:o,numPages:s}=e;if(!r||!t||t.rangeCount!==1)return t&&t.rangeCount>1?{ok:!1,error:C.crossPage}:{ok:!1,error:null};const i=t.getRangeAt(0);if(i.collapsed)return{ok:!1,error:null};const a=G(i.startContainer,r),u=G(i.endContainer,r),d=ue(i.commonAncestorContainer);if(!d||!r.contains(d))return{ok:!1,error:C.outside};if(a===null||u===null)return{ok:!1,error:C.outside};if(a!==u)return{ok:!1,error:C.crossPage};if(s&&(a<1||a>s))return{ok:!1,error:C.crossPage};const h=t.toString(),l=le(h);return l?l.length>ae||ce(l)>se?{ok:!1,error:C.tooLarge}:{ok:!0,selection:{routeId:n,paperVersion:o,page:a,text:l}}:{ok:!1,error:C.crossPage}}const qe=10,We=3;function z(e,t){const n=e.slice(0,t).lastIndexOf("@");if(n<0)return null;const o=n>0?e[n-1]:"";if(o&&/[\p{L}\p{M}\p{N}_@]/u.test(o))return null;const s=e.slice(n+1,t);return/[\n\r@]/.test(s)?null:{start:n,end:t,query:s}}function X(e,t,r){let n=0;for(;na.end<=n?[a]:a.start>=s?[{...a,start:a.start+i,end:a.end+i}]:[])}function yt({draft:e,onChange:t,enabled:r,textareaRef:n}){var V;const o=`chat-paper-picker-${f.useId().replace(/:/g,"")}`,s=`${o}-option`,[i,a]=f.useState(null),[u,d]=f.useState(""),[h,l]=f.useState(0),[O,L]=f.useState(""),Y=f.useRef(new Set);f.useEffect(()=>{r||a(null)},[r]),f.useEffect(()=>{const c=window.setTimeout(()=>d((i==null?void 0:i.query.trim())??""),150);return()=>window.clearTimeout(c)},[i==null?void 0:i.query]);const D=oe({queryKey:["chat-paper-mention-search",u.toLowerCase()],queryFn:({signal:c})=>Re.search(u,1,10,"hybrid",c),enabled:r&&!!i&&u.length>=1,staleTime:3e4,refetchOnWindowFocus:!1,retry:!1}),y=f.useMemo(()=>{var c;return((c=D.data)==null?void 0:c.results)??[]},[(V=D.data)==null?void 0:V.results]);f.useEffect(()=>l(0),[u]),f.useEffect(()=>{var c;(c=document.getElementById(`${s}-${h}`))==null||c.scrollIntoView({block:"nearest"})},[h,s]);const be=f.useCallback(c=>{var v;if(!r){a(null);return}const m=c??((v=n.current)==null?void 0:v.selectionStart)??e.text.length;if(e.paperMentions.some(T=>m>T.start&&m<=T.end)){a(null);return}a(z(e.text,m))},[e.paperMentions,e.text,r,n]),Oe=f.useCallback((c,m)=>{var M;const v=X(e.text,c,e.paperMentions),T=K(e,c,v);t(T);const E=m??((M=n.current)==null?void 0:M.selectionStart)??c.length;r&&!v.some(P=>E>P.start&&E<=P.end)?a(z(c,E)):a(null)},[e,r,t,n]),W=f.useCallback(c=>{if(!i)return!1;const m=c.arxiv_id||c.id,v=new Set(e.paperMentions.map(I=>I.route_id));if(e.paperMentions.length>=qe)return L("A message can contain at most 10 paper mentions."),!1;if(!v.has(m)&&v.size>=We)return L("A message can attach at most 3 distinct papers."),!1;const T=c.title,E=e.text.slice(i.end),M=E.length===0,P=e.text.slice(0,i.start)+T+(M?" ":"")+E,Ee=X(e.text,P,e.paperMentions),$={key:crypto.randomUUID(),route_id:m,title:c.title,source:c.source==="external"?"external":"arxiv",start:i.start,end:i.start+T.length};return t(K(e,P,[...Ee,$].sort((I,F)=>I.start-F.start))),a(null),L(""),window.requestAnimationFrame(()=>{var F,B;const I=$.end+(M||E.startsWith(" ")?1:0);(F=n.current)==null||F.focus(),(B=n.current)==null||B.setSelectionRange(I,I)}),Y.current.has(m)||(Y.current.add(m),k.prewarmPaperContext(m).catch(()=>{})),!0},[i,e,t,n]),Te=f.useCallback(c=>!i||c.nativeEvent.isComposing?!1:c.key==="Tab"?(a(null),!1):c.key==="Escape"?(c.preventDefault(),a(null),!0):c.key==="ArrowDown"||c.key==="ArrowUp"?(c.preventDefault(),y.length&&l(m=>c.key==="ArrowDown"?(m+1)%y.length:(m-1+y.length)%y.length),!0):c.key==="Home"&&y.length?(c.preventDefault(),l(0),!0):c.key==="End"&&y.length?(c.preventDefault(),l(y.length-1),!0):c.key==="Enter"&&!c.shiftKey?(c.preventDefault(),y[h]?W(y[h]):D.isFetching||a(null),!0):!1,[i,h,y,D.isFetching,W]);return{open:!!i,query:(i==null?void 0:i.query)??"",results:y,activeIndex:h,loading:D.isFetching,error:D.isError,message:O,pickerId:o,optionIdPrefix:s,updateText:Oe,refresh:be,select:W,keyDown:Te,close:()=>a(null)}}const g=(e,t)=>new Promise(r=>{const n=setTimeout(o,e);function o(){t==null||t.removeEventListener("abort",o),clearTimeout(n),r()}t==null||t.addEventListener("abort",o)}),S=e=>({arxiv_id:null,source:"arxiv",source_url:null,thumbnail_url:null,authors:[],published:null,conference:null,citation_count:null,tasks:[],methods:[],repositories:[],project_pages:[],...e}),w={name:"Object Detection",slug:"object-detection"},x={name:"Real-Time Object Detection",slug:"real-time-object-detection"},He={"2502.12524":{route_id:"2502.12524",title:"YOLOv12: Attention-Centric Real-Time Object Detectors",content:"Enhancing the network architecture of the YOLO framework has been crucial for a long time. This work introduces an attention-centric YOLO framework, namely YOLOv12, built around area attention and residual efficient layer aggregation networks (R-ELAN). YOLOv12-N reaches 40.6 mAP at 1.64 ms on a T4 GPU, closing the gap to attention-based detectors without the usual latency penalty and surpassing YOLOv10/YOLOv11 by +1.2–1.6 mAP at matched latency.",content_truncated:!1,metadata:S({arxiv_id:"2502.12524",authors:[{name:"Y. Tian"},{name:"Q. Ye"},{name:"D. Doermann"}],published:"2025-02-18",citation_count:412,tasks:[w,x],methods:[{name:"Area Attention",slug:"area-attention"}],repositories:[{url:"https://github.com/sunsmarterjie/yolov12",stars:18700}]})},"2407.17140":{route_id:"2407.17140",title:"RT-DETRv2: Improved Baseline with Bag-of-Freebies for Real-Time Detection",content:"RT-DETRv2 improves the real-time DETR baseline with selective multi-scale feature extraction, a discrete sampling operator to ease deployment, and training-only 'bag-of-freebies' that add no inference cost. RT-DETRv2-R18/R50/R101 reach 47.9 / 53.4 / 54.3 mAP on COCO at 217 / 108 / 74 FPS on T4 TensorRT FP16, remaining NMS-free end to end.",content_truncated:!1,metadata:S({arxiv_id:"2407.17140",authors:[{name:"W. Lv"},{name:"Y. Zhao"},{name:"J. Chang"}],published:"2024-07-24",citation_count:268,tasks:[w,x],methods:[{name:"DETR",slug:"detr"}],repositories:[{url:"https://github.com/lyuwenyu/RT-DETR",stars:9400}]})},"2410.13842":{route_id:"2410.13842",title:"D-FINE: Redefining Regression as Fine-grained Distribution Refinement",content:"D-FINE reformulates bounding-box regression in DETR-style detectors as iterative refinement of probability distributions (FDR) and adds a localization self-distillation scheme (GO-LSD). D-FINE-L reaches 54.0 mAP at ~9 ms and D-FINE-X 55.8 mAP on COCO while staying real-time on modern GPUs, dominating RT-DETRv2 and YOLOv10 on the accuracy–latency Pareto front.",content_truncated:!1,metadata:S({arxiv_id:"2410.13842",authors:[{name:"Y. Peng"},{name:"H. Li"},{name:"P. Wu"}],published:"2024-10-17",conference:"ICLR 2025",citation_count:187,tasks:[w,x],methods:[{name:"Knowledge Distillation",slug:"knowledge-distillation"}],repositories:[{url:"https://github.com/Peterande/D-FINE",stars:12100}]})},"2406.03459":{route_id:"2406.03459",title:"LW-DETR: A Transformer Replacement to YOLO for Real-Time Detection",content:"LW-DETR pairs a plain ViT encoder with a lightweight DETR decoder and shows the combination outperforms YOLOv8 and YOLO-NAS at comparable latency, arguing transformer detectors are viable even at the fast end of the accuracy–latency curve. Uses multi-level feature aggregation, window-attention interleaving, and IoU-aware classification.",content_truncated:!1,metadata:S({arxiv_id:"2406.03459",authors:[{name:"Q. Chen"},{name:"X. Su"},{name:"X. Zhang"}],published:"2024-06-05",citation_count:94,tasks:[w,x],methods:[{name:"Vision Transformer",slug:"vision-transformer"}],repositories:[{url:"https://github.com/Atten4Vis/LW-DETR",stars:5200}]})},"2304.08069":{route_id:"2304.08069",title:"DETRs Beat YOLOs on Real-time Object Detection",content:"RT-DETR is the first real-time end-to-end object detector, built on an efficient hybrid encoder that decouples intra-scale interaction and cross-scale fusion, plus IoU-aware query selection. RT-DETR-R50 achieves 53.1 mAP at 108 FPS on COCO, beating comparably sized YOLO detectors in both speed and accuracy while eliminating NMS entirely; its Figure 1 accuracy–latency plot became the reference for later real-time detectors.",content_truncated:!1,metadata:S({arxiv_id:"2304.08069",authors:[{name:"Y. Zhao"},{name:"W. Lv"},{name:"S. Xu"}],published:"2023-04-17",conference:"CVPR 2024",citation_count:2310,tasks:[w,x],methods:[{name:"DETR",slug:"detr"}],repositories:[{url:"https://github.com/lyuwenyu/RT-DETR",stars:9400}]})},"2405.14458":{route_id:"2405.14458",title:"YOLOv10: Real-Time End-to-End Object Detection",content:"YOLOv10 removes NMS from the YOLO pipeline via consistent dual assignments during training and applies a holistic efficiency–accuracy driven design across the architecture. YOLOv10-S is 1.8x faster than RT-DETR-R18 at similar COCO accuracy; the family spans 46.3–54.4 mAP with substantially lower end-to-end latency than prior YOLOs because post-processing disappears.",content_truncated:!1,metadata:S({arxiv_id:"2405.14458",authors:[{name:"A. Wang"},{name:"H. Chen"},{name:"L. Liu"}],published:"2024-05-23",conference:"NeurIPS 2024",citation_count:1650,tasks:[w,x],methods:[{name:"NMS-free Training",slug:"nms-free-training"}],repositories:[{url:"https://github.com/THU-MIG/yolov10",stars:44200}]})},"2401.17270":{route_id:"2401.17270",title:"YOLO-World: Real-Time Open-Vocabulary Object Detection",content:"YOLO-World extends the YOLO paradigm to open-vocabulary detection through vision-language modeling with a re-parameterizable vision-language path aggregation network (RepVL-PAN) and region-text contrastive pretraining. It detects categories never seen at training time while running at 35+ FPS, and its prompt-then-detect deployment re-parameterizes text embeddings for zero runtime text-encoder cost.",content_truncated:!1,metadata:S({arxiv_id:"2401.17270",authors:[{name:"T. Cheng"},{name:"L. Song"},{name:"Y. Ge"}],published:"2024-01-30",conference:"CVPR 2024",citation_count:890,tasks:[{name:"Open-Vocabulary Object Detection",slug:"open-vocabulary-object-detection"},w],methods:[{name:"Contrastive Learning",slug:"contrastive-learning"}],repositories:[{url:"https://github.com/AILab-CVC/YOLO-World",stars:16800}]})},158342:{route_id:"158342",title:"Ultralytics YOLO: real-time detection framework and model zoo",content:"Official Ultralytics framework release covering YOLO11 and YOLOv12 deployment: pretrained COCO checkpoints from nano to x-large, TensorRT/ONNX/CoreML export paths, and reproducible latency benchmarks on T4, Jetson Orin, and CPU targets. Widely used as the practical baseline for real-time detection deployments.",content_truncated:!1,metadata:S({source:"external",source_url:"https://docs.ultralytics.com/models/",authors:[{name:"Ultralytics"}],published:"2025-01-02",tasks:[w,x],repositories:[{url:"https://github.com/ultralytics/ultralytics",stars:46e3}],project_pages:[{url:"https://docs.ultralytics.com"}]})}},de=e=>e.map(t=>He[t]),J=de(["2502.12524","2407.17140","2410.13842","2406.03459","2304.08069","2405.14458","2401.17270","158342"]),Q=de(["2410.13842","2502.12524","2407.17140","2405.14458","2304.08069"]),Z="The user wants the current state-of-the-art for real-time object detection. That's a moving target split across two lineages — the YOLO family (fast CNN one-stage detectors) and the DETR family (transformer, end-to-end, NMS-free). I should ground the answer in recent papers benchmarked on COCO with reported latency or FPS, not just accuracy. Let me start with a broad hybrid search, see which papers surface, then run a second, narrower query to pin down the head-to-head COCO mAP vs latency trade-offs before I write anything.",ee="Good — both lineages are well represented. YOLOv12, YOLOv10 and RT-DETRv2 / D-FINE keep coming up. To actually rank them I need the accuracy-vs-latency numbers side by side on the same COCO val2017 protocol, so let me narrow the query to the benchmark comparison specifically.",te=`There isn't a single winner — real-time object detection in 2026 is a two-horse race between the [YOLO family](paper:2502.12524) (fast one-stage CNNs) and the end-to-end [DETR family](paper:2304.08069) (NMS-free transformers). Which one is “SOTA” depends entirely on where you sit on the accuracy-vs-latency curve. + +**At the fast / edge end**, [YOLOv12](paper:2502.12524) is the current leader. Its area-attention design pushes attention into the YOLO backbone without the usual latency hit — YOLOv12-N reaches 40.6 mAP at ~1.6 ms on a T4, roughly +1.5 mAP over [YOLOv10](paper:2405.14458) at matched speed. [YOLOv10](paper:2405.14458) is still very relevant because it made the YOLO head NMS-free, cutting real end-to-end latency. + +**At the high-accuracy end**, the transformer detectors win. [D-FINE](paper:2410.13842) currently holds the accuracy-latency Pareto front, reporting 55.8 mAP by reformulating box regression as fine-grained distribution refinement with self-distillation. It builds on [RT-DETRv2](paper:2407.17140), which hardened the [original RT-DETR](paper:2304.08069) recipe (the paper that first showed DETRs beating YOLOs in real time) with training-only “bag-of-freebies” that add no inference cost. + +**My recommendation:** for edge or high-FPS deployment, start with [YOLOv12](paper:2502.12524) — the [Ultralytics framework](paper:158342) has ready-made checkpoints and export paths. If you have GPU headroom and want maximum accuracy while staying real-time, use [D-FINE](paper:2410.13842) or [RT-DETRv2](paper:2407.17140). And if you need open-vocabulary detection rather than fixed COCO classes, [YOLO-World](paper:2401.17270) is the one to look at.`,Ue=["How do these compare on edge devices like Jetson?","Show me open-vocabulary detectors","What about small-object detection?"];async function*Ve(e,t){const r=()=>(t==null?void 0:t.aborted)===!0,n=e.trim().slice(0,90)||"state-of-the-art real-time object detection";if(yield{type:"stream_start",request_id:"req_mock",session_id:null},await g(350,t),!r()){yield{type:"reasoning_start"};for(let o=0;o=0;t-=1)if(e[t].role==="user")return e[t]}function vt(e){return{text:(e==null?void 0:e.text)??"",paperMentions:(e==null?void 0:e.paperMentions)??[],...e!=null&&e.paperSelection?{paperSelection:e.paperSelection}:{}}}function St(e){const t={};for(const r of e)for(const n of r.blocks??[])if(n.kind==="tool")for(const o of n.results??[])t[o.route_id]=o;return t}const he=()=>{const t=String("0").trim().toLowerCase();return t==="1"||t==="true"||t==="yes"},wt=()=>!0;class H extends Error{constructor(t,r,n,o){super(t),this.code=r,this.status=n,this.retryAfterSeconds=o,this.name="ChatStreamError"}}class re extends Error{constructor(t="The assistant stream was interrupted."){super(t),this.name="ChatTransportError"}}function bt(e,t){if(he())try{k.reportLatency(e,t).catch(()=>{})}catch{}}function Ot(e,t={}){return he()?$e(e,t):Ve(e.message,t.signal)}function Tt(e,t={}){return Be(e,t)}async function*$e(e,t){try{const r=await k.stream(e,t.signal);yield*me(r,t)}catch(r){throw fe(r)}}async function*Be(e,t){try{const r=await k.resumeStream(e,t.signal,t.afterSequence);yield*me(r,t)}catch(r){throw fe(r)}}function fe(e){return e instanceof H||e instanceof re?e:e instanceof SyntaxError?new H("The assistant returned an invalid stream event.","invalid_stream_event"):new re(e instanceof Error?e.message:"The assistant stream was interrupted.")}function Ke(e){let t=null,r="message";const n=[];for(const o of e.split(` +`))if(o.startsWith("id:")){const s=o.slice(3).trim();/^[1-9]\d*$/.test(s)&&(t=Number(s))}else o.startsWith("event:")?r=o.slice(6).trimStart():o.startsWith("data:")&&n.push(o.slice(5).trimStart());return{sequence:t,event:r,data:n.join(` +`)}}async function*me(e,t){var i;if(!e.ok||!e.body){const a=e.ok?null:new Ce(e,await e.text());a&&xe(a);const u=a==null?void 0:a.detail,d=typeof u=="object"&&u!==null?u:null,h=e.status===403&&!u,l=Number(e.headers.get("Retry-After")),O=Number.isFinite(l)&&l>=0?Math.min(300,Math.ceil(l)):void 0;throw new H(h?"Chat on staging is limited to approved Hugging Face users. Sign in with an approved account and try again.":(a==null?void 0:a.message)||`Chat stream failed (${e.status})`,d&&"code"in d&&typeof d.code=="string"?d.code:h?"staging_access_required":void 0,e.status,O)}const r=e.body.getReader(),n=new TextDecoder;let o="",s=t.afterSequence&&t.afterSequence>0?t.afterSequence:0;try{for(;;){const{done:a,value:u}=await r.read();if(a)break;o+=n.decode(u,{stream:!0});let d;for(;(d=o.indexOf(` + +`))!==-1;){const h=o.slice(0,d);o=o.slice(d+2);const l=Ke(h);if(!l.data||l.data==="[DONE]"||l.sequence!==null&&l.sequence<=s)continue;const O=JSON.parse(l.data);l.sequence!==null&&(s=l.sequence,(i=t.onSequence)==null||i.call(t,l.sequence)),yield O}}}finally{r.releaseLock()}}const A="pwc:chat-oauth-draft",R="pwc:chat-oauth-model",b="pwc:chat-oauth-auto-send",j="pwc:chat-oauth-attempted",U="pwc:chat-reasoning-effort";function ge(e){try{return je(JSON.parse(e),e)??N(e)}catch{}return N(e)}function Et(e,t,r={}){const n=typeof e=="string"?e:e.text,o=n.length-n.trimStart().length,s=n.trim();if(!s)return;const i=o+s.length,a=typeof e=="string"?[]:e.paperMentions.filter(d=>d.start>=o&&d.end<=i).map(d=>({...d,start:d.start-o,end:d.end-o})),u={text:s,paperMentions:a,...typeof e!="string"&&e.paperSelection?{paperSelection:e.paperSelection}:{}};sessionStorage.setItem(A,u.paperMentions.length||u.paperSelection?JSON.stringify(u):s),r.autoSend===!1?sessionStorage.removeItem(b):sessionStorage.setItem(b,"1"),t?sessionStorage.setItem(R,t):sessionStorage.removeItem(R),sessionStorage.setItem(U,r.reasoningEffort??pe)}function Ct(){var n;if(typeof window>"u"||sessionStorage.getItem(b)!=="1")return null;const e=(n=sessionStorage.getItem(A))==null?void 0:n.trim();if(!e)return null;const t=ge(e),r=t.text.trim();return r?{draft:{...t,text:r},model:sessionStorage.getItem(R)}:null}function xt(){const e=sessionStorage.getItem(A);return e?{draft:ge(e),autoSend:sessionStorage.getItem(b)==="1"}:null}function Rt(e,t,r){sessionStorage.setItem(A,JSON.stringify(e)),sessionStorage.setItem(R,t),sessionStorage.setItem(U,r),sessionStorage.setItem(b,"1"),sessionStorage.setItem(j,"1")}function kt(e,t){sessionStorage.setItem(A,JSON.stringify(e)),sessionStorage.setItem(R,t),sessionStorage.removeItem(b),sessionStorage.removeItem(j)}const At=()=>sessionStorage.getItem(j)==="1",Dt=()=>sessionStorage.getItem(R),It=()=>sessionStorage.removeItem(A),Lt=()=>sessionStorage.removeItem(b);function Mt(){sessionStorage.removeItem(A),sessionStorage.removeItem(R),sessionStorage.removeItem(b),sessionStorage.removeItem(j),sessionStorage.removeItem(U)}const _={class:"draft"},ne={hf_inference_billing_exhausted:{class:"provider",restoredMessage:"Hugging Face could not bill this request. Your included credits may be exhausted; enable or review pay-as-you-go billing in Settings.",actions:["hf_billing"]},hf_inference_billing_required:{actions:["reauthorize"]},hf_inference_credential_expired:{restoredMessage:"Your Hugging Face Inference Providers authorization is missing or expired. Re-sign in with Hugging Face to continue.",actions:["reauthorize"]},hf_sponsored_unavailable:{actions:["retry_with_luna"]},openrouter_monthly_budget_exhausted:{class:"provider",restoredMessage:"The remaining shared Papers With Code OpenRouter allowance was not enough to continue this response.",actions:["openrouter_budget"]},openrouter_staging_funding_disabled:{restoredMessage:"Shared staging credits have ended because chat is now live on paperswithcode.co. Continue there with your included monthly allowance.",actions:["continue_on_production"]},openrouter_unavailable:{class:"provider",restoredMessage:"OpenRouter is currently unavailable. However, you can still bring your own key in Settings.",actions:["openrouter_unavailable"]},openrouter_byok_credential_invalid:{class:"provider",restoredMessage:"Your OpenRouter API key is no longer valid. Reconnect it in Settings, then try again.",actions:["openrouter_settings"]},openrouter_byok_billing_error:{class:"provider",restoredMessage:"Your OpenRouter key is connected, but OpenRouter rejected billing for the account behind it. A key spending limit is not an account credit balance. Add credits or enable pay-as-you-go in OpenRouter, then try again.",actions:["openrouter_billing"]},openrouter_byok_rate_limit:{class:"provider",restoredMessage:"Your OpenRouter API key is temporarily rate-limited.",actions:["openrouter_settings"]},openai_budget_exhausted:{restoredMessage:"The Papers With Code direct OpenAI allowance is exhausted. Select another model or try again later."},provider_rate_limit:{restoredMessage:"The selected model is temporarily rate-limited. Try again shortly."},provider_timeout:{restoredMessage:"The model provider timed out. Try again shortly."},provider_error:{restoredMessage:"The model provider failed before completing the response. You can edit and retry your question.",actions:["retry"]},provider_unavailable:{restoredMessage:"The model provider failed before completing the response. You can edit and retry your question."},context_too_large:{restoredMessage:"This conversation is too large for the selected model. Start a new chat or shorten the context.",actions:["retry"]},persistence_error:{restoredMessage:"The response could not be saved. You can edit and retry your question.",actions:["retry"]},transcript_mirror_error:{restoredMessage:"The conversation could not be saved. Please try again in a new chat."},external_worker_lost:{restoredMessage:"The assistant worker lost contact before the response could be saved. You can edit and retry your question."},chat_disabled_interrupted:{display:{kind:"fixed",text:"Chat was disabled while this response was running. The partial response is saved. Please try again later."}},chat_session_quota_exceeded:{display:{kind:"raw"},actions:["archive_chats"]},paper_context_unavailable:_,paper_mention_unavailable:_,paper_mentions_disabled:_,paper_selection_disabled:_,paper_selection_requires_reader:_,paper_selection_paper_mismatch:_,paper_selection_version_mismatch:_,paper_selection_page_invalid:_,paper_selection_too_large:_,chat_storage_quota_exceeded:_},q=e=>e&&Object.prototype.hasOwnProperty.call(ne,e)?ne[e]:void 0;function Pt(e){var t;return(t=q(e))==null?void 0:t.class}function Ge(e){var t;return((t=q(e))==null?void 0:t.restoredMessage)??"The response did not complete. You can edit and retry your question."}function Nt(e,t){var n;const r=(n=q(e))==null?void 0:n.display;return(r==null?void 0:r.kind)==="fixed"?r.text:(r==null?void 0:r.kind)==="raw"?t:`The assistant hit an error: ${t}`}function Yt(e){var t;return((t=q(e))==null?void 0:t.actions)??[]}const ye="gpt-5.6-luna@openai",ze="deepseek-ai/DeepSeek-V4-Flash-0731",Xe="openai/gpt-5.6-luna",_e="deepseek-ai/DeepSeek-V4.1-Flash-1017";function Ft(e,t){var r;return((r=e.find(n=>n.id===t))==null?void 0:r.provider)??(t===Xe?"openrouter":t===ye?"openai":"huggingface")}function jt(e,t){const r=e.find(n=>n.id===t);return r?r.sponsored===!0:t===_e}const qt=[{id:ye,label:"GPT-6 Luna",provider:"openai"},{id:_e,label:"DeepSeek V4.1 Flash",provider:"huggingface",sponsored:!0}],Wt=[{id:ze,label:"DeepSeek V4 Flash",provider:"huggingface"},{id:"moonshotai/Kimi-K3",label:"Kimi K3",provider:"huggingface"},{id:"gpt-5.6-luna@openrouter",label:"GPT-5.6 Luna",provider:"openrouter"},{id:"gpt-5.6-luna@openai",label:"GPT-6 Luna (Direct)",provider:"openai"}];async function Ht(){const e=[];let t=null;do{const r=await k.listSessions(t);e.push(...r.items),t=r.next_cursor}while(t&&e.length<100);return e}function Ut(e){return k.createSession(e,pe)}function ve(e,t){return e.display_blocks.length===0&&e.content?[{kind:"answer",text:e.content,done:!0}]:Se(e.display_blocks,t)}function Se(e,t){const r=e.map(n=>n.kind==="reasoning"?{...n,active:!1,open:!1}:n.kind==="tool"?{...n,status:n.status==="running"?"error":n.status,open:t&&(n.status==="error"||n.status==="denied"||n.status==="running")}:n.kind==="app"?{...n,schema_version:1,result:n.result??{content:[],structuredContent:{},isError:!1},csp:n.csp??{},permissions:n.permissions??{clipboardWrite:!0},height:n.height||525,public_fork:!!n.public_fork}:n.kind==="artifact"?{...n}:{...n,done:!0});return r.filter((n,o)=>{const s=r[o-1];return!(n.kind==="reasoning"&&(s==null?void 0:s.kind)==="reasoning"&&n.text===s.text)})}function we(e){if(e!=null&&e.text)return{routeId:e.route_id,paperVersion:e.paper_version,page:e.page,text:e.text}}function Vt(e){const t=r=>r==null||["cancelled","interrupted","stopped"].includes(r);return e.messages.flatMap(r=>{if(r.role==="assistant")return[{id:r.id,role:"assistant",blocks:ve(r,!0),followups:r.followups,citations:r.citations,finishReason:r.finish_reason??void 0,streaming:!1}];const n={id:r.id,role:"user",text:r.content,paperMentions:(r.paper_mentions??[]).map(s=>({...s,key:s.occurrence_id})),paperSelection:we(r.paper_selection),revision:r.revision,status:r.status,error:r.status==="complete"?void 0:r.error_code||r.status};if(!["error","interrupted"].includes(r.status))return[n];const o=r.status==="interrupted"&&t(r.error_code);return[n,{id:`${r.id}-${r.status==="interrupted"?"interrupted":"error"}`,role:"assistant",blocks:Se(r.display_blocks,!0),streaming:!1,finishReason:o?"stopped":void 0,error:o?void 0:Ge(r.error_code),errorCode:o?void 0:r.error_code??void 0}]})}function $t(e){return e.messages.map(t=>t.role==="user"?{id:t.id,role:"user",text:t.content,paperMentions:(t.paper_mentions??[]).map(r=>({...r,key:r.occurrence_id})),paperSelection:we(t.paper_selection)}:{id:t.id,role:"assistant",blocks:ve(t,!1),citations:t.citations,finishReason:t.finish_reason??void 0,error:t.error??void 0,streaming:!1})}function Bt(e){const t=Date.now(),r=new Date().setHours(0,0,0,0),n=[{label:"Today",items:[]},{label:"Previous 7 Days",items:[]},{label:"Previous 30 Days",items:[]},{label:"Older",items:[]}];for(const o of[...e].sort((s,i)=>Date.parse(i.updated_at)-Date.parse(s.updated_at))){const s=Date.parse(o.updated_at),i=t-s;s>=r?n[0].items.push(o):i<7*864e5?n[1].items.push(o):i<30*864e5?n[2].items.push(o):n[3].items.push(o)}return n.filter(o=>o.items.length>0)}export{nt as $,ot as A,At as B,mt as C,ye as D,pe as E,bt as F,re as G,Tt as H,Pt as I,H as J,Ot as K,wt as L,Vt as M,Ct as N,Lt as O,ct as P,Mt as Q,ut as R,ke as S,it as T,Yt as U,Nt as V,Ht as W,gt as X,ft as Y,rt as Z,tt as _,dt as a,lt as b,ht as c,Ut as d,et as e,St as f,he as g,at as h,pt as i,st as j,Bt as k,_t as l,vt as m,It as n,N as o,$t as p,Et as q,xt as r,Wt as s,qt as t,yt as u,Dt as v,Ft as w,jt as x,Rt as y,kt as z}; diff --git a/assets/chatSessions-Ck_dyM0d.js b/assets/chatSessions-Ck_dyM0d.js deleted file mode 100644 index 884b30955f111109da5f1d3a27f911b5dffbb8e5..0000000000000000000000000000000000000000 --- a/assets/chatSessions-Ck_dyM0d.js +++ /dev/null @@ -1,14 +0,0 @@ -import{j as h,V as f,b as ee,U as te,ab as Oe}from"./index-DyXq7-Tg.js";import{c as m}from"./chat-Ix1IrIwq.js";import{p as be}from"./papers-Dh3ljlL0.js";const Xe=({light:e})=>h.jsx("span",{className:`chat-spinner${e?" chat-spinner-light":""}`}),Qe=({open:e})=>h.jsx("svg",{className:`chat-chev${e?" chat-chev-open":""}`,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"m6 9 6 6 6-6"})}),Je=()=>h.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"12",cy:"12",r:"9"}),h.jsx("path",{d:"m9 12 2 2 4-4"})]}),Ze=({size:e=14})=>h.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"m21 21-4.3-4.3"})]}),et=()=>h.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",children:h.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})}),tt=()=>h.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M12 5v14M5 12h14"})}),rt=()=>h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[h.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),h.jsx("path",{d:"M9 4v16"})]}),nt=()=>h.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2M6 6l1 14a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-14"})}),at=({text:e,mentions:t,scrollTop:n=0,variant:r="composer",completion:a=""})=>{const i=[];let s=0;for(const o of[...t].sort((u,d)=>u.start-d.start)){const u=e.slice(o.start,o.end),d=u===o.title||u===`@${o.title}`;o.starte.length||!d||(i.push(e.slice(s,o.start)),i.push(h.jsx("span",{className:`chat-paper-inline-highlight${o.unavailable?" is-unavailable":""}`,"data-paper-route-id":o.route_id,children:u},o.key)),s=o.end)}return i.push(e.slice(s)),a&&i.push(h.jsx("span",{className:"chat-prompt-completion",children:a},"completion")),e.endsWith(` -`)&&i.push("​"),h.jsx("div",{"aria-hidden":"true",className:`chat-paper-highlight-layer chat-paper-highlight-layer-${r}`,children:h.jsx("div",{style:{transform:`translateY(-${n}px)`},children:i})})},ot=({open:e,query:t,results:n,activeIndex:r,loading:a,error:i,onSelect:s,id:o="chat-paper-picker",optionIdPrefix:u="chat-paper-option"})=>{if(!e)return null;const d=t.trim()?a?"Searching papers…":i?"Paper search is unavailable":n.length?`${n.length} paper${n.length===1?"":"s"} found`:"No papers found":"Type to search papers";return h.jsxs("div",{className:"chat-paper-picker",id:o,role:"listbox","aria-label":"Paper results",children:[h.jsx("div",{className:"chat-paper-picker-status",role:"status","aria-live":"polite",children:d}),n.map((p,l)=>{const O=p.arxiv_id||p.id,k=p.arxiv_id||(()=>{try{return p.source_url?new URL(p.source_url).hostname:"External resource"}catch{return"External resource"}})();return h.jsxs("button",{type:"button",id:`${u}-${l}`,role:"option","aria-selected":l===r,className:`chat-paper-option${l===r?" is-active":""}`,onMouseDown:P=>{P.preventDefault(),s(p)},children:[h.jsx("span",{className:"chat-paper-option-title",children:p.title}),h.jsx("span",{className:"chat-paper-option-meta",children:k})]},O)})]})},Te=["What are decision models?","Find relevant papers on RLVR","What's the state-of-the-art for real-time object detection?"],Ee=[...Te,"What are the latest papers on ","Which benchmarks are used for ","Which methods work best for ","How does ","Explain how ","Compare ","Summarize the key contributions of "],Ce=3,Re=4,xe=new Set(["about","all","and","are","best","can","compare","does","explain","find","for","from","give","how","into","latest","list","method","methods","model","models","new","paper","papers","recent","show","state","summarize","task","tasks","the","this","use","what","when","where","which","who","why","with","work"]),ke=new RegExp(`(?:^|(?<=[\\s("'“‘]))(?=\\S)`,"g"),Ae=e=>{const t=e.toLowerCase(),n=Ee.find(r=>r.length>e.length&&r.toLowerCase().startsWith(t));return n?n.slice(e.length):""},De=(e,t)=>{const n=[...e.matchAll(ke)].map(r=>r.index??0);for(const r of n.slice(-4)){const a=e.slice(r),i=a.toLowerCase(),s=/\s/.test(a);if(a.length<(s?Ce:Re)||!s&&xe.has(i))continue;const o=t.find(u=>u.length>a.length&&u.toLowerCase().startsWith(i));if(o)return o.slice(a.length)}return""},Le=(e,t)=>!e.trim()||/\s$/.test(e)?"":Ae(e)||De(e,t);function st(e,t=!1){var p;const n=e.text,[r,a]=f.useState(null),i=ee({queryKey:["chatAutocompleteVocabulary"],queryFn:()=>m.getAutocompleteVocabulary(),enabled:n.length>0,staleTime:1/0,gcTime:1/0,retry:!1}),s=(r==null?void 0:r.text)===n?r.atEnd:!0,o=e.paperMentions.some(l=>l.end===n.length);return{completion:!t&&s&&!o?Le(n,((p=i.data)==null?void 0:p.names)??[]):"",trackCaret:l=>a({text:l.value,atEnd:l.selectionStart===l.selectionEnd&&l.selectionEnd===l.value.length})}}const it=e=>e.key==="Tab"&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.nativeEvent.isComposing,ct=e=>{var n;const t=(n=e.parentElement)==null?void 0:n.querySelector(".chat-paper-highlight-layer");return Math.max(e.scrollHeight,(t==null?void 0:t.scrollHeight)??0)},re=8e3,ne=16384,ae=1e4,E={crossPage:"Select text within one PDF page.",outside:"Select text from the paper, not the surrounding interface.",tooLarge:"Select a shorter passage (maximum 8,000 characters)."};function oe(e){return new TextEncoder().encode(e).length}function se(e){return e.replace(/\r\n/g,` -`).replace(/\r/g,` -`).replace(/\u00a0/g," ").replace(/[^\S\n]+/g," ").trim()}function lt(e){return`${e.routeId}\0${e.paperVersion}\0${e.page}\0${e.text}`}function ut(e){return{route_id:e.routeId,paper_version:e.paperVersion,page:e.page,text:e.text}}function L(e="",t){return t?{text:e,paperMentions:[],paperSelection:t}:{text:e,paperMentions:[]}}function V(e,t,n){return e.paperSelection?{text:t,paperMentions:n,paperSelection:e.paperSelection}:{text:t,paperMentions:n}}function Pe(e){if(!e||typeof e!="object")return;const t=e;if(typeof t.routeId!="string"||!t.routeId.trim()||typeof t.paperVersion!="string"||!t.paperVersion.trim())return;const n=t.page;if(typeof n!="number"||!Number.isInteger(n)||n<1||n>ae||typeof t.text!="string")return;const r=se(t.text);if(r&&!(r.length>re)&&!(oe(r)>ne))return{routeId:t.routeId.trim(),paperVersion:t.paperVersion.trim(),page:n,text:r}}function Ie(e,t){if(typeof e=="string")return L(e);if(!e||typeof e!="object")return t===void 0?null:L(t);const n=e;if(typeof n.text!="string"||!Array.isArray(n.paperMentions))return t===void 0?null:L(t);const r=Pe(n.paperSelection);return r?{text:n.text,paperMentions:n.paperMentions,paperSelection:r}:{text:n.text,paperMentions:n.paperMentions}}function ie(e){return e?e instanceof Element?e:e.parentElement:null}function $(e,t){const n=ie(e);if(!n||!t.contains(n)||!n.closest(".textLayer, .reader-web-document"))return null;const r=n.closest(".pdf-page[data-page], .reader-web-document[data-page]");if(!r||!t.contains(r))return null;const a=Number(r.dataset.page);return!Number.isInteger(a)||a<1||a>ae?null:a}function dt(e){const{selection:t,pagesRoot:n,routeId:r,paperVersion:a,numPages:i}=e;if(!n||!t||t.rangeCount!==1)return t&&t.rangeCount>1?{ok:!1,error:E.crossPage}:{ok:!1,error:null};const s=t.getRangeAt(0);if(s.collapsed)return{ok:!1,error:null};const o=$(s.startContainer,n),u=$(s.endContainer,n),d=ie(s.commonAncestorContainer);if(!d||!n.contains(d))return{ok:!1,error:E.outside};if(o===null||u===null)return{ok:!1,error:E.outside};if(o!==u)return{ok:!1,error:E.crossPage};if(i&&(o<1||o>i))return{ok:!1,error:E.crossPage};const p=t.toString(),l=se(p);return l?l.length>re||oe(l)>ne?{ok:!1,error:E.tooLarge}:{ok:!0,selection:{routeId:r,paperVersion:a,page:o,text:l}}:{ok:!1,error:E.crossPage}}const Ne=10,Me=3;function B(e,t){const r=e.slice(0,t).lastIndexOf("@");if(r<0)return null;const a=r>0?e[r-1]:"";if(a&&/[\p{L}\p{M}\p{N}_@]/u.test(a))return null;const i=e.slice(r+1,t);return/[\n\r@]/.test(i)?null:{start:r,end:t,query:i}}function K(e,t,n){let r=0;for(;ro.end<=r?[o]:o.start>=i?[{...o,start:o.start+s,end:o.end+s}]:[])}function ht({draft:e,onChange:t,enabled:n,textareaRef:r}){var q;const a=`chat-paper-picker-${f.useId().replace(/:/g,"")}`,i=`${a}-option`,[s,o]=f.useState(null),[u,d]=f.useState(""),[p,l]=f.useState(0),[O,k]=f.useState(""),P=f.useRef(new Set);f.useEffect(()=>{n||o(null)},[n]),f.useEffect(()=>{const c=window.setTimeout(()=>d((s==null?void 0:s.query.trim())??""),150);return()=>window.clearTimeout(c)},[s==null?void 0:s.query]);const R=ee({queryKey:["chat-paper-mention-search",u.toLowerCase()],queryFn:({signal:c})=>be.search(u,1,10,"hybrid",c),enabled:n&&!!s&&u.length>=1,staleTime:3e4,refetchOnWindowFocus:!1,retry:!1}),_=f.useMemo(()=>{var c;return((c=R.data)==null?void 0:c.results)??[]},[(q=R.data)==null?void 0:q.results]);f.useEffect(()=>l(0),[u]),f.useEffect(()=>{var c;(c=document.getElementById(`${i}-${p}`))==null||c.scrollIntoView({block:"nearest"})},[p,i]);const _e=f.useCallback(c=>{var w;if(!n){o(null);return}const g=c??((w=r.current)==null?void 0:w.selectionStart)??e.text.length;if(e.paperMentions.some(b=>g>b.start&&g<=b.end)){o(null);return}o(B(e.text,g))},[e.paperMentions,e.text,n,r]),we=f.useCallback((c,g)=>{var A;const w=K(e.text,c,e.paperMentions),b=V(e,c,w);t(b);const T=g??((A=r.current)==null?void 0:A.selectionStart)??c.length;n&&!w.some(D=>T>D.start&&T<=D.end)?o(B(c,T)):o(null)},[e,n,t,r]),j=f.useCallback(c=>{if(!s)return!1;const g=c.arxiv_id||c.id,w=new Set(e.paperMentions.map(x=>x.route_id));if(e.paperMentions.length>=Ne)return k("A message can contain at most 10 paper mentions."),!1;if(!w.has(g)&&w.size>=Me)return k("A message can attach at most 3 distinct papers."),!1;const b=c.title,T=e.text.slice(s.end),A=T.length===0,D=e.text.slice(0,s.start)+b+(A?" ":"")+T,Se=K(e.text,D,e.paperMentions),H={key:crypto.randomUUID(),route_id:g,title:c.title,source:c.source==="external"?"external":"arxiv",start:s.start,end:s.start+b.length};return t(V(e,D,[...Se,H].sort((x,I)=>x.start-I.start))),o(null),k(""),window.requestAnimationFrame(()=>{var I,U;const x=H.end+(A||T.startsWith(" ")?1:0);(I=r.current)==null||I.focus(),(U=r.current)==null||U.setSelectionRange(x,x)}),P.current.has(g)||(P.current.add(g),m.prewarmPaperContext(g).catch(()=>{})),!0},[s,e,t,r]),ve=f.useCallback(c=>!s||c.nativeEvent.isComposing?!1:c.key==="Tab"?(o(null),!1):c.key==="Escape"?(c.preventDefault(),o(null),!0):c.key==="ArrowDown"||c.key==="ArrowUp"?(c.preventDefault(),_.length&&l(g=>c.key==="ArrowDown"?(g+1)%_.length:(g-1+_.length)%_.length),!0):c.key==="Home"&&_.length?(c.preventDefault(),l(0),!0):c.key==="End"&&_.length?(c.preventDefault(),l(_.length-1),!0):c.key==="Enter"&&!c.shiftKey?(c.preventDefault(),_[p]?j(_[p]):R.isFetching||o(null),!0):!1,[s,p,_,R.isFetching,j]);return{open:!!s,query:(s==null?void 0:s.query)??"",results:_,activeIndex:p,loading:R.isFetching,error:R.isError,message:O,pickerId:a,optionIdPrefix:i,updateText:we,refresh:_e,select:j,keyDown:ve,close:()=>o(null)}}const y=(e,t)=>new Promise(n=>{const r=setTimeout(a,e);function a(){t==null||t.removeEventListener("abort",a),clearTimeout(r),n()}t==null||t.addEventListener("abort",a)}),v=e=>({arxiv_id:null,source:"arxiv",source_url:null,thumbnail_url:null,authors:[],published:null,conference:null,citation_count:null,tasks:[],methods:[],repositories:[],project_pages:[],...e}),S={name:"Object Detection",slug:"object-detection"},C={name:"Real-Time Object Detection",slug:"real-time-object-detection"},Ye={"2502.12524":{route_id:"2502.12524",title:"YOLOv12: Attention-Centric Real-Time Object Detectors",content:"Enhancing the network architecture of the YOLO framework has been crucial for a long time. This work introduces an attention-centric YOLO framework, namely YOLOv12, built around area attention and residual efficient layer aggregation networks (R-ELAN). YOLOv12-N reaches 40.6 mAP at 1.64 ms on a T4 GPU, closing the gap to attention-based detectors without the usual latency penalty and surpassing YOLOv10/YOLOv11 by +1.2–1.6 mAP at matched latency.",content_truncated:!1,metadata:v({arxiv_id:"2502.12524",authors:[{name:"Y. Tian"},{name:"Q. Ye"},{name:"D. Doermann"}],published:"2025-02-18",citation_count:412,tasks:[S,C],methods:[{name:"Area Attention",slug:"area-attention"}],repositories:[{url:"https://github.com/sunsmarterjie/yolov12",stars:18700}]})},"2407.17140":{route_id:"2407.17140",title:"RT-DETRv2: Improved Baseline with Bag-of-Freebies for Real-Time Detection",content:"RT-DETRv2 improves the real-time DETR baseline with selective multi-scale feature extraction, a discrete sampling operator to ease deployment, and training-only 'bag-of-freebies' that add no inference cost. RT-DETRv2-R18/R50/R101 reach 47.9 / 53.4 / 54.3 mAP on COCO at 217 / 108 / 74 FPS on T4 TensorRT FP16, remaining NMS-free end to end.",content_truncated:!1,metadata:v({arxiv_id:"2407.17140",authors:[{name:"W. Lv"},{name:"Y. Zhao"},{name:"J. Chang"}],published:"2024-07-24",citation_count:268,tasks:[S,C],methods:[{name:"DETR",slug:"detr"}],repositories:[{url:"https://github.com/lyuwenyu/RT-DETR",stars:9400}]})},"2410.13842":{route_id:"2410.13842",title:"D-FINE: Redefining Regression as Fine-grained Distribution Refinement",content:"D-FINE reformulates bounding-box regression in DETR-style detectors as iterative refinement of probability distributions (FDR) and adds a localization self-distillation scheme (GO-LSD). D-FINE-L reaches 54.0 mAP at ~9 ms and D-FINE-X 55.8 mAP on COCO while staying real-time on modern GPUs, dominating RT-DETRv2 and YOLOv10 on the accuracy–latency Pareto front.",content_truncated:!1,metadata:v({arxiv_id:"2410.13842",authors:[{name:"Y. Peng"},{name:"H. Li"},{name:"P. Wu"}],published:"2024-10-17",conference:"ICLR 2025",citation_count:187,tasks:[S,C],methods:[{name:"Knowledge Distillation",slug:"knowledge-distillation"}],repositories:[{url:"https://github.com/Peterande/D-FINE",stars:12100}]})},"2406.03459":{route_id:"2406.03459",title:"LW-DETR: A Transformer Replacement to YOLO for Real-Time Detection",content:"LW-DETR pairs a plain ViT encoder with a lightweight DETR decoder and shows the combination outperforms YOLOv8 and YOLO-NAS at comparable latency, arguing transformer detectors are viable even at the fast end of the accuracy–latency curve. Uses multi-level feature aggregation, window-attention interleaving, and IoU-aware classification.",content_truncated:!1,metadata:v({arxiv_id:"2406.03459",authors:[{name:"Q. Chen"},{name:"X. Su"},{name:"X. Zhang"}],published:"2024-06-05",citation_count:94,tasks:[S,C],methods:[{name:"Vision Transformer",slug:"vision-transformer"}],repositories:[{url:"https://github.com/Atten4Vis/LW-DETR",stars:5200}]})},"2304.08069":{route_id:"2304.08069",title:"DETRs Beat YOLOs on Real-time Object Detection",content:"RT-DETR is the first real-time end-to-end object detector, built on an efficient hybrid encoder that decouples intra-scale interaction and cross-scale fusion, plus IoU-aware query selection. RT-DETR-R50 achieves 53.1 mAP at 108 FPS on COCO, beating comparably sized YOLO detectors in both speed and accuracy while eliminating NMS entirely; its Figure 1 accuracy–latency plot became the reference for later real-time detectors.",content_truncated:!1,metadata:v({arxiv_id:"2304.08069",authors:[{name:"Y. Zhao"},{name:"W. Lv"},{name:"S. Xu"}],published:"2023-04-17",conference:"CVPR 2024",citation_count:2310,tasks:[S,C],methods:[{name:"DETR",slug:"detr"}],repositories:[{url:"https://github.com/lyuwenyu/RT-DETR",stars:9400}]})},"2405.14458":{route_id:"2405.14458",title:"YOLOv10: Real-Time End-to-End Object Detection",content:"YOLOv10 removes NMS from the YOLO pipeline via consistent dual assignments during training and applies a holistic efficiency–accuracy driven design across the architecture. YOLOv10-S is 1.8x faster than RT-DETR-R18 at similar COCO accuracy; the family spans 46.3–54.4 mAP with substantially lower end-to-end latency than prior YOLOs because post-processing disappears.",content_truncated:!1,metadata:v({arxiv_id:"2405.14458",authors:[{name:"A. Wang"},{name:"H. Chen"},{name:"L. Liu"}],published:"2024-05-23",conference:"NeurIPS 2024",citation_count:1650,tasks:[S,C],methods:[{name:"NMS-free Training",slug:"nms-free-training"}],repositories:[{url:"https://github.com/THU-MIG/yolov10",stars:44200}]})},"2401.17270":{route_id:"2401.17270",title:"YOLO-World: Real-Time Open-Vocabulary Object Detection",content:"YOLO-World extends the YOLO paradigm to open-vocabulary detection through vision-language modeling with a re-parameterizable vision-language path aggregation network (RepVL-PAN) and region-text contrastive pretraining. It detects categories never seen at training time while running at 35+ FPS, and its prompt-then-detect deployment re-parameterizes text embeddings for zero runtime text-encoder cost.",content_truncated:!1,metadata:v({arxiv_id:"2401.17270",authors:[{name:"T. Cheng"},{name:"L. Song"},{name:"Y. Ge"}],published:"2024-01-30",conference:"CVPR 2024",citation_count:890,tasks:[{name:"Open-Vocabulary Object Detection",slug:"open-vocabulary-object-detection"},S],methods:[{name:"Contrastive Learning",slug:"contrastive-learning"}],repositories:[{url:"https://github.com/AILab-CVC/YOLO-World",stars:16800}]})},158342:{route_id:"158342",title:"Ultralytics YOLO: real-time detection framework and model zoo",content:"Official Ultralytics framework release covering YOLO11 and YOLOv12 deployment: pretrained COCO checkpoints from nano to x-large, TensorRT/ONNX/CoreML export paths, and reproducible latency benchmarks on T4, Jetson Orin, and CPU targets. Widely used as the practical baseline for real-time detection deployments.",content_truncated:!1,metadata:v({source:"external",source_url:"https://docs.ultralytics.com/models/",authors:[{name:"Ultralytics"}],published:"2025-01-02",tasks:[S,C],repositories:[{url:"https://github.com/ultralytics/ultralytics",stars:46e3}],project_pages:[{url:"https://docs.ultralytics.com"}]})}},ce=e=>e.map(t=>Ye[t]),G=ce(["2502.12524","2407.17140","2410.13842","2406.03459","2304.08069","2405.14458","2401.17270","158342"]),z=ce(["2410.13842","2502.12524","2407.17140","2405.14458","2304.08069"]),X="The user wants the current state-of-the-art for real-time object detection. That's a moving target split across two lineages — the YOLO family (fast CNN one-stage detectors) and the DETR family (transformer, end-to-end, NMS-free). I should ground the answer in recent papers benchmarked on COCO with reported latency or FPS, not just accuracy. Let me start with a broad hybrid search, see which papers surface, then run a second, narrower query to pin down the head-to-head COCO mAP vs latency trade-offs before I write anything.",Q="Good — both lineages are well represented. YOLOv12, YOLOv10 and RT-DETRv2 / D-FINE keep coming up. To actually rank them I need the accuracy-vs-latency numbers side by side on the same COCO val2017 protocol, so let me narrow the query to the benchmark comparison specifically.",J=`There isn't a single winner — real-time object detection in 2026 is a two-horse race between the [YOLO family](paper:2502.12524) (fast one-stage CNNs) and the end-to-end [DETR family](paper:2304.08069) (NMS-free transformers). Which one is “SOTA” depends entirely on where you sit on the accuracy-vs-latency curve. - -**At the fast / edge end**, [YOLOv12](paper:2502.12524) is the current leader. Its area-attention design pushes attention into the YOLO backbone without the usual latency hit — YOLOv12-N reaches 40.6 mAP at ~1.6 ms on a T4, roughly +1.5 mAP over [YOLOv10](paper:2405.14458) at matched speed. [YOLOv10](paper:2405.14458) is still very relevant because it made the YOLO head NMS-free, cutting real end-to-end latency. - -**At the high-accuracy end**, the transformer detectors win. [D-FINE](paper:2410.13842) currently holds the accuracy-latency Pareto front, reporting 55.8 mAP by reformulating box regression as fine-grained distribution refinement with self-distillation. It builds on [RT-DETRv2](paper:2407.17140), which hardened the [original RT-DETR](paper:2304.08069) recipe (the paper that first showed DETRs beating YOLOs in real time) with training-only “bag-of-freebies” that add no inference cost. - -**My recommendation:** for edge or high-FPS deployment, start with [YOLOv12](paper:2502.12524) — the [Ultralytics framework](paper:158342) has ready-made checkpoints and export paths. If you have GPU headroom and want maximum accuracy while staying real-time, use [D-FINE](paper:2410.13842) or [RT-DETRv2](paper:2407.17140). And if you need open-vocabulary detection rather than fixed COCO classes, [YOLO-World](paper:2401.17270) is the one to look at.`,je=["How do these compare on edge devices like Jetson?","Show me open-vocabulary detectors","What about small-object detection?"];async function*Fe(e,t){const n=()=>(t==null?void 0:t.aborted)===!0,r=e.trim().slice(0,90)||"state-of-the-art real-time object detection";if(yield{type:"stream_start",request_id:"req_mock",session_id:null},await y(350,t),!n()){yield{type:"reasoning_start"};for(let a=0;a{const t=String("0").trim().toLowerCase();return t==="1"||t==="true"||t==="yes"},pt=()=>!0;class F extends Error{constructor(t,n,r,a){super(t),this.code=n,this.status=r,this.retryAfterSeconds=a,this.name="ChatStreamError"}}class Z extends Error{constructor(t="The assistant stream was interrupted."){super(t),this.name="ChatTransportError"}}function ft(e,t){if(ue())try{m.reportLatency(e,t).catch(()=>{})}catch{}}function mt(e,t={}){return ue()?We(e,t):Fe(e.message,t.signal)}function gt(e,t={}){return qe(e,t)}async function*We(e,t){try{const n=await m.stream(e,t.signal);yield*he(n,t)}catch(n){throw de(n)}}async function*qe(e,t){try{const n=await m.resumeStream(e,t.signal,t.afterSequence);yield*he(n,t)}catch(n){throw de(n)}}function de(e){return e instanceof F||e instanceof Z?e:e instanceof SyntaxError?new F("The assistant returned an invalid stream event.","invalid_stream_event"):new Z(e instanceof Error?e.message:"The assistant stream was interrupted.")}function He(e){let t=null,n="message";const r=[];for(const a of e.split(` -`))if(a.startsWith("id:")){const i=a.slice(3).trim();/^[1-9]\d*$/.test(i)&&(t=Number(i))}else a.startsWith("event:")?n=a.slice(6).trimStart():a.startsWith("data:")&&r.push(a.slice(5).trimStart());return{sequence:t,event:n,data:r.join(` -`)}}async function*he(e,t){var s;if(!e.ok||!e.body){const o=e.ok?null:new te(e,await e.text());o&&Oe(o);const u=o==null?void 0:o.detail,d=typeof u=="object"&&u!==null?u:null,p=e.status===403&&!u,l=Number(e.headers.get("Retry-After")),O=Number.isFinite(l)&&l>=0?Math.min(300,Math.ceil(l)):void 0;throw new F(p?"Chat on staging is limited to approved Hugging Face users. Sign in with an approved account and try again.":(o==null?void 0:o.message)||`Chat stream failed (${e.status})`,d&&"code"in d&&typeof d.code=="string"?d.code:p?"staging_access_required":void 0,e.status,O)}const n=e.body.getReader(),r=new TextDecoder;let a="",i=t.afterSequence&&t.afterSequence>0?t.afterSequence:0;try{for(;;){const{done:o,value:u}=await n.read();if(o)break;a+=r.decode(u,{stream:!0});let d;for(;(d=a.indexOf(` - -`))!==-1;){const p=a.slice(0,d);a=a.slice(d+2);const l=He(p);if(!l.data||l.data==="[DONE]"||l.sequence!==null&&l.sequence<=i)continue;const O=JSON.parse(l.data);l.sequence!==null&&(i=l.sequence,(s=t.onSequence)==null||s.call(t,l.sequence)),yield O}}}finally{n.releaseLock()}}const W="pwc:chat-oauth-draft",N="pwc:chat-oauth-model",M="pwc:chat-oauth-auto-send",Ue="pwc:chat-oauth-attempted",Y="pwc:chat-reasoning-effort";function yt(e,t,n={}){const r=typeof e=="string"?e:e.text,a=r.length-r.trimStart().length,i=r.trim();if(!i)return;const s=a+i.length,o=typeof e=="string"?[]:e.paperMentions.filter(d=>d.start>=a&&d.end<=s).map(d=>({...d,start:d.start-a,end:d.end-a})),u={text:i,paperMentions:o,...typeof e!="string"&&e.paperSelection?{paperSelection:e.paperSelection}:{}};sessionStorage.setItem(W,u.paperMentions.length||u.paperSelection?JSON.stringify(u):i),n.autoSend===!1?sessionStorage.removeItem(M):sessionStorage.setItem(M,"1"),t?sessionStorage.setItem(N,t):sessionStorage.removeItem(N),sessionStorage.setItem(Y,n.reasoningEffort??le)}function _t(){var r;if(typeof window>"u"||sessionStorage.getItem(M)!=="1")return null;const e=(r=sessionStorage.getItem(W))==null?void 0:r.trim();if(!e)return null;let t=L(e);try{t=Ie(JSON.parse(e),e)??L(e)}catch{}const n=t.text.trim();return n?{prompt:n,draft:{...t,text:n},model:sessionStorage.getItem(N),reasoningEffort:["low","medium","high","max"].includes(sessionStorage.getItem(Y)??"")?sessionStorage.getItem(Y):"low"}:null}function wt(){sessionStorage.removeItem(W),sessionStorage.removeItem(N),sessionStorage.removeItem(M),sessionStorage.removeItem(Ue),sessionStorage.removeItem(Y)}const pe="gpt-5.6-luna@openai",Ve="deepseek-ai/DeepSeek-V4-Flash-0731",$e="openai/gpt-5.6-luna",fe="deepseek-ai/DeepSeek-V4.1-Flash-1017";function vt(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.provider)??(t===$e?"openrouter":t===pe?"openai":"huggingface")}function St(e,t){const n=e.find(r=>r.id===t);return n?n.sponsored===!0:t===fe}const Ot=[{id:pe,label:"GPT-6 Luna",provider:"openai"},{id:fe,label:"DeepSeek V4.1 Flash",provider:"huggingface",sponsored:!0}],bt=[{id:Ve,label:"DeepSeek V4 Flash",provider:"huggingface"},{id:"moonshotai/Kimi-K3",label:"Kimi K3",provider:"huggingface"},{id:"gpt-5.6-luna@openrouter",label:"GPT-5.6 Luna",provider:"openrouter"},{id:"gpt-5.6-luna@openai",label:"GPT-6 Luna (Direct)",provider:"openai"}];class Be extends Error{constructor(t,n){super(t),this.status=n}}async function Tt(){const e=[];let t=null;do{const n=await m.listSessions(t);e.push(...n.items),t=n.next_cursor}while(t&&e.length<100);return e}function Et(e,t=le){return m.createSession(e,t)}function Ct(e){return m.getSession(e)}function Rt(e,t){return m.updateSession(e,t)}function xt(e){return m.removeSession(e)}function kt(){return m.archiveOldChats()}function At(){return m.archiveOldestChats()}function Dt(e){return m.cancelSession(e)}function Lt(e){return m.createOrRefreshShare(e)}async function Pt(e){try{return await m.getSharedChat(e)}catch(t){throw t instanceof te?new Be(t.message,t.status):t}}async function It(){return m.getModels()}function me(e,t){return e.display_blocks.length===0&&e.content?[{kind:"answer",text:e.content,done:!0}]:ge(e.display_blocks,t)}function ge(e,t){const n=e.map(r=>r.kind==="reasoning"?{...r,active:!1,open:!1}:r.kind==="tool"?{...r,status:r.status==="running"?"error":r.status,open:t&&(r.status==="error"||r.status==="denied"||r.status==="running")}:r.kind==="app"?{...r,schema_version:1,result:r.result??{content:[],structuredContent:{},isError:!1},csp:r.csp??{},permissions:r.permissions??{clipboardWrite:!0},height:r.height||525,public_fork:!!r.public_fork}:r.kind==="artifact"?{...r}:{...r,done:!0});return n.filter((r,a)=>{const i=n[a-1];return!(r.kind==="reasoning"&&(i==null?void 0:i.kind)==="reasoning"&&r.text===i.text)})}function ye(e){if(e!=null&&e.text)return{routeId:e.route_id,paperVersion:e.paper_version,page:e.page,text:e.text}}function Nt(e){const t=r=>r==="hf_inference_billing_exhausted"?"Hugging Face could not bill this request. Your included credits may be exhausted; enable or review pay-as-you-go billing in Settings.":r==="hf_inference_credential_expired"?"Your Hugging Face Inference Providers authorization is missing or expired. Re-sign in with Hugging Face to continue.":r==="provider_rate_limit"?"The selected model is temporarily rate-limited. Try again shortly.":r==="provider_timeout"?"The model provider timed out. Try again shortly.":r==="openrouter_monthly_budget_exhausted"?"The remaining shared Papers With Code OpenRouter allowance was not enough to continue this response.":r==="openrouter_staging_funding_disabled"?"Shared staging credits have ended because chat is now live on paperswithcode.co. Continue there with your included monthly allowance.":r==="openrouter_unavailable"?"OpenRouter is currently unavailable. However, you can still bring your own key in Settings.":r==="openrouter_byok_credential_invalid"?"Your OpenRouter API key is no longer valid. Reconnect it in Settings, then try again.":r==="openrouter_byok_billing_error"?"Your OpenRouter key is connected, but OpenRouter rejected billing for the account behind it. A key spending limit is not an account credit balance. Add credits or enable pay-as-you-go in OpenRouter, then try again.":r==="openrouter_byok_rate_limit"?"Your OpenRouter API key is temporarily rate-limited.":r==="openai_budget_exhausted"?"The Papers With Code direct OpenAI allowance is exhausted. Select another model or try again later.":r==="context_too_large"?"This conversation is too large for the selected model. Start a new chat or shorten the context.":["provider_error","provider_unavailable"].includes(r??"")?"The model provider failed before completing the response. You can edit and retry your question.":r==="persistence_error"?"The response could not be saved. You can edit and retry your question.":r==="transcript_mirror_error"?"The conversation could not be saved. Please try again in a new chat.":r==="external_worker_lost"?"The assistant worker lost contact before the response could be saved. You can edit and retry your question.":"The response did not complete. You can edit and retry your question.",n=r=>r==null||["cancelled","interrupted","stopped"].includes(r);return e.messages.flatMap(r=>{if(r.role==="assistant")return[{id:r.id,role:"assistant",blocks:me(r,!0),followups:r.followups,citations:r.citations,finishReason:r.finish_reason??void 0,streaming:!1}];const a={id:r.id,role:"user",text:r.content,paperMentions:(r.paper_mentions??[]).map(s=>({...s,key:s.occurrence_id})),paperSelection:ye(r.paper_selection),revision:r.revision,status:r.status,error:r.status==="complete"?void 0:r.error_code||r.status};if(!["error","interrupted"].includes(r.status))return[a];const i=r.status==="interrupted"&&n(r.error_code);return[a,{id:`${r.id}-${r.status==="interrupted"?"interrupted":"error"}`,role:"assistant",blocks:ge(r.display_blocks,!0),streaming:!1,finishReason:i?"stopped":void 0,error:i?void 0:t(r.error_code),errorCode:i?void 0:r.error_code??void 0}]})}function Mt(e){return e.messages.map(t=>t.role==="user"?{id:t.id,role:"user",text:t.content,paperMentions:(t.paper_mentions??[]).map(n=>({...n,key:n.occurrence_id})),paperSelection:ye(t.paper_selection)}:{id:t.id,role:"assistant",blocks:me(t,!1),citations:t.citations,finishReason:t.finish_reason??void 0,error:t.error??void 0,streaming:!1})}function Yt(e){const t=Date.now(),n=new Date().setHours(0,0,0,0),r=[{label:"Today",items:[]},{label:"Previous 7 Days",items:[]},{label:"Previous 30 Days",items:[]},{label:"Older",items:[]}];for(const a of[...e].sort((i,s)=>Date.parse(s.updated_at)-Date.parse(i.updated_at))){const i=Date.parse(a.updated_at),s=t-i;i>=n?r[0].items.push(a):s<7*864e5?r[1].items.push(a):s<30*864e5?r[2].items.push(a):r[3].items.push(a)}return r.filter(a=>a.items.length>0)}export{Je as $,et as A,pt as B,Be as C,pe as D,Ct as E,Nt as F,Tt as G,_t as H,bt as I,Ot as J,vt as K,St as L,W as M,N,Y as O,at as P,M as Q,Ue as R,Te as S,nt as T,wt as U,It as V,Ie as W,Rt as X,xt as Y,dt as Z,lt as _,st as a,Qe as a0,Ze as a1,ot as b,ct as c,Et as d,Xe as e,ue as f,Pt as g,tt as h,it as i,rt as j,Yt as k,Lt as l,At as m,kt as n,Z as o,Mt as p,yt as q,ft as r,gt as s,F as t,ht as u,L as v,le as w,Dt as x,ut as y,mt as z}; diff --git a/assets/chevron-up-DYSYRyvz.js b/assets/chevron-up-BwiJ46dh.js similarity index 91% rename from assets/chevron-up-DYSYRyvz.js rename to assets/chevron-up-BwiJ46dh.js index 4b76e66518ea0db72969e3920c04e80e11ce5057..b3fe2370adacc6088a7dc10649921367d63c7c7b 100644 --- a/assets/chevron-up-DYSYRyvz.js +++ b/assets/chevron-up-BwiJ46dh.js @@ -1,4 +1,4 @@ -import{s as o}from"./index-DyXq7-Tg.js";/** +import{s as o}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/circle-check-GGlu5UCV.js b/assets/circle-check-B2vTBhyc.js similarity index 87% rename from assets/circle-check-GGlu5UCV.js rename to assets/circle-check-B2vTBhyc.js index 21de91c199ce0dfca6e7b026156dab6f50681af4..041d5d27203ee362883c3bbedb75e0cef8e8eef1 100644 --- a/assets/circle-check-GGlu5UCV.js +++ b/assets/circle-check-B2vTBhyc.js @@ -1,4 +1,4 @@ -import{s as c}from"./index-DyXq7-Tg.js";/** +import{s as c}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/codex-DFj4KHqP.js b/assets/codex-CgFzL2AI.js similarity index 95% rename from assets/codex-DFj4KHqP.js rename to assets/codex-CgFzL2AI.js index 6e47b913c6a949944e5f305ddbd3452974580487..1009f02891744ae2f7fd6176ead0ea299990b780 100644 --- a/assets/codex-DFj4KHqP.js +++ b/assets/codex-CgFzL2AI.js @@ -1 +1 @@ -import{ac as i,a6 as c}from"./index-DyXq7-Tg.js";const u="No paper text was available yet. This job starts again automatically within an hour of the paper's Markdown being extracted.",r="/admin/codex-curation/jobs";class n{constructor(e){this.request=e}startPaperJob(e,t){return this.request(`/admin/codex-${e}/jobs`,{method:"POST",body:JSON.stringify({paper_id:t})})}getPaperJob(e,t){return this.request(`/admin/codex-${e}/jobs/${t}`)}cancelPaperJob(e,t){return this.request(`/admin/codex-${e}/jobs/${t}`,{method:"DELETE"})}listJobs(e=100,t={}){const a=new URLSearchParams({limit:String(e)});return Object.entries(t).forEach(([o,s])=>{s&&a.set(o,s)}),this.request(`${r}?${a}`,{cache:"no-store"})}retryJob(e){return this.request(`${r}/${e}/retry`,{method:"POST"})}cancelJob(e){return this.request(`${r}/${e}`,{method:"DELETE"})}async retryTrace(e){await this.request(`${r}/${e}/retry-trace`,{method:"POST"})}async setScheduler(e){await this.request(`${r}/scheduler/${e}`,{method:"POST"})}async promoteBenchmarkCandidate(e,t){await this.request(`${r}/benchmark-candidates/${e}/promote`,{method:"POST",body:JSON.stringify(t)})}async rollbackBenchmarkCandidate(e){await this.request(`${r}/benchmark-candidates/${e}/rollback`,{method:"POST"})}traceUrl(e){return c(`/api/v1${r}/${e}/trace`)}}const m=new n(i);export{u as A,m as c}; +import{ac as i,a5 as c}from"./index-CjdUkE4w.js";const u="No paper text was available yet. This job starts again automatically within an hour of the paper's Markdown being extracted.",r="/admin/codex-curation/jobs";class n{constructor(e){this.request=e}startPaperJob(e,t){return this.request(`/admin/codex-${e}/jobs`,{method:"POST",body:JSON.stringify({paper_id:t})})}getPaperJob(e,t){return this.request(`/admin/codex-${e}/jobs/${t}`)}cancelPaperJob(e,t){return this.request(`/admin/codex-${e}/jobs/${t}`,{method:"DELETE"})}listJobs(e=100,t={}){const a=new URLSearchParams({limit:String(e)});return Object.entries(t).forEach(([o,s])=>{s&&a.set(o,s)}),this.request(`${r}?${a}`,{cache:"no-store"})}retryJob(e){return this.request(`${r}/${e}/retry`,{method:"POST"})}cancelJob(e){return this.request(`${r}/${e}`,{method:"DELETE"})}async retryTrace(e){await this.request(`${r}/${e}/retry-trace`,{method:"POST"})}async setScheduler(e){await this.request(`${r}/scheduler/${e}`,{method:"POST"})}async promoteBenchmarkCandidate(e,t){await this.request(`${r}/benchmark-candidates/${e}/promote`,{method:"POST",body:JSON.stringify(t)})}async rollbackBenchmarkCandidate(e){await this.request(`${r}/benchmark-candidates/${e}/rollback`,{method:"POST"})}traceUrl(e){return c(`/api/v1${r}/${e}/trace`)}}const m=new n(i);export{u as A,m as c}; diff --git a/assets/copy-CxR0OKx2.js b/assets/copy-SoF5zg-g.js similarity index 89% rename from assets/copy-CxR0OKx2.js rename to assets/copy-SoF5zg-g.js index 9d0971f0de38b9f100bf5ac6c1beffb962f53885..385f536a040d8c4c228a9e5a002b13afdfc50a72 100644 --- a/assets/copy-CxR0OKx2.js +++ b/assets/copy-SoF5zg-g.js @@ -1,4 +1,4 @@ -import{s as e}from"./index-DyXq7-Tg.js";/** +import{s as e}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/curation-YeS7FBYf.js b/assets/curation-CyyuHfv5.js similarity index 96% rename from assets/curation-YeS7FBYf.js rename to assets/curation-CyyuHfv5.js index 16c9a899c953355b2efbe79167be4afe95115071..7e8aa5c6aa19c30c947d1a29527fda619bba450e 100644 --- a/assets/curation-YeS7FBYf.js +++ b/assets/curation-CyyuHfv5.js @@ -1 +1 @@ -var f=Object.defineProperty;var w=(i,e,t)=>e in i?f(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var d=(i,e,t)=>w(i,typeof e!="symbol"?e+"":e,t);import{U as l,b2 as g,ac as v}from"./index-DyXq7-Tg.js";const y={tasks:"tasks",methods:"methods",organizations:"organizations",repositories:"GitHub repositories",project_pages:"project pages",hf_artifacts:"Hugging Face artifacts",source_url:"source URL",x_threads:"X threads",evaluations:"evaluation results"};function _(i){return Object.prototype.hasOwnProperty.call(y,i)}const p="pwc:fresh-auth-edit",c="pwc:fresh-auth-mutation";function E(i){if(typeof window>"u")return;sessionStorage.setItem(p,i);const e=g("/api/v1/auth/hf/login");window.location.assign(`${e}?return_to=${encodeURIComponent(window.location.href)}`)}class S{constructor(e,t=E){d(this,"paperLoads",new Map);d(this,"evaluationLoads",new Map);this.request=e,this.recoverFreshAuth=t}primePaper(e,t=!1){t&&this.paperLoads.delete(e);let s=this.paperLoads.get(e);return s||(s=this.request(`/papers/${e}/curation-state`).catch(o=>{throw this.paperLoads.delete(e),o}),this.paperLoads.set(e,s)),s}primeEvaluations(e,t=!1){t&&this.evaluationLoads.delete(e);let s=this.evaluationLoads.get(e);return s||(s=this.request(`/evaluations/curation-state?paper_id=${e}`).catch(o=>{throw this.evaluationLoads.delete(e),o}),this.evaluationLoads.set(e,s)),s}async mutatePaper(e,t,s,o,a){const r=this.paperLoads.get(e);if(!r)throw new Error("The catalog version was not loaded when this editor opened. Close and reopen the editor.");const h=(await r).sections[t];if(!h)throw new Error(`Missing curation version for ${t}`);return this.mutate(t,o,s,h,a,`paper:${e}:${t}`)}async mutateEvaluations(e,t,s,o){const a=this.evaluationLoads.get(String(e));if(!a)throw new Error("The evaluation version was not loaded when this editor opened. Close and reopen the editor.");const r=(await a).version;return this.mutate("evaluations",s,t,r,o,`paper:${e}:evaluations`)}async mutate(e,t,s,o,a,r){const h=new Headers(a.headers);Object.entries(this.idempotencyHeaders(r,s,o)).forEach(([n,m])=>h.set(n,m));const u={...a,headers:h};try{const n=await this.request(t,u);return this.clearAttempt(u),n}catch(n){throw n instanceof l&&n.status===401&&n.code==="fresh_auth_required"?(this.saveFreshAuthMutation(e,t,s,u),this.recoverFreshAuth(e)):n instanceof l&&n.status===409&&(this.clearAttempt(u),typeof window<"u"&&window.dispatchEvent(new CustomEvent("pwc:catalog-conflict",{detail:{endpoint:t}}))),n}}freshAuthMutationDraft(){const e=sessionStorage.getItem(c);if(!e)return null;try{const t=JSON.parse(e);if(!t.endpoint.startsWith("/")||t.endpoint.startsWith("//")||!["POST","PUT","PATCH","DELETE"].includes(t.options.method))throw new Error("Invalid saved mutation draft");return t}catch{return sessionStorage.removeItem(c),null}}async resumeFreshAuthMutation(){const e=this.freshAuthMutationDraft();if(!e)throw new Error("No saved catalog edit is available.");const t=await this.request(e.endpoint,{method:e.options.method,body:e.options.body,headers:e.options.headers});return this.clearAttempt({headers:e.options.headers}),sessionStorage.removeItem(c),sessionStorage.removeItem(p),t}saveFreshAuthMutation(e,t,s,o){const a=Object.fromEntries(new Headers(o.headers).entries()),r=typeof o.body=="string"?o.body:void 0;sessionStorage.setItem(c,JSON.stringify({section:e,endpoint:t,payload:s,options:{method:(o.method??"POST").toUpperCase(),body:r,headers:a}}))}idempotencyHeaders(e,t,s){const o=`pwc:mutation:${e}:${JSON.stringify(t)}`,a=sessionStorage.getItem(o);if(a){const h=JSON.parse(a);return{"Idempotency-Key":h.key,"If-Match":h.version}}const r=crypto.randomUUID();return sessionStorage.setItem(o,JSON.stringify({key:r,version:s})),sessionStorage.setItem(`pwc:mutation-key:${r}`,o),{"Idempotency-Key":r,"If-Match":s}}clearAttempt(e){const t=new Headers(e.headers).get("Idempotency-Key");if(!t)return;const s=sessionStorage.getItem(`pwc:mutation-key:${t}`);s&&sessionStorage.removeItem(s),sessionStorage.removeItem(`pwc:mutation-key:${t}`),this.paperLoads.clear(),this.evaluationLoads.clear()}}const T=new S(v);export{p as F,y as P,_ as i,T as p}; +var f=Object.defineProperty;var w=(i,e,t)=>e in i?f(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var d=(i,e,t)=>w(i,typeof e!="symbol"?e+"":e,t);import{A as l,b2 as g,ac as v}from"./index-CjdUkE4w.js";const y={tasks:"tasks",methods:"methods",organizations:"organizations",repositories:"GitHub repositories",project_pages:"project pages",hf_artifacts:"Hugging Face artifacts",source_url:"source URL",x_threads:"X threads",evaluations:"evaluation results"};function _(i){return Object.prototype.hasOwnProperty.call(y,i)}const p="pwc:fresh-auth-edit",c="pwc:fresh-auth-mutation";function E(i){if(typeof window>"u")return;sessionStorage.setItem(p,i);const e=g("/api/v1/auth/hf/login");window.location.assign(`${e}?return_to=${encodeURIComponent(window.location.href)}`)}class S{constructor(e,t=E){d(this,"paperLoads",new Map);d(this,"evaluationLoads",new Map);this.request=e,this.recoverFreshAuth=t}primePaper(e,t=!1){t&&this.paperLoads.delete(e);let s=this.paperLoads.get(e);return s||(s=this.request(`/papers/${e}/curation-state`).catch(o=>{throw this.paperLoads.delete(e),o}),this.paperLoads.set(e,s)),s}primeEvaluations(e,t=!1){t&&this.evaluationLoads.delete(e);let s=this.evaluationLoads.get(e);return s||(s=this.request(`/evaluations/curation-state?paper_id=${e}`).catch(o=>{throw this.evaluationLoads.delete(e),o}),this.evaluationLoads.set(e,s)),s}async mutatePaper(e,t,s,o,a){const r=this.paperLoads.get(e);if(!r)throw new Error("The catalog version was not loaded when this editor opened. Close and reopen the editor.");const h=(await r).sections[t];if(!h)throw new Error(`Missing curation version for ${t}`);return this.mutate(t,o,s,h,a,`paper:${e}:${t}`)}async mutateEvaluations(e,t,s,o){const a=this.evaluationLoads.get(String(e));if(!a)throw new Error("The evaluation version was not loaded when this editor opened. Close and reopen the editor.");const r=(await a).version;return this.mutate("evaluations",s,t,r,o,`paper:${e}:evaluations`)}async mutate(e,t,s,o,a,r){const h=new Headers(a.headers);Object.entries(this.idempotencyHeaders(r,s,o)).forEach(([n,m])=>h.set(n,m));const u={...a,headers:h};try{const n=await this.request(t,u);return this.clearAttempt(u),n}catch(n){throw n instanceof l&&n.status===401&&n.code==="fresh_auth_required"?(this.saveFreshAuthMutation(e,t,s,u),this.recoverFreshAuth(e)):n instanceof l&&n.status===409&&(this.clearAttempt(u),typeof window<"u"&&window.dispatchEvent(new CustomEvent("pwc:catalog-conflict",{detail:{endpoint:t}}))),n}}freshAuthMutationDraft(){const e=sessionStorage.getItem(c);if(!e)return null;try{const t=JSON.parse(e);if(!t.endpoint.startsWith("/")||t.endpoint.startsWith("//")||!["POST","PUT","PATCH","DELETE"].includes(t.options.method))throw new Error("Invalid saved mutation draft");return t}catch{return sessionStorage.removeItem(c),null}}async resumeFreshAuthMutation(){const e=this.freshAuthMutationDraft();if(!e)throw new Error("No saved catalog edit is available.");const t=await this.request(e.endpoint,{method:e.options.method,body:e.options.body,headers:e.options.headers});return this.clearAttempt({headers:e.options.headers}),sessionStorage.removeItem(c),sessionStorage.removeItem(p),t}saveFreshAuthMutation(e,t,s,o){const a=Object.fromEntries(new Headers(o.headers).entries()),r=typeof o.body=="string"?o.body:void 0;sessionStorage.setItem(c,JSON.stringify({section:e,endpoint:t,payload:s,options:{method:(o.method??"POST").toUpperCase(),body:r,headers:a}}))}idempotencyHeaders(e,t,s){const o=`pwc:mutation:${e}:${JSON.stringify(t)}`,a=sessionStorage.getItem(o);if(a){const h=JSON.parse(a);return{"Idempotency-Key":h.key,"If-Match":h.version}}const r=crypto.randomUUID();return sessionStorage.setItem(o,JSON.stringify({key:r,version:s})),sessionStorage.setItem(`pwc:mutation-key:${r}`,o),{"Idempotency-Key":r,"If-Match":s}}clearAttempt(e){const t=new Headers(e.headers).get("Idempotency-Key");if(!t)return;const s=sessionStorage.getItem(`pwc:mutation-key:${t}`);s&&sessionStorage.removeItem(s),sessionStorage.removeItem(`pwc:mutation-key:${t}`),this.paperLoads.clear(),this.evaluationLoads.clear()}}const T=new S(v);export{p as F,y as P,_ as i,T as p}; diff --git a/assets/database-DflzbaZ5.js b/assets/database-b_ekt_5x.js similarity index 89% rename from assets/database-DflzbaZ5.js rename to assets/database-b_ekt_5x.js index a95a8128a159bcf64a30e016ab49654ed11374b0..9dffdc5c9c2101dce3b6040b0f6c39ac5d777b56 100644 --- a/assets/database-DflzbaZ5.js +++ b/assets/database-b_ekt_5x.js @@ -1,4 +1,4 @@ -import{s as e}from"./index-DyXq7-Tg.js";/** +import{s as e}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/dialog-CfM0Uql2.js b/assets/dialog-BzX9PD3v.js similarity index 93% rename from assets/dialog-CfM0Uql2.js rename to assets/dialog-BzX9PD3v.js index d2e5cfb07dbae68d669a8ad967e3ffea04f8fdd9..20b5d20464038bb0a83a06fccd03f3cdd4fa10ce 100644 --- a/assets/dialog-CfM0Uql2.js +++ b/assets/dialog-BzX9PD3v.js @@ -1 +1 @@ -import{ag as f,d as l,j as t,ah as p,aj as d,al as g,X as x,G as o,ai as n,am as i,an as r}from"./index-DyXq7-Tg.js";const w=f,u=p,c=l.forwardRef(({className:a,...e},s)=>t.jsx(n,{ref:s,className:o("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...e}));c.displayName=n.displayName;const y=l.forwardRef(({className:a,children:e,...s},m)=>t.jsxs(u,{children:[t.jsx(c,{}),t.jsxs(d,{ref:m,className:o("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...s,children:[e,t.jsxs(g,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[t.jsx(x,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));y.displayName=d.displayName;const N=({className:a,...e})=>t.jsx("div",{className:o("flex flex-col space-y-1.5 text-center sm:text-left",a),...e});N.displayName="DialogHeader";const j=({className:a,...e})=>t.jsx("div",{className:o("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...e});j.displayName="DialogFooter";const D=l.forwardRef(({className:a,...e},s)=>t.jsx(i,{ref:s,className:o("text-lg font-semibold leading-none tracking-tight",a),...e}));D.displayName=i.displayName;const b=l.forwardRef(({className:a,...e},s)=>t.jsx(r,{ref:s,className:o("text-sm text-muted-foreground",a),...e}));b.displayName=r.displayName;export{w as D,y as a,D as b,N as c,b as d,j as e}; +import{ag as f,d as l,j as t,ah as p,aj as d,al as g,X as x,I as o,ai as n,am as i,an as r}from"./index-CjdUkE4w.js";const w=f,u=p,c=l.forwardRef(({className:a,...e},s)=>t.jsx(n,{ref:s,className:o("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...e}));c.displayName=n.displayName;const y=l.forwardRef(({className:a,children:e,...s},m)=>t.jsxs(u,{children:[t.jsx(c,{}),t.jsxs(d,{ref:m,className:o("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...s,children:[e,t.jsxs(g,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[t.jsx(x,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));y.displayName=d.displayName;const N=({className:a,...e})=>t.jsx("div",{className:o("flex flex-col space-y-1.5 text-center sm:text-left",a),...e});N.displayName="DialogHeader";const j=({className:a,...e})=>t.jsx("div",{className:o("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...e});j.displayName="DialogFooter";const D=l.forwardRef(({className:a,...e},s)=>t.jsx(i,{ref:s,className:o("text-lg font-semibold leading-none tracking-tight",a),...e}));D.displayName=i.displayName;const b=l.forwardRef(({className:a,...e},s)=>t.jsx(r,{ref:s,className:o("text-sm text-muted-foreground",a),...e}));b.displayName=r.displayName;export{w as D,y as a,D as b,N as c,b as d,j as e}; diff --git a/assets/evaluationQueryInvalidation-Cm3s7Pfm.js b/assets/evaluationQueryInvalidation-BAyi4YoG.js similarity index 95% rename from assets/evaluationQueryInvalidation-Cm3s7Pfm.js rename to assets/evaluationQueryInvalidation-BAyi4YoG.js index 3a66179fbd3a1d2cb5d72de6337f753348c8627c..4afb9d3a84b100898fa0521fb566121d682dca19 100644 --- a/assets/evaluationQueryInvalidation-Cm3s7Pfm.js +++ b/assets/evaluationQueryInvalidation-BAyi4YoG.js @@ -1 +1 @@ -var F=a=>{throw TypeError(a)};var B=(a,e,t)=>e.has(a)||F("Cannot "+t);var u=(a,e,t)=>(B(a,e,"read from private field"),t?t.call(a):e.get(a)),v=(a,e,t)=>e.has(a)?F("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(a):e.set(a,t),l=(a,e,t,s)=>(B(a,e,"write to private field"),s?s.call(a,t):e.set(a,t),t),g=(a,e,t)=>(B(a,e,"access private method"),t);import{aE as X,aF as H,aG as Y,aH as Z,aI as J,i as W,aJ as ee,aK as se,d as x,aL as te,aM as re,aN as ae,aO as ie,aP as U,aQ as ne,aR as oe,t as A,o as I}from"./index-DyXq7-Tg.js";import{i as ue,a as ce}from"./queryInvalidation-CfHeNeUY.js";function j(a,e){const t=new Set(e);return a.filter(s=>!t.has(s))}function de(a,e,t){const s=a.slice(0);return s[e]=t,s}var _,f,w,E,y,R,C,K,M,P,d,L,D,N,$,T,z,G,he=(G=class extends X{constructor(e,t,s){super();v(this,d);v(this,_);v(this,f);v(this,w);v(this,E);v(this,y);v(this,R);v(this,C);v(this,K);v(this,M);v(this,P,[]);l(this,_,e),l(this,E,s),l(this,w,[]),l(this,y,[]),l(this,f,[]),this.setQueries(t)}onSubscribe(){this.listeners.size===1&&u(this,y).forEach(e=>{e.subscribe(t=>{g(this,d,T).call(this,e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,u(this,y).forEach(e=>{e.destroy()})}setQueries(e,t){l(this,w,e),l(this,E,t),H.batch(()=>{const s=u(this,y),n=g(this,d,$).call(this,u(this,w));n.forEach(i=>i.observer.setOptions(i.defaultedQueryOptions));const r=n.map(i=>i.observer),o=r.map(i=>i.getCurrentResult()),h=s.length!==r.length,m=r.some((i,b)=>i!==s[b]),S=h||m,c=S?!0:o.some((i,b)=>{const k=u(this,f)[b];return!k||!Y(i,k)});!S&&!c||(S&&(l(this,P,n),l(this,y,r)),l(this,f,o),this.hasListeners()&&(S&&(j(s,r).forEach(i=>{i.destroy()}),j(r,s).forEach(i=>{i.subscribe(b=>{g(this,d,T).call(this,i,b)})})),g(this,d,z).call(this)))})}getCurrentResult(){return u(this,f)}getQueries(){return u(this,y).map(e=>e.getCurrentQuery())}getObservers(){return u(this,y)}getOptimisticResult(e,t){const s=g(this,d,$).call(this,e),n=s.map(o=>o.observer.getOptimisticResult(o.defaultedQueryOptions)),r=s.map(o=>o.defaultedQueryOptions.queryHash);return[n,o=>g(this,d,D).call(this,o??n,t,r),()=>g(this,d,L).call(this,n,s)]}},_=new WeakMap,f=new WeakMap,w=new WeakMap,E=new WeakMap,y=new WeakMap,R=new WeakMap,C=new WeakMap,K=new WeakMap,M=new WeakMap,P=new WeakMap,d=new WeakSet,L=function(e,t){return t.map((s,n)=>{const r=e[n];return s.defaultedQueryOptions.notifyOnChangeProps?r:s.observer.trackResult(r,o=>{t.forEach(h=>{h.observer.trackProp(o)})})})},D=function(e,t,s){if(t){const n=u(this,M),r=s!==void 0&&n!==void 0&&(n.length!==s.length||s.some((o,h)=>o!==n[h]));return(!u(this,R)||u(this,f)!==u(this,K)||r||t!==u(this,C))&&(l(this,C,t),l(this,K,u(this,f)),s!==void 0&&l(this,M,s),l(this,R,Z(u(this,R),t(e)))),u(this,R)}return e},N=function(){var e;return((e=u(this,E))==null?void 0:e.combine)!==void 0&&u(this,y).some((t,s)=>{var n;return t.options.suspense&&((n=u(this,f)[s])==null?void 0:n.data)===void 0})},$=function(e){const t=new Map;u(this,y).forEach(n=>{const r=n.options.queryHash;if(!r)return;const o=t.get(r);o?o.push(n):t.set(r,[n])});const s=[];return e.forEach(n=>{var m;const r=u(this,_).defaultQueryOptions(n),h=((m=t.get(r.queryHash))==null?void 0:m.shift())??new J(u(this,_),r);s.push({defaultedQueryOptions:r,observer:h})}),s},T=function(e,t){const s=u(this,y).indexOf(e);s!==-1&&(l(this,f,de(u(this,f),s,t)),g(this,d,z).call(this))},z=function(){var e;if(this.hasListeners()){const t=g(this,d,L).call(this,u(this,f),u(this,P)),s=g(this,d,N).call(this),n=u(this,R),r=s?n:g(this,d,D).call(this,t,(e=u(this,E))==null?void 0:e.combine);(s||n!==r)&&H.batch(()=>{this.listeners.forEach(o=>{o(u(this,f))})})}},G);function ye({queries:a,...e},t){const s=W(),n=ee(),r=se(),o=x.useMemo(()=>a.map(p=>{const Q=s.defaultQueryOptions(p);return Q._optimisticResults=n?"isRestoring":"optimistic",Q}),[a,s,n]);o.forEach(p=>{te(p);const Q=s.getQueryCache().get(p.queryHash);re(p,r,Q)}),ae(r);const[h]=x.useState(()=>new he(s,o,e)),[m,S,c]=h.getOptimisticResult(o,e.combine),i=!n&&e.subscribed!==!1;x.useSyncExternalStore(x.useCallback(p=>i?h.subscribe(H.batchCalls(p)):ie,[h,i]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),x.useEffect(()=>{h.setQueries(o,e)},[o,e,h]);const k=m.some((p,Q)=>U(o[Q],p))?m.flatMap((p,Q)=>{const O=o[Q];if(O&&U(O,p)){const V=new J(s,O);return ne(O,V,r)}return[]}):[];if(k.length>0)throw Promise.all(k);const q=m.find((p,Q)=>{const O=o[Q];return O&&oe({result:p,errorResetBoundary:r,throwOnError:O.throwOnError,query:s.getQueryCache().get(O.queryHash),suspense:O.suspense})});if(q!=null&&q.error)throw q.error;return S(c())}function be(a,e,t,s){const n=new Set(t.flatMap(r=>r.op==="create"?[]:[String(r.evaluation_id)]));return{paperId:a,arxivId:s,contexts:[...e.filter(r=>r.id!==void 0&&n.has(String(r.id))),...t.flatMap(r=>r.op==="delete"?[]:[r.data])]}}function ve(a,e){const t=new Set(e.contexts.flatMap(c=>c.dataset_id==null?[]:[String(c.dataset_id)])),s=new Set(e.contexts.flatMap(c=>c.task_id==null?[]:[String(c.task_id)])),n=new Set([e.paperId]),r=new Set;e.arxivId&&r.add(e.arxivId);const o=new Set(e.contexts.map(c=>`${c.task_id}:${c.dataset_id}`)),h=a.getQueryCache(),m=[...h.findAll({queryKey:A.byDatasetAll}),...h.findAll({queryKey:A.byPaperAll})];for(const c of m)for(const i of c.state.data??[])o.has(`${i.task_id}:${i.dataset_id}`)&&(n.add(String(i.paper_id)),i.paper_arxiv_id&&r.add(i.paper_arxiv_id));ue(a,[...n,...r]),ce(a),a.invalidateQueries({queryKey:A.byPaperAll,predicate:c=>n.has(String(c.queryKey[2]))});const S=c=>t.has(String(c.queryKey[1]));a.invalidateQueries({queryKey:A.byDatasetAll,predicate:S}),a.invalidateQueries({queryKey:I.datasetTasks,predicate:S}),a.invalidateQueries({queryKey:I.datasets,predicate:c=>{const i=c.state.data;return S(c)||!!(i&&t.has(String(i.id)))}}),a.invalidateQueries({queryKey:I.taskPage,predicate:c=>{const i=c.state.data;return s.has(String(c.queryKey[1]))||!!(i&&(s.has(String(i.task.id))||i.subtask_benchmarks.some(b=>s.has(String(b.subtask_id)))||i.benchmarks.some(b=>t.has(String(b.id)))||i.subtask_benchmarks.some(b=>b.benchmarks.some(k=>t.has(String(k.id))))))}}),a.invalidateQueries({queryKey:I.taskBenchmarkTrends,predicate:c=>{const i=c.state.data;return s.has(String(c.queryKey[1]))||!!(i&&s.has(String(i.task_id)))}})}export{be as e,ve as r,ye as u}; +var F=a=>{throw TypeError(a)};var B=(a,e,t)=>e.has(a)||F("Cannot "+t);var u=(a,e,t)=>(B(a,e,"read from private field"),t?t.call(a):e.get(a)),v=(a,e,t)=>e.has(a)?F("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(a):e.set(a,t),l=(a,e,t,s)=>(B(a,e,"write to private field"),s?s.call(a,t):e.set(a,t),t),g=(a,e,t)=>(B(a,e,"access private method"),t);import{aF as X,aG as H,aH as Y,aI as Z,aJ as J,i as W,aK as ee,aL as se,d as x,aM as te,aN as re,aO as ae,aP as ie,aQ as U,aR as ne,aS as oe,t as A,o as I}from"./index-CjdUkE4w.js";import{i as ue,a as ce}from"./queryInvalidation-LiTu0GxY.js";function j(a,e){const t=new Set(e);return a.filter(s=>!t.has(s))}function de(a,e,t){const s=a.slice(0);return s[e]=t,s}var _,f,w,E,y,R,C,K,M,P,d,L,D,N,$,T,z,G,he=(G=class extends X{constructor(e,t,s){super();v(this,d);v(this,_);v(this,f);v(this,w);v(this,E);v(this,y);v(this,R);v(this,C);v(this,K);v(this,M);v(this,P,[]);l(this,_,e),l(this,E,s),l(this,w,[]),l(this,y,[]),l(this,f,[]),this.setQueries(t)}onSubscribe(){this.listeners.size===1&&u(this,y).forEach(e=>{e.subscribe(t=>{g(this,d,T).call(this,e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,u(this,y).forEach(e=>{e.destroy()})}setQueries(e,t){l(this,w,e),l(this,E,t),H.batch(()=>{const s=u(this,y),n=g(this,d,$).call(this,u(this,w));n.forEach(i=>i.observer.setOptions(i.defaultedQueryOptions));const r=n.map(i=>i.observer),o=r.map(i=>i.getCurrentResult()),h=s.length!==r.length,m=r.some((i,b)=>i!==s[b]),S=h||m,c=S?!0:o.some((i,b)=>{const k=u(this,f)[b];return!k||!Y(i,k)});!S&&!c||(S&&(l(this,P,n),l(this,y,r)),l(this,f,o),this.hasListeners()&&(S&&(j(s,r).forEach(i=>{i.destroy()}),j(r,s).forEach(i=>{i.subscribe(b=>{g(this,d,T).call(this,i,b)})})),g(this,d,z).call(this)))})}getCurrentResult(){return u(this,f)}getQueries(){return u(this,y).map(e=>e.getCurrentQuery())}getObservers(){return u(this,y)}getOptimisticResult(e,t){const s=g(this,d,$).call(this,e),n=s.map(o=>o.observer.getOptimisticResult(o.defaultedQueryOptions)),r=s.map(o=>o.defaultedQueryOptions.queryHash);return[n,o=>g(this,d,D).call(this,o??n,t,r),()=>g(this,d,L).call(this,n,s)]}},_=new WeakMap,f=new WeakMap,w=new WeakMap,E=new WeakMap,y=new WeakMap,R=new WeakMap,C=new WeakMap,K=new WeakMap,M=new WeakMap,P=new WeakMap,d=new WeakSet,L=function(e,t){return t.map((s,n)=>{const r=e[n];return s.defaultedQueryOptions.notifyOnChangeProps?r:s.observer.trackResult(r,o=>{t.forEach(h=>{h.observer.trackProp(o)})})})},D=function(e,t,s){if(t){const n=u(this,M),r=s!==void 0&&n!==void 0&&(n.length!==s.length||s.some((o,h)=>o!==n[h]));return(!u(this,R)||u(this,f)!==u(this,K)||r||t!==u(this,C))&&(l(this,C,t),l(this,K,u(this,f)),s!==void 0&&l(this,M,s),l(this,R,Z(u(this,R),t(e)))),u(this,R)}return e},N=function(){var e;return((e=u(this,E))==null?void 0:e.combine)!==void 0&&u(this,y).some((t,s)=>{var n;return t.options.suspense&&((n=u(this,f)[s])==null?void 0:n.data)===void 0})},$=function(e){const t=new Map;u(this,y).forEach(n=>{const r=n.options.queryHash;if(!r)return;const o=t.get(r);o?o.push(n):t.set(r,[n])});const s=[];return e.forEach(n=>{var m;const r=u(this,_).defaultQueryOptions(n),h=((m=t.get(r.queryHash))==null?void 0:m.shift())??new J(u(this,_),r);s.push({defaultedQueryOptions:r,observer:h})}),s},T=function(e,t){const s=u(this,y).indexOf(e);s!==-1&&(l(this,f,de(u(this,f),s,t)),g(this,d,z).call(this))},z=function(){var e;if(this.hasListeners()){const t=g(this,d,L).call(this,u(this,f),u(this,P)),s=g(this,d,N).call(this),n=u(this,R),r=s?n:g(this,d,D).call(this,t,(e=u(this,E))==null?void 0:e.combine);(s||n!==r)&&H.batch(()=>{this.listeners.forEach(o=>{o(u(this,f))})})}},G);function ye({queries:a,...e},t){const s=W(),n=ee(),r=se(),o=x.useMemo(()=>a.map(p=>{const Q=s.defaultQueryOptions(p);return Q._optimisticResults=n?"isRestoring":"optimistic",Q}),[a,s,n]);o.forEach(p=>{te(p);const Q=s.getQueryCache().get(p.queryHash);re(p,r,Q)}),ae(r);const[h]=x.useState(()=>new he(s,o,e)),[m,S,c]=h.getOptimisticResult(o,e.combine),i=!n&&e.subscribed!==!1;x.useSyncExternalStore(x.useCallback(p=>i?h.subscribe(H.batchCalls(p)):ie,[h,i]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),x.useEffect(()=>{h.setQueries(o,e)},[o,e,h]);const k=m.some((p,Q)=>U(o[Q],p))?m.flatMap((p,Q)=>{const O=o[Q];if(O&&U(O,p)){const V=new J(s,O);return ne(O,V,r)}return[]}):[];if(k.length>0)throw Promise.all(k);const q=m.find((p,Q)=>{const O=o[Q];return O&&oe({result:p,errorResetBoundary:r,throwOnError:O.throwOnError,query:s.getQueryCache().get(O.queryHash),suspense:O.suspense})});if(q!=null&&q.error)throw q.error;return S(c())}function be(a,e,t,s){const n=new Set(t.flatMap(r=>r.op==="create"?[]:[String(r.evaluation_id)]));return{paperId:a,arxivId:s,contexts:[...e.filter(r=>r.id!==void 0&&n.has(String(r.id))),...t.flatMap(r=>r.op==="delete"?[]:[r.data])]}}function ve(a,e){const t=new Set(e.contexts.flatMap(c=>c.dataset_id==null?[]:[String(c.dataset_id)])),s=new Set(e.contexts.flatMap(c=>c.task_id==null?[]:[String(c.task_id)])),n=new Set([e.paperId]),r=new Set;e.arxivId&&r.add(e.arxivId);const o=new Set(e.contexts.map(c=>`${c.task_id}:${c.dataset_id}`)),h=a.getQueryCache(),m=[...h.findAll({queryKey:A.byDatasetAll}),...h.findAll({queryKey:A.byPaperAll})];for(const c of m)for(const i of c.state.data??[])o.has(`${i.task_id}:${i.dataset_id}`)&&(n.add(String(i.paper_id)),i.paper_arxiv_id&&r.add(i.paper_arxiv_id));ue(a,[...n,...r]),ce(a),a.invalidateQueries({queryKey:A.byPaperAll,predicate:c=>n.has(String(c.queryKey[2]))});const S=c=>t.has(String(c.queryKey[1]));a.invalidateQueries({queryKey:A.byDatasetAll,predicate:S}),a.invalidateQueries({queryKey:I.datasetTasks,predicate:S}),a.invalidateQueries({queryKey:I.datasets,predicate:c=>{const i=c.state.data;return S(c)||!!(i&&t.has(String(i.id)))}}),a.invalidateQueries({queryKey:I.taskPage,predicate:c=>{const i=c.state.data;return s.has(String(c.queryKey[1]))||!!(i&&(s.has(String(i.task.id))||i.subtask_benchmarks.some(b=>s.has(String(b.subtask_id)))||i.benchmarks.some(b=>t.has(String(b.id)))||i.subtask_benchmarks.some(b=>b.benchmarks.some(k=>t.has(String(k.id))))))}}),a.invalidateQueries({queryKey:I.taskBenchmarkTrends,predicate:c=>{const i=c.state.data;return s.has(String(c.queryKey[1]))||!!(i&&s.has(String(i.task_id)))}})}export{be as e,ve as r,ye as u}; diff --git a/assets/external-link-orY1Xz1I.js b/assets/external-link-CTLWFJ8S.js similarity index 89% rename from assets/external-link-orY1Xz1I.js rename to assets/external-link-CTLWFJ8S.js index 47cacba7194e4754d3a0bf6192da3275c5f940f2..b391c66bc966e72e8248ef41d1c6c051d30fda70 100644 --- a/assets/external-link-orY1Xz1I.js +++ b/assets/external-link-CTLWFJ8S.js @@ -1,4 +1,4 @@ -import{s as a}from"./index-DyXq7-Tg.js";/** +import{s as a}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/file-text-dvKtHbmD.js b/assets/file-text-CHlxsNJC.js similarity index 91% rename from assets/file-text-dvKtHbmD.js rename to assets/file-text-CHlxsNJC.js index 0e5d25282ed37811a214e9a99ba5e44c382e4835..8c5ac1a7093a7ce9da6f2f8efdb217df7828b986 100644 --- a/assets/file-text-dvKtHbmD.js +++ b/assets/file-text-CHlxsNJC.js @@ -1,4 +1,4 @@ -import{s as e}from"./index-DyXq7-Tg.js";/** +import{s as e}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/github-RNrgGHRT.js b/assets/github-4bW4WI_e.js similarity index 92% rename from assets/github-RNrgGHRT.js rename to assets/github-4bW4WI_e.js index 6d72a793c9eec484bb245bc72e65d0eee63e500d..ceb7fc550e46d4db67f24e90d2cf218c10a30abf 100644 --- a/assets/github-RNrgGHRT.js +++ b/assets/github-4bW4WI_e.js @@ -1,4 +1,4 @@ -import{s as c}from"./index-DyXq7-Tg.js";/** +import{s as c}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/globe-BMJtRs4F.js b/assets/globe-mBp0l-nC.js similarity index 89% rename from assets/globe-BMJtRs4F.js rename to assets/globe-mBp0l-nC.js index e3169cf9b5229758d187e40765235212e16a043d..659ecb857d0b0e5471e82b8489a2020bdd7ec401 100644 --- a/assets/globe-BMJtRs4F.js +++ b/assets/globe-mBp0l-nC.js @@ -1,4 +1,4 @@ -import{s as e}from"./index-DyXq7-Tg.js";/** +import{s as e}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/hover-card-B45EJIn_.js b/assets/hover-card-B45EJIn_.js deleted file mode 100644 index 97bb818e9993e43fe03c79319128110c5a52b44d..0000000000000000000000000000000000000000 --- a/assets/hover-card-B45EJIn_.js +++ /dev/null @@ -1 +0,0 @@ -import{d as n,A as M,j as c,ap as k,aq as I,z as U,D as l,ar as T,P as O,as as $,F as z,B,at as W,au as G,av as K,G as q}from"./index-DyXq7-Tg.js";var E,g="HoverCard",[y]=z(g,[T]),w=T(),[V,S]=y(g),N=e=>{const{__scopeHoverCard:o,children:r,open:s,defaultOpen:a,onOpenChange:i,openDelay:f=700,closeDelay:v=300}=e,d=w(o),C=n.useRef(0),u=n.useRef(0),h=n.useRef(!1),p=n.useRef(!1),[m,t]=M({prop:s,defaultProp:a??!1,onChange:i,caller:g}),x=n.useCallback(()=>{clearTimeout(u.current),C.current=window.setTimeout(()=>t(!0),f)},[f,t]),P=n.useCallback(()=>{clearTimeout(C.current),!h.current&&!p.current&&(u.current=window.setTimeout(()=>t(!1),v))},[v,t]),F=n.useCallback(()=>t(!1),[t]);return n.useEffect(()=>()=>{clearTimeout(C.current),clearTimeout(u.current)},[]),c.jsx(V,{scope:o,open:m,onOpenChange:t,onOpen:x,onClose:P,onDismiss:F,hasSelectionRef:h,isPointerDownOnContentRef:p,children:c.jsx(k,{...d,children:r})})};N.displayName=g;var _="HoverCardTrigger",D=n.forwardRef((e,o)=>{const{__scopeHoverCard:r,...s}=e,a=S(_,r),i=w(r);return c.jsx(I,{asChild:!0,...i,children:c.jsx(U.a,{"data-state":a.open?"open":"closed",...s,ref:o,onPointerEnter:l(e.onPointerEnter,b(a.onOpen)),onPointerLeave:l(e.onPointerLeave,b(a.onClose)),onFocus:l(e.onFocus,a.onOpen),onBlur:l(e.onBlur,a.onClose),onTouchStart:l(e.onTouchStart,f=>f.preventDefault())})})});D.displayName=_;var H="HoverCardPortal",[J,Q]=y(H,{forceMount:void 0}),j=e=>{const{__scopeHoverCard:o,forceMount:r,children:s,container:a}=e,i=S(H,o);return c.jsx(J,{scope:o,forceMount:r,children:c.jsx(O,{present:r||i.open,children:c.jsx($,{asChild:!0,container:a,children:s})})})};j.displayName=H;var R="HoverCardContent",A=n.forwardRef((e,o)=>{const r=Q(R,e.__scopeHoverCard),{forceMount:s=r.forceMount,...a}=e,i=S(R,e.__scopeHoverCard);return c.jsx(O,{present:s||i.open,children:c.jsx(X,{"data-state":i.open?"open":"closed",...a,onPointerEnter:l(e.onPointerEnter,b(i.onOpen)),onPointerLeave:l(e.onPointerLeave,b(i.onClose)),ref:o})})});A.displayName=R;var X=n.forwardRef((e,o)=>{const{__scopeHoverCard:r,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:f,...v}=e,d=S(R,r),C=w(r),u=n.useRef(null),h=B(o,u),[p,m]=n.useState(!1);return n.useEffect(()=>{if(p){const t=document.body;return E=t.style.userSelect||t.style.webkitUserSelect,t.style.userSelect="none",t.style.webkitUserSelect="none",()=>{t.style.userSelect=E,t.style.webkitUserSelect=E}}},[p]),n.useEffect(()=>{if(u.current){const t=()=>{m(!1),d.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var P;((P=document.getSelection())==null?void 0:P.toString())!==""&&(d.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",t),()=>{document.removeEventListener("pointerup",t),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!1}}},[d.isPointerDownOnContentRef,d.hasSelectionRef]),n.useEffect(()=>{u.current&&ee(u.current).forEach(x=>x.setAttribute("tabindex","-1"))}),c.jsx(W,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:f,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:l(i,t=>{t.preventDefault()}),onDismiss:d.onDismiss,children:c.jsx(G,{...C,...v,onPointerDown:l(v.onPointerDown,t=>{t.currentTarget.contains(t.target)&&m(!0),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!0}),ref:h,style:{...v.style,userSelect:p?"text":void 0,WebkitUserSelect:p?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),Y="HoverCardArrow",Z=n.forwardRef((e,o)=>{const{__scopeHoverCard:r,...s}=e,a=w(r);return c.jsx(K,{...a,...s,ref:o})});Z.displayName=Y;function b(e){return o=>o.pointerType==="touch"?void 0:e()}function ee(e){const o=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;r.nextNode();)o.push(r.currentNode);return o}var te=N,oe=D,re=j,L=A;const se=te,ce=oe,ne=n.forwardRef(({className:e,align:o="center",sideOffset:r=4,...s},a)=>c.jsx(re,{children:c.jsx(L,{ref:a,align:o,sideOffset:r,className:q("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s})}));ne.displayName=L.displayName;export{se as H,ce as a,ne as b}; diff --git a/assets/hover-card-CIBIV2Hx.js b/assets/hover-card-CIBIV2Hx.js new file mode 100644 index 0000000000000000000000000000000000000000..171f4eb81fc8ed710667972ae6f3df2acc4d9c4e --- /dev/null +++ b/assets/hover-card-CIBIV2Hx.js @@ -0,0 +1 @@ +import{d as n,B as k,j as c,ap as F,aq as I,z as U,E as l,ar as T,P as O,as as $,G as z,D as B,at as W,au as G,av as K,I as q}from"./index-CjdUkE4w.js";var E,g="HoverCard",[y]=z(g,[T]),w=T(),[V,S]=y(g),N=e=>{const{__scopeHoverCard:o,children:r,open:s,defaultOpen:a,onOpenChange:i,openDelay:f=700,closeDelay:v=300}=e,d=w(o),C=n.useRef(0),u=n.useRef(0),h=n.useRef(!1),p=n.useRef(!1),[m,t]=k({prop:s,defaultProp:a??!1,onChange:i,caller:g}),x=n.useCallback(()=>{clearTimeout(u.current),C.current=window.setTimeout(()=>t(!0),f)},[f,t]),P=n.useCallback(()=>{clearTimeout(C.current),!h.current&&!p.current&&(u.current=window.setTimeout(()=>t(!1),v))},[v,t]),M=n.useCallback(()=>t(!1),[t]);return n.useEffect(()=>()=>{clearTimeout(C.current),clearTimeout(u.current)},[]),c.jsx(V,{scope:o,open:m,onOpenChange:t,onOpen:x,onClose:P,onDismiss:M,hasSelectionRef:h,isPointerDownOnContentRef:p,children:c.jsx(F,{...d,children:r})})};N.displayName=g;var _="HoverCardTrigger",D=n.forwardRef((e,o)=>{const{__scopeHoverCard:r,...s}=e,a=S(_,r),i=w(r);return c.jsx(I,{asChild:!0,...i,children:c.jsx(U.a,{"data-state":a.open?"open":"closed",...s,ref:o,onPointerEnter:l(e.onPointerEnter,b(a.onOpen)),onPointerLeave:l(e.onPointerLeave,b(a.onClose)),onFocus:l(e.onFocus,a.onOpen),onBlur:l(e.onBlur,a.onClose),onTouchStart:l(e.onTouchStart,f=>f.preventDefault())})})});D.displayName=_;var H="HoverCardPortal",[J,Q]=y(H,{forceMount:void 0}),j=e=>{const{__scopeHoverCard:o,forceMount:r,children:s,container:a}=e,i=S(H,o);return c.jsx(J,{scope:o,forceMount:r,children:c.jsx(O,{present:r||i.open,children:c.jsx($,{asChild:!0,container:a,children:s})})})};j.displayName=H;var R="HoverCardContent",A=n.forwardRef((e,o)=>{const r=Q(R,e.__scopeHoverCard),{forceMount:s=r.forceMount,...a}=e,i=S(R,e.__scopeHoverCard);return c.jsx(O,{present:s||i.open,children:c.jsx(X,{"data-state":i.open?"open":"closed",...a,onPointerEnter:l(e.onPointerEnter,b(i.onOpen)),onPointerLeave:l(e.onPointerLeave,b(i.onClose)),ref:o})})});A.displayName=R;var X=n.forwardRef((e,o)=>{const{__scopeHoverCard:r,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:f,...v}=e,d=S(R,r),C=w(r),u=n.useRef(null),h=B(o,u),[p,m]=n.useState(!1);return n.useEffect(()=>{if(p){const t=document.body;return E=t.style.userSelect||t.style.webkitUserSelect,t.style.userSelect="none",t.style.webkitUserSelect="none",()=>{t.style.userSelect=E,t.style.webkitUserSelect=E}}},[p]),n.useEffect(()=>{if(u.current){const t=()=>{m(!1),d.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var P;((P=document.getSelection())==null?void 0:P.toString())!==""&&(d.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",t),()=>{document.removeEventListener("pointerup",t),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!1}}},[d.isPointerDownOnContentRef,d.hasSelectionRef]),n.useEffect(()=>{u.current&&ee(u.current).forEach(x=>x.setAttribute("tabindex","-1"))}),c.jsx(W,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:f,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:l(i,t=>{t.preventDefault()}),onDismiss:d.onDismiss,children:c.jsx(G,{...C,...v,onPointerDown:l(v.onPointerDown,t=>{t.currentTarget.contains(t.target)&&m(!0),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!0}),ref:h,style:{...v.style,userSelect:p?"text":void 0,WebkitUserSelect:p?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),Y="HoverCardArrow",Z=n.forwardRef((e,o)=>{const{__scopeHoverCard:r,...s}=e,a=w(r);return c.jsx(K,{...a,...s,ref:o})});Z.displayName=Y;function b(e){return o=>o.pointerType==="touch"?void 0:e()}function ee(e){const o=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;r.nextNode();)o.push(r.currentNode);return o}var te=N,oe=D,re=j,L=A;const se=te,ce=oe,ne=n.forwardRef(({className:e,align:o="center",sideOffset:r=4,...s},a)=>c.jsx(re,{children:c.jsx(L,{ref:a,align:o,sideOffset:r,className:q("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s})}));ne.displayName=L.displayName;export{se as H,ce as a,ne as b}; diff --git a/assets/index-C041TDos.js b/assets/index-BxR27SAB.js similarity index 72% rename from assets/index-C041TDos.js rename to assets/index-BxR27SAB.js index eedb6d6d29cb8c4a938f95527172859adfe5a60e..27332764e6cd0589d3a3dd4cdb7afb58e9f59f9f 100644 --- a/assets/index-C041TDos.js +++ b/assets/index-BxR27SAB.js @@ -1 +1 @@ -import{d as u}from"./index-DyXq7-Tg.js";function o(r){const e=u.useRef({value:r,previous:r});return u.useMemo(()=>(e.current.value!==r&&(e.current.previous=e.current.value,e.current.value=r),e.current.previous),[r])}export{o as u}; +import{d as u}from"./index-CjdUkE4w.js";function o(r){const e=u.useRef({value:r,previous:r});return u.useMemo(()=>(e.current.value!==r&&(e.current.previous=e.current.value,e.current.value=r),e.current.previous),[r])}export{o as u}; diff --git a/assets/index-DyXq7-Tg.js b/assets/index-CjdUkE4w.js similarity index 86% rename from assets/index-DyXq7-Tg.js rename to assets/index-CjdUkE4w.js index fcdfc7f90b3555b07faaa5d2d43ed3c78b8f58ce..76c49aaf0189a561ca225a9ca326e11588a4e3ed 100644 --- a/assets/index-DyXq7-Tg.js +++ b/assets/index-CjdUkE4w.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AuthorizePaperEditView-DNfre5z5.js","assets/useMutation-UWxBeqtn.js","assets/button-DZeAbOf2.js","assets/paperEdits-CIjFYfYE.js","assets/FollowingView-Ctbw54vk.js","assets/FeedView-tA68x8iy.js","assets/sparkles-CcIiUzzc.js","assets/dialog-CfM0Uql2.js","assets/catalog-CRar2olQ.js","assets/researchTopic-DbX0eko-.js","assets/transform-D46m70Qr.js","assets/plus-Yh42pKZz.js","assets/arrow-right-BzPanrWZ.js","assets/PaperFeed-EBt97iOL.js","assets/PaperCard-57p1OSGy.js","assets/AuthorAvatar-B-9xS2Wo.js","assets/AuthorAvatar-o5W6pl_W.css","assets/SotaBadges-vbLLOUtT.js","assets/colors-BkWRhvFI.js","assets/Icon-T4LYkEQj.js","assets/LatexTitle-Bkyz3jCs.js","assets/papers-Dh3ljlL0.js","assets/curation-YeS7FBYf.js","assets/safeExternalHref-CkBrsh84.js","assets/popover-CTBEUp7Y.js","assets/skeleton-C3IIzpSL.js","assets/useIntersectionObserver-D6_Iig9a.js","assets/McpShowcase-CLO4HLon.js","assets/AgentLogos-j-Qekw7T.js","assets/chatSessions-Ck_dyM0d.js","assets/chat-Ix1IrIwq.js","assets/usePapers-B0s20UcU.js","assets/useInfiniteQuery-BYh2zN-T.js","assets/alert-gbJBhAVE.js","assets/ChatView-D06zYumh.js","assets/ArtifactWorkspace-Ya79_F5k.js","assets/hover-card-B45EJIn_.js","assets/CatalogEntityPreviewLink-BktpwL3_.js","assets/github-RNrgGHRT.js","assets/file-text-dvKtHbmD.js","assets/PaperPreviewLink-CpCZSa8K.js","assets/index-mCi_y_l3.js","assets/index-2CvJmBVB.js","assets/katex-DkKDou_j.js","assets/copy-CxR0OKx2.js","assets/thumbs-up-CPLlGli7.js","assets/arrow-left-PA_b6law.js","assets/external-link-orY1Xz1I.js","assets/search-8ssWDP68.js","assets/chevron-up-DYSYRyvz.js","assets/ArtifactWorkspace-Lr_OJaUk.css","assets/katex-wklAmtGL.css","assets/share-2-fiavn5SS.js","assets/openrouter-o51Eagw8.js","assets/queryOptions-C9woPjwX.js","assets/SharedChatView-Cd2cL7B4.js","assets/PapersListView-BwwaBBb8.js","assets/useDebounce-B9jkN7LV.js","assets/apiErrors-BSvbQBb0.js","assets/frameworks-DDA0P4Tf.js","assets/PaperDetailView-BlSDULsI.js","assets/ExternalSourceEvalBadge-K3r45EmO.js","assets/ExternalSourceEvalBadge-CWUQ52cV.css","assets/paperReader-BIpQD5HO.js","assets/useDocumentTitle-DcxM2Zv_.js","assets/preferences-COzeOLyS.js","assets/account-cbblajck.js","assets/evaluationQueryInvalidation-Cm3s7Pfm.js","assets/queryInvalidation-CfHeNeUY.js","assets/input-DJqCAbs7.js","assets/searchable-select-DiDLwvbI.js","assets/loader-circle-C75KLEgx.js","assets/SignInToEditDialog-B-oWVno5.js","assets/textarea-DPixlM5U.js","assets/submissions-Cz_J-Ha2.js","assets/database-DflzbaZ5.js","assets/badge-e6t3GCyf.js","assets/globe-BMJtRs4F.js","assets/index-C041TDos.js","assets/codex-DFj4KHqP.js","assets/savedPapersAuth-TV7AiXOw.js","assets/organizationNames-BVKzYEBp.js","assets/PaperDetailView-CUWCgV3F.css","assets/PaperReaderView-C7GrMxPx.js","assets/MarkdownText-CUzPoC9Y.js","assets/TagsIndexView-BwVoxBoD.js","assets/slug-BpH-Nkvz.js","assets/triangle-alert-uZ3fXFkp.js","assets/trending-up-OM6wBVvQ.js","assets/moon-DMVsctTM.js","assets/trophy-BtgLmZ39.js","assets/activity-S-FQ6Anu.js","assets/AreaSection-BxnKzNK0.js","assets/TaxonomySuggestionTile-jIiLMp4q.js","assets/useHashScrollOnReady-D5UCCQuT.js","assets/areas-Dvi8w2dp.js","assets/TagBrowseView-DKVo9Mlp.js","assets/ResearchFollowButton-Dv316ClR.js","assets/BenchmarkTrendSparkline-DhXxdQ2D.js","assets/NotFound-DV_nwcxG.js","assets/MethodsIndexView-D_aKGLyJ.js","assets/FrameworksIndexView-CZmHXkeL.js","assets/TrendsView-DCijqOnv.js","assets/ConferencesIndexView-DJVYKUiz.js","assets/deadlines-BH32v7D1.js","assets/AiDeadlinesView--bEB1R4q.js","assets/switch-nfvTohnt.js","assets/ConferenceDetailView-DgDeLFoO.js","assets/conferenceListings-BnmhBx-_.js","assets/ConferenceTaskView-BvWfAecx.js","assets/OrganizationsIndexView-DpJistoL.js","assets/OrganizationsIndexView-CJnrfIkP.css","assets/OrganizationDetailView-DYOQ1Mwd.js","assets/OrganizationContributionGraph-DsoZR4EG.js","assets/AuthorDetailView-BykOxZh0.js","assets/MethodDetailView-5wFkSBs8.js","assets/BenchmarkDetailView-BObHaEFx.js","assets/BenchmarkDetailView-CXxK75GR.css","assets/SavedPapersView-B2fQDeYi.js","assets/SettingsView-BuCdwlbq.js","assets/PrivacyView-BQ3x7IFA.js","assets/ApiDocsView-DhYUFS5g.js","assets/ApiDocsView-DPuMdYvY.css","assets/McpView-DYa6GKrp.js","assets/McpView-EGeqkP46.css","assets/SubmitView-CDuD6xEz.js","assets/CronDashboard-kqcQ1rzf.js","assets/CronDashboard-qYV75PLc.js","assets/CronDashboard-DwChfW9h.css","assets/refresh-cw-DYXzpRir.js","assets/circle-check-GGlu5UCV.js","assets/AutonomousOperations-B4vSAvB8.js","assets/SubmissionsDashboard-CZ6QfHso.js","assets/SubmissionsDashboard-BTmvDoLW.css","assets/UserProfileView-BnW4I15t.js","assets/RateLimitsView-phVSVOy1.js","assets/AstraForRoboticsView-BZJ-P8S9.js","assets/AstraForRoboticsView-C_lTF_XB.css","assets/SearchOverlay-5zBt7fdP.js","assets/StagingAccessRequestView-CZz80h2x.js"])))=>i.map(i=>d[i]); -var Vk=Object.defineProperty;var ym=e=>{throw TypeError(e)};var Bk=(e,t,n)=>t in e?Vk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var kr=(e,t,n)=>Bk(e,typeof t!="symbol"?t+"":t,n),Nd=(e,t,n)=>t.has(e)||ym("Cannot "+n);var k=(e,t,n)=>(Nd(e,t,"read from private field"),n?n.call(e):t.get(e)),X=(e,t,n)=>t.has(e)?ym("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),H=(e,t,n,r)=>(Nd(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ue=(e,t,n)=>(Nd(e,t,"access private method"),n);var Tl=(e,t,n,r)=>({set _(i){H(e,t,i,n)},get _(){return k(e,t,r)}});function qk(e,t){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var nz=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function aw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var lw={exports:{}},Gc={},uw={exports:{}},le={};/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AuthorizePaperEditView-C-sg5DHX.js","assets/useMutation-BYtVrkc7.js","assets/button-DetZl_ch.js","assets/paperEdits-C_3nZTKz.js","assets/FollowingView-C0KL9Wds.js","assets/FeedView-BZs7imUl.js","assets/sparkles-CIfeDmV2.js","assets/dialog-BzX9PD3v.js","assets/catalog-qXcKve0z.js","assets/researchTopic-NmABF6tT.js","assets/transform-CRNzYLch.js","assets/plus-AztI1566.js","assets/arrow-right-BrRhWCQS.js","assets/PaperFeed-D3FZw29k.js","assets/PaperCard-dvXhr75r.js","assets/AuthorAvatar-D9249Frl.js","assets/AuthorAvatar-o5W6pl_W.css","assets/SotaBadges-CyScuNCv.js","assets/colors-BkWRhvFI.js","assets/Icon-CGRs4BYD.js","assets/LatexTitle-DESKtS30.js","assets/papers-DgZwjF3K.js","assets/curation-CyyuHfv5.js","assets/safeExternalHref-CkBrsh84.js","assets/popover-Df5_dywQ.js","assets/skeleton-DTWi7Ctg.js","assets/useIntersectionObserver-Ch6RpsSk.js","assets/McpShowcase-Bo79ATLK.js","assets/AgentLogos-xoTIu0NB.js","assets/chatSessions-9VEG8seW.js","assets/chat-B1EBF720.js","assets/usePapers-BZThqZCx.js","assets/useInfiniteQuery-DeZTTVbI.js","assets/alert-BM9Xfuyy.js","assets/ChatView-DeilSeCH.js","assets/chatLifecycle-B6B3Dpfi.js","assets/hover-card-CIBIV2Hx.js","assets/CatalogEntityPreviewLink-DY_jhXy9.js","assets/github-4bW4WI_e.js","assets/file-text-CHlxsNJC.js","assets/PaperPreviewLink-zGfFNaz6.js","assets/index-tLcwYp0U.js","assets/index-Dj6aE-6E.js","assets/katex-DkKDou_j.js","assets/thumbs-up-Dn_5H93T.js","assets/copy-SoF5zg-g.js","assets/queryOptions-C9woPjwX.js","assets/arrow-left-CkQb0MI4.js","assets/external-link-CTLWFJ8S.js","assets/search-DxMn7VKI.js","assets/chevron-up-BwiJ46dh.js","assets/chatLifecycle-Lr_OJaUk.css","assets/katex-wklAmtGL.css","assets/share-2-Nvga0TP8.js","assets/openrouter-B-ghWDkd.js","assets/SharedChatView-BS81XNKW.js","assets/PapersListView-DL7UDvBC.js","assets/useDebounce-wGQ3PIQd.js","assets/apiErrors-D0w5By9R.js","assets/frameworks-DDA0P4Tf.js","assets/PaperDetailView-DSf05yVz.js","assets/ExternalSourceEvalBadge-B3fyun97.js","assets/ExternalSourceEvalBadge-CWUQ52cV.css","assets/paperReader-h6jqpWHI.js","assets/useDocumentTitle-2Ho8_KfW.js","assets/preferences-DMhkYrri.js","assets/account-DoluPGSd.js","assets/evaluationQueryInvalidation-BAyi4YoG.js","assets/queryInvalidation-LiTu0GxY.js","assets/input-7i-rZ7fA.js","assets/searchable-select-EPf13F1I.js","assets/loader-circle-xTdSzHv_.js","assets/SignInToEditDialog-rWxdYNRK.js","assets/textarea-biscLKBK.js","assets/submissions-CQ6M0giV.js","assets/database-b_ekt_5x.js","assets/badge-C8r6F6JD.js","assets/globe-mBp0l-nC.js","assets/index-BxR27SAB.js","assets/codex-CgFzL2AI.js","assets/savedPapersAuth-DT83MLdi.js","assets/organizationNames-BVKzYEBp.js","assets/PaperDetailView-CUWCgV3F.css","assets/PaperReaderView-CqbyUlPD.js","assets/MarkdownText-MrITlqRE.js","assets/TagsIndexView-Bqdox0Xx.js","assets/slug-BpH-Nkvz.js","assets/triangle-alert-DF8Mdy0J.js","assets/trending-up-BMb-8Pi8.js","assets/moon-HVqBvdxs.js","assets/trophy-BQy3NGXy.js","assets/activity--6WvmXv2.js","assets/AreaSection-iYSRoy6-.js","assets/TaxonomySuggestionTile-ByzqhBFs.js","assets/useHashScrollOnReady-mScSLUem.js","assets/areas-Dvi8w2dp.js","assets/TagBrowseView-jVCzOB7D.js","assets/ResearchFollowButton-DcTptDpW.js","assets/BenchmarkTrendSparkline-Dfex1cLI.js","assets/NotFound-BeWhm9El.js","assets/MethodsIndexView-BlMbRRsu.js","assets/FrameworksIndexView-BBgK14SQ.js","assets/TrendsView-DPKj3I8y.js","assets/ConferencesIndexView-CS7nG4hL.js","assets/deadlines-BH32v7D1.js","assets/AiDeadlinesView-Dh-TYdum.js","assets/switch-hcLL2FH0.js","assets/ConferenceDetailView-CujSkc9V.js","assets/conferenceListings-BnmhBx-_.js","assets/ConferenceTaskView-BrixcLRv.js","assets/OrganizationsIndexView-ec7nj_SS.js","assets/OrganizationsIndexView-CJnrfIkP.css","assets/OrganizationDetailView-ysggtQzi.js","assets/OrganizationContributionGraph-JI11b4D1.js","assets/AuthorDetailView-BwEN_vpq.js","assets/MethodDetailView-DVIskZnq.js","assets/BenchmarkDetailView-B6qFGTVj.js","assets/BenchmarkDetailView-CXxK75GR.css","assets/SavedPapersView-CCKo8hBZ.js","assets/SettingsView-DAkLrhMP.js","assets/PrivacyView-BHODG2cO.js","assets/ApiDocsView-LwSN2FTa.js","assets/ApiDocsView-DPuMdYvY.css","assets/McpView-A6zV6cTb.js","assets/McpView-EGeqkP46.css","assets/SubmitView-BCL1MLcF.js","assets/CronDashboard-BgGmgfB6.js","assets/CronDashboard-Di5xM1py.js","assets/CronDashboard-DwChfW9h.css","assets/refresh-cw-BuRFYuxm.js","assets/circle-check-B2vTBhyc.js","assets/AutonomousOperations-BMzZOLm6.js","assets/SubmissionsDashboard-CkzOBcpM.js","assets/SubmissionsDashboard-BTmvDoLW.css","assets/UserProfileView-kB3mGrtz.js","assets/RateLimitsView-CrvlGHnU.js","assets/AstraForRoboticsView-BMiTVC2T.js","assets/AstraForRoboticsView-C_lTF_XB.css","assets/SearchOverlay-Dvr0LreX.js","assets/StagingAccessRequestView-D1t7icpG.js"])))=>i.map(i=>d[i]); +var Uk=Object.defineProperty;var ym=e=>{throw TypeError(e)};var Vk=(e,t,n)=>t in e?Uk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var kr=(e,t,n)=>Vk(e,typeof t!="symbol"?t+"":t,n),Nd=(e,t,n)=>t.has(e)||ym("Cannot "+n);var k=(e,t,n)=>(Nd(e,t,"read from private field"),n?n.call(e):t.get(e)),X=(e,t,n)=>t.has(e)?ym("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),H=(e,t,n,r)=>(Nd(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ue=(e,t,n)=>(Nd(e,t,"access private method"),n);var Tl=(e,t,n,r)=>({set _(i){H(e,t,i,n)},get _(){return k(e,t,r)}});function Bk(e,t){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var nz=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function aw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var lw={exports:{}},Gc={},uw={exports:{}},le={};/** * @license React * react.production.min.js * @@ -7,7 +7,7 @@ var Vk=Object.defineProperty;var ym=e=>{throw TypeError(e)};var Bk=(e,t,n)=>t in * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var gl=Symbol.for("react.element"),Wk=Symbol.for("react.portal"),Hk=Symbol.for("react.fragment"),Gk=Symbol.for("react.strict_mode"),Kk=Symbol.for("react.profiler"),Qk=Symbol.for("react.provider"),Yk=Symbol.for("react.context"),Xk=Symbol.for("react.forward_ref"),Jk=Symbol.for("react.suspense"),Zk=Symbol.for("react.memo"),eP=Symbol.for("react.lazy"),_m=Symbol.iterator;function tP(e){return e===null||typeof e!="object"?null:(e=_m&&e[_m]||e["@@iterator"],typeof e=="function"?e:null)}var cw={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},dw=Object.assign,fw={};function Oo(e,t,n){this.props=e,this.context=t,this.refs=fw,this.updater=n||cw}Oo.prototype.isReactComponent={};Oo.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Oo.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function hw(){}hw.prototype=Oo.prototype;function gv(e,t,n){this.props=e,this.context=t,this.refs=fw,this.updater=n||cw}var mv=gv.prototype=new hw;mv.constructor=gv;dw(mv,Oo.prototype);mv.isPureReactComponent=!0;var wm=Array.isArray,pw=Object.prototype.hasOwnProperty,yv={current:null},vw={key:!0,ref:!0,__self:!0,__source:!0};function gw(e,t,n){var r,i={},s=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(s=""+t.key),t)pw.call(t,r)&&!vw.hasOwnProperty(r)&&(i[r]=t[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1{throw TypeError(e)};var Bk=(e,t,n)=>t in * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var oP=g,aP=Symbol.for("react.element"),lP=Symbol.for("react.fragment"),uP=Object.prototype.hasOwnProperty,cP=oP.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,dP={key:!0,ref:!0,__self:!0,__source:!0};function yw(e,t,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)uP.call(t,r)&&!dP.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:aP,type:e,key:s,ref:o,props:i,_owner:cP.current}}Gc.Fragment=lP;Gc.jsx=yw;Gc.jsxs=yw;lw.exports=Gc;var w=lw.exports,_w={exports:{}},Zt={},ww={exports:{}},xw={};/** + */var sP=g,oP=Symbol.for("react.element"),aP=Symbol.for("react.fragment"),lP=Object.prototype.hasOwnProperty,uP=sP.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,cP={key:!0,ref:!0,__self:!0,__source:!0};function yw(e,t,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)lP.call(t,r)&&!cP.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:oP,type:e,key:s,ref:o,props:i,_owner:uP.current}}Gc.Fragment=aP;Gc.jsx=yw;Gc.jsxs=yw;lw.exports=Gc;var w=lw.exports,_w={exports:{}},Zt={},ww={exports:{}},xw={};/** * @license React * scheduler.production.min.js * @@ -23,7 +23,7 @@ var Vk=Object.defineProperty;var ym=e=>{throw TypeError(e)};var Bk=(e,t,n)=>t in * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(e){function t(O,A){var V=O.length;O.push(A);e:for(;0>>1,te=O[K];if(0>>1;Ki(be,V))Pei(Be,be)?(O[K]=Be,O[Pe]=V,K=Pe):(O[K]=be,O[de]=V,K=de);else if(Pei(Be,V))O[K]=Be,O[Pe]=V,K=Pe;else break e}}return A}function i(O,A){var V=O.sortIndex-A.sortIndex;return V!==0?V:O.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var l=[],u=[],c=1,d=null,f=3,m=!1,_=!1,p=!1,y=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(O){for(var A=n(u);A!==null;){if(A.callback===null)r(u);else if(A.startTime<=O)r(u),A.sortIndex=A.expirationTime,t(l,A);else break;A=n(u)}}function b(O){if(p=!1,x(O),!_)if(n(l)!==null)_=!0,B(E);else{var A=n(u);A!==null&&Q(b,A.startTime-O)}}function E(O,A){_=!1,p&&(p=!1,h(C),C=-1),m=!0;var V=f;try{for(x(A),d=n(l);d!==null&&(!(d.expirationTime>A)||O&&!N());){var K=d.callback;if(typeof K=="function"){d.callback=null,f=d.priorityLevel;var te=K(d.expirationTime<=A);A=e.unstable_now(),typeof te=="function"?d.callback=te:d===n(l)&&r(l),x(A)}else r(l);d=n(l)}if(d!==null)var oe=!0;else{var de=n(u);de!==null&&Q(b,de.startTime-A),oe=!1}return oe}finally{d=null,f=V,m=!1}}var S=!1,P=null,C=-1,T=5,R=-1;function N(){return!(e.unstable_now()-RO||125K?(O.sortIndex=V,t(u,O),n(l)===null&&O===n(u)&&(p?(h(C),C=-1):p=!0,Q(b,V-K))):(O.sortIndex=te,t(l,O),_||m||(_=!0,B(E))),O},e.unstable_shouldYield=N,e.unstable_wrapCallback=function(O){var A=f;return function(){var V=f;f=A;try{return O.apply(this,arguments)}finally{f=V}}}})(xw);ww.exports=xw;var fP=ww.exports;/** + */(function(e){function t(O,A){var V=O.length;O.push(A);e:for(;0>>1,te=O[K];if(0>>1;Ki(be,V))Pei(Be,be)?(O[K]=Be,O[Pe]=V,K=Pe):(O[K]=be,O[de]=V,K=de);else if(Pei(Be,V))O[K]=Be,O[Pe]=V,K=Pe;else break e}}return A}function i(O,A){var V=O.sortIndex-A.sortIndex;return V!==0?V:O.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var l=[],u=[],c=1,d=null,f=3,m=!1,_=!1,p=!1,y=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(O){for(var A=n(u);A!==null;){if(A.callback===null)r(u);else if(A.startTime<=O)r(u),A.sortIndex=A.expirationTime,t(l,A);else break;A=n(u)}}function b(O){if(p=!1,x(O),!_)if(n(l)!==null)_=!0,B(E);else{var A=n(u);A!==null&&Q(b,A.startTime-O)}}function E(O,A){_=!1,p&&(p=!1,h(C),C=-1),m=!0;var V=f;try{for(x(A),d=n(l);d!==null&&(!(d.expirationTime>A)||O&&!N());){var K=d.callback;if(typeof K=="function"){d.callback=null,f=d.priorityLevel;var te=K(d.expirationTime<=A);A=e.unstable_now(),typeof te=="function"?d.callback=te:d===n(l)&&r(l),x(A)}else r(l);d=n(l)}if(d!==null)var oe=!0;else{var de=n(u);de!==null&&Q(b,de.startTime-A),oe=!1}return oe}finally{d=null,f=V,m=!1}}var S=!1,P=null,C=-1,T=5,R=-1;function N(){return!(e.unstable_now()-RO||125K?(O.sortIndex=V,t(u,O),n(l)===null&&O===n(u)&&(p?(h(C),C=-1):p=!0,Q(b,V-K))):(O.sortIndex=te,t(l,O),_||m||(_=!0,B(E))),O},e.unstable_shouldYield=N,e.unstable_wrapCallback=function(O){var A=f;return function(){var V=f;f=A;try{return O.apply(this,arguments)}finally{f=V}}}})(xw);ww.exports=xw;var dP=ww.exports;/** * @license React * react-dom.production.min.js * @@ -31,16 +31,16 @@ var Vk=Object.defineProperty;var ym=e=>{throw TypeError(e)};var Bk=(e,t,n)=>t in * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var hP=g,Jt=fP;function U(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),oh=Object.prototype.hasOwnProperty,pP=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,bm={},Em={};function vP(e){return oh.call(Em,e)?!0:oh.call(bm,e)?!1:pP.test(e)?Em[e]=!0:(bm[e]=!0,!1)}function gP(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function mP(e,t,n,r){if(t===null||typeof t>"u"||gP(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Pt(e,t,n,r,i,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var ut={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ut[e]=new Pt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ut[t]=new Pt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ut[e]=new Pt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ut[e]=new Pt(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){ut[e]=new Pt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ut[e]=new Pt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ut[e]=new Pt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ut[e]=new Pt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ut[e]=new Pt(e,5,!1,e.toLowerCase(),null,!1,!1)});var wv=/[\-:]([a-z])/g;function xv(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(wv,xv);ut[t]=new Pt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(wv,xv);ut[t]=new Pt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(wv,xv);ut[t]=new Pt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ut[e]=new Pt(e,1,!1,e.toLowerCase(),null,!1,!1)});ut.xlinkHref=new Pt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ut[e]=new Pt(e,1,!1,e.toLowerCase(),null,!0,!0)});function bv(e,t,n,r){var i=ut.hasOwnProperty(t)?ut[t]:null;(i!==null?i.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),oh=Object.prototype.hasOwnProperty,hP=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,bm={},Em={};function pP(e){return oh.call(Em,e)?!0:oh.call(bm,e)?!1:hP.test(e)?Em[e]=!0:(bm[e]=!0,!1)}function vP(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function gP(e,t,n,r){if(t===null||typeof t>"u"||vP(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Pt(e,t,n,r,i,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var ut={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ut[e]=new Pt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ut[t]=new Pt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ut[e]=new Pt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ut[e]=new Pt(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){ut[e]=new Pt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ut[e]=new Pt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ut[e]=new Pt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ut[e]=new Pt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ut[e]=new Pt(e,5,!1,e.toLowerCase(),null,!1,!1)});var wv=/[\-:]([a-z])/g;function xv(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(wv,xv);ut[t]=new Pt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(wv,xv);ut[t]=new Pt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(wv,xv);ut[t]=new Pt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ut[e]=new Pt(e,1,!1,e.toLowerCase(),null,!1,!1)});ut.xlinkHref=new Pt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ut[e]=new Pt(e,1,!1,e.toLowerCase(),null,!0,!0)});function bv(e,t,n,r){var i=ut.hasOwnProperty(t)?ut[t]:null;(i!==null?i.type!==0:r||!(2a||i[o]!==s[a]){var l=` -`+i[o].replace(" at new "," at ");return e.displayName&&l.includes("")&&(l=l.replace("",e.displayName)),l}while(1<=o&&0<=a);break}}}finally{Ld=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?sa(e):""}function yP(e){switch(e.tag){case 5:return sa(e.type);case 16:return sa("Lazy");case 13:return sa("Suspense");case 19:return sa("SuspenseList");case 0:case 2:case 15:return e=jd(e.type,!1),e;case 11:return e=jd(e.type.render,!1),e;case 1:return e=jd(e.type,!0),e;default:return""}}function ch(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ss:return"Fragment";case Es:return"Portal";case ah:return"Profiler";case Ev:return"StrictMode";case lh:return"Suspense";case uh:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Sw:return(e.displayName||"Context")+".Consumer";case Ew:return(e._context.displayName||"Context")+".Provider";case Sv:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Cv:return t=e.displayName||null,t!==null?t:ch(e.type)||"Memo";case $r:t=e._payload,e=e._init;try{return ch(e(t))}catch{}}return null}function _P(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ch(t);case 8:return t===Ev?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function oi(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function kw(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function wP(e){var t=kw(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ml(e){e._valueTracker||(e._valueTracker=wP(e))}function Pw(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=kw(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Du(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function dh(e,t){var n=t.checked;return Ve({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Cm(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=oi(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Rw(e,t){t=t.checked,t!=null&&bv(e,"checked",t,!1)}function fh(e,t){Rw(e,t);var n=oi(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?hh(e,t.type,n):t.hasOwnProperty("defaultValue")&&hh(e,t.type,oi(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function km(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function hh(e,t,n){(t!=="number"||Du(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var oa=Array.isArray;function js(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i"+t.valueOf().toString()+"",t=Al.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ma(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var va={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},xP=["Webkit","ms","Moz","O"];Object.keys(va).forEach(function(e){xP.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),va[t]=va[e]})});function Mw(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||va.hasOwnProperty(e)&&va[e]?(""+t).trim():t+"px"}function Aw(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Mw(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var bP=Ve({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function gh(e,t){if(t){if(bP[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(U(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(U(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(U(61))}if(t.style!=null&&typeof t.style!="object")throw Error(U(62))}}function mh(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var yh=null;function kv(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var _h=null,Ds=null,zs=null;function Tm(e){if(e=_l(e)){if(typeof _h!="function")throw Error(U(280));var t=e.stateNode;t&&(t=Zc(t),_h(e.stateNode,e.type,t))}}function Nw(e){Ds?zs?zs.push(e):zs=[e]:Ds=e}function $w(){if(Ds){var e=Ds,t=zs;if(zs=Ds=null,Tm(e),t)for(e=0;e>>=0,e===0?32:31-(AP(e)/NP|0)|0}var Nl=64,$l=4194304;function aa(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bu(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,s=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=aa(a):(s&=o,s!==0&&(r=aa(s)))}else o=n&~i,o!==0?r=aa(o):s!==0&&(r=aa(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,s=t&-t,i>=s||i===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function ml(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Sn(t),e[t]=n}function jP(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=ma),jm=" ",Dm=!1;function tx(e,t){switch(e){case"keyup":return fR.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function nx(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Cs=!1;function pR(e,t){switch(e){case"compositionend":return nx(t);case"keypress":return t.which!==32?null:(Dm=!0,jm);case"textInput":return e=t.data,e===jm&&Dm?null:e;default:return null}}function vR(e,t){if(Cs)return e==="compositionend"||!Nv&&tx(e,t)?(e=Zw(),yu=Ov=Gr=null,Cs=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Bm(n)}}function ox(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ox(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ax(){for(var e=window,t=Du();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Du(e.document)}return t}function $v(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function SR(e){var t=ax(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&ox(n.ownerDocument.documentElement,n)){if(r!==null&&$v(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!e.extend&&s>r&&(i=r,r=s,s=i),i=qm(n,s);var o=qm(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,ks=null,Ch=null,_a=null,kh=!1;function Wm(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;kh||ks==null||ks!==Du(r)||(r=ks,"selectionStart"in r&&$v(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),_a&&ja(_a,r)||(_a=r,r=Hu(Ch,"onSelect"),0Ts||(e.current=Mh[Ts],Mh[Ts]=null,Ts--)}function Te(e,t){Ts++,Mh[Ts]=e.current,e.current=t}var ai={},yt=hi(ai),jt=hi(!1),Ki=ai;function po(e,t){var n=e.type.contextTypes;if(!n)return ai;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Dt(e){return e=e.childContextTypes,e!=null}function Ku(){$e(jt),$e(yt)}function Jm(e,t,n){if(yt.current!==ai)throw Error(U(168));Te(yt,t),Te(jt,n)}function gx(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(U(108,_P(e)||"Unknown",i));return Ve({},n,r)}function Qu(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ai,Ki=yt.current,Te(yt,e),Te(jt,jt.current),!0}function Zm(e,t,n){var r=e.stateNode;if(!r)throw Error(U(169));n?(e=gx(e,t,Ki),r.__reactInternalMemoizedMergedChildContext=e,$e(jt),$e(yt),Te(yt,e)):$e(jt),Te(jt,n)}var rr=null,ed=!1,Jd=!1;function mx(e){rr===null?rr=[e]:rr.push(e)}function FR(e){ed=!0,mx(e)}function pi(){if(!Jd&&rr!==null){Jd=!0;var e=0,t=xe;try{var n=rr;for(xe=1;e>=o,i-=o,cr=1<<32-Sn(t)+i|n<C?(T=P,P=null):T=P.sibling;var R=f(h,P,x[C],b);if(R===null){P===null&&(P=T);break}e&&P&&R.alternate===null&&t(h,P),v=s(R,v,C),S===null?E=R:S.sibling=R,S=R,P=T}if(C===x.length)return n(h,P),je&&bi(h,C),E;if(P===null){for(;CC?(T=P,P=null):T=P.sibling;var N=f(h,P,R.value,b);if(N===null){P===null&&(P=T);break}e&&P&&N.alternate===null&&t(h,P),v=s(N,v,C),S===null?E=N:S.sibling=N,S=N,P=T}if(R.done)return n(h,P),je&&bi(h,C),E;if(P===null){for(;!R.done;C++,R=x.next())R=d(h,R.value,b),R!==null&&(v=s(R,v,C),S===null?E=R:S.sibling=R,S=R);return je&&bi(h,C),E}for(P=r(h,P);!R.done;C++,R=x.next())R=m(P,h,C,R.value,b),R!==null&&(e&&R.alternate!==null&&P.delete(R.key===null?C:R.key),v=s(R,v,C),S===null?E=R:S.sibling=R,S=R);return e&&P.forEach(function(M){return t(h,M)}),je&&bi(h,C),E}function y(h,v,x,b){if(typeof x=="object"&&x!==null&&x.type===Ss&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case Ol:e:{for(var E=x.key,S=v;S!==null;){if(S.key===E){if(E=x.type,E===Ss){if(S.tag===7){n(h,S.sibling),v=i(S,x.props.children),v.return=h,h=v;break e}}else if(S.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===$r&&ny(E)===S.type){n(h,S.sibling),v=i(S,x.props),v.ref=Wo(h,S,x),v.return=h,h=v;break e}n(h,S);break}else t(h,S);S=S.sibling}x.type===Ss?(v=Wi(x.props.children,h.mode,b,x.key),v.return=h,h=v):(b=ku(x.type,x.key,x.props,null,h.mode,b),b.ref=Wo(h,v,x),b.return=h,h=b)}return o(h);case Es:e:{for(S=x.key;v!==null;){if(v.key===S)if(v.tag===4&&v.stateNode.containerInfo===x.containerInfo&&v.stateNode.implementation===x.implementation){n(h,v.sibling),v=i(v,x.children||[]),v.return=h,h=v;break e}else{n(h,v);break}else t(h,v);v=v.sibling}v=af(x,h.mode,b),v.return=h,h=v}return o(h);case $r:return S=x._init,y(h,v,S(x._payload),b)}if(oa(x))return _(h,v,x,b);if(zo(x))return p(h,v,x,b);Vl(h,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,v!==null&&v.tag===6?(n(h,v.sibling),v=i(v,x),v.return=h,h=v):(n(h,v),v=of(x,h.mode,b),v.return=h,h=v),o(h)):n(h,v)}return y}var go=xx(!0),bx=xx(!1),Ju=hi(null),Zu=null,Ms=null,Dv=null;function zv(){Dv=Ms=Zu=null}function Uv(e){var t=Ju.current;$e(Ju),e._currentValue=t}function $h(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Vs(e,t){Zu=e,Dv=Ms=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ft=!0),e.firstContext=null)}function cn(e){var t=e._currentValue;if(Dv!==e)if(e={context:e,memoizedValue:t,next:null},Ms===null){if(Zu===null)throw Error(U(308));Ms=e,Zu.dependencies={lanes:0,firstContext:e}}else Ms=Ms.next=e;return t}var Ti=null;function Vv(e){Ti===null?Ti=[e]:Ti.push(e)}function Ex(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Vv(t)):(n.next=i.next,i.next=n),t.interleaved=n,gr(e,r)}function gr(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Fr=!1;function Bv(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Sx(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function hr(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ei(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,pe&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,gr(e,n)}return i=r.interleaved,i===null?(t.next=t,Vv(r)):(t.next=i.next,i.next=t),r.interleaved=t,gr(e,n)}function wu(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Rv(e,n)}}function ry(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=t:s=s.next=t}else i=s=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ec(e,t,n,r){var i=e.updateQueue;Fr=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,u=l.next;l.next=null,o===null?s=u:o.next=u,o=l;var c=e.alternate;c!==null&&(c=c.updateQueue,a=c.lastBaseUpdate,a!==o&&(a===null?c.firstBaseUpdate=u:a.next=u,c.lastBaseUpdate=l))}if(s!==null){var d=i.baseState;o=0,c=u=l=null,a=s;do{var f=a.lane,m=a.eventTime;if((r&f)===f){c!==null&&(c=c.next={eventTime:m,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var _=e,p=a;switch(f=t,m=n,p.tag){case 1:if(_=p.payload,typeof _=="function"){d=_.call(m,d,f);break e}d=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=p.payload,f=typeof _=="function"?_.call(m,d,f):_,f==null)break e;d=Ve({},d,f);break e;case 2:Fr=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[a]:f.push(a))}else m={eventTime:m,lane:f,tag:a.tag,payload:a.payload,callback:a.callback,next:null},c===null?(u=c=m,l=d):c=c.next=m,o|=f;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;f=a,a=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(!0);if(c===null&&(l=d),i.baseState=l,i.firstBaseUpdate=u,i.lastBaseUpdate=c,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else s===null&&(i.shared.lanes=0);Xi|=o,e.lanes=o,e.memoizedState=d}}function iy(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ef.transition;ef.transition={};try{e(!1),t()}finally{xe=n,ef.transition=r}}function Ux(){return dn().memoizedState}function zR(e,t,n){var r=ni(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Vx(e))Bx(t,n);else if(n=Ex(e,t,n,r),n!==null){var i=Ct();Cn(n,e,r,i),qx(n,t,r)}}function UR(e,t,n){var r=ni(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Vx(e))Bx(t,i);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,kn(a,o)){var l=t.interleaved;l===null?(i.next=i,Vv(t)):(i.next=l.next,l.next=i),t.interleaved=i;return}}catch{}finally{}n=Ex(e,t,i,r),n!==null&&(i=Ct(),Cn(n,e,r,i),qx(n,t,r))}}function Vx(e){var t=e.alternate;return e===ze||t!==null&&t===ze}function Bx(e,t){wa=nc=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function qx(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Rv(e,n)}}var rc={readContext:cn,useCallback:dt,useContext:dt,useEffect:dt,useImperativeHandle:dt,useInsertionEffect:dt,useLayoutEffect:dt,useMemo:dt,useReducer:dt,useRef:dt,useState:dt,useDebugValue:dt,useDeferredValue:dt,useTransition:dt,useMutableSource:dt,useSyncExternalStore:dt,useId:dt,unstable_isNewReconciler:!1},VR={readContext:cn,useCallback:function(e,t){return Nn().memoizedState=[e,t===void 0?null:t],e},useContext:cn,useEffect:oy,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,bu(4194308,4,Fx.bind(null,t,e),n)},useLayoutEffect:function(e,t){return bu(4194308,4,e,t)},useInsertionEffect:function(e,t){return bu(4,2,e,t)},useMemo:function(e,t){var n=Nn();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Nn();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=zR.bind(null,ze,e),[r.memoizedState,e]},useRef:function(e){var t=Nn();return e={current:e},t.memoizedState=e},useState:sy,useDebugValue:Xv,useDeferredValue:function(e){return Nn().memoizedState=e},useTransition:function(){var e=sy(!1),t=e[0];return e=DR.bind(null,e[1]),Nn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ze,i=Nn();if(je){if(n===void 0)throw Error(U(407));n=n()}else{if(n=t(),it===null)throw Error(U(349));Yi&30||Rx(r,t,n)}i.memoizedState=n;var s={value:n,getSnapshot:t};return i.queue=s,oy(Ix.bind(null,r,s,e),[e]),r.flags|=2048,Ha(9,Tx.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Nn(),t=it.identifierPrefix;if(je){var n=dr,r=cr;n=(r&~(1<<32-Sn(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=qa++,0")&&(l=l.replace("",e.displayName)),l}while(1<=o&&0<=a);break}}}finally{Ld=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?sa(e):""}function mP(e){switch(e.tag){case 5:return sa(e.type);case 16:return sa("Lazy");case 13:return sa("Suspense");case 19:return sa("SuspenseList");case 0:case 2:case 15:return e=jd(e.type,!1),e;case 11:return e=jd(e.type.render,!1),e;case 1:return e=jd(e.type,!0),e;default:return""}}function ch(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ss:return"Fragment";case Es:return"Portal";case ah:return"Profiler";case Ev:return"StrictMode";case lh:return"Suspense";case uh:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Sw:return(e.displayName||"Context")+".Consumer";case Ew:return(e._context.displayName||"Context")+".Provider";case Sv:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Cv:return t=e.displayName||null,t!==null?t:ch(e.type)||"Memo";case $r:t=e._payload,e=e._init;try{return ch(e(t))}catch{}}return null}function yP(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ch(t);case 8:return t===Ev?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function oi(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function kw(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function _P(e){var t=kw(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ml(e){e._valueTracker||(e._valueTracker=_P(e))}function Pw(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=kw(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Du(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function dh(e,t){var n=t.checked;return Ve({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Cm(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=oi(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Rw(e,t){t=t.checked,t!=null&&bv(e,"checked",t,!1)}function fh(e,t){Rw(e,t);var n=oi(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?hh(e,t.type,n):t.hasOwnProperty("defaultValue")&&hh(e,t.type,oi(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function km(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function hh(e,t,n){(t!=="number"||Du(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var oa=Array.isArray;function js(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i"+t.valueOf().toString()+"",t=Al.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ma(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var va={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},wP=["Webkit","ms","Moz","O"];Object.keys(va).forEach(function(e){wP.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),va[t]=va[e]})});function Mw(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||va.hasOwnProperty(e)&&va[e]?(""+t).trim():t+"px"}function Aw(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Mw(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var xP=Ve({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function gh(e,t){if(t){if(xP[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(U(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(U(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(U(61))}if(t.style!=null&&typeof t.style!="object")throw Error(U(62))}}function mh(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var yh=null;function kv(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var _h=null,Ds=null,zs=null;function Tm(e){if(e=_l(e)){if(typeof _h!="function")throw Error(U(280));var t=e.stateNode;t&&(t=Zc(t),_h(e.stateNode,e.type,t))}}function Nw(e){Ds?zs?zs.push(e):zs=[e]:Ds=e}function $w(){if(Ds){var e=Ds,t=zs;if(zs=Ds=null,Tm(e),t)for(e=0;e>>=0,e===0?32:31-(MP(e)/AP|0)|0}var Nl=64,$l=4194304;function aa(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bu(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,s=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=aa(a):(s&=o,s!==0&&(r=aa(s)))}else o=n&~i,o!==0?r=aa(o):s!==0&&(r=aa(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,s=t&-t,i>=s||i===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function ml(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Sn(t),e[t]=n}function LP(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=ma),jm=" ",Dm=!1;function tx(e,t){switch(e){case"keyup":return dR.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function nx(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Cs=!1;function hR(e,t){switch(e){case"compositionend":return nx(t);case"keypress":return t.which!==32?null:(Dm=!0,jm);case"textInput":return e=t.data,e===jm&&Dm?null:e;default:return null}}function pR(e,t){if(Cs)return e==="compositionend"||!Nv&&tx(e,t)?(e=Zw(),yu=Ov=Gr=null,Cs=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Bm(n)}}function ox(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ox(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ax(){for(var e=window,t=Du();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Du(e.document)}return t}function $v(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function ER(e){var t=ax(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&ox(n.ownerDocument.documentElement,n)){if(r!==null&&$v(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!e.extend&&s>r&&(i=r,r=s,s=i),i=qm(n,s);var o=qm(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,ks=null,Ch=null,_a=null,kh=!1;function Wm(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;kh||ks==null||ks!==Du(r)||(r=ks,"selectionStart"in r&&$v(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),_a&&ja(_a,r)||(_a=r,r=Hu(Ch,"onSelect"),0Ts||(e.current=Mh[Ts],Mh[Ts]=null,Ts--)}function Te(e,t){Ts++,Mh[Ts]=e.current,e.current=t}var ai={},yt=hi(ai),jt=hi(!1),Ki=ai;function po(e,t){var n=e.type.contextTypes;if(!n)return ai;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Dt(e){return e=e.childContextTypes,e!=null}function Ku(){$e(jt),$e(yt)}function Jm(e,t,n){if(yt.current!==ai)throw Error(U(168));Te(yt,t),Te(jt,n)}function gx(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(U(108,yP(e)||"Unknown",i));return Ve({},n,r)}function Qu(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ai,Ki=yt.current,Te(yt,e),Te(jt,jt.current),!0}function Zm(e,t,n){var r=e.stateNode;if(!r)throw Error(U(169));n?(e=gx(e,t,Ki),r.__reactInternalMemoizedMergedChildContext=e,$e(jt),$e(yt),Te(yt,e)):$e(jt),Te(jt,n)}var rr=null,ed=!1,Jd=!1;function mx(e){rr===null?rr=[e]:rr.push(e)}function $R(e){ed=!0,mx(e)}function pi(){if(!Jd&&rr!==null){Jd=!0;var e=0,t=xe;try{var n=rr;for(xe=1;e>=o,i-=o,cr=1<<32-Sn(t)+i|n<C?(T=P,P=null):T=P.sibling;var R=f(h,P,x[C],b);if(R===null){P===null&&(P=T);break}e&&P&&R.alternate===null&&t(h,P),v=s(R,v,C),S===null?E=R:S.sibling=R,S=R,P=T}if(C===x.length)return n(h,P),je&&bi(h,C),E;if(P===null){for(;CC?(T=P,P=null):T=P.sibling;var N=f(h,P,R.value,b);if(N===null){P===null&&(P=T);break}e&&P&&N.alternate===null&&t(h,P),v=s(N,v,C),S===null?E=N:S.sibling=N,S=N,P=T}if(R.done)return n(h,P),je&&bi(h,C),E;if(P===null){for(;!R.done;C++,R=x.next())R=d(h,R.value,b),R!==null&&(v=s(R,v,C),S===null?E=R:S.sibling=R,S=R);return je&&bi(h,C),E}for(P=r(h,P);!R.done;C++,R=x.next())R=m(P,h,C,R.value,b),R!==null&&(e&&R.alternate!==null&&P.delete(R.key===null?C:R.key),v=s(R,v,C),S===null?E=R:S.sibling=R,S=R);return e&&P.forEach(function(M){return t(h,M)}),je&&bi(h,C),E}function y(h,v,x,b){if(typeof x=="object"&&x!==null&&x.type===Ss&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case Ol:e:{for(var E=x.key,S=v;S!==null;){if(S.key===E){if(E=x.type,E===Ss){if(S.tag===7){n(h,S.sibling),v=i(S,x.props.children),v.return=h,h=v;break e}}else if(S.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===$r&&ny(E)===S.type){n(h,S.sibling),v=i(S,x.props),v.ref=Wo(h,S,x),v.return=h,h=v;break e}n(h,S);break}else t(h,S);S=S.sibling}x.type===Ss?(v=Wi(x.props.children,h.mode,b,x.key),v.return=h,h=v):(b=ku(x.type,x.key,x.props,null,h.mode,b),b.ref=Wo(h,v,x),b.return=h,h=b)}return o(h);case Es:e:{for(S=x.key;v!==null;){if(v.key===S)if(v.tag===4&&v.stateNode.containerInfo===x.containerInfo&&v.stateNode.implementation===x.implementation){n(h,v.sibling),v=i(v,x.children||[]),v.return=h,h=v;break e}else{n(h,v);break}else t(h,v);v=v.sibling}v=af(x,h.mode,b),v.return=h,h=v}return o(h);case $r:return S=x._init,y(h,v,S(x._payload),b)}if(oa(x))return _(h,v,x,b);if(zo(x))return p(h,v,x,b);Vl(h,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,v!==null&&v.tag===6?(n(h,v.sibling),v=i(v,x),v.return=h,h=v):(n(h,v),v=of(x,h.mode,b),v.return=h,h=v),o(h)):n(h,v)}return y}var go=xx(!0),bx=xx(!1),Ju=hi(null),Zu=null,Ms=null,Dv=null;function zv(){Dv=Ms=Zu=null}function Uv(e){var t=Ju.current;$e(Ju),e._currentValue=t}function $h(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Vs(e,t){Zu=e,Dv=Ms=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ft=!0),e.firstContext=null)}function cn(e){var t=e._currentValue;if(Dv!==e)if(e={context:e,memoizedValue:t,next:null},Ms===null){if(Zu===null)throw Error(U(308));Ms=e,Zu.dependencies={lanes:0,firstContext:e}}else Ms=Ms.next=e;return t}var Ti=null;function Vv(e){Ti===null?Ti=[e]:Ti.push(e)}function Ex(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Vv(t)):(n.next=i.next,i.next=n),t.interleaved=n,gr(e,r)}function gr(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Fr=!1;function Bv(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Sx(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function hr(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ei(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,pe&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,gr(e,n)}return i=r.interleaved,i===null?(t.next=t,Vv(r)):(t.next=i.next,i.next=t),r.interleaved=t,gr(e,n)}function wu(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Rv(e,n)}}function ry(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=t:s=s.next=t}else i=s=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ec(e,t,n,r){var i=e.updateQueue;Fr=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,u=l.next;l.next=null,o===null?s=u:o.next=u,o=l;var c=e.alternate;c!==null&&(c=c.updateQueue,a=c.lastBaseUpdate,a!==o&&(a===null?c.firstBaseUpdate=u:a.next=u,c.lastBaseUpdate=l))}if(s!==null){var d=i.baseState;o=0,c=u=l=null,a=s;do{var f=a.lane,m=a.eventTime;if((r&f)===f){c!==null&&(c=c.next={eventTime:m,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var _=e,p=a;switch(f=t,m=n,p.tag){case 1:if(_=p.payload,typeof _=="function"){d=_.call(m,d,f);break e}d=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=p.payload,f=typeof _=="function"?_.call(m,d,f):_,f==null)break e;d=Ve({},d,f);break e;case 2:Fr=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[a]:f.push(a))}else m={eventTime:m,lane:f,tag:a.tag,payload:a.payload,callback:a.callback,next:null},c===null?(u=c=m,l=d):c=c.next=m,o|=f;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;f=a,a=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(!0);if(c===null&&(l=d),i.baseState=l,i.firstBaseUpdate=u,i.lastBaseUpdate=c,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else s===null&&(i.shared.lanes=0);Xi|=o,e.lanes=o,e.memoizedState=d}}function iy(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ef.transition;ef.transition={};try{e(!1),t()}finally{xe=n,ef.transition=r}}function Ux(){return dn().memoizedState}function DR(e,t,n){var r=ni(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Vx(e))Bx(t,n);else if(n=Ex(e,t,n,r),n!==null){var i=Ct();Cn(n,e,r,i),qx(n,t,r)}}function zR(e,t,n){var r=ni(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Vx(e))Bx(t,i);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,kn(a,o)){var l=t.interleaved;l===null?(i.next=i,Vv(t)):(i.next=l.next,l.next=i),t.interleaved=i;return}}catch{}finally{}n=Ex(e,t,i,r),n!==null&&(i=Ct(),Cn(n,e,r,i),qx(n,t,r))}}function Vx(e){var t=e.alternate;return e===ze||t!==null&&t===ze}function Bx(e,t){wa=nc=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function qx(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Rv(e,n)}}var rc={readContext:cn,useCallback:dt,useContext:dt,useEffect:dt,useImperativeHandle:dt,useInsertionEffect:dt,useLayoutEffect:dt,useMemo:dt,useReducer:dt,useRef:dt,useState:dt,useDebugValue:dt,useDeferredValue:dt,useTransition:dt,useMutableSource:dt,useSyncExternalStore:dt,useId:dt,unstable_isNewReconciler:!1},UR={readContext:cn,useCallback:function(e,t){return Nn().memoizedState=[e,t===void 0?null:t],e},useContext:cn,useEffect:oy,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,bu(4194308,4,Fx.bind(null,t,e),n)},useLayoutEffect:function(e,t){return bu(4194308,4,e,t)},useInsertionEffect:function(e,t){return bu(4,2,e,t)},useMemo:function(e,t){var n=Nn();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Nn();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=DR.bind(null,ze,e),[r.memoizedState,e]},useRef:function(e){var t=Nn();return e={current:e},t.memoizedState=e},useState:sy,useDebugValue:Xv,useDeferredValue:function(e){return Nn().memoizedState=e},useTransition:function(){var e=sy(!1),t=e[0];return e=jR.bind(null,e[1]),Nn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ze,i=Nn();if(je){if(n===void 0)throw Error(U(407));n=n()}else{if(n=t(),it===null)throw Error(U(349));Yi&30||Rx(r,t,n)}i.memoizedState=n;var s={value:n,getSnapshot:t};return i.queue=s,oy(Ix.bind(null,r,s,e),[e]),r.flags|=2048,Ha(9,Tx.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Nn(),t=it.identifierPrefix;if(je){var n=dr,r=cr;n=(r&~(1<<32-Sn(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=qa++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[zn]=t,e[Ua]=r,eb(e,t,!1,!1),t.stateNode=e;e:{switch(o=mh(n,r),n){case"dialog":Me("cancel",e),Me("close",e),i=r;break;case"iframe":case"object":case"embed":Me("load",e),i=r;break;case"video":case"audio":for(i=0;i_o&&(t.flags|=128,r=!0,Ho(s,!1),t.lanes=4194304)}else{if(!r)if(e=tc(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Ho(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!je)return ft(t),null}else 2*Qe()-s.renderingStartTime>_o&&n!==1073741824&&(t.flags|=128,r=!0,Ho(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(n=s.last,n!==null?n.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Qe(),t.sibling=null,n=De.current,Te(De,r?n&1|2:n&1),t):(ft(t),null);case 22:case 23:return rg(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Vt&1073741824&&(ft(t),t.subtreeFlags&6&&(t.flags|=8192)):ft(t),null;case 24:return null;case 25:return null}throw Error(U(156,t.tag))}function YR(e,t){switch(Lv(t),t.tag){case 1:return Dt(t.type)&&Ku(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return mo(),$e(jt),$e(yt),Hv(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Wv(t),null;case 13:if($e(De),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(U(340));vo()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return $e(De),null;case 4:return mo(),null;case 10:return Uv(t.type._context),null;case 22:case 23:return rg(),null;case 24:return null;default:return null}}var ql=!1,gt=!1,XR=typeof WeakSet=="function"?WeakSet:Set,G=null;function As(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){He(e,t,r)}else n.current=null}function qh(e,t,n){try{n()}catch(r){He(e,t,r)}}var my=!1;function JR(e,t){if(Ph=qu,e=ax(),$v(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,u=0,c=0,d=e,f=null;t:for(;;){for(var m;d!==n||i!==0&&d.nodeType!==3||(a=o+i),d!==s||r!==0&&d.nodeType!==3||(l=o+r),d.nodeType===3&&(o+=d.nodeValue.length),(m=d.firstChild)!==null;)f=d,d=m;for(;;){if(d===e)break t;if(f===n&&++u===i&&(a=o),f===s&&++c===r&&(l=o),(m=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=m}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(Rh={focusedElem:e,selectionRange:n},qu=!1,G=t;G!==null;)if(t=G,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,G=e;else for(;G!==null;){t=G;try{var _=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var p=_.memoizedProps,y=_.memoizedState,h=t.stateNode,v=h.getSnapshotBeforeUpdate(t.elementType===t.type?p:mn(t.type,p),y);h.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(U(163))}}catch(b){He(t,t.return,b)}if(e=t.sibling,e!==null){e.return=t.return,G=e;break}G=t.return}return _=my,my=!1,_}function xa(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var s=i.destroy;i.destroy=void 0,s!==void 0&&qh(t,n,s)}i=i.next}while(i!==r)}}function rd(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Wh(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function rb(e){var t=e.alternate;t!==null&&(e.alternate=null,rb(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[zn],delete t[Ua],delete t[Oh],delete t[NR],delete t[$R])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function ib(e){return e.tag===5||e.tag===3||e.tag===4}function yy(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ib(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Hh(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Gu));else if(r!==4&&(e=e.child,e!==null))for(Hh(e,t,n),e=e.sibling;e!==null;)Hh(e,t,n),e=e.sibling}function Gh(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Gh(e,t,n),e=e.sibling;e!==null;)Gh(e,t,n),e=e.sibling}var st=null,wn=!1;function Pr(e,t,n){for(n=n.child;n!==null;)sb(e,t,n),n=n.sibling}function sb(e,t,n){if(qn&&typeof qn.onCommitFiberUnmount=="function")try{qn.onCommitFiberUnmount(Qc,n)}catch{}switch(n.tag){case 5:gt||As(n,t);case 6:var r=st,i=wn;st=null,Pr(e,t,n),st=r,wn=i,st!==null&&(wn?(e=st,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):st.removeChild(n.stateNode));break;case 18:st!==null&&(wn?(e=st,n=n.stateNode,e.nodeType===8?Xd(e.parentNode,n):e.nodeType===1&&Xd(e,n),Fa(e)):Xd(st,n.stateNode));break;case 4:r=st,i=wn,st=n.stateNode.containerInfo,wn=!0,Pr(e,t,n),st=r,wn=i;break;case 0:case 11:case 14:case 15:if(!gt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&qh(n,t,o),i=i.next}while(i!==r)}Pr(e,t,n);break;case 1:if(!gt&&(As(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){He(n,t,a)}Pr(e,t,n);break;case 21:Pr(e,t,n);break;case 22:n.mode&1?(gt=(r=gt)||n.memoizedState!==null,Pr(e,t,n),gt=r):Pr(e,t,n);break;default:Pr(e,t,n)}}function _y(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new XR),t.forEach(function(r){var i=aT.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function vn(e,t){var n=t.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Qe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*eT(r/1960))-r,10e?16:e,Kr===null)var r=!1;else{if(e=Kr,Kr=null,oc=0,pe&6)throw Error(U(331));var i=pe;for(pe|=4,G=e.current;G!==null;){var s=G,o=s.child;if(G.flags&16){var a=s.deletions;if(a!==null){for(var l=0;lQe()-tg?qi(e,0):eg|=n),zt(e,t)}function hb(e,t){t===0&&(e.mode&1?(t=$l,$l<<=1,!($l&130023424)&&($l=4194304)):t=1);var n=Ct();e=gr(e,t),e!==null&&(ml(e,t,n),zt(e,n))}function oT(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),hb(e,n)}function aT(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(U(314))}r!==null&&r.delete(t),hb(e,n)}var pb;pb=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||jt.current)Ft=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ft=!1,KR(e,t,n);Ft=!!(e.flags&131072)}else Ft=!1,je&&t.flags&1048576&&yx(t,Xu,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Eu(e,t),e=t.pendingProps;var i=po(t,yt.current);Vs(t,n),i=Kv(null,t,r,e,i,n);var s=Qv();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Dt(r)?(s=!0,Qu(t)):s=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Bv(t),i.updater=nd,t.stateNode=i,i._reactInternals=t,Lh(t,r,e,n),t=zh(null,t,r,!0,s,n)):(t.tag=0,je&&s&&Fv(t),bt(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Eu(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=uT(r),e=mn(r,e),i){case 0:t=Dh(null,t,r,e,n);break e;case 1:t=py(null,t,r,e,n);break e;case 11:t=fy(null,t,r,e,n);break e;case 14:t=hy(null,t,r,mn(r.type,e),n);break e}throw Error(U(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:mn(r,i),Dh(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:mn(r,i),py(e,t,r,i,n);case 3:e:{if(Xx(t),e===null)throw Error(U(387));r=t.pendingProps,s=t.memoizedState,i=s.element,Sx(e,t),ec(t,r,null,n);var o=t.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){i=yo(Error(U(423)),t),t=vy(e,t,r,n,i);break e}else if(r!==i){i=yo(Error(U(424)),t),t=vy(e,t,r,n,i);break e}else for(Gt=Zr(t.stateNode.containerInfo.firstChild),Qt=t,je=!0,xn=null,n=bx(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(vo(),r===i){t=mr(e,t,n);break e}bt(e,t,r,n)}t=t.child}return t;case 5:return Cx(t),e===null&&Nh(t),r=t.type,i=t.pendingProps,s=e!==null?e.memoizedProps:null,o=i.children,Th(r,i)?o=null:s!==null&&Th(r,s)&&(t.flags|=32),Yx(e,t),bt(e,t,o,n),t.child;case 6:return e===null&&Nh(t),null;case 13:return Jx(e,t,n);case 4:return qv(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=go(t,null,r,n):bt(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:mn(r,i),fy(e,t,r,i,n);case 7:return bt(e,t,t.pendingProps,n),t.child;case 8:return bt(e,t,t.pendingProps.children,n),t.child;case 12:return bt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,s=t.memoizedProps,o=i.value,Te(Ju,r._currentValue),r._currentValue=o,s!==null)if(kn(s.value,o)){if(s.children===i.children&&!jt.current){t=mr(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(s.tag===1){l=hr(-1,n&-n),l.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?l.next=l:(l.next=c.next,c.next=l),u.pending=l}}s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),$h(s.return,n,t),a.lanes|=n;break}l=l.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(U(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),$h(o,n,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}bt(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Vs(t,n),i=cn(i),r=r(i),t.flags|=1,bt(e,t,r,n),t.child;case 14:return r=t.type,i=mn(r,t.pendingProps),i=mn(r.type,i),hy(e,t,r,i,n);case 15:return Kx(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:mn(r,i),Eu(e,t),t.tag=1,Dt(r)?(e=!0,Qu(t)):e=!1,Vs(t,n),Wx(t,r,i),Lh(t,r,i,n),zh(null,t,r,!0,e,n);case 19:return Zx(e,t,n);case 22:return Qx(e,t,n)}throw Error(U(156,t.tag))};function vb(e,t){return Vw(e,t)}function lT(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function on(e,t,n,r){return new lT(e,t,n,r)}function sg(e){return e=e.prototype,!(!e||!e.isReactComponent)}function uT(e){if(typeof e=="function")return sg(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Sv)return 11;if(e===Cv)return 14}return 2}function ri(e,t){var n=e.alternate;return n===null?(n=on(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function ku(e,t,n,r,i,s){var o=2;if(r=e,typeof e=="function")sg(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Ss:return Wi(n.children,i,s,t);case Ev:o=8,i|=8;break;case ah:return e=on(12,n,t,i|2),e.elementType=ah,e.lanes=s,e;case lh:return e=on(13,n,t,i),e.elementType=lh,e.lanes=s,e;case uh:return e=on(19,n,t,i),e.elementType=uh,e.lanes=s,e;case Cw:return sd(n,i,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ew:o=10;break e;case Sw:o=9;break e;case Sv:o=11;break e;case Cv:o=14;break e;case $r:o=16,r=null;break e}throw Error(U(130,e==null?e:typeof e,""))}return t=on(o,n,t,i),t.elementType=e,t.type=r,t.lanes=s,t}function Wi(e,t,n,r){return e=on(7,e,r,t),e.lanes=n,e}function sd(e,t,n,r){return e=on(22,e,r,t),e.elementType=Cw,e.lanes=n,e.stateNode={isHidden:!1},e}function of(e,t,n){return e=on(6,e,null,t),e.lanes=n,e}function af(e,t,n){return t=on(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function cT(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=zd(0),this.expirationTimes=zd(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zd(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function og(e,t,n,r,i,s,o,a,l){return e=new cT(e,t,n,a,l),t===1?(t=1,s===!0&&(t|=8)):t=0,s=on(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Bv(s),e}function dT(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(_b)}catch(e){console.error(e)}}_b(),_w.exports=Zt;var xl=_w.exports;const gT=aw(xl);var wb,Py=xl;wb=Py.createRoot,Py.hydrateRoot;var uc=["light","dark"],cg="(prefers-color-scheme: dark)",mT=typeof window>"u",dg=g.createContext(void 0),yT={setTheme:e=>{},themes:[]},rz=()=>{var e;return(e=g.useContext(dg))!=null?e:yT},_T=e=>g.useContext(dg)?e.children:g.createElement(xT,{...e}),wT=["light","dark"],xT=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:n=!0,enableColorScheme:r=!0,storageKey:i="theme",themes:s=wT,defaultTheme:o=n?"system":"light",attribute:a="data-theme",value:l,children:u,nonce:c})=>{let[d,f]=g.useState(()=>Ry(i,o)),[m,_]=g.useState(()=>Ry(i)),p=l?Object.values(l):s,y=g.useCallback(b=>{let E=b;if(!E)return;b==="system"&&n&&(E=Ty());let S=l?l[E]:E,P=t?ET():null,C=document.documentElement;if(a==="class"?(C.classList.remove(...p),S&&C.classList.add(S)):S?C.setAttribute(a,S):C.removeAttribute(a),r){let T=uc.includes(o)?o:null,R=uc.includes(E)?E:T;C.style.colorScheme=R}P==null||P()},[]),h=g.useCallback(b=>{let E=typeof b=="function"?b(b):b;f(E);try{localStorage.setItem(i,E)}catch{}},[e]),v=g.useCallback(b=>{let E=Ty(b);_(E),d==="system"&&n&&!e&&y("system")},[d,e]);g.useEffect(()=>{let b=window.matchMedia(cg);return b.addListener(v),v(b),()=>b.removeListener(v)},[v]),g.useEffect(()=>{let b=E=>{if(E.key!==i)return;let S=E.newValue||o;h(S)};return window.addEventListener("storage",b),()=>window.removeEventListener("storage",b)},[h]),g.useEffect(()=>{y(e??d)},[e,d]);let x=g.useMemo(()=>({theme:d,setTheme:h,forcedTheme:e,resolvedTheme:d==="system"?m:d,themes:n?[...s,"system"]:s,systemTheme:n?m:void 0}),[d,h,e,m,n,s]);return g.createElement(dg.Provider,{value:x},g.createElement(bT,{forcedTheme:e,disableTransitionOnChange:t,enableSystem:n,enableColorScheme:r,storageKey:i,themes:s,defaultTheme:o,attribute:a,value:l,children:u,attrs:p,nonce:c}),u)},bT=g.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:s,value:o,attrs:a,nonce:l})=>{let u=s==="system",c=n==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${a.map(_=>`'${_}'`).join(",")})`};`:`var d=document.documentElement,n='${n}',s='setAttribute';`,d=i?uc.includes(s)&&s?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${s}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",f=(_,p=!1,y=!0)=>{let h=o?o[_]:_,v=p?_+"|| ''":`'${h}'`,x="";return i&&y&&!p&&uc.includes(_)&&(x+=`d.style.colorScheme = '${_}';`),n==="class"?p||h?x+=`c.add(${v})`:x+="null":h&&(x+=`d[s](n,${v})`),x},m=e?`!function(){${c}${f(e)}}()`:r?`!function(){try{${c}var e=localStorage.getItem('${t}');if('system'===e||(!e&&${u})){var t='${cg}',m=window.matchMedia(t);if(m.media!==t||m.matches){${f("dark")}}else{${f("light")}}}else if(e){${o?`var x=${JSON.stringify(o)};`:""}${f(o?"x[e]":"e",!0)}}${u?"":"else{"+f(s,!1,!1)+"}"}${d}}catch(e){}}()`:`!function(){try{${c}var e=localStorage.getItem('${t}');if(e){${o?`var x=${JSON.stringify(o)};`:""}${f(o?"x[e]":"e",!0)}}else{${f(s,!1,!1)};}${d}}catch(t){}}();`;return g.createElement("script",{nonce:l,dangerouslySetInnerHTML:{__html:m}})}),Ry=(e,t)=>{if(mT)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},ET=()=>{let e=document.createElement("style");return e.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(e),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(e)},1)}},Ty=e=>(e||(e=window.matchMedia(cg)),e.matches?"dark":"light"),I=typeof window<"u"?window:void 0,mt=typeof globalThis<"u"?globalThis:I,St=mt==null?void 0:mt.navigator,j=mt==null?void 0:mt.document,Ae=mt==null?void 0:mt.location,fg=mt==null?void 0:mt.fetch,Jh=mt!=null&&mt.XMLHttpRequest&&"withCredentials"in new mt.XMLHttpRequest?mt.XMLHttpRequest:void 0,Iy=mt==null?void 0:mt.AbortController,ST=mt==null?void 0:mt.CompressionStream,Mt=St==null?void 0:St.userAgent;function xb(){return!(!I||I.navigator.onLine===!1)}var Ko=typeof globalThis<"u"?globalThis:I;Ko&&typeof self>"u"&&(Ko.self=Ko),Ko&&typeof File>"u"&&(Ko.File=function(){});var Y=I??{},Ee={DEBUG:!1,LIB_VERSION:"0.5.1",LIB_NAME:"browser-common"};function Oy(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(u){return void n(u)}a.done?t(l):Promise.resolve(l).then(r,i)}function Ce(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var s=e.apply(t,n);function o(l){Oy(s,r,i,o,a,"next",l)}function a(l){Oy(s,r,i,o,a,"throw",l)}o(void 0)})}}function $(){return $=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},$.apply(null,arguments)}function bb(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var My=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};function Ay(e){return typeof e=="string"||e}function Ny(e){return typeof e=="string"?e:void 0}var Qo,CT=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],nr=function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.AiCaptureQueue="ai_capture_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e}({}),$y=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),kT=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],PT=["token"],Eb="NativeGzipValidationError",Zh=e=>e.length>=2&&e[0]===31&&e[1]===139,Fy=(e,t)=>e===$y.GZipJS||t===$y.GZipJS||t==="gzip",Ly=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError",Gl=e=>{var t=new Error("Native gzip produced invalid output: "+e);throw t.name=Eb,t},RT=function(){var e=Ce(function*(t,n){18>t.size&&Gl("too-short");var r=new Uint8Array(yield t.slice(0,10).arrayBuffer());Zh(r)&&r[2]===8||Gl("invalid-header");var i=new DataView(yield t.slice(t.size-8).arrayBuffer());i.getUint32(0,!0)!==(o=>{for(var a=(()=>{if(Qo)return Qo;Qo=[];for(var c=0;256>c;c++){for(var d=c,f=0;8>f;f++)d=1&d?3988292384^d>>>1:d>>>1;Qo[c]=d>>>0}return Qo})(),l=4294967295,u=0;o.length>u;u++)l=a[255&(l^o[u])]^l>>>8;return(4294967295^l)>>>0})(n)&&Gl("invalid-crc");var s=n.length>>>0;i.getUint32(4,!0)!==s&&Gl("invalid-size")});return function(t,n){return e.apply(this,arguments)}}();function ep(){return ep=Ce(function*(e,t,n){t===void 0&&(t=!0);try{var r=new TextEncoder().encode(e),i=new globalThis.CompressionStream("gzip"),s=i.writable.getWriter(),o=s.write(r).then(()=>s.close()).catch(function(){var u=Ce(function*(c){try{yield s.abort(c)}catch{}throw c});return function(c){return u.apply(this,arguments)}}()),a=new Response(i.readable).blob(),l=(yield Promise.all([a,o]))[0];return yield RT(l,r),l}catch(u){if(n!=null&&n.rethrow)throw u;return t&&console.error("Failed to gzip compress data",u),null}}),ep.apply(this,arguments)}var TT=20,Sb=1e3,IT=1e4,OT="[Circular]",tp="[Truncated]",cd="[Unserializable]",MT="[Function]";function qs(e){for(var t="",n=0;e.length>n;n++){var r=e.charCodeAt(n);if(55296>r||r>56319)t+=56320>r||r>57343?e[n]:"�";else{var i=e.charCodeAt(n+1);56320>i||i>57343?t+="�":(t+=e[n]+e[n+1],n++)}}return t}var AT=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],jy=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return AT.concat(t).some(r=>{var i=r.toLowerCase();return n.indexOf(i)!==-1})};function J(e,t){return e.indexOf(t)!==-1}var dd=function(e){return e.trim()},np=function(e){return e.replace(/^\$/,"")};function Cb(e){var t,n=[];return(t=JSON.stringify(e,function(r,i){if(typeof i=="bigint")return i.toString();if(typeof i!="function"&&typeof i!="symbol"){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&typeof i=="object"){for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(i))return"[Circular]";n.push(i)}return i}}))!==null&&t!==void 0?t:"null"}var kb=Object.prototype,Pb=kb.hasOwnProperty,fd=kb.toString,Z=Array.isArray||function(e){return fd.call(e)==="[object Array]"},vt=e=>typeof e=="function",Se=e=>e===Object(e)&&!Z(e),En=e=>{if(Se(e)){for(var t in e)if(Pb.call(e,t))return!1;return!0}return!1},L=e=>e===void 0,ce=e=>fd.call(e)=="[object String]",cc=e=>ce(e)&&e.trim().length===0,rt=e=>e===null,ne=e=>L(e)||rt(e),Ge=e=>fd.call(e)=="[object Number]"&&e==e,Jn=e=>Ge(e)&&e>0,$t=e=>fd.call(e)==="[object Boolean]",NT=e=>e instanceof FormData,$T=e=>J(kT,e),FT=e=>J(PT,e);function Rb(e){return e===null||typeof e!="object"}function dc(e,t){return{}.toString.call(e)==="[object "+t+"]"}function Tb(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Ib(e,Error)}}function hg(e){return typeof Event<"u"&&Ib(e,Event)}function Ib(e,t){try{return e instanceof t}catch{return!1}}var LT=[!0,"true",1,"1","yes"],lf=e=>J(LT,e),jT=[!1,"false",0,"0","no"];function Vn(e,t,n,r,i){return t>n&&(r.warn("min cannot be greater than max."),t=n),Ge(e)?e>n?(r.warn(" cannot be greater than max: "+n+". Using max value instead."),n):t>e?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+i),Vn(i||n,t,n,r))}class DT{constructor(t){this.k={},this.S=t.S,this.C=Vn(t.bucketSize,0,100,t.I),this.R=Vn(t.refillRate,0,this.C,t.I),this.A=Vn(t.refillInterval,0,864e5,t.I)}O(t,n){var r=Math.floor((n-t.lastAccess)/this.A);r>0&&(t.tokens=Math.min(t.tokens+r*this.R,this.C),t.lastAccess=t.lastAccess+r*this.A)}consumeRateLimit(t){var n,r=Date.now(),i=String(t),s=this.k[i];return s?this.O(s,r):this.k[i]=s={tokens:this.C,lastAccess:r},s.tokens===0||(s.tokens--,s.tokens===0&&((n=this.S)==null||n.call(this,t)),s.tokens===0)}stop(){this.k={}}}var Yt="Mobile",fc="iOS",fr="Android",wo="Tablet",Ob=fr+" "+wo,Mb="iPad",Ab="Apple",Nb=Ab+" Watch",Sa="Safari",xo="BlackBerry",$b="Samsung",Fb=$b+"Browser",Lb=$b+" Internet",Hi="Chrome",zT=Hi+" OS",jb=Hi+" "+fc,pg="Internet Explorer",Db=pg+" "+Yt,vg="Opera",UT=vg+" Mini",gg="Edge",zb="Microsoft "+gg,Ws="Firefox",Ub=Ws+" "+fc,Ka="Nintendo",Qa="PlayStation",Hs="Xbox",Vb=fr+" "+Yt,Bb=Yt+" "+Sa,ua="Windows",rp=ua+" Phone",Dy="Nokia",ip="Ouya",qb="Generic",VT=qb+" "+Yt.toLowerCase(),Wb=qb+" "+wo.toLowerCase(),sp="Konqueror",Hb="Oculus Browser",hc="Vivaldi",Gb="Yandex",pc="Whale",op="DuckDuckGo",Kb="Pale Moon",vc="Waterfox",Ca="Brave",Qb="Google Search App",Le="(\\d+(\\.\\d+)?)",uf=new RegExp("Version/"+Le),BT=new RegExp(Hs,"i"),qT=new RegExp(Qa+" \\w+","i"),WT=new RegExp(Ka+" \\w+","i"),mg=new RegExp(xo+"|PlayBook|BB10","i"),HT={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},Yb=function(e,t,n,r){t=t||"";var i=function(s){return s!=null&&s.brave?Ca:null}(n);return i||(r!=null&&r.detectGoogleSearchApp&&J(e,"GSA/")?Qb:J(e," OPR/")&&J(e,"Mini")?UT:J(e," OPR/")?vg:mg.test(e)?xo:J(e,"IE"+Yt)||J(e,"WPDesktop")?Db:J(e,"OculusBrowser")?Hb:J(e,Fb)?Lb:J(e,gg)||J(e,"Edg/")?zb:J(e,hc+"/")?hc:J(e,"YaBrowser/")?Gb:J(e,pc+"/")?pc:J(e,op+"/")||J(e,"Ddg/")?op:J(e,"FBIOS")?"Facebook "+Yt:J(e,"UCWEB")||J(e,"UCBrowser")?"UC Browser":J(e,"CriOS")?jb:J(e,"CrMo")||J(e,Hi)?Hi:J(e,fr)&&J(e,Sa)?Vb:J(e,"FxiOS")?Ub:J(e.toLowerCase(),sp.toLowerCase())?sp:J(e,Ca+"/")?Ca:((s,o)=>o&&J(o,Ab)||function(a){return J(a,Sa)&&!J(a,Hi)&&!J(a,fr)}(s))(e,t)?J(e,Yt)?Bb:Sa:J(e,"PaleMoon/")?Kb:J(e,vc+"/")?vc:J(e,Ws)?Ws:J(e,"MSIE")||J(e,"Trident/")?pg:J(e,"Gecko")?Ws:"")},GT={[Db]:[new RegExp("rv:"+Le)],[zb]:[new RegExp(gg+"?\\/"+Le)],[Hi]:[new RegExp("("+Hi+"|CrMo)\\/"+Le)],[jb]:[new RegExp("CriOS\\/"+Le)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Le)],[Sa]:[uf],[Bb]:[uf],[vg]:[new RegExp("(Opera|OPR)\\/"+Le)],[Ws]:[new RegExp(Ws+"\\/"+Le)],[Ub]:[new RegExp("FxiOS\\/"+Le)],[sp]:[new RegExp("Konqueror[:/]?"+Le,"i")],[xo]:[new RegExp(xo+" "+Le),uf],[Vb]:[new RegExp("android\\s"+Le,"i")],[Lb]:[new RegExp(Fb+"\\/"+Le)],[Hb]:[new RegExp("OculusBrowser\\/"+Le)],[hc]:[new RegExp(hc+"\\/"+Le)],[Gb]:[new RegExp("YaBrowser\\/"+Le)],[pc]:[new RegExp(pc+"\\/"+Le)],[Ca]:[new RegExp(Ca+"\\/"+Le)],[op]:[new RegExp("(DuckDuckGo|Ddg)\\/"+Le)],[Kb]:[new RegExp("PaleMoon\\/"+Le)],[vc]:[new RegExp(vc+"\\/"+Le)],[Qb]:[new RegExp("GSA\\/"+Le)],[pg]:[new RegExp("(rv:|MSIE )"+Le)],Mozilla:[new RegExp("rv:"+Le)]},KT=function(e,t,n,r){var i=Yb(e,t,n,r),s=GT[i];if(L(s))return null;for(var o=0;s.length>o;o++){var a=e.match(s[o]);if(a)return parseFloat(a[a.length-2])}return null},zy=[[new RegExp(Hs+"; "+Hs+" (.*?)[);]","i"),e=>[Hs,e&&e[1]||""]],[new RegExp(Ka,"i"),[Ka,""]],[new RegExp(Qa,"i"),[Qa,""]],[mg,[xo,""]],[new RegExp(ua,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[rp,""];if(new RegExp(Yt).test(t)&&!/IEMobile\b/.test(t))return[ua+" "+Yt,""];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=HT[n[1]]||"";return/arm/i.test(t)&&(r="RT"),[ua,r]}return[ua,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[fc,[e[3],e[4],e[5]||"0"].join(".")]:[fc,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=L(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+fr+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+fr+")","i"),e=>e&&e[2]?[fr,[e[2],e[3],e[4]||"0"].join(".")]:[fr,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[zT,""]],[/Linux|debian/i,["Linux",""]]],Uy=function(e){return WT.test(e)?Ka:qT.test(e)?Qa:BT.test(e)?Hs:new RegExp(ip,"i").test(e)?ip:new RegExp("("+rp+"|WPDesktop)","i").test(e)?rp:/iPad/.test(e)?Mb:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Nb:mg.test(e)?xo:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Dy,"i").test(e)?Dy:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(Yt).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?fr:Ob:new RegExp("(pda|"+Yt+")","i").test(e)?VT:new RegExp(wo,"i").test(e)&&!new RegExp(wo+" pc","i").test(e)?Wb:""},QT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Vy(e,t){return typeof(n=e)=="string"&&QT.test(n)?e:t();var n}function li(e){return e&&e.split("#")[0]}function yg(e,t){var n=setTimeout(e,t);return n!=null&&n.unref&&(n==null||n.unref()),n}function By(e,t,n){return Xb.apply(this,arguments)}function Xb(){return(Xb=Ce(function*(e,t,n){var r;try{return yield Promise.race([e,new Promise((i,s)=>{r=yg(()=>{try{n==null||n(),i()}catch(o){s(o)}},t)})])}finally{clearTimeout(r)}})).apply(this,arguments)}var Jb={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},YT=Jb.info,qy=9223372036854776e3,XT={}.propertyIsEnumerable;function gc(e,t){try{return Zb(e,t,{ancestors:new WeakSet,remainingNodes:IT},0)}catch{return[]}}function _g(e,t,n,r){if(0>=n.remainingNodes)return{stringValue:tp};if(n.remainingNodes--,$t(e))return{boolValue:e};if(typeof e=="number"){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>"u")return{stringValue:String(e)};var i=BigInt(e).toString();return e>=qy||-qy>e?(t==null||t.debug("Attribute "+i+" is outside the int64 range; encoding it as a string"),{stringValue:i}):{intValue:i}}return{doubleValue:e}}if(typeof e=="string")return{stringValue:qs(e)};if(typeof e=="function")return{stringValue:MT};if(typeof e=="symbol")return{stringValue:String(e)};if(typeof e=="object"&&e!==null){if(n.ancestors.has(e))return{stringValue:OT};if(r>=TT)return{stringValue:tp};if(e instanceof Date){var s=e.getTime(),o=Number.isFinite(s)?e.toISOString():String(e);return{stringValue:typeof o=="string"?qs(o):String(o)}}n.ancestors.add(e);try{try{var a=e.toJSON;if(typeof a=="function")return _g(a.call(e),t,n,r+1)}catch{}return Z(e)?{arrayValue:{values:JT(e,t,n,r+1)}}:{kvlistValue:{values:Zb(e,t,n,r+1)}}}finally{n.ancestors.delete(e)}}return{stringValue:qs(String(e))}}function JT(e,t,n,r){for(var i=[],s=Math.min(e.length,Sb),o=0;s>o&&n.remainingNodes>0;o++)try{var a=o in e?e[o]:void 0;if(ne(a))continue;i.push(_g(a,t,n,r))}catch{i.push({stringValue:cd})}return e.length>o&&i.push({stringValue:tp}),i}function Zb(e,t,n,r){var i=[];for(var s in e)if(XT.call(e,s)){if(i.length>=Sb||0>=n.remainingNodes){t==null||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=e[s];if(rt(o)||L(o))continue;i.push({key:qs(s),value:_g(o,t,n,r)})}catch{i.push({key:qs(s),value:{stringValue:cd}})}}return i}function ZT(e){try{return qs(String(e))}catch{return cd}}function eI(e,t,n){var r=Jb[e.level||"info"]||YT,i=r.text,s=r.number,o=String(Date.now())+"000000",a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.windowId&&(a["window.id"]=t.windowId),ne(t.sessionStartTimestamp)||(a.sessionStartTimestamp=String(t.sessionStartTimestamp)),ne(t.lastActivityTimestamp)||(a.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(a["url.full"]=t.currentUrl),t.screenName&&(a["screen.name"]=t.screenName),t.appState&&(a["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var l=$({},a),u=e.attributes;if(u){var c=[];try{c=Object.keys(u)}catch{c=[]}for(var d of c){var f=void 0;try{f=u[d]}catch{f=cd}Object.defineProperty(l,d,{value:f,enumerable:!0,writable:!0,configurable:!0})}}var m={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:s,severityText:i,body:{stringValue:ZT(e.body)},attributes:gc(l,n)};return e.trace_id&&(m.traceId=e.trace_id),e.span_id&&(m.spanId=e.span_id),L(e.trace_flags)||(m.flags=e.trace_flags),m}function eE(e,t,n){return $({},e.resourceAttributes,{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment},e.serviceVersion&&{"service.version":e.serviceVersion},{"telemetry.sdk.name":t,"telemetry.sdk.version":n})}function tE(e,t,n,r){return{resourceLogs:[{resource:{attributes:gc(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}let tI=class{constructor(e,t,n,r,i,s,o){var a;s===void 0&&(s=()=>Promise.resolve()),this._instance=e,this.qi=t,this.I=n,this.rn=r,this.nn=i,this.sn=s,this.an=o,this.ln=null,this.un=0,this.hn=0,this.dn=0,this.vn=0,this.cn=!1,this.fn=t.maxBufferSize,this.pn=Math.max((a=t.maxQueueSize)!==null&&a!==void 0?a:t.maxBufferSize,t.maxBufferSize),this.gn=t.flushIntervalMs,this.mn=t.maxBatchRecordsPerPost,this.yn=t.rateCapWindowMs,this.bn=t.maxLogsPerInterval}reset(){this._n(),this.ln=null,this.dn=0,this.vn=0,this.cn=!1,this.un=0,this.hn=0,this.mn=this.qi.maxBatchRecordsPerPost}onReconnect(){this.hn=0,this.wn()}captureLog(e){if(!this._instance.isDisabled&&!this._instance.optedOut&&e!=null&&e.body){var t=this.kn(e);if(t!==null)if(t.body){if(this.Sn()){var n={record:eI(t,this.rn(),this.I)};this.nn(()=>this.xn(n))}}else this.I.info("Log was rejected in beforeSend function")}}kn(e){var t=this.qi.beforeSend;if(!t)return e;var n=Z(t)?t:[t],r=e;for(var i of n)try{var s=i(r);if(!s)return this.I.info("Log was rejected in beforeSend function"),null;r=s}catch(o){return this.I.error("Error in beforeSend function for log:",o),null}return r}Sn(){if(this.bn===void 0)return!0;var e=Date.now(),t=e-this.dn;return this.yn>t&&t>=0||(this.dn=e,this.vn=0,this.cn=!1),this.bn>this.vn?(this.vn++,!0):(this.cn||(this.I.warn("captureLog dropping logs: exceeded "+this.bn+" logs per "+this.yn+"ms"),this.cn=!0),!1)}flush(){var e=this;return Ce(function*(){if(!e._instance.isDisabled)return e.ln||(e.ln=e.Cn().finally(()=>{e.ln=null})),e.ln})()}Cn(){var e=this;return Ce(function*(){var t;e._n();var n=(t=e._instance.getPersistedProperty(nr.LogsQueue))!==null&&t!==void 0?t:[];if(n.length!==0)for(var r=n.length,i=0;n.length>0&&r>i;){var s,o;e.un=0;var a=Math.min(n.length,e.mn),l=n.slice(0,a),u=tE(l.map(d=>d.record),e.Tn(),(s=e.an)!==null&&s!==void 0?s:e._instance.getLibraryId(),e._instance.getLibraryVersion()),c=yield e._instance.Mn(u);if(c.kind==="too-large"&&l.length>1)e.mn=Math.max(1,Math.floor(l.length/2)),e.I.warn("Received 413 when sending logs batch of size "+l.length+", reducing batch size to "+e.mn);else if(c.kind==="retry-later"||(c.kind==="too-large"?e.I.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):c.kind==="ok"&&e.qi.maxBatchRecordsPerPost>e.mn&&(e.mn=Math.min(e.qi.maxBatchRecordsPerPost,e.mn+1)),yield e.En(l.length),n=(o=e._instance.getPersistedProperty(nr.LogsQueue))!==null&&o!==void 0?o:[],i+=l.length,c.kind==="fatal"))throw c.error}})()}En(e){var t=this;return Ce(function*(){var n,r=Math.max(0,e-t.un),i=(n=t._instance.getPersistedProperty(nr.LogsQueue))!==null&&n!==void 0?n:[];t._instance.setPersistedProperty(nr.LogsQueue,i.slice(r)),yield t.sn()})()}Tn(){return eE(this.qi,this._instance.getLibraryId(),this._instance.getLibraryVersion())}xn(e){var t;if(!this._instance.optedOut){var n=(t=this._instance.getPersistedProperty(nr.LogsQueue))!==null&&t!==void 0?t:[];this.pn>n.length||(n.shift(),this.un++,this.I.info("Logs queue is full, dropping oldest record.")),n.push(e),this._instance.setPersistedProperty(nr.LogsQueue,n),this.fn>n.length?this.In():this.wn()}}In(e){e===void 0&&(e=this.gn),this.Rn||(this.Rn=yg(()=>{this.Rn=void 0,this.wn()},e))}Pn(){var e=Math.min(Math.max(0,this.hn-1),6);return this.gn*Math.pow(2,e)}An(){var e=this._instance.getPersistedProperty(nr.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return Ce(function*(){t._n();var n=t.flush().catch(()=>{});e!==void 0?yield By(n,e):yield n})()}flushWithTimeout(e){var t=this;return Ce(function*(){var n=t.flush();yield By(n,e,()=>{n.catch(()=>{})})})()}wn(){this.flush().then(()=>{this.hn=0},e=>{this.hn++,this.I.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.An()&&this.In(this.Pn())})}_n(){this.Rn&&(clearTimeout(this.Rn),this.Rn=void 0)}};var cf=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Wy(e){return String(e)+"000000"}function Hy(e,t,n,r){var i="";return r&&(i=Object.keys(r).sort().map(s=>JSON.stringify(s)+":"+JSON.stringify(r[s])).join(",")),e+"\0"+t+"\0"+(n??"")+"\0"+i}let nI=class{constructor(e,t,n){this._instance=e,this.qi=t,this.I=n,this.Fn=new Map,this.ln=null,this.On=!1,this.Ln=new Map,this.$n=new Set,this.Dn=0}count(e,t,n){t===void 0&&(t=1),this.Nn({name:e,type:"count",value:t,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}gauge(e,t,n){this.Nn({name:e,type:"gauge",value:t,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}histogram(e,t,n){this.Nn({name:e,type:"histogram",value:t,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}flush(){var e=this,t=this.ln,n=function(){var i=Ce(function*(){t&&(yield t.catch(()=>{})),yield e.qn()});return function(){return i.apply(this,arguments)}}(),r=n().finally(()=>{this.ln===r&&(this.ln=null)});return this.ln=r,r}drainWindow(){if(this.Fn.size===0)return null;var e=this.Fn;return this.Fn=new Map,this.On=!1,this.Ln=new Map,this.$n=new Set,this.jn(e)}reset(){this.Dn++,this._n(),this.Fn=new Map,this.ln=null,this.On=!1,this.Ln=new Map,this.$n=new Set}Nn(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var t=this.kn(e);if(t!==null)if(t.name&&typeof t.name=="string")if(typeof t.value=="number"&&Number.isFinite(t.value))if(t.type==="count"&&0>t.value)this.I.warn("Dropping count '"+t.name+"': counters are monotonic, value must be >= 0");else{var n,r;try{n=t.attributes?$({},t.attributes):void 0,r=Hy(t.type,t.name,t.unit,n)}catch(o){return void this.I.warn("Dropping metric '"+t.name+"': attributes could not be serialized",o)}var i=this.Fn.get(r);if(!i){if(!this.Bn())return;i={name:t.name,type:t.type,unit:t.unit,attributes:n,windowStartMs:Date.now()},this.Fn.set(r,i)}var s=this.Ln.get(t.name);s===void 0?this.Ln.set(t.name,t.type):s===t.type||this.$n.has(t.name)||(this.$n.add(t.name),this.I.warn("Metric name '"+t.name+"' is already used as a "+s+"; recording it as a "+t.type+" too will blend both series in charts. Use a distinct name.")),this.Hn(i,t.value),this.In()}else this.I.warn("Dropping metric '"+t.name+"': value must be a finite number");else this.I.warn("Dropping metric with empty name")}}Bn(){return this.qi.maxSeriesPerFlush>this.Fn.size||(this.On||(this.On=!0,this.I.warn("Metric series cap reached ("+this.qi.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Hn(e,t){var n;switch(e.type){case"count":e.total=((n=e.total)!==null&&n!==void 0?n:0)+t;break;case"gauge":e.last=t;break;case"histogram":e.hist||(e.hist={count:0,sum:0,min:t,max:t,bucketCounts:new Array(cf.length+1).fill(0)});var r=e.hist;r.count+=1,r.sum+=t,r.min=Math.min(r.min,t),r.max=Math.max(r.max,t),r.bucketCounts[function(i,s){for(var o=0;s.length>o;o++)if(s[o]>=i)return o;return s.length}(t,cf)]+=1}}kn(e){var t=this.qi.beforeSend;if(!t)return e;var n=Z(t)?t:[t],r=e;for(var i of n)try{var s=i(r);if(!s)return this.I.info("Metric was rejected in beforeSend function"),null;r=s}catch(o){return this.I.error("Error in beforeSend function for metric:",o),null}return r}In(){this.Rn||(this.Rn=yg(()=>{this.Rn=void 0,this.flush().catch(e=>{this.I.error("Metrics flush failed:",e)})},this.qi.flushIntervalMs))}_n(){this.Rn&&(clearTimeout(this.Rn),this.Rn=void 0)}qn(){var e=this;return Ce(function*(){if(e.Fn.size!==0){var t=e.Fn;e.Fn=new Map,e.On=!1,e.Ln=new Map,e.$n=new Set;var n=e.Dn,r=yield e._instance.Un(e.jn(t));if(n===e.Dn)switch(r.kind){case"ok":return;case"retry-later":return e.zn(t),void e.In();case"too-large":return void e.I.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.I.error("Failed to send metrics batch:",r.error)}}})()}jn(e){return t=this.Wn(e),n=function(s,o,a){return $({},s.resourceAttributes,{"service.name":s.serviceName||"unknown_service"},s.environment&&{"deployment.environment":s.environment},s.serviceVersion&&{"service.version":s.serviceVersion},{"telemetry.sdk.name":o,"telemetry.sdk.version":a})}(this.qi,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),i=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:gc(n)},scopeMetrics:[{scope:{name:r,version:i},metrics:t}]}]};var t,n,r,i}Wn(e){var t=Wy(Date.now()),n=new Map;for(var r of e.values()){var i,s=Hy(r.type,r.name,r.unit,void 0),o=n.get(s);o||(o=$({name:r.name},r.unit&&{unit:r.unit}),r.type==="count"?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:r.type==="gauge"?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},n.set(s,o));var a=gc((i=r.attributes)!==null&&i!==void 0?i:{},this.I),l=Wy(r.windowStartMs);if(r.type==="count"){var u,c={attributes:a,startTimeUnixNano:l,timeUnixNano:t,asDouble:(u=r.total)!==null&&u!==void 0?u:0};o.sum.dataPoints.push(c)}else if(r.type==="gauge"){var d,f={attributes:a,timeUnixNano:t,asDouble:(d=r.last)!==null&&d!==void 0?d:0};o.gauge.dataPoints.push(f)}else r.hist&&o.histogram.dataPoints.push({attributes:a,startTimeUnixNano:l,timeUnixNano:t,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:cf})}return Array.from(n.values())}zn(e){var t,n;for(var r of e){var i=r[0],s=r[1],o=this.Fn.get(i);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,s.windowStartMs),o.type){case"count":o.total=((t=o.total)!==null&&t!==void 0?t:0)+((n=s.total)!==null&&n!==void 0?n:0);break;case"gauge":break;case"histogram":if(s.hist)if(o.hist){o.hist.count+=s.hist.count,o.hist.sum+=s.hist.sum,o.hist.min=Math.min(o.hist.min,s.hist.min),o.hist.max=Math.max(o.hist.max,s.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=s.hist.bucketCounts[a]}else o.hist=s.hist}else this.Bn()&&this.Fn.set(i,s)}}};var Kl,Gy,df;function rI(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return df&&n.length===Gy||(Gy=n.length,df=n.reduce((r,i)=>{Kl||(Kl={});var s=Kl[i];if(s)r[s[0]]=s[1];else for(var o=e(i),a=o.length-1;a>=0;a--){var l=o[a],u=l==null?void 0:l.filename,c=t[i];if(u&&c){r[u]=c,Kl[i]=[u,c];break}}return r},{})),df}}class iI{constructor(t,n,r){r===void 0&&(r=[]),this.coercers=t,this.stackParser=n,this.modifiers=r}buildFromUnknown(t,n){n===void 0&&(n={});var r=n&&n.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(r,n,0).apply(t),s=this.buildParsingContext(n),o=this.parseStacktrace(i,s);return{$exception_list:this.convertToExceptionList(o,r),$exception_level:"error"}}modifyFrames(t){var n=this;return Ce(function*(){for(var r of t)r.stacktrace&&r.stacktrace.frames&&Z(r.stacktrace.frames)&&(r.stacktrace.frames=yield n.applyModifiers(r.stacktrace.frames));return t})()}coerceFallback(t){var n;return{type:"Error",value:"Unknown error",stack:(n=t.syntheticException)==null?void 0:n.stack,synthetic:!0}}parseStacktrace(t,n){var r,i;return t.cause!=null&&(r=this.parseStacktrace(t.cause,n)),t.stack!=""&&t.stack!=null&&(i=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?n.skipFirstLines:0),n.chunkIdMap)),$({},t,{cause:r,stack:i})}applyChunkIds(t,n){return t.map(r=>(r.filename&&n&&(r.chunk_id=n[r.filename]),r))}applyCoercers(t,n){for(var r of this.coercers)if(r.match(t))return r.coerce(t,n);return this.coerceFallback(n)}applyModifiers(t){var n=this;return Ce(function*(){var r=t;for(var i of n.modifiers)r=yield i(r);return r})()}convertToExceptionList(t,n){var r,i,s,o={type:t.type,value:t.value,mechanism:{type:(r=n.type)!==null&&r!==void 0?r:"generic",handled:(i=n.handled)===null||i===void 0||i,synthetic:(s=t.synthetic)!==null&&s!==void 0&&s}};t.stack&&(o.stacktrace={type:"raw",frames:t.stack});var a=[o];return t.cause!=null&&a.push(...this.convertToExceptionList(t.cause,$({},n,{handled:!0}))),a}buildParsingContext(t){var n;return{chunkIdMap:rI(this.stackParser),skipFirstLines:(n=t.skipFirstLines)!==null&&n!==void 0?n:1}}buildCoercingContext(t,n,r){r===void 0&&(r=0);var i=(s,o)=>{if(4>=o){var a=this.buildCoercingContext(t,n,o);return this.applyCoercers(s,a)}};return $({},n,{syntheticException:r==0?n.syntheticException:void 0,mechanism:t,apply:s=>i(s,r),next:s=>i(s,r+1)})}}var bo="?";function ap(e,t,n,r,i){var s={platform:e,filename:t,function:n===""?bo:n,in_app:!(t!=null&&t.startsWith("webkit-masked-url://"))&&t!==""};return L(r)||(s.lineno=r),L(i)||(s.colno=i),s}var nE=(e,t)=>{var n=e.indexOf("safari-extension")!==-1,r=e.indexOf("safari-web-extension")!==-1;return n||r?[e.indexOf("@")!==-1?e.split("@")[0]:bo,n?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},sI=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,oI=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,aI=/\((\S*)(?::(\d+))(?::(\d+))\)/,lI=(e,t)=>{var n=sI.exec(e);if(n)return ap(t,n[1],bo,+n[2],+n[3]);var r=oI.exec(e);if(r){if(r[2]&&r[2].indexOf("eval")===0){var i=aI.exec(r[2]);i&&(r[2]=i[1],r[3]=i[2],r[4]=i[3])}var s=nE(r[1]||bo,r[2]);return ap(t,s[1],s[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},uI=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,cI=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,dI=(e,t)=>{var n=uI.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var r=cI.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}var i=n[3],s=n[1]||bo,o=nE(s,i);return ap(t,i=o[1],s=o[0],n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},Ky=/\(error: (.*)\)/;class fI{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,n){var r=ce(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:r?t.stack:void 0,cause:t.cause?n.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var n=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?n+": "+t.message:n}isDOMException(t){return dc(t,"DOMException")}isDOMError(t){return dc(t,"DOMError")}}class hI{match(t){return Tb(t)}coerce(t,n){var r,i=this.getStack(t),s=i===void 0;return{type:this.getType(t),value:this.getMessage(t,n),stack:i??((r=n.syntheticException)==null?void 0:r.stack),cause:t.cause?n.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,n){var r=t.message;return String(r.error&&typeof r.error.message=="string"?r.error.message:r)}getStack(t){return t.stacktrace||t.stack||void 0}}class pI{constructor(){}match(t){return!!dc(t,"ErrorEvent")&&(t.error!=null||this.fi(t))}coerce(t,n){var r;if(t.error!=null)return n.apply(t.error);var i=n.apply(t.message);return $({},i,{stack:(r=this.pi(t))!==null&&r!==void 0?r:i.stack,synthetic:!0})}fi(t){return ce(t.message)&&t.message.length>0}pi(t){var n,r,i=t,s=(n=i.lineno)!==null&&n!==void 0?n:0,o=(r=i.colno)!==null&&r!==void 0?r:0;if(ce(i.filename)&&i.filename.length!==0&&s!==0)return`Error - at `+i.filename+":"+s+":"+o}}var vI=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class gI{match(t){return typeof t=="string"}coerce(t,n){var r,i=this.getInfos(t),s=i[0],o=i[1];return{type:s??"Error",value:o??t,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(t){var n="Error",r=t,i=t.match(vI);return i&&(n=i[1],r=i[2]),[n,r]}}var mI=["fatal","error","warning","log","info","debug"];function rE(e,t){t===void 0&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return"[object has no keys]";for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(", ");if(t>=i.length)return r===n.length?i:i.length>t?i.slice(0,t)+"...":i}return""}class yI{match(t){return typeof t=="object"&&t!==null}coerce(t,n){var r,i,s=this.getErrorPropertyFromObject(t);return s?n.apply(s):{type:this.getType(t),value:this.getValue(t),stack:(r=this.getStack(t))!==null&&r!==void 0?r:(i=n.syntheticException)==null?void 0:i.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(hg(t))return t.constructor.name;var n="name"in t?t.name:void 0;return ce(n)&&!cc(n)?n:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){var n="'"+t.name+"' captured as exception";return"message"in t&&typeof t.message=="string"&&(n+=" with message: '"+t.message+"'"),n}if("message"in t&&typeof t.message=="string")return t.message;var r=this.getObjectClassName(t);return(r&&r!=="Object"?"'"+r+"'":"Object")+" captured as exception with keys: "+rE(t)}isSeverityLevel(t){return ce(t)&&!cc(t)&&mI.indexOf(t)>=0}getStack(t){try{return ce(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:ce(t.stack)&&t.stack.length>0?t.stack:void 0}catch{return}}getErrorPropertyFromObject(t){for(var n in t)if({}.hasOwnProperty.call(t,n)){var r=t[n];if(Tb(r))return r}}getObjectClassName(t){try{var n=Object.getPrototypeOf(t);return n?n.constructor.name:void 0}catch{return}}}class _I{match(t){return hg(t)}coerce(t,n){var r,i=t.constructor.name;return{type:i,value:i+" captured as exception with keys: "+rE(t),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class wI{match(t){return Rb(t)}coerce(t,n){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class xI{match(t){return dc(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!hg(t))return!1;try{var n=t.detail;return n!=null&&typeof n=="object"&&"reason"in n}catch{return!1}}coerce(t,n){var r,i=this.getUnhandledRejectionReason(t);return Rb(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}:n.apply(i)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&t.detail!=null&&typeof t.detail=="object"&&"reason"in t.detail)return t.detail.reason}catch{}return t}}var mc="$message",yc="$timestamp",bI=new Set([mc,yc]),ff={enabled:!0,max_bytes:32768};function _c(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:ff.enabled,max_bytes:SI(e.max_bytes,ff.max_bytes)}:$({},ff)}class EI{constructor(t){this.Vn=[],this.Gn=0,this.qi=_c(t)}setConfig(t){this.qi=_c(t),this.Zn()}add(t){var n=function(i){var s;try{s=Cb(i)}catch{return}try{var o=JSON.parse(s);if(!Se(o))return;var a=o,l=a[mc],u=a[yc];return!ce(l)||l.trim().length===0||!ce(u)&&!Ge(u)?void 0:{step:a,json:s}}catch{return}}(t);if(n){var r=function(i){if(typeof TextEncoder<"u")return new TextEncoder().encode(i).length;for(var s=encodeURIComponent(i),o=0,a=0;s.length>a;a++)s[a]==="%"?(o+=1,a+=2):o+=1;return o}(n.json);r>this.qi.max_bytes||(this.Vn.push({step:n.step,bytes:r}),this.Gn+=r,this.Zn())}}getAttachable(){return this.Vn.map(t=>t.step)}clear(){this.Vn=[],this.Gn=0}size(){return this.Vn.length}Zn(){for(;this.Gn>this.qi.max_bytes&&this.Vn.length>0;){var t=this.Vn.shift();t&&(this.Gn-=t.bytes)}}}function SI(e,t){if(!Ge(e)||e===1/0||e===-1/0)return t;var n=Math.floor(e);return 0>n?t:n}var iE=function(e,t){var n=(t===void 0?{}:t).debugEnabled,r={F(i){if(I&&(Ee.DEBUG||I.POSTHOG_DEBUG||n)&&!L(I.console)&&I.console){for(var s=("__rrweb_original__"in I.console[i])?I.console[i].__rrweb_original__:I.console[i],o=arguments.length,a=new Array(o>1?o-1:0),l=1;o>l;l++)a[l-1]=arguments[l];s(e,...a)}},debug(){for(var i=arguments.length,s=new Array(i),o=0;i>o;o++)s[o]=arguments[o];r.F("debug",...s)},info(){for(var i=arguments.length,s=new Array(i),o=0;i>o;o++)s[o]=arguments[o];r.F("log",...s)},warn(){for(var i=arguments.length,s=new Array(i),o=0;i>o;o++)s[o]=arguments[o];r.F("warn",...s)},error(){for(var i=arguments.length,s=new Array(i),o=0;i>o;o++)s[o]=arguments[o];r.F("error",...s)},critical(){for(var i=arguments.length,s=new Array(i),o=0;i>o;o++)s[o]=arguments[o];console.error(e,...s)},uninitializedWarning(i){r.error("You must initialize PostHog before calling "+i)},createLogger:(i,s)=>iE(e+" "+i,s)};return r},D=iE("[PostHog.js]"),Ie=D.createLogger,CI=Ie("[ExternalScriptsLoader]"),wc=e=>{var t=j==null?void 0:j.querySelectorAll("script");if(t){for(var n=0;t.length>n;n++)if(t[n].src===e||t[n].getAttribute("src")===e)return t[n]}},Si=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return CI.warn(t+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var r=wc(t);if(r){if(r.__posthog_loading_callback_fired)return n();var i=r.__posthog_loading_error;return i?n(i):(r.addEventListener("load",o=>{r.__posthog_loading_callback_fired=!0,n(void 0,o)}),void r.addEventListener("error",o=>{r.__posthog_loading_error=o,n(o)}))}var s=()=>{if(!j)return n("document not found");if(wc(t))return Si(e,t,n);var o=j.createElement("script");if(o.type="text/javascript",o.crossOrigin="anonymous",o.src=t,o.onload=u=>{o.__posthog_loading_callback_fired=!0,n(void 0,u)},o.onerror=u=>{o.__posthog_loading_error=u,n(u)},e.config.prepare_external_dependency_script&&(o=e.config.prepare_external_dependency_script(o)),!o)return n("prepare_external_dependency_script returned null");if(e.config.external_scripts_inject_target==="head")j.head.appendChild(o);else{var a,l=j.querySelectorAll("body > script");l.length>0?(a=l[0].parentNode)==null||a.insertBefore(o,l[0]):j.body.appendChild(o)}};j!=null&&j.body?s():j==null||j.addEventListener("DOMContentLoaded",s)},hf={},Qy=(e,t)=>{var n="/static/"+t+".js?v="+e.version;if(t==="toolbar"){var r=3e5;n=n+"&t="+Math.floor(Date.now()/r)*r}return e.requestRouter.endpointFor("assets",n)};Y.__PosthogExtensions__=Y.__PosthogExtensions__||{},Y.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!=="remote-config"){var r=e.config.strict_script_versioning;if(r){var i=e.requestRouter.endpointFor("assets","/static/"+e.version+"/"+t+".js"),s=hf[i];if(r==="fallback"&&s){if(wc(s))return void Si(e,s,n);delete hf[i]}Si(e,i,r==="fallback"?(a,l)=>{if(a)if(typeof a=="string")n(a);else{var u,c=Qy(e,t);hf[i]=c;var d=wc(i);d==null||(u=d.parentNode)==null||u.removeChild(d),Si(e,c,n)}else n(void 0,l)}:n)}else Si(e,Qy(e,t),n)}else{var o=e.requestRouter.endpointFor("assets","/array/"+e.config.token+"/config.js");Si(e,o,n)}},Y.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var r=e.requestRouter.endpointFor("api",t);Si(e,r,n)};Ee.DEBUG=!1,Ee.LIB_VERSION="1.418.16",Ee.LIB_NAME="web";var sE="$people_distinct_id",wt="distinct_id",Ya="$device_id",pf="$device_model",$s="__alias",ca="__timers",lp="$autocapture_disabled_server_side",up="$heatmaps_enabled_server_side",cp="$exception_capture_enabled_server_side",dp="$error_tracking_suppression_rules",fp="$error_tracking_capture_extension_exceptions",hp="$web_vitals_enabled_server_side",wg="$dead_clicks_enabled_server_side",xg="$product_tours_enabled_server_side",pp="$web_vitals_allowed_metrics",Oi="$session_recording_remote_config",oE="$replay_sample_rate",aE="$replay_override_sampling",lE="$replay_override_linked_flag",uE="$replay_override_url_trigger",cE="$replay_override_event_trigger",Fs="$sesid",bg="$session_is_sampled",ir="$enabled_feature_flags",Mi="$active_feature_flags",Pu="$early_access_features",Xa="$feature_flag_details",Ai="$feature_flag_payloads",Gs="$feature_flag_request_id",xc="$minimal_flag_called_events",Mn="$override_feature_flags",Ci="$override_feature_flag_payloads",yn="$stored_person_properties",Dn="$stored_group_properties",dE="$groups",vp="$surveys",bc="$surveys_loaded_at",gp="$surveys_activated",Ru="$surveys_activated_session",Tu="$surveys_activated_timestamps",da="ph_product_tours",ar="$flag_call_reported",fa="$flag_call_reported_session_id",Ks="$feature_flag_errors",Gi="$feature_flag_evaluated_at",se="$user_state",mp="$client_session_props",yp="$capture_rate_limit",_p="$initial_campaign_params",wp="$initial_referrer_info",Ec="$initial_person_info",Sc="$epp",fs="$posthog_cookieless",fE="$cookieless_mode",hE="$sdk_debug_extensions_init_method",pE="$sdk_debug_extensions_init_time_ms",xp="$sdk_debug_recording_script_not_loaded",Eg="PostHog loadExternalDependency extension not found.",ki="on_reject",lr="always",We="anonymous",ot="identified",bp="identified_only",Cc="visibilitychange",kc="beforeunload",xs="$pageview",vf="$pageleave",gf="$identify",Yy="$groupidentify";function Ql(e,t){Z(e)&&e.forEach(t)}function ve(e,t){if(!ne(e))if(Z(e))e.forEach(t);else if(NT(e))e.forEach((r,i)=>t(r,i));else for(var n in e)Pb.call(e,n)&&t(e[n],n)}var _e=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];for(var i of n)for(var s in i)i[s]!==void 0&&(e[s]=i[s]);return e};function Iu(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var Xy=function(e){try{return e()}catch{return}},kI=function(e){return function(){try{for(var t=arguments.length,n=new Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,n)}catch(i){D.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),D.critical(i)}}},Sg=function(e){var t={};return ve(e,function(n,r){(ce(n)&&n.length>0||Ge(n))&&(t[r]=n)}),t},PI=["herokuapp.com","vercel.app","netlify.app"];function RI(e){var t=e==null?void 0:e.hostname;if(!ce(t))return!1;var n=t.split(".").slice(-2).join(".");for(var r of PI)if(n===r)return!1;return!0}function Re(e,t,n,r){var i=r??{},s=i.capture,o=i.passive;e==null||e.addEventListener(t,n,{capture:s!==void 0&&s,passive:o===void 0||o})}function Ep(e){return e.name==="ph_toolbar_internal"}var vE=e=>{if(j){try{for(var t=e+"=",n=j.cookie.split(";").filter(s=>s.length),r=0;n.length>r;r++){for(var i=n[r];i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(t)===0)return decodeURIComponent(i.substring(t.length,i.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Ge(e)&&isFinite(e)&&Math.floor(e)===e});class Pc{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/256,s[5]=t,s[6]=112|n>>>8,s[7]=n,s[8]=128|r>>>24,s[9]=r>>>16,s[10]=r>>>8,s[11]=r,s[12]=i>>>24,s[13]=i>>>16,s[14]=i>>>8,s[15]=i,new Pc(s)}toString(){for(var t="",n=0;this.bytes.length>n;n++)t=t+(this.bytes[n]>>>4).toString(16)+(15&this.bytes[n]).toString(16),n!==3&&n!==5&&n!==7&&n!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new Pc(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var n=0;16>n;n++){var r=this.bytes[n]-t.bytes[n];if(r!==0)return Math.sign(r)}return 0}}class TI{generate(){var t=this.generateOrAbort();if(!L(t))return t;this.Rr=0;var n=this.generateOrAbort();if(L(n))throw new Error("Could not generate UUID after timestamp reset");return n}generateOrAbort(){var t=Date.now();if(t>this.Rr)this.Rr=t,this.Ar();else{if(this.Rr>=t+1e4)return;this.Lr++,this.Lr>4398046511103&&(this.Rr++,this.Ar())}return Pc.fromFieldsV7(this.Rr,Math.trunc(this.Lr/Math.pow(2,30)),this.Lr&Math.pow(2,30)-1,this.Or.nextUint32())}Ar(){this.Lr=1024*this.Or.nextUint32()+(1023&this.Or.nextUint32())}constructor(){this.Rr=0,this.Lr=0,this.Or=new II}}var Jy,gE=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};I&&!L(I.crypto)&&crypto.getRandomValues&&(gE=e=>crypto.getRandomValues(e));class II{nextUint32(){return this.ft.length>this.Fr||(gE(this.ft),this.Fr=0),this.ft[this.Fr++]}constructor(){this.ft=new Uint32Array(8),this.Fr=1/0}}var $n=()=>OI().toString(),OI=()=>(Jy||(Jy=new TI)).generate(),Yo="",MI=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Ke={Dr:()=>!!j,jr(e){D.error("cookieStore error: "+e)},Pr:vE,Br(e){var t;try{t=JSON.parse(Ke.Pr(e))||{}}catch{}return t},Nr(e,t,n,r,i){if(!j)return!1;try{var s="",o="",a=function(c,d){if(d){var f=function(_,p){if(p===void 0&&(p=j),Yo)return Yo;if(!p||["localhost","127.0.0.1"].includes(_))return"";for(var y=_.split("."),h=Math.min(y.length,8),v="dmn_chk_"+$n();!Yo&&h--;){var x=y.slice(h).join("."),b=v+"=1;domain=."+x+";path=/";p.cookie=b+";max-age=3",p.cookie.includes(v)&&(p.cookie=b+";max-age=0",Yo=x)}return Yo}(c);if(!f){var m=(_=>{var p=_.match(MI);return p?p[0]:""})(c);m!==f&&D.info("Warning: cookie subdomain discovery mismatch",m,f),f=m}return f?"; domain=."+f:""}return""}(j.location.hostname,r);if(n){var l=new Date;l.setTime(l.getTime()+864e5*n),s="; expires="+l.toUTCString()}i&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+s+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&D.warn("cookieStore warning: large cookie, len="+u.length),j.cookie=u,!0}catch{return!1}},qr(e,t){if(j!=null&&j.cookie)try{Ke.Nr(e,"",-1,t)}catch{return}}},mf=null,ge={Dr(){if(!rt(mf))return mf;var e=!0;if(L(I))e=!1;else try{var t="__mplssupport__";ge.Nr(t,"xyz"),ge.Pr(t)!=='"xyz"'&&(e=!1),ge.qr(t)}catch{e=!1}return e||D.error("localStorage unsupported; falling back to cookie store"),mf=e,e},jr(e){D.error("localStorage error: "+e)},Pr(e){try{return I==null?void 0:I.localStorage.getItem(e)}catch(t){ge.jr(t)}return null},Br(e){try{return JSON.parse(ge.Pr(e))||{}}catch{}return null},Nr(e,t){try{return I==null||I.localStorage.setItem(e,JSON.stringify(t)),!0}catch(n){ge.jr(n)}return!1},qr(e){try{I==null||I.localStorage.removeItem(e)}catch(t){ge.jr(t)}}},yf=[yn,Mi,ir,Xa,Ai,Gs,Gi,Ks,ar],Pi=[Ya,wt,Fs,bg,Sc,Ec,se],Rc=e=>e+"_cpm",AI=["__proto__","constructor","prototype"],_f=e=>{if(!Se(e))return{};var t={};return Object.keys(e).forEach(n=>{AI.indexOf(n)===-1&&(t[n]=e[n])}),t},wf=function(e,t){t===void 0&&(t=[]);var n={};return[...Pi,...t].forEach(r=>{var i=e[r];L(i)||rt(i)||i===""||(n[r]=i)}),n},mE=e=>{for(var t=5381,n=2166136261,r=0;e.length>r;r++){var i=e.charCodeAt(r);t=33*t^i,n=Math.imul(n^i,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(n>>>0).toString(36)},Zy=(e,t)=>({p:t,f:mE(JSON.stringify(e))}),e_=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{var n=Ke.Br(Rc(e)),r=(n==null?void 0:n.f)===mE(t)&&Z(n.p);return{properties:r?n.p:[],isValid:r}}catch{return{properties:[],isValid:!1}}},xf=(e,t)=>t+"|"+(Ke.Pr(Rc(e))||""),Yl={},NI={Dr:()=>!0,jr(e){D.error("memoryStorage error: "+e)},Pr:e=>Yl[e]||null,Br:e=>Yl[e]||null,Nr:(e,t)=>(Yl[e]=t,!0),qr(e){delete Yl[e]}},mi=null,we={Dr(){if(!rt(mi))return mi;if(mi=!0,L(I))mi=!1;else try{var e="__support__";we.Nr(e,"xyz"),we.Pr(e)!=='"xyz"'&&(mi=!1),we.qr(e)}catch{mi=!1}return mi},jr(e){D.error("sessionStorage error: ",e)},Pr(e){try{return I==null?void 0:I.sessionStorage.getItem(e)}catch(t){we.jr(t)}return null},Br(e){try{return JSON.parse(we.Pr(e))||null}catch{}return null},Nr(e,t){try{return I==null||I.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(n){we.jr(n)}return!1},qr(e){try{I==null||I.sessionStorage.removeItem(e)}catch(t){we.jr(t)}}};class $I{constructor(t){this._instance=t}get qi(){return this._instance.config}get consent(){return this.cs()?0:this.fs}isOptedOut(){return this.qi.cookieless_mode===lr||this.isRejected()||this.consent===-1&&this.qi.cookieless_mode===ki}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.qi.opt_out_capturing_by_default}optInOut(t){this.ps.Nr(this.gs,t?1:0,this.qi.cookie_expiration,this.qi.cross_subdomain_cookie,this.qi.secure_cookie)}reset(){this.ps.qr(this.gs,this.qi.cross_subdomain_cookie)}get gs(){var t=this._instance.config,n=t.token,r=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(r?r+n:"__ph_opt_in_out_"+n)}get fs(){var t=this.ps.Pr(this.gs);return lf(t)?1:J(jT,t)?0:-1}get ps(){var t=this.qi.opt_out_capturing_persistence_type,n=t==="localStorage"?ge:Ke;if(!this.ys||this.ys!==n){this.ys=n;var r=t==="localStorage"?Ke:ge;r.Pr(this.gs)&&(this.ys.Pr(this.gs)||this.optInOut(lf(r.Pr(this.gs))),r.qr(this.gs,this.qi.cross_subdomain_cookie))}return this.ys}cs(){return!!this.qi.respect_dnt&&[St==null?void 0:St.doNotTrack,St==null?void 0:St.msDoNotTrack,Y.doNotTrack].some(t=>lf(t))}}function yE(e,t){var n,r=e==null||(n=e.config)==null?void 0:n.get_current_url;if(!vt(r))return t;try{var i=r(t);return ce(i)&&i?i:t}catch(s){return D.error("Error in get_current_url, falling back to window.location.href",s),t}}var _E="__POSTHOG_TOOLBAR__",FI=1,LI=3,jI=11;function t_(e){return e instanceof Element&&(e.id===_E||!(e.closest==null||!e.closest(".toolbar-global-fade-container")))}function ui(e){return!!e&&e.nodeType===FI}function Kt(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function wE(e){return!!e&&e.nodeType===LI}function xE(e){return!!e&&e.nodeType===jI&&ui(e.host)}var bE=1e3;function Cg(e){return e?dd(e).split(/\s+/):[]}function n_(e,t){var n=function(r){var i,s=I==null||(i=I.location)==null?void 0:i.href;return L(s)?void 0:yE(r,s)}(t);return!!(n&&e&&e.some(r=>n.match(r)))}function Tc(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Cg(t)}function EE(e){return ne(e)?null:dd(e).split(/(\s+)/).filter(t=>ka(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ja(e){var t="";return kp(e)&&!RE(e)&&e.childNodes&&e.childNodes.length&&ve(e.childNodes,function(n){var r;wE(n)&&n.textContent&&(t+=(r=EE(n.textContent))!==null&&r!==void 0?r:"")}),dd(t)}function Sp(e){var t;return L(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}var kg=["a","button","form","input","select","textarea","label"];function Cp(e,t){if(L(t))return!0;var n,r=function(s){if(t.some(o=>function(a,l){var u=a.matches||a.matchesSelector||a.msMatchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.oMatchesSelector;try{return!!u&&u.call(a,l)}catch{return!1}}(s,o)))return{v:!0}};for(var i of e)if(n=r(i))return n.v;return!1}function SE(e){var t=e.parentNode;return!(!t||!ui(t))&&t}var DI=[".ph-no-autocapture","[data-ph-no-autocapture]"],CE=["next","previous","prev",">","<"],zI=[...CE,"+","-","−","–"],r_=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,i_=[".ph-no-rageclick",".ph-no-capture"],UI=["","text","search","email","password","url","tel","number"];function kE(e,t){if(!I||Pg(e))return!1;var n,r,i,s,o;if($t(t)?(n=!!t&&i_,r=void 0,i=!1):(n=(s=t==null?void 0:t.css_selector_ignorelist)!==null&&s!==void 0?s:i_,r=t==null?void 0:t.content_ignorelist,i=(o=t==null?void 0:t.ignore_text_selection)!==null&&o!==void 0&&o),n===!1||i&&function(l){return!(!l||!ui(l))&&(!!Kt(l,"textarea")||(Kt(l,"input")?J(UI,(l.getAttribute("type")||"").toLowerCase()):function(u){if(u.isContentEditable)return!0;var c=u.getAttribute==null?void 0:u.getAttribute("contenteditable");return c==="true"||c===""}(l)))}(e))return!1;var a=PE(e,!1).targetElementList;return!function(l,u){if(l===!1||L(l))return!1;var c;if(l===!0)c=CE;else{if(!Z(l))return!1;if(l.length>10)return D.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;c=l.map(d=>d.toLowerCase())}return u.some(d=>{var f=d.safeText,m=d.ariaLabel;return c.some(_=>r_(f,_)||r_(m,_))})}(r,a.map(l=>{var u;return{safeText:Ja(l).toLowerCase(),ariaLabel:((u=l.getAttribute("aria-label"))==null?void 0:u.toLowerCase().trim())||""}}))&&!Cp(a,n)}var Pg=e=>!e||Kt(e,"html")||!ui(e),PE=(e,t)=>{if(!I||Pg(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[e],i=e;i.parentNode&&!Kt(i,"body");)if(xE(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=SE(i);if(!s)break;if(t||kg.indexOf(s.tagName.toLowerCase())>-1)n=!0;else try{var o=I.getComputedStyle(s);o&&o.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}r.push(s),i=s}return{parentIsUsefulElement:n,targetElementList:r}};function kp(e){for(var t=new Set,n=0,r=e;r.parentNode&&!Kt(r,"body");r=r.parentNode){if(n++>=bE||t.has(r))return!1;t.add(r);var i=Tc(r);if(J(i,"ph-sensitive")||J(i,"ph-no-capture"))return!1}if(J(Tc(e),"ph-include"))return!0;var s=e.type||"";if(ce(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var o=e.name||e.id||"";return!ce(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function RE(e){return!!(Kt(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Kt(e,"select")||Kt(e,"textarea")||e.getAttribute("contenteditable")==="true")}var s_=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),o_=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,VI=[16,15,14,13],BI=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),a_=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),l_=/[0-9A-Za-z_]/;function qI(e){for(var t=0,n=!1,r=e.length-1;r>=0;r--){var i=e.charCodeAt(r)-48;n&&(i*=2)>9&&(i-=9),t+=i,n=!n}return t%10==0}function ka(e,t){if(t===void 0&&(t=!0),ne(e))return!1;if(ce(e)){e=dd(e);var n=t?s_.test((e||"").replace(/[- ]/g,"")):function(i){var s;for(o_.lastIndex=0;s=o_.exec(i);){var o=s[2];if(o)for(var a=o.replace(/[- ]/g,""),l=0;a.length>l;l++)for(var u of VI){var c=l+u;if(a.length>=c){var d=a.slice(l,c);if(s_.test(d)&&qI(d))return!0}}}return!1}(e);if(n)return!1;var r=t?BI.test(e):function(i){var s;for(a_.lastIndex=0;s=a_.exec(i);){var o=s[1],a=s[3];if(!(o&&a&&l_.test(o)&&l_.test(a)))return!0}return!1}(e);if(r)return!1}return!0}function u_(e){var t=Ja(e);return ka(t=(t+" "+TE(e)).trim())?t:""}function TE(e){var t="";return e&&e.childNodes&&e.childNodes.length&&ve(e.childNodes,function(n){var r;if(n&&((r=n.tagName)==null?void 0:r.toLowerCase())==="span")try{var i=Ja(n);t=(t+" "+i).trim(),n.childNodes&&n.childNodes.length&&(t=(t+" "+TE(n)).trim())}catch(s){D.error("[AutoCapture]",s)}}),t}function c_(e){return e.replace(/"|\\"/g,'\\"')}function WI(e){var t=e.attr__class;if(t)return Z(t)?t:Cg(t)}var Xl=Ie("[Dead Clicks]"),HI=()=>!0,GI=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(wg)),r=e.instance.config.capture_dead_clicks;return $t(r)?r:!!Se(r)||n};class d_{get lazyLoadedDeadClicksAutocapture(){return this.bs}constructor(t,n,r){this.instance=t,this.isEnabled=n,this.onCapture=r,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var n=t.config;"captureDeadClicks"in n&&(this.instance.persistence&&this.instance.persistence.register({[wg]:n.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this._s(()=>{this.ws()}):this.stop()}_s(t){var n,r;(n=Y.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture?t():(r=Y.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?Xl.error("failed to load script",i):t()})}ws(){var t;if(j){if(!this.bs&&(t=Y.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture){var n=Se(this.instance.config.capture_dead_clicks)?$({},this.instance.config.capture_dead_clicks):{};n.__onCapture=this.onCapture,this.onCapture&&(n.capture_dead_swipes=!1),this.bs=Y.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.bs.start(j),Xl.info("starting...")}}else Xl.error("`document` not found. Cannot start.")}stop(){this.bs&&(this.bs.stop(),this.bs=void 0,Xl.info("stopping..."))}}var bf=Ie("[SegmentIntegration]"),IE="posthog-js";function OE(e,t){var n=t===void 0?{}:t,r=n.organization,i=n.projectId,s=n.prefix,o=n.severityAllowList,a=o===void 0?["error"]:o,l=n.sendExceptionsToPostHog,u=l===void 0||l;return c=>{var d,f,m,_,p;if(a!=="*"&&!a.includes(c.level)||!e.__loaded)return c;c.tags||(c.tags={});var y=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());c.tags["PostHog Person URL"]=y,e.sessionRecordingStarted()&&(c.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var h,v=((d=c.exception)==null?void 0:d.values)||[],x=v.map(E=>$({},E,{stacktrace:E.stacktrace?$({},E.stacktrace,{type:"raw",frames:(E.stacktrace.frames||[]).map(S=>$({},S,{platform:"web:javascript"}))}):void 0})),b={$exception_message:((f=v[0])==null?void 0:f.value)||c.message,$exception_type:(m=v[0])==null?void 0:m.type,$exception_level:c.level,$exception_list:x,$sentry_event_id:c.event_id,$sentry_exception:c.exception,$sentry_exception_message:((_=v[0])==null?void 0:_.value)||c.message,$sentry_exception_type:(p=v[0])==null?void 0:p.type,$sentry_tags:c.tags};return r&&i&&(b.$sentry_url=(s||"https://sentry.io/organizations/")+r+"/issues/?project="+i+"&query="+c.event_id),u&&((h=e.exceptions)==null||h.sendExceptionEvent(b)),c}}class KI{constructor(t,n,r,i,s,o){this.name=IE,this.setupOnce=function(a){a(OE(t,{organization:n,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}}class f_{constructor(t){this.ks=(n,r,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(D.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:n,changeReason:i}),this.Ss=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.xs()}xs(){var t;this.Cs=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(this.ks)}destroy(){var t;(t=this.Cs)==null||t.call(this),this.Cs=void 0}doPageView(t,n){var r,i=this.Ts(t,n);return this.Ss={pathname:(r=I==null?void 0:I.location.pathname)!==null&&r!==void 0?r:"",pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),i}doPageLeave(t){var n;return this.Ts(t,(n=this.Ss)==null?void 0:n.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this.Ss)==null?void 0:t.pageViewId}}Ts(t,n){var r=this.Ss;if(!r)return{$pageview_id:n};var i={$pageview_id:n,$prev_pageview_id:r.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var o=s.maxScrollHeight,a=s.lastScrollY,l=s.maxScrollY,u=s.maxContentHeight,c=s.lastContentY,d=s.maxContentY;if(!(L(o)||L(a)||L(l)||L(u)||L(c)||L(d))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c),d=Math.ceil(d);var f=o>1?Vn(a/o,0,1,D):1,m=o>1?Vn(l/o,0,1,D):1,_=u>1?Vn(c/u,0,1,D):1,p=u>1?Vn(d/u,0,1,D):1;i=_e(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:f,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:m,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:_,$prev_pageview_max_content:d,$prev_pageview_max_content_percentage:p})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(t.getTime()-r.timestamp.getTime())/1e3),i}}var Ef=["flags","surveys"],QI={[sE]:{exposure:"hidden"},[$s]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[ca]:{exposure:"hidden"},[lp]:{exposure:"event"},[up]:{exposure:"hidden"},[cp]:{exposure:"event"},[dp]:{exposure:"hidden"},[fp]:{exposure:"event"},[hp]:{exposure:"event"},[wg]:{exposure:"event"},[xg]:{exposure:"hidden"},[pp]:{exposure:"event"},[Oi]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[Fs]:{exposure:"hidden"},[bg]:{exposure:"event"},[oE]:{exposure:"event",shouldSkipFromEventProperties:e=>rt(e)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[ir]:{exposure:"hidden",storageGroup:"flags"},[Mi]:{exposure:"hidden",storageGroup:"flags"},[Pu]:{exposure:"hidden"},[Xa]:{exposure:"hidden",storageGroup:"flags"},[Ai]:{exposure:"hidden",storageGroup:"flags"},[Gs]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[xc]:{exposure:"hidden",storageGroup:"flags"},[Mn]:{exposure:"hidden"},[Ci]:{exposure:"hidden"},[yn]:{exposure:"hidden"},[Dn]:{exposure:"hidden"},[vp]:{exposure:"hidden",storageGroup:"surveys"},[bc]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[gp]:{exposure:"event"},[Ru]:{exposure:"hidden"},[Tu]:{exposure:"hidden"},[da]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$product_tours_activated_session:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[ar]:{exposure:"hidden"},[fa]:{exposure:"hidden"},[dE]:{exposure:"event"},[Ks]:{exposure:"hidden"},[Gi]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[se]:{exposure:"hidden"},[mp]:{exposure:"hidden"},[yp]:{exposure:"hidden"},[_p]:{exposure:"hidden"},[wp]:{exposure:"hidden"},[Ec]:{exposure:"hidden"},[Sc]:{exposure:"hidden"},[aE]:{exposure:"event"},[lE]:{exposure:"event"},[uE]:{exposure:"event"},[cE]:{exposure:"event"},[hE]:{exposure:"event"},[pE]:{exposure:"event"},[xp]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_pending_trigger_conditions:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},YI=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],An=e=>{var t=QI[e];if(t)return t;for(var n of YI){var r=n[1];if(e.indexOf(n[0])===0)return r}},Ls=(e,t)=>{try{return JSON.stringify(e,(n,r)=>typeof r=="bigint"?r.toString():r,t)}catch{return Cb(e)}},Eo=e=>{var t=j==null?void 0:j.createElement("a");return L(t)?null:(t.href=e,t)},So=function(e,t){for(var n,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;r.length>i;i++){var s=r[i].split("=");if(s[0]===t){n=s;break}}if(!Z(n)||2>n.length)return"";var o=n[1];try{o=decodeURIComponent(o)}catch{D.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Za=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split("#"),i=r[1],s=(r[0]||"").split("?"),o=s[1],a=s[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var d=l[c].split("=");Z(d)&&(t.includes(d[0])?u.push(d[0]+"="+n):u.push(l[c]))}var f=a;return o!=null&&(f+="?"+u.join("&")),i!=null&&(f+="#"+i),f},Ic=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},ME=(e,t)=>e>=t&&xb(),AE=(e,t,n,r)=>{if(e===0){if(xb()){var i=t+1;return i===n&&r(),i}return t}return 0},Jl="https?://(.*)",Co=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],XI=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Co],el="",JI=["li_fat_id"];function NE(e,t,n){if(!j)return{};var r,i=t?[...Co,...n||[]]:[],s=$E(Za(j.URL,i,el),e),o=(r={},ve(JI,function(a){var l=vE(a);r[a]=l||null}),r);return _e(o,s)}function $E(e,t){var n=XI.concat(t||[]),r={};return ve(n,function(i){var s=So(e,i);r[i]=s||null}),r}function FE(e){var t=function(s){return s?s.search(Jl+"google.([^/?]*)")===0?"google":s.search(Jl+"bing.com")===0?"bing":s.search(Jl+"yahoo.com")===0?"yahoo":s.search(Jl+"duckduckgo.com")===0?"duckduckgo":null:null}(e),n=t!="yahoo"?"q":"p",r={};if(!rt(t)){r.$search_engine=t;var i=j?So(j.referrer,n):"";i.length&&(r.ph_keyword=i)}return r}function h_(){return navigator.language||navigator.userLanguage}var Oc="$direct";function LE(){return(j==null?void 0:j.referrer)||Oc}function jE(e,t,n){n===void 0&&(n=!1);var r=e?[...Co,...t||[]]:[],i=n?li(Ae==null?void 0:Ae.href):Ae==null?void 0:Ae.href,s=i==null?void 0:i.substring(0,1e3);return{r:LE().substring(0,1e3),u:s?Za(s,r,el):void 0}}function DE(e,t){var n;t===void 0&&(t=!1);var r=e.r,i=e.u,s=t?li(i):i,o={$referrer:r,$referring_domain:r==null?void 0:r==Oc?Oc:(n=Eo(r))==null?void 0:n.host};if(s){o.$current_url=s;var a=Eo(s);o.$host=a==null?void 0:a.host,o.$pathname=a==null?void 0:a.pathname;var l=$E(s);_e(o,l)}if(r){var u=FE(r);_e(o,u)}return o}function zE(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function ZI(){try{return new Date().getTimezoneOffset()}catch{return}}var eO={flags:Gi,surveys:bc},tO=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Zl=e=>e+"_cookie_identity_change_pending",Rr="main",p_=(e,t)=>{ve(e,(n,r)=>{var i=An(r);i&&i.exposure!=="event"||{}.hasOwnProperty.call(t,r)||delete e[r]})};class Sf{constructor(t,n,r){if(r===void 0&&(r=!0),this.Ms={},this.Es=!1,this.Is=!1,this.Rs=!1,this.Ps=!1,this.qi=t,this.As=r,this.props={},this.Fs=void 0,this.Os=(s=>{var o="";return s.token&&(o=s.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),s.persistence_name?"ph_"+s.persistence_name:"ph_"+o+"_posthog"})(t),this.ps=this.Ls(t),this.Is=this.$s(t),this.load(),t.debug&&D.info("Persistence loaded",t.persistence,$({},this.props)),this.update_config(t,t,n),this.save(),I){var i=()=>this.flush();Re(I,"beforeunload",i,{capture:!1}),Re(I,"pagehide",i,{capture:!1})}}Ds(){var t,n=(t=this.qi)==null?void 0:t.persistence_save_debounce_ms;return Ge(n)&&n>0?n:0}Ns(t){if(this.qi.cookieWinsOnConflict&&this.qi.persistence.toLowerCase()==="localstorage+cookie")if(t)try{var n=wf(t,this.qi.cookie_persisted_properties||[]),r=Zy(n,this.qi.cookie_persisted_properties||[]),i=JSON.stringify(n)+"|"+JSON.stringify(r),s=Ke.Pr(this.Os)||void 0;s&&xf(this.Os,s)===i&&(this.qs=i,this.js=s)}catch{}else try{var o=Ke.Pr(this.Os)||void 0;this.qs=o?xf(this.Os,o):void 0,this.js=o}catch{}}syncCookieProperties(){return this.Bs(this.qi)}Bs(t,n){if(n===void 0&&(n=!1),this.Hs&&!n||this.Ps||!t.cookieWinsOnConflict||t.persistence.toLowerCase()!=="localstorage+cookie")return!1;var r;try{r=Ke.Pr(this.Os)||void 0}catch{}if(!r||r===this.js)return!1;var i,s=xf(this.Os,r);try{i=_f(JSON.parse(r))}catch{return!1}if((Ke.Pr(this.Os)||void 0)!==r)return!1;this.qs=s,this.js=r;var o=e_(this.Os,r),a=[...Pi,...o.properties],l={};if(Object.keys(i).forEach(p=>{var y=i[p];(L(y)||rt(y)||y===""||p===se&&y!==We&&y!==ot)&&(l[p]=!0,delete i[p])}),En(i))return!1;var u=wt in i||i[se]===We||i[se]===ot,c=this.props[wt],d=this.props[se],f=_e({},this.props);[...Pi,...t.cookie_persisted_properties||[]].forEach(p=>{if(a.indexOf(p)!==-1&&!(p in i)&&!l[p]&&(u||p!==wt&&p!==se)){var y=f[p];!o.isValid&&Pi.indexOf(p)!==-1&&(y===!1||y===0)||delete f[p]}}),this.props=_e(f,i),!u||se in i||se in this.props||this.Us(se,We);var m=this.props[wt],_=this.props[se];return!u||m===c&&_===d||(this.Rs=!0,we.Nr(Zl(this.Os),!0),this.zs(yn),this.zs(Mi),this.zs(ir),this.zs(Xa),this.zs(Ai),this.zs(Gs),this.zs(Gi),this.zs(Ks),this.zs(ar),_===We&&(d===ot||i[se]===We||!L(c)&&m!==c)&&(p_(this.props,i),this.zs(Dn)),_===ot?this.props.$user_id=m:delete this.props.$user_id,this.zs($s)),!0}consumeCookieIdentityChange(){var t=Zl(this.Os),n=this.Rs||!!we.Pr(t);return this.Rs=!1,n&&we.qr(t),n}Ws(t){return t===void 0&&(t=!1),!(this.Ps||this.Hs&&!t||!this.qi.cookieWinsOnConflict||this.qi.persistence.toLowerCase()!=="localstorage+cookie"||(this.Ps=!0,0))}Vs(){this.Ps&&(L(this.Gs)||(clearTimeout(this.Gs),this.Gs=void 0),delete this.Ms[Rr],this.Zs(!0))}Qs(t){if(t===void 0&&(t=!0),this.Ps)try{t?this.Vs():L(this.Gs)||(clearTimeout(this.Gs),this.Gs=void 0)}finally{this.Ps=!1}}isDisabled(){return!!this.Hs}Ls(t){tO.indexOf(t.persistence.toLowerCase())===-1&&(D.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var n,r=function(o,a){o===void 0&&(o=[]),a===void 0&&(a=!1);var l=[...Pi,...o];return $({},ge,{Br(u){try{var c,d={};try{c=Ke.Pr(u)||void 0,d=c?_f(JSON.parse(c)):{}}catch{}var f,m=JSON.parse(ge.Pr(u)||"{}");if(a){var _=e_(u,c),p=[...Pi,..._.properties],y={};Object.keys(d).forEach(E=>{var S=d[E];rt(S)||S===""||E===se&&S!==We&&S!==ot||(y[E]=S)});var h=wt in y||y[se]===We||y[se]===ot;if(Object.keys(y).length>0){var v,x=m[wt],b=(v=m[se])!==null&&v!==void 0?v:We;l.forEach(E=>{if(p.indexOf(E)!==-1&&!(E in d)&&(h||E!==wt&&E!==se)){var S=m[E];!_.isValid&&Pi.indexOf(E)!==-1&&(S===!1||S===0)||delete m[E]}}),!h||se in d||se in m||(m[se]=We),!h||(wt in y?y[wt]:m[wt])===x&&(se in y?y[se]:m[se])===b||(yf.forEach(E=>delete m[E]),y[se]===ot&&wt in y?m.$user_id=y[wt]:delete m.$user_id,y[se]!==ot&&(delete m[dE],delete m[Dn]),delete m.__alias)}f=_e(m,y)}else f=_e(d,m);return ge.Nr(u,f),f}catch{}return null},Nr(u,c,d,f,m,_){var p=ge.Nr(u,c,void 0,void 0,_);try{var y=wf(c,o);if(Object.keys(y).length){if(a){var h=Rc(u),v=Zy(y,o);if(Ke.Nr(h,v,d,f,m,_),Ke.Pr(h)!==JSON.stringify(v)){Ke.qr(h,f);var x=wf(c);return Ke.Nr(u,x,d,f,m,_),p}}Ke.Nr(u,y,d,f,m,_)}}catch(b){ge.jr(b)}return p},qr(u,c){try{I==null||I.localStorage.removeItem(u),Ke.qr(u,c),Ke.qr(Rc(u),c)}catch(d){ge.jr(d)}}})}(t.cookie_persisted_properties||[],t.cookieWinsOnConflict),i=!1,s=t.persistence.toLowerCase();return s==="localstorage"&&ge.Dr()?(n=ge,i=!0):s==="localstorage+cookie"&&r.Dr()?(n=r,i=!0):s==="sessionstorage"&&we.Dr()?n=we:s==="memory"?n=NI:s==="cookie"?n=Ke:r.Dr()?(n=r,i=!0):n=Ke,this.Es=i,n}Js(t){return this.Os+"__"+t}$s(t){return this.Es&&!!t.split_storage}properties(){var t={};return ve(this.props,(n,r)=>{var i=An(r);if(!i||i.exposure==="event"){if(i!=null&&i.shouldSkipFromEventProperties!=null&&i.shouldSkipFromEventProperties(n))return;t[r]=n}}),t}load(t){if(t===void 0&&(t=!1),!this.Hs||t){var n=this.qi.cookieWinsOnConflict&&this.qi.persistence.toLowerCase()==="localstorage+cookie",r=n?ge.Br(this.Os):null,i={};if(n)try{ve(i=_f(Ke.Br(this.Os)),(_,p)=>{(L(_)||rt(_)||_==="")&&delete i[p]})}catch{}var s=this.ps.Br(this.Os);if(s&&(this.props=_e({},s)),this.Is&&this.Ks(),n&&s){var o,a,l=r==null?void 0:r[wt],u=(o=r==null?void 0:r[se])!==null&&o!==void 0?o:We,c=s[wt],d=(a=s[se])!==null&&a!==void 0?a:We;if(c!==l||d!==u){this.Rs=!0,we.Nr(Zl(this.Os),!0);var f=_e({},this.props);yf.forEach(_=>delete f[_]),d===We&&(u===ot||i[se]===We||!L(l)&&c!==l)&&(p_(f,i),delete f[Dn]),this.props=f;var m=new Set;yf.forEach(_=>{var p,y=(p=An(_))==null?void 0:p.storageGroup;y&&m.add(y)}),m.forEach(_=>{var p={};ve(this.props,(y,h)=>{var v;((v=An(h))==null?void 0:v.storageGroup)===_&&(p[h]=y)}),En(p)?(ge.qr(this.Js(_)),this.Ms[_]={}):ge.Nr(this.Js(_),p)&&(this.Ms[_]={persisted:!0,fingerprint:this.Ys(p,_)})})}}we.Pr(Zl(this.Os))&&(this.Rs=!0)}}Ks(){for(var t of Ef){var n=ge.Br(this.Js(t));if(n&&!En(n)){var r=this.Xs(t);r.persisted=!0,this.ta(t)||(r.fingerprint=this.Ys(n,t)),this.ea(t,n)||_e(this.props,n)}}}ta(t){return Object.keys(this.props).some(n=>{var r;return((r=An(n))==null?void 0:r.storageGroup)===t})}ea(t,n){var r=eO[t];if(!r)return!1;var i=n[r],s=this.props[r];return Ge(i)&&Ge(s)&&s>i}refreshKey(t){var n;if(!this.Hs){var r=this.Is?(n=An(t))==null?void 0:n.storageGroup:void 0,i=r?ge.Br(this.Js(r)):this.ps.Br(this.Os);if(i&&t in i)this.Us(t,i[t]);else{if(r){var s=this.ps.Br(this.Os);if(s&&t in s)return void this.Us(t,s[t])}this.zs(t)}}}save(){if(!this.Hs){var t=this.Ds();t>0?L(this.Gs)&&(this.Gs=setTimeout(()=>{this.Gs=void 0,this.Zs()},t)):this.Zs()}}flush(){L(this.Gs)||(clearTimeout(this.Gs),this.Gs=void 0,this.Zs())}Zs(t){t===void 0&&(t=!1),this.Hs||this.Ps&&!t||(t||this.syncCookieProperties(),this.Is?this.ia():this.ra(this.ps,this.Os,this.props,Rr)&&this.Ns(this.props))}ia(){var t=this.na(),n=t.main,r=t.groups;for(var i of(this.ra(this.ps,this.Os,n,Rr)&&this.Ns(n),Ef)){var s,o=r[i];(!En(o)||(s=this.Ms[i])!=null&&s.persisted)&&this.ra(ge,this.Js(i),o,i)}}na(){var t={},n={flags:{},surveys:{}};return ve(this.props,(r,i)=>{var s,o=(s=An(i))==null?void 0:s.storageGroup;o?n[o][i]=r:t[i]=r}),{main:t,groups:n}}Ys(t,n){if(n===Rr)return JSON.stringify(t)+"|"+this.sa+"|"+this.aa+"|"+this.oa;var r={};return ve(t,(i,s)=>{var o;r[s]=(o=An(s))!=null&&o.volatile?"__volatile__":i}),JSON.stringify(r)}ra(t,n,r,i){var s,o=this.Xs(i);if(i!==Rr&&!o.dirty&&!L(o.fingerprint))return!1;try{if((s=this.Ys(r,i))===o.fingerprint)return o.dirty=!1,!1}catch{s=void 0}return t.Nr(n,r,this.sa,this.aa,this.oa,this.qi.debug)?(o.dirty=!1,i!==Rr&&(o.persisted=!0),L(s)||(o.fingerprint=s),!0):(this.qi.debug&&D.warn('failed to persist storage entry "'+n+'"; will retry on next save'),!1)}remove(t){var n=(t===void 0?{}:t).keepGroupEntries,r=n!==void 0&&n;if(L(this.Gs)||(clearTimeout(this.Gs),this.Gs=void 0),this.ps.qr(this.Os,!1),this.ps.qr(this.Os,!0),!r&&this.As)for(var i of Ef)ge.qr(this.Js(i));r?delete this.Ms[Rr]:this.Ms={},this.qs=void 0,this.js=void 0}clear(){this.remove(),this.props={}}register_once(t,n,r){if(Se(t)){this.syncCookieProperties(),L(n)&&(n="None"),this.sa=L(r)?this.la:r;var i=!1;if(ve(t,(s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==n||(this.Us(o,s),i=!0)}),i)return this.save(),!0}return!1}register(t,n){if(Se(t)){this.syncCookieProperties(),this.sa=L(n)?this.la:n;var r=!1;if(ve(t,(i,s)=>{t.hasOwnProperty(s)&&(this.props[s]!==i||Se(i)||Z(i))&&(this.Us(s,i),r=!0)}),r)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();var n=typeof t=="string"?[t]:t,r=!1;for(var i of n)i in this.props&&(this.zs(i),r=!0);r&&this.save()}update_campaign_params(){var t=j==null?void 0:j.URL;if(t!==this.Fs){var n=NE(this.qi.custom_campaign_params,this.qi.mask_personal_data_properties,this.qi.custom_personal_data_properties);En(Sg(n))||this.register(n),this.Fs=t}}update_search_keyword(){var t;this.register((t=j==null?void 0:j.referrer)?FE(t):{})}update_referrer_info(){var t;this.register_once({$referrer:LE(),$referring_domain:j!=null&&j.referrer&&((t=Eo(j.referrer))==null?void 0:t.host)||Oc},void 0)}set_initial_person_info(){this.props[_p]||this.props[wp]||this.register_once({[Ec]:jE(this.qi.mask_personal_data_properties,this.qi.custom_personal_data_properties,this.qi.disable_capture_url_hashes)},void 0)}get_initial_props(){var t={};ve([wp,_p],i=>{var s=this.props[i];s&&ve(s,function(o,a){t["$initial_"+np(a)]=o})});var n=this.props[Ec];if(n){var r=function(i,s){s===void 0&&(s=!1);var o=DE(i,s),a={};return ve(o,function(l,u){a["$initial_"+np(u)]=l}),a}(n,this.qi.disable_capture_url_hashes);_e(t,r)}return t}safe_merge(t){return ve(this.props,function(n,r){r in t||(t[r]=n)}),t}update_config(t,n,r){var i=t.persistence!==n.persistence,s=!((p,y)=>{if(p.length!==y.length)return!1;var h=[...p].sort(),v=[...y].sort();return h.every((x,b)=>x===v[b])})(t.cookie_persisted_properties||[],n.cookie_persisted_properties||[]),o=i||s,a=t.cookieWinsOnConflict!==n.cookieWinsOnConflict,l=t.disable_persistence||!!r,u=!!this.Hs&&!l;l||this.Bs(n,u),this.qi=t,!l&&(i||s||a)&&(this.qs=void 0,this.js=void 0,this.Bs($({},t,{cookie_persisted_properties:n.cookie_persisted_properties}),u));var c=o||a?this.Ls(t):this.ps,d=this.$s(t),f=o||d!==this.Is,m=!l&&(f||t.cross_subdomain_cookie!==this.aa||t.secure_cookie!==this.oa)&&this.Ws(u);try{if(this.la=this.sa=t.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),f){var _=this.props;this.clear(),this.ps=c,this.Is=d,this.props=_,this.save()}else a&&(this.ps=c,l||(delete this.Ms[Rr],this.Zs()))}finally{m&&this.Qs()}}set_disabled(t){this.Hs=t,this.Hs?this.remove():this.save()}set_cross_subdomain(t){t!==this.aa&&(this.aa=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.oa&&(this.oa=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,n){var r=this.props[ca]||{};r[t]=n,this.Us(ca,r),this.save()}remove_event_timer(t){var n=this.props[ca]||{},r=n[t];return L(r)||(delete n[t],this.Us(ca,n),this.save()),r}get_property(t){return this.props[t]}set_property(t,n){this.Us(t,n),this.save()}Us(t,n){var r;this.props[t]=n,(r=An(t))!=null&&r.volatile||this.ua(t)}zs(t){delete this.props[t],this.ua(t)}ua(t){var n,r=(n=An(t))==null?void 0:n.storageGroup;r&&(this.Xs(r).dirty=!0)}Xs(t){return this.Ms[t]||(this.Ms[t]={})}}function eu(e){var t=!0;return{dispose(){if(t){t=!1;var n=e();n&&vt(n.then)&&n.then(void 0,()=>{})}}}}var Et={GZipJS:"gzip-js",Base64:"base64"},Xo={Activation:"events",Cancellation:"cancelEvents"},Cf={Popover:"popover",API:"api",Widget:"widget"},ur={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},kf={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},Pp={Popover:"popover",Inline:"inline"},nO={SHOWN:"product tour shown"},v_={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},g_=Ie("[RateLimiter]");class rO{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=n=>{var r=n.text;if(r&&r.length)try{(JSON.parse(r).quota_limited||[]).forEach(i=>{g_.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void g_.warn('could not rate limit - continuing. Error: "'+(i==null?void 0:i.message)+'"',{text:r})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return((t=this.instance.config.rate_limiting)==null?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max(((t=this.instance.config.rate_limiting)==null?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var n,r,i;t===void 0&&(t=!1);var s=this.captureEventsBurstLimit,o=this.captureEventsPerSecond,a=new Date().getTime(),l=(n=(r=this.instance.persistence)==null?void 0:r.get_property(yp))!==null&&n!==void 0?n:{tokens:s,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>s&&(l.tokens=s);var u=1>l.tokens;if(u||t||(l.tokens=Math.max(0,l.tokens-1)),u&&!t){var c=(Ge(l.dropped)?l.dropped:0)+1;l.dropped=c,!this.lastEventRateLimited&&this.ha(c)&&(l.dropped=0)}return this.lastEventRateLimited=u,(i=this.instance.persistence)==null||i.set_property(yp,l),{isRateLimited:u,remainingTokens:l.tokens}}da(t){var n=this.instance.config.property_denylist;return!Z(n)||!n.includes(t)}va(){var t;if(this.da("$current_url")&&this.da("$pathname")&&Ae!=null&&Ae.pathname)return""+((t=Ae.origin)!==null&&t!==void 0?t:"")+Ae.pathname}ha(t){var n,r,i=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,o=this.va(),a=this.da("$session_id")?(n=(r=this.instance).get_session_id)==null?void 0:n.call(r):void 0,l=[t+" event(s) dropped since the last warning",o?"triggered on "+o:void 0,a?"session "+a:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+l+". Config is set to "+s+" events per second and "+i+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var n=this.serverLimits[t||"events"]||!1;return n!==!1&&new Date().getTime()t(this.remoteConfig)):t()}fa(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return Tr.info("Using preloaded remote config",this.remoteConfig),this.pa(this.remoteConfig),void this.ga();if(this._instance.ma())return void Tr.warn("Remote config is disabled. Falling back to local config.");this.ca(t=>{if(!t)return Tr.info("No config found after loading remote JS config. Falling back to JSON."),void this.fa(n=>{this.pa(n.json,n),this.ga()});this.pa(t),this.ga()})}catch(t){Tr.error("Error loading remote config",t),this.pa()}}stop(){this.ya&&(clearInterval(this.ya),this.ya=void 0)}refresh(){!this._instance.ma()&&j&&j.visibilityState!=="hidden"&&this._instance.reloadFeatureFlags()}ga(){var t;if(!this.ya){var n=(t=this._instance.config.remote_config_refresh_interval_ms)!==null&&t!==void 0?t:3e5;n!==0&&(this.ya=setInterval(()=>{this.refresh()},n))}}pa(t,n){!t&&n&&(n.statusCode===0?n.error||Tr.warn("Failed to fetch remote config from PostHog."):Tr.error("Failed to fetch remote config from PostHog."));try{this._instance.pa(t?{ok:!0,config:t}:{ok:!1})}catch(i){Tr.error("Error applying remote config",i)}if((t==null?void 0:t.hasFeatureFlags)!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var r;(r=this._instance.featureFlags)==null||r.ensureFlagsLoaded()}catch(i){Tr.error("Error loading feature flags",i)}}}var ln=Uint8Array,Lt=Uint16Array,ko=Uint32Array,Rg=new ln([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Tg=new ln([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),m_=new ln([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),VE=function(e,t){for(var n=new Lt(31),r=0;31>r;++r)n[r]=t+=1<r;++r)for(var s=n[r];n[r+1]>s;++s)i[s]=s-n[r]<<5|r;return[n,i]},BE=VE(Rg,2),Rp=BE[1];BE[0][28]=258,Rp[258]=28;for(var y_=VE(Tg,0)[1],qE=new Lt(32768),Ne=0;32768>Ne;++Ne){var hs=(43690&Ne)>>>1|(21845&Ne)<<1;qE[Ne]=((65280&(hs=(61680&(hs=(52428&hs)>>>2|(13107&hs)<<2))>>>4|(3855&hs)<<4))>>>8|(255&hs)<<8)>>>1}var Pa=function(e,t,n){for(var r=e.length,i=0,s=new Lt(t);r>i;++i)++s[e[i]-1];var o,a=new Lt(t);for(i=0;t>i;++i)a[i]=a[i-1]+s[i-1]<<1;for(o=new Lt(r),i=0;r>i;++i)o[i]=qE[a[e[i]-1]++]>>>15-e[i];return o},Zi=new ln(288);for(Ne=0;144>Ne;++Ne)Zi[Ne]=8;for(Ne=144;256>Ne;++Ne)Zi[Ne]=9;for(Ne=256;280>Ne;++Ne)Zi[Ne]=7;for(Ne=280;288>Ne;++Ne)Zi[Ne]=8;var Mc=new ln(32);for(Ne=0;32>Ne;++Ne)Mc[Ne]=5;var iO=Pa(Zi,9),sO=Pa(Mc,5),WE=function(e){return(e/8>>0)+(7&e&&1)},HE=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof Lt?Lt:e instanceof ko?ko:ln)(n-t);return r.set(e.subarray(t,n)),r},Qn=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},Jo=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Pf=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,s=n.slice();if(!i)return[new ln(0),0];if(i==1){var o=new ln(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort(function(E,S){return E.f-S.f}),n.push({s:-1,f:25001});var a=n[0],l=n[1],u=0,c=1,d=2;for(n[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=i-1;)a=n[n[d].f>n[u].f?u++:d++],l=n[u!=c&&n[d].f>n[u].f?u++:d++],n[c++]={s:-1,f:a.f+l.f,l:a,r:l};var f=s[0].s;for(r=1;i>r;++r)s[r].s>f&&(f=s[r].s);var m=new Lt(f+1),_=Tp(n[c-1],m,0);if(_>t){r=0;var p=0,y=_-t,h=1<r;++r){var v=s[r].s;if(t>=m[v])break;p+=h-(1<<_-m[v]),m[v]=t}for(p>>>=y;p>0;){var x=s[r].s;t>m[x]?p-=1<=0&&p;--r){var b=s[r].s;m[b]==t&&(--m[b],++p)}_=t}return[new ln(m),_]},Tp=function(e,t,n){return e.s==-1?Math.max(Tp(e.l,t,n+1),Tp(e.r,t,n+1)):t[e.s]=n},__=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Lt(++t),r=0,i=e[0],s=1,o=function(l){n[r++]=l},a=1;t>=a;++a)if(e[a]==i&&a!=t)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=e[a]}return[n.subarray(0,r),t]},Zo=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},Ip=function(e,t,n){var r=n.length,i=WE(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var s=0;r>s;++s)e[i+s+4]=n[s];return 8*(i+4+r)},w_=function(e,t,n,r,i,s,o,a,l,u,c){Qn(t,c++,n),++i[256];for(var d=Pf(i,15),f=d[0],m=d[1],_=Pf(s,15),p=_[0],y=_[1],h=__(f),v=h[0],x=h[1],b=__(p),E=b[0],S=b[1],P=new Lt(19),C=0;v.length>C;++C)P[31&v[C]]++;for(C=0;E.length>C;++C)P[31&E[C]]++;for(var T=Pf(P,7),R=T[0],N=T[1],M=19;M>4&&!R[m_[M-1]];--M);var z,F,W,B,Q=u+5<<3,O=Zo(i,Zi)+Zo(s,Mc)+o,A=Zo(i,f)+Zo(s,p)+o+14+3*M+Zo(P,R)+(2*P[16]+3*P[17]+7*P[18]);if(O>=Q&&A>=Q)return Ip(t,c,e.subarray(l,l+u));if(Qn(t,c,1+(O>A)),c+=2,O>A){z=Pa(f,m),F=f,W=Pa(p,y),B=p;var V=Pa(R,N);for(Qn(t,c,x-257),Qn(t,c+5,S-1),Qn(t,c+10,M-4),c+=14,C=0;M>C;++C)Qn(t,c+3*C,R[m_[C]]);c+=3*M;for(var K=[v,E],te=0;2>te;++te){var oe=K[te];for(C=0;oe.length>C;++C)Qn(t,c,V[de=31&oe[C]]),c+=R[de],de>15&&(Qn(t,c,oe[C]>>>5&127),c+=oe[C]>>>12)}}else z=iO,F=Zi,W=sO,B=Mc;for(C=0;a>C;++C)if(r[C]>255){var de;Jo(t,c,z[257+(de=r[C]>>>18&31)]),c+=F[de+257],de>7&&(Qn(t,c,r[C]>>>23&31),c+=Rg[de]);var be=31&r[C];Jo(t,c,W[be]),c+=B[be],be>3&&(Jo(t,c,r[C]>>>5&8191),c+=Tg[be])}else Jo(t,c,z[r[C]]),c+=F[r[C]];return Jo(t,c,z[256]),c+F[256]},oO=new ko([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),aO=function(){for(var e=new ko(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),Rf=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function lO(e,t){t===void 0&&(t={});var n=function(){var d=4294967295;return{p(f){for(var m=d,_=0;f.length>_;++_)m=aO[255&m^f[_]]^m>>>8;d=m},d(){return 4294967295^d}}}(),r=e.length;n.p(e);var i,s,o,a,l,u=(a=10+((i=t).filename&&i.filename.length+1||0),l=8,function(d,f,m,_,p,y){var h=d.length,v=new ln(_+h+5*(1+Math.floor(h/7e3))+p),x=v.subarray(_,v.length-p),b=0;if(!f||8>h)for(var E=0;h>=E;E+=65535){var S=E+65535;h>S?b=Ip(x,b,d.subarray(E,S)):(x[E]=!0,b=Ip(x,b,d.subarray(E,h)))}else{for(var P=oO[f-1],C=P>>>13,T=8191&P,R=(1<E;++E){var de=W(E),be=32767&E,Pe=M[de];if(N[be]=Pe,M[de]=be,E>=te){var Be=h-E;if((A>7e3||K>24576)&&Be>423){b=w_(d,x,0,B,Q,O,V,K,oe,E-oe,b),K=A=V=0,oe=E;for(var ye=0;286>ye;++ye)Q[ye]=0;for(ye=0;30>ye;++ye)O[ye]=0}var Fe=2,Tt=0,Sr=T,_t=be-Pe&32767;if(Be>2&&de==W(E-_t))for(var Ye=Math.min(C,Be)-1,gi=Math.min(32767,E),us=Math.min(258,Be);gi>=_t&&--Sr&&be!=Pe;){if(d[E+Fe]==d[E+Fe-_t]){for(var It=0;us>It&&d[E+It]==d[E+It-_t];++It);if(It>Fe){if(Fe=It,Tt=_t,It>Ye)break;var cs=Math.min(_t,It-2),Cr=0;for(ye=0;cs>ye;++ye){var pn=E-_t+ye+32768&32767,Do=pn-N[pn]+32768&32767;Do>Cr&&(Cr=Do,Pe=pn)}}}_t+=(be=Pe)-(Pe=N[be])+32768&32767}if(Tt){B[K++]=268435456|Rp[Fe]<<18|y_[Tt];var gm=31&Rp[Fe],mm=31&y_[Tt];V+=Rg[gm]+Tg[mm],++Q[257+gm],++O[mm],te=E+Fe,++A}else B[K++]=d[E],++Q[d[E]]}}b=w_(d,x,!0,B,Q,O,V,K,oe,E-oe,b)}return HE(v,0,_+WE(b)+p)}(s=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(s.length)))):12+o.mem,a,l)),c=u.length;return function(d,f){var m=f.filename;if(d[0]=31,d[1]=139,d[2]=8,d[8]=2>f.level?4:f.level==9?2:0,d[9]=3,f.mtime!=0&&Rf(d,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),m){d[3]=8;for(var _=0;m.length>=_;++_)d[_+10]=m.charCodeAt(_)}}(u,t),Rf(u,c-8,n.d()),Rf(u,c-4,r),u}var uO=!!Jh||!!fg,GE="text/plain",Ou=!1,KE=(e,t)=>{var n=e.split("#"),r=n[1],i=n[0].split("?"),s=i[0],o=i[1];if(!o)return e;var a=o.split("&").filter(l=>l.split("=")[0]!==t).join("&");return s+(a?"?"+a:"")+(r?"#"+r:"")},bl=function(e,t,n){var r;n===void 0&&(n=!0);var i=e.split("?"),s=i[0],o=i[1],a=$({},t),l=(r=o==null?void 0:o.split("&").map(c=>{var d,f=c.split("="),m=f[0],_=n&&(d=a[m])!==null&&d!==void 0?d:f[1];return delete a[m],m+"="+_}))!==null&&r!==void 0?r:[],u=function(c,d){var f,m;d===void 0&&(d="&");var _=[];return ve(c,function(p,y){L(p)||L(y)||y==="undefined"||(f=encodeURIComponent((h=>h instanceof File)(p)?p.name:p.toString()),m=encodeURIComponent(y),_[_.length]=m+"="+f)}),_.join(d)}(a);return u&&l.push(u),l.length>0?s+"?"+l.join("&"):s},Tf=e=>{if(e.ba)return e.ba;var t=e.data,n=e.compression;if(t){if(n===Et.GZipJS){var r=lO(function(a,l){var u=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var c=new ln(a.length+(a.length>>>1)),d=0,f=function(y){c[d++]=y},m=0;u>m;++m){if(d+5>c.length){var _=new ln(d+8+(u-m<<1));_.set(c),c=_}var p=a.charCodeAt(m);128>p?f(p):2048>p?(f(192|p>>>6),f(128|63&p)):p>55295&&57344>p?(f(240|(p=65536+(1047552&p)|1023&a.charCodeAt(++m))>>>18),f(128|p>>>12&63),f(128|p>>>6&63),f(128|63&p)):(f(224|p>>>12),f(128|p>>>6&63),f(128|63&p))}return HE(c,0,d)}(Ls(t)),{mtime:0});return{contentType:GE,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===Et.Base64){var i=function(a){return a&&btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,(l,u)=>String.fromCharCode(parseInt(u,16))))}(Ls(t)),s=(a=>"data="+encodeURIComponent(typeof a=="string"?a:Ls(a)))(i);return{contentType:"application/x-www-form-urlencoded",body:s,estimatedSize:new Blob([s]).size}}var o=Ls(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},QE=e=>{var t,n,r=()=>e.transport==="sendBeacon"?{url:bl(e.url,{compression:Et.Base64}),encodedBody:Tf($({},e,{compression:Et.Base64,ba:void 0}))}:{url:KE(e.url,"compression"),encodedBody:Tf($({},e,{compression:void 0,ba:void 0}))};try{t=Tf(e)}catch(i){if(Fy(e.compression,So(e.url,"compression")))return D.error("Failed to gzip request body, sending uncompressed payload",i),r();throw i}return t&&Fy(e.compression,So(e.url,"compression"))&&!((n=t.body)instanceof ArrayBuffer?Zh(new Uint8Array(n)):ArrayBuffer.isView(n)&&Zh(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(Ou=!0,r()):{url:e.url,encodedBody:t}},YE=e=>{try{return QE(e)}catch(t){return D.error(t),void(e.callback==null||e.callback({statusCode:0,error:t}))}},cO=function(){var e=Ce(function*(t){var n=Ls(t.data),r=yield function(s,o,a){return ep.apply(this,arguments)}(n,Ee.DEBUG,{rethrow:!0});if(!r)return t;var i=yield r.arrayBuffer();return $({},t,{ba:{contentType:GE,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}}(),dO=/Failed to fetch|NetworkError|Load failed/i,XE=e=>(e==null?void 0:e.name)==="TypeError"&&dO.test((e==null?void 0:e.message)||""),JE=e=>{var t=YE(e);if(t){var n=t.url,r=t.encodedBody,i=r??{},s=i.contentType,o=i.body,a=i.estimatedSize,l=new Headers;ve(e.headers,function(_,p){l.append(p,_)}),s&&l.append("Content-Type",s);var u=null,c=!1;if(Iy){var d=new Iy;u={signal:d.signal,timeout:setTimeout(()=>{var _,p;c=!0,d.abort((_=e.timeout,(p=new Error("PostHog request timed out"+(_?" after "+_+"ms":""))).name="AbortError",p))},e.timeout)}}var f=_=>{c&&(_==null?void 0:_.name)==="AbortError"||XE(_)?D.warn(_):D.error(_),e.callback==null||e.callback({statusCode:0,error:_})};try{var m;fg(n,$({method:(e==null?void 0:e.method)||"GET",headers:l,keepalive:e.method==="POST"&&!e._a&&52428.8>(a||0),body:o,signal:(m=u)==null?void 0:m.signal},e.fetchOptions)).then(_=>_.text().then(p=>{var y={statusCode:_.status,text:p};if(_.status===200)try{y.json=JSON.parse(p)}catch(h){D.error(h)}e.callback==null||e.callback(y)})).catch(f).finally(()=>u?clearTimeout(u.timeout):null)}catch(_){u&&clearTimeout(u.timeout),f(_)}}},Op=e=>{try{var t,n=QE(e),r=n.url,i=n.encodedBody,s=i??{},o=s.body,a=s.estimatedSize;if(!o)return;var l=o instanceof Blob?o:new Blob([o],{type:s.contentType});if(St.sendBeacon(r,l))return;var u=Z(e.data)?e.data:(t=e.data)==null?void 0:t.batch;if(Z(u)&&u.length>1&&(a??0)>16384){var c=Math.ceil(u.length/2),d=f=>Z(e.data)?f:$({},e.data,{batch:f});return Op($({},e,{data:d(u.slice(0,c))})),void Op($({},e,{data:d(u.slice(c))}))}D.warn("Beacon of ~"+(a??0)+" bytes was rejected by the browser, falling back to fetch"),JE($({},e,{_a:!0}))}catch(f){D.warn("Beacon send failed",f)}},x_=(e,t,n,r)=>{var i=r==="query"?t==="POST"?"sent_at":"_":void 0;return bl(n===Et.GZipJS?KE(e,"compression"):e,$({},i?{[i]:Date.now().toString()}:{},n===Et.GZipJS?{}:{compression:n}))},Mu=[];fg&&Mu.push({transport:"fetch",method:JE}),Jh&&Mu.push({transport:"XHR",method(e){var t=YE(e);if(t){var n=new Jh,r=t.encodedBody;n.open(e.method||"GET",t.url,!0);var i=r??{},s=i.contentType,o=i.body;ve(e.headers,function(a,l){n.setRequestHeader(l,a)}),s&&n.setRequestHeader("Content-Type",s),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var a={statusCode:n.status,text:n.responseText};if(n.status===200)try{a.json=JSON.parse(n.responseText)}catch{}e.callback==null||e.callback(a)}},n.send(o)}}}),St!=null&&St.sendBeacon&&Mu.push({transport:"sendBeacon",method:Op});var Mp=3e3;class fO{constructor(t,n){this.wa=!0,this.ka=[],this.Sa=Vn((n==null?void 0:n.flush_interval_ms)||Mp,250,5e3,D.createLogger("flush interval"),Mp),this.xa=t}enqueue(t){this.ka.push(t),this.Ca||this.Ta()}unload(){this.Ma();var t=this.ka.length>0?this.Ea():{},n=Object.values(t);[...n.filter(r=>r.url.indexOf("/e")===0),...n.filter(r=>r.url.indexOf("/e")!==0)].map(r=>{this.Ia($({},r,{transport:"sendBeacon"}))})}enable(){this.wa=!1,this.Ta()}Ta(){var t=this;this.wa||(this.Ca=setTimeout(()=>{if(this.Ma(),this.ka.length>0){var n=this.Ea(),r=function(){var s=n[i],o=new Date().getTime();s.data&&Z(s.data)&&ve(s.data,a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp}),t.Ia(s)};for(var i in n)r()}},this.Sa))}Ia(t){try{this.xa(t)}catch(n){D.error(n)}}Ma(){clearTimeout(this.Ca),this.Ca=void 0}Ea(){var t={};return ve(this.ka,n=>{var r,i=n,s=(i?i.batchKey:null)||i.url;L(t[s])&&(t[s]=$({},i,{data:[]})),(r=t[s].data)==null||r.push(i.data)}),this.ka=[],t}}var hO=["retriesPerformedSoFar"];class pO{constructor(t){this.Ra=!1,this.Pa=3e3,this.ka=[],this._instance=t,this.ka=[],this.Aa=!0,!L(I)&&"onLine"in I.navigator&&(this.Aa=I.navigator.onLine,this.Fa=()=>{this.Aa=!0,this.Oa()},this.La=()=>{this.Aa=!1},Re(I,"online",this.Fa),Re(I,"offline",this.La))}get length(){return this.ka.length}retriableRequest(t){var n=t.retriesPerformedSoFar,r=bb(t,hO);Jn(n)&&(r.url=bl(r.url,{retry_count:n})),this._instance._send_request($({},r,{callback:i=>{if(i.statusCode!==200&&(400>i.statusCode||i.statusCode>=500)){if((i.statusCode===0?3:10)>(n??0))return void this.xn($({retriesPerformedSoFar:n},r));i.statusCode===0&&D.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(n??0)+" retries.")}r.callback==null||r.callback(i)}}))}xn(t){var n=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=n+1;var r=function(o){var a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),c=Math.random()-.5;return Math.ceil(u+c*(u-l))}(n),i=Date.now()+r;this.ka.push({retryAt:i,requestOptions:t});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),D.warn(s),this.Ra||(this.Ra=!0,this.$a())}$a(){if(this.Da&&clearTimeout(this.Da),this.ka.length===0)return this.Ra=!1,void(this.Da=void 0);this.Da=setTimeout(()=>{this.Aa&&this.ka.length>0&&this.Oa(),this.$a()},this.Pa)}Oa(){var t=Date.now(),n=[],r=this.ka.filter(s=>t>s.retryAt||(n.push(s),!1));if(this.ka=n,r.length>0)for(var i of r)this.retriableRequest(i.requestOptions)}unload(){for(var t of(this.Da&&(clearTimeout(this.Da),this.Da=void 0),this.Ra=!1,L(I)||(this.Fa&&(I.removeEventListener("online",this.Fa),this.Fa=void 0),this.La&&(I.removeEventListener("offline",this.La),this.La=void 0)),this.ka)){var n=t.requestOptions;try{this._instance._send_request($({},n,{transport:"sendBeacon"}))}catch(r){D.error(r)}}this.ka=[]}}class vO{constructor(t){this.Na=()=>{var n,r,i,s;this.qa||(this.qa={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=a+((o==null?void 0:o.clientHeight)||0),c=(o==null?void 0:o.scrollHeight)||0;this.qa.lastScrollY=Math.ceil(a),this.qa.maxScrollY=Math.max(a,(n=this.qa.maxScrollY)!==null&&n!==void 0?n:0),this.qa.maxScrollHeight=Math.max(l,(r=this.qa.maxScrollHeight)!==null&&r!==void 0?r:0),this.qa.lastContentY=u,this.qa.maxContentY=Math.max(u,(i=this.qa.maxContentY)!==null&&i!==void 0?i:0),this.qa.maxContentHeight=Math.max(c,(s=this.qa.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=t}get ja(){return this._instance.config.scroll_root_selector}getContext(){return this.qa}resetContext(){var t=this.qa;return setTimeout(this.Na,0),t}startMeasuringScrollPosition(){Re(I,"scroll",this.Na,{capture:!0}),Re(I,"scrollend",this.Na,{capture:!0}),Re(I,"resize",this.Na)}scrollElement(){if(!this.ja)return I==null?void 0:I.document.documentElement;var t=Z(this.ja)?this.ja:[this.ja];for(var n of t){var r=I==null?void 0:I.document.querySelector(n);if(r)return r}}Ba(t){var n=t==="y"?"scrollTop":"scrollLeft";if(this.ja){var r=this.scrollElement();return r&&r[n]||0}return I?t==="y"?I.scrollY||I.pageYOffset||I.document.documentElement.scrollTop||0:I.scrollX||I.pageXOffset||I.document.documentElement.scrollLeft||0:0}scrollY(){return this.Ba("y")}scrollX(){return this.Ba("x")}}var gO=e=>jE(e==null?void 0:e.config.mask_personal_data_properties,e==null?void 0:e.config.custom_personal_data_properties,e==null?void 0:e.config.disable_capture_url_hashes);class b_{constructor(t,n,r,i){this.ot=s=>{var o=this.Ha();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Ua(this._instance)};this.za.register({[mp]:a})}},this._instance=t,this.Wa=n,this.za=r,this.Ua=i||gO,this.Wa.onSessionId(this.ot)}Ha(){return this.za.props[mp]}getSetOnceProps(){var t,n=(t=this.Ha())==null?void 0:t.props;return n?"r"in n?DE(n,this._instance.config.disable_capture_url_hashes):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var t={};return ve(Sg(this.getSetOnceProps()),(n,r)=>{r==="$current_url"&&(r="url"),t["$session_entry_"+np(r)]=n}),t}}class Ac{on(t,n){return this.Va[t]||(this.Va[t]=[]),this.Va[t].push(n),()=>{this.Va[t]=this.Va[t].filter(r=>r!==n)}}emit(t,n){for(var r of this.Va[t]||[])r(n);for(var i of this.Va["*"]||[])i(t,n)}constructor(){this.Va={}}}var ps=Ie("[SessionId]"),E_=864e5;class S_{on(t,n){return this.Ga.on(t,n)}constructor(t,n,r){var i;if(this.Za=null,this.Qa=null,this.Ja=[],this.Ka=void 0,this.Ya=!1,this.Ga=new Ac,this.Xa=(l,u)=>!(!Jn(l)||!Jn(u))&&Math.abs(l-u)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode===lr)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.qi=t.config,this.za=t.persistence,this.st=void 0,this._e=void 0,this._sessionStartTimestamp=null,this.eo=void 0,this._sessionActivityTimestamp=null,this.io=n||$n,this.ro=r||$n;var s=this.qi.persistence_name||this.qi.token;if(this._sessionTimeoutMs=1e3*Vn(this.qi.session_idle_timeout_seconds||1800,60,36e3,ps.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.no(),this.so="ph_"+s+"_window_id",this.ao="ph_"+s+"_primary_window_exists",this.oo()){var o=we.Br(this.so),a=we.Br(this.ao);o&&!a?this.st=o:we.qr(this.so),we.Nr(this.ao,!0)}(i=this.qi.bootstrap)!=null&&i.sessionID&&this.setBootstrapSessionId(this.qi.bootstrap.sessionID),this.lo()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return L(this.Ja)&&(this.Ja=[]),this.Ja.push(t),this._e&&t(this._e,this.st),()=>{this.Ja=this.Ja.filter(n=>n!==t)}}oo(){return this.qi.persistence!=="memory"&&!this.za.Hs&&we.Dr()}uo(t){t!==this.st&&(this.st=t,this.oo()&&we.Nr(this.so,t))}ho(){return this.st?this.st:this.oo()?we.Br(this.so):null}do(t){var n=this.Za;return!rt(n)&&!rt(t)&&5e3>Math.abs(t-n)}vo(t,n,r){var i=n!==this._sessionActivityTimestamp,s=!(t!==this._e||r!==this._sessionStartTimestamp);this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this._e=t,s&&!i||s&&this.do(n)||(this.Za=n,this.za.register({[Fs]:[n,t,r]}))}co(){var t,n=(t=this.qi)==null?void 0:t.persistence_save_debounce_ms;return Jn(n)&&n>0}fo(){this.co()?this.za.refreshKey(Fs):(this.za.flush(),this.za.load())}po(){var t;if(!rt(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Za){this.fo();var n=this.mo();n[1]===this._e&&n[2]===this._sessionStartTimestamp&&(this.Za=this._sessionActivityTimestamp,this.za.register({[Fs]:[this._sessionActivityTimestamp,(t=this._e)!==null&&t!==void 0?t:null,this._sessionStartTimestamp]}),this.za.flush())}}yo(){var t=this.mo()[0],n=Jn(t)?t:0,r=Jn(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(n,r)}bo(t){return this.fo(),this.Xa(t,this.yo())}mo(){var t=this.za.props[Fs];return Z(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Za=null,this.eo=void 0,clearTimeout(this._o),this._o=void 0,this.vo(null,null,null)}setBootstrapSessionId(t,n){n===void 0&&(n=!1);var r=function(i,s){s===void 0&&(s=new Date().getTime());try{var o=(a=>{var l=a.replace(/-/g,"");if(l.length!==32)throw new Error("Not a valid UUID");if(l[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(l.substring(0,12),16)})(i);return o>s+6e4?void ps.error("Bootstrap sessionID cannot be in the future"):o}catch(a){return void ps.error("Invalid sessionID in bootstrap",a)}}(t);return!L(r)&&(n?this.eo={sessionId:t,sessionStartTimestamp:r}:this.vo(t,new Date().getTime(),r),!0)}destroy(){this.Ya=!0,this.po(),clearTimeout(this._o),this._o=void 0,this.Ka&&I&&(I.removeEventListener(kc,this.Ka,{capture:!1}),this.Ka=void 0),this.Ja=[]}lo(){this.Ka=()=>{this.po(),this.oo()&&we.qr(this.ao)},Re(I,kc,this.Ka,{capture:!1})}checkAndGetSessionAndWindowId(t,n,r){if(t===void 0&&(t=!1),n===void 0&&(n=null),r===void 0&&(r=!1),this.qi.cookieless_mode===lr)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=n||new Date().getTime(),s=this._e;if(r)this.Qa=i;else if(rt(this.Qa)||this.Qa>i||i-this.Qa>=1e3){var o,a;(o=(a=this.za).syncCookieProperties)==null||o.call(a),this.Qa=i}var l=this.mo(),u=l[1],c=l[2],d=!L(s)&&u!==s,f=this.yo(),m=this.ho(),_=this.eo,p=!!_&&(_.sessionStartTimestamp>i+6e4||i-_.sessionStartTimestamp>E_),y=_?p:Jn(c)&&Math.abs(i-c)>E_,h=!1,v=d,x=!u||!!_,b=u,E=!x&&!t&&this.Xa(i,f);if(E){(E=this.bo(i))||ps.info("cross-tab refresh kept the session alive",{sessionId:u});var S=this.mo();u=S[1],c=S[2]}if(x||E||y){v=!1;var P=_&&!p;u=P?_.sessionId:this.io(),m=this.ro(),ps.info("new session ID assigned",{sessionId:u,windowId:m,bootstrapped:!!P,changeReason:{noSessionId:x,activityTimeout:E,sessionPastMaximumLength:y}}),c=P?_.sessionStartTimestamp:i,this.eo=void 0,h=!0}else m||(m=this.ro(),h=!0),(v=v||u!==b)&&(ps.info("adopted cross-tab session id",{sessionId:u,windowId:m}),h=!0);var C=Jn(f)&&t&&!y?f:i,T=Jn(c)?c:new Date().getTime();this.uo(m),this.vo(u,C,T),t||this.no();var R={noSessionId:x,activityTimeout:E,sessionPastMaximumLength:y,crossTabAdoption:v};return h&&this.Ja.forEach(N=>N(u,m,R)),{sessionId:u,windowId:m,sessionStartTimestamp:T,changeReason:h?R:void 0,lastActivityTimestamp:f}}no(){this.Ya||(clearTimeout(this._o),this._o=setTimeout(()=>{if(!this.Ya)if(this.bo(new Date().getTime())){var t=this._e;this.resetSessionId(),this.Ga.emit("forcedIdleReset",{idleSessionId:t})}else this.no()},1.1*this.sessionTimeoutMs))}}var ZE=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&jy(n,t))return!0;try{var r=e==null?void 0:e.userAgentData;if(r!=null&&r.brands&&r.brands.some(i=>jy(i==null?void 0:i.brand,t)))return!0}catch{}return!!e.webdriver};function eS(){return(eS=Ce(function*(){var e=St==null?void 0:St.userAgentData;if(e!=null&&e.getHighEntropyValues)try{var t=yield e.getHighEntropyValues(["model"]),n=t==null?void 0:t.model;return ce(n)&&n.length>0?n:void 0}catch(r){return void D.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",r)}})).apply(this,arguments)}var Nc=function(e,t){if(!function(n){try{new RegExp(n)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function If(e,t,n){return Ls({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var tS={exact:(e,t)=>t.some(n=>e.some(r=>n===r)),is_not:(e,t)=>t.every(n=>e.every(r=>n!==r)),regex:(e,t)=>t.some(n=>e.some(r=>Nc(n,r))),not_regex:(e,t)=>t.every(n=>e.every(r=>!Nc(n,r))),icontains:(e,t)=>t.map(tu).some(n=>e.map(tu).some(r=>n.includes(r))),not_icontains:(e,t)=>t.map(tu).every(n=>e.map(tu).every(r=>!n.includes(r))),gt:(e,t)=>t.some(n=>{var r=parseFloat(n);return!isNaN(r)&&e.some(i=>r>parseFloat(i))}),lt:(e,t)=>t.some(n=>{var r=parseFloat(n);return!isNaN(r)&&e.some(i=>re.toLowerCase();function nS(e,t){return!e||Object.entries(e).every(n=>{var r=n[1],i=t==null?void 0:t[n[0]];if(L(i)||rt(i))return!1;var s=[String(i)],o=tS[r.operator];return!!o&&o(r.values,s)})}var Ap="custom",C_="i.posthog.com",mO=/^\/static\//,yO=["/s/","/e/","/i/"];class _O{constructor(t){this.wo={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,n=(t=this.instance.config.ui_host)==null?void 0:t.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+C_,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.wo[this.apiHost]||(this.wo[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":Ap),this.wo[this.apiHost]}ko(t){if(mO.test(t)){var n=this.instance.config.asset_host;if(typeof n=="string")return n.trim().replace(/\/$/,"")||void 0}}So(t){var n=Eo(t);return n?n.protocol+"//"+n.host+n.pathname:void 0}xo(t,n,r){if(t==="ui")return r;var i=r,s=this.instance.config.rewriteRequestPath;if(s){var o,a=((o=Eo(r))==null?void 0:o.href)||r;i=s(new URL(a)).toString()}if(s&&t==="api"&&yO.some(f=>n.indexOf(f)===0)){var l=this.So(i);if(l){var u,c=this.apiHost,d=this.Co;((u=d)==null?void 0:u.apiHost)===c&&d.rewriteRequestPath===s||(d={apiHost:c,rewriteRequestPath:s,urls:new Set},this.Co=d),d.urls.add(l)}}return i}isIngestionEndpoint(t){var n=this.Co,r=this.So(t);return(n==null?void 0:n.apiHost)===this.apiHost&&n.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!r&&n.urls.has(r)}endpointFor(t,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),t==="ui")return this.xo(t,n,this.uiHost+n);if(t==="flags")return this.xo(t,n,this.flagsApiHost+n);if(t==="assets"){var r=this.ko(n);if(r)return this.xo(t,n,""+r+n)}if(this.region===Ap)return this.xo(t,n,this.apiHost+n);var i=C_+n;switch(t){case"assets":return this.xo(t,n,"https://"+this.region+"-assets."+i);case"api":return this.xo(t,n,"https://"+this.region+"."+i)}}}function rS(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}var he=Ie("[Surveys]"),iS="seenSurvey_",sS=e=>{try{var t=(n=>((r,i)=>""+iS+function(s){return s.current_iteration&&s.current_iteration>0?s.id+"_"+s.current_iteration:s.id}(i))(0,n))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(n){he.error("Failed to persist survey seen state",n)}},wO=[Cf.Popover,Cf.Widget,Cf.API],xO={ignoreConditions:!1,ignoreDelay:!1,displayType:Pp.Popover},bO=Ie("[PostHog ExternalIntegrations]"),EO={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class SO{constructor(t){this._instance=t}_s(t,n){var r;(r=Y.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,t,i=>{if(i)return bO.error("failed to load script",i);n()})}startIfEnabledOrStop(){var t=this,n=function(){var s,o,a,l=r[0],u=r[1];!u||(s=Y.__PosthogExtensions__)!=null&&(s=s.integrations)!=null&&s[l]||t._s(EO[l],()=>{var c;(c=Y.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[l])==null||c.start(t._instance)}),!u&&(o=Y.__PosthogExtensions__)!=null&&(o=o.integrations)!=null&&o[l]&&((a=Y.__PosthogExtensions__)==null||(a=a.integrations)==null||(a=a[l])==null||a.stop())};for(var r of Object.entries((i=this._instance.config.integrations)!==null&&i!==void 0?i:{})){var i;n()}}}class CO{constructor(t,n){this.I=t,this.ns=n,this.To=new Map,this.Xn=!1}add(t){var n=this;return Ce(function*(){if(n.Xn)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(n.To.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');n.To.set(t.name,t);try{var r=t.setup(n.ns);r&&(yield r)}catch(s){var i=n.To.get(t.name)===t;i&&n.To.delete(t.name),n.I.error('Failed to set up browser extension "'+t.name+'"',s),i&&n.Mo(t)}})()}dispose(){if(!this.Xn){this.Xn=!0;var t=Array.from(this.To.values()).reverse();for(var n of(this.To.clear(),t))this.Mo(n)}}Mo(t){try{var n=t.dispose==null?void 0:t.dispose();n&&vt(n.then)&&n.then(void 0,r=>{this.I.error('Failed to dispose browser extension "'+t.name+'"',r)})}catch(r){this.I.error('Failed to dispose browser extension "'+t.name+'"',r)}}}class kO{constructor(t){this._instance=t}initialize(){}get(t){var n=this._instance.persistence;if(typeof t=="string")return n==null?void 0:n.get_property(t);var r={};for(var i of t){var s=n==null?void 0:n.get_property(i);L(s)||(r[i]=s)}return r}set(t,n){var r;(r=this._instance.persistence)==null||r.register(typeof t=="string"?{[t]:n}:t)}remove(t){var n;(n=this._instance.persistence)==null||n.unregister(t)}}var k_="extensionsRemoteConfig";class PO{constructor(t){this.Xn=!1,this.instance=t,this.I=D,this.Eo=t.Io,this.kv=new kO(t),this.onEvent=n=>eu(this.instance.on("eventCaptured",r=>{try{n({event:r.event,properties:r.properties})}catch(i){this.I.error("Browser extension event listener failed",i)}})),this.onRemoteConfig=n=>{if(this.Xn)return eu(()=>{});var r=s=>{try{n(s)}catch(o){this.I.error("Browser extension remote config listener failed",o)}},i=this.instance.Ro.on(k_,r);return this.Eo&&r(this.Eo),eu(i)},this.Po=new CO(D.createLogger("[BrowserExtensions]"),this)}get logger(){return this.I}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return(t=this.instance.get_property(Ya))!==null&&t!==void 0?t:this.distinctId}get deviceId(){var t=this.instance.get_property(Ya);return typeof t=="string"?t:void 0}get library(){return{name:Ee.LIB_NAME,version:Ee.LIB_VERSION}}get initialPersonProperties(){var t,n;return(t=(n=this.instance.persistence)==null?void 0:n.get_initial_props())!==null&&t!==void 0?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,n,r,i,s=(t=this.instance.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:(n=s==null?void 0:s.sessionId)!==null&&n!==void 0?n:"",windowId:(r=s==null?void 0:s.windowId)!==null&&r!==void 0?r:"",sessionStartTimestamp:(i=s==null?void 0:s.sessionStartTimestamp)!==null&&i!==void 0?i:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(t){return this.Po.add(t)}capture(t,n,r){var i=this;return Ce(function*(){r?i.instance.capture(t,n,{timestamp:r.timestamp,uuid:r.uuid,$set:r.set,$set_once:r.setOnce}):i.instance.capture(t,n)})()}registerDynamicEventProperties(t){return eu(this.instance.Ao(t))}handleRemoteConfig(t){this.Xn||(this.Eo=t,this.instance.Ro.emit(k_,t))}sendRequest(t,n){var r=this;return Ce(function*(){var i;n===void 0&&(n={});var s=r.instance.requestRouter.endpointFor((i=n.target)!==null&&i!==void 0?i:"api",t),o={method:n.method,url:n.query?bl(s,n.query):s,data:n.body,headers:n.headers,timeout:n.timeoutMs,fireCallbackOnDrop:!0,transport:n.transport,compression:n.compression,timestampMode:n.sentAt};return n.transport==="sendBeacon"?(r.instance._send_request(o),{statusCode:202}):new Promise(a=>{o.callback=a,r.instance._send_request(o)})})()}dispose(){this.Xn||(this.Xn=!0,this.Po.dispose())}}var Ra={},Of=0,Ta=()=>{},P_='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',ea="Surveys module not available",R_="sanitize_properties is deprecated. Use before_send instead",oS="Invalid value for property_denylist config: ",RO=["token","distinct_id",fE],bs="posthog",aS=!uO&&(Mt==null?void 0:Mt.indexOf("MSIE"))===-1&&(Mt==null?void 0:Mt.indexOf("Mozilla"))===-1,Mf=e=>{var t;return $({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:RI(j==null?void 0:j.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Ta,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:e??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Ae&&ce(Ae==null?void 0:Ae.search)&&Ae.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:(I==null||(t=I.location)==null?void 0:t.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(n){D.error("Bad HTTP status: "+n.statusCode+" "+n.text)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:bp,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Mp},error_tracking:{},_onCapture:Ta},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:zI,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:n&&n>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:n&&n>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:n&&n>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:n&&n>="2026-01-30"?"head":"body",internal_or_test_user_hostname:n&&n>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:n&&n>="2026-05-30"?250:0,split_storage:!(!n||"2026-05-30">n),detect_google_search_app:!(!n||"2026-05-30">n),disable_capture_url_hashes:!(!n||"2026-06-25">n),cookieWinsOnConflict:!(!n||n==="unset"||"2026-08-29">n)}))(e))},TO=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],T_=e=>{var t={};for(var n of TO){var r=n[0],i=n[1];L(e[r])||(t[i]=e[r])}var s=_e({},t,e),o=e.__preview_external_dependency_versioned_paths;return L(o)||(L(e.strict_script_versioning)&&(s.strict_script_versioning=!!o),ce(o)&&L(e.asset_host)&&(s.asset_host=o)),Z(e.property_blacklist)&&(L(e.property_denylist)?s.property_denylist=e.property_blacklist:Z(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:D.error(oS+e.property_denylist)),s};class IO{constructor(){this.__forceAllowLocalhost=!1}get Fo(){return this.__forceAllowLocalhost}set Fo(t){D.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class qt{Oo(t,n){if(t){var r=this.To.indexOf(t);r!==-1&&this.To.splice(r,1)}return this.To.push(n),n.initialize==null||n.initialize(),n}Lo(){return this.config.cookieless_mode===lr||this.config.cookieless_mode===ki&&this.consent.isRejected()}$o(){if(!this.Lo()&&this.get_distinct_id()===fs){var t=this.persistence;if(t){this.Do()||t.load(!0);var n=this.get_distinct_id();if(!n||n===fs){var r=this.config.get_device_id($n());this.register({distinct_id:r,$device_id:r}),t.set_property(se,We)}this.No()}}}get decideEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}get flagsEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){var t;this.webPerformance=new IO,this.qo=!1,this.version=Ee.LIB_VERSION,this.jo=new Set,this.Bo="",this.Ro=new Ac,this.To=[],this.Ho=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Mf(),this.SentryIntegration=KI,this.sentryIntegration=r=>function(i,s){var o=OE(i,s);return{name:IE,processEvent:a=>o(a)}}(this,r),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Uo=!1,this.zo=null,this.Wo=null,this.Vo=null,this.scrollManager=new vO(this),this.pageViewManager=new f_(this),this.rateLimiter=new rO(this),this.requestRouter=new _O(this),this.consent=new $I(this),this.externalIntegrations=new SO(this);var n=(t=qt.__defaultExtensionClasses)!==null&&t!==void 0?t:{};this.featureFlags=n.featureFlags&&new n.featureFlags(this),this.toolbar=n.toolbar&&new n.toolbar(this),this.surveys=n.surveys&&new n.surveys(this),this.conversations=n.conversations&&new n.conversations(this),this.logs=n.logs&&new n.logs(this),this.metrics=n.metrics&&new n.metrics(this),this.experiments=n.experiments&&new n.experiments(this),this.exceptions=n.exceptions&&new n.exceptions(this),this.people={set:(r,i,s)=>{var o=ce(r)?{[r]:i}:r;this.setPersonProperties(o),s==null||s({})},set_once:(r,i,s)=>{var o=ce(r)?{[r]:i}:r;this.setPersonProperties(void 0,o),s==null||s({})}},this.on("eventCaptured",r=>D.info('send "'+(r==null?void 0:r.event)+'"',r))}init(t,n,r){if(r&&r!==bs){var i,s=(i=Ra[r])!==null&&i!==void 0?i:new qt;return s._init(t,n,r),Ra[r]=s,Ra[bs][r]=s,s}return this._init(t,n,r)}_init(t,n,r){var i,s;n===void 0&&(n={});var o,a=ce(t)?t.trim():"";if(!a)return D.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return a!==((o=this.config)==null?void 0:o.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+a+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Mf(n.defaults),n.debug=this.Go(n.debug),this.Zo=n,this.Qo=[],n.person_profiles?this.Wo=n.person_profiles:n.process_person&&(this.Wo=n.process_person);var l=Mf(n.defaults),u=T_(n),c=_e({},l,u,{name:r,token:a});Se(l.rageclick)&&Se(u.rageclick)&&(c.rageclick=_e({},l.rageclick,u.rageclick)),Se(l.session_recording)&&Se(u.session_recording)&&(c.session_recording=_e({},l.session_recording,u.session_recording)),this.set_config(c),this.config.on_xhr_error&&D.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:Et.GZipJS;var d=this.Do();if(this.persistence=new Sf(this.config,d),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Sf($({},this.config,{persistence:"sessionStorage"}),d,!1),this.Bo="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!d&&we.Dr()){var f=we.Br(this.Bo);Z(f)&&f.forEach(S=>{ce(S)&&this.jo.add(S)})}else we.qr(this.Bo);var m=$({},this.persistence.props),_=$({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Jo=new fO(S=>this.Ko(S),this.config.request_queue_config),this.Yo=new pO(this),this.__request_queue=[];var p=this.Lo();if(p||(this.sessionManager=new S_(this),this.sessionPropsManager=new b_(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((S,P,C)=>{(C!=null&&C.activityTimeout||C!=null&&C.sessionPastMaximumLength||C!=null&&C.crossTabAdoption)&&this.Xo()})),this.tl(),this.config.__preview_deferred_init_extensions?(D.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.el(p)},0)):(D.info("Initializing extensions synchronously"),this.el(p)),Ee.DEBUG=Ee.DEBUG||this.config.debug,Ee.DEBUG&&D.info("Starting in debug mode",{this:this,config:n,thisC:$({},this.config),p:m,s:_}),!this.config.identity_distinct_id||(i=n.bootstrap)!=null&&i.distinctID||(n.bootstrap=$({},n.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((s=n.bootstrap)==null?void 0:s.distinctID)!==void 0){var y=n.bootstrap.distinctID,h=this.get_distinct_id(),v=this.persistence.get_property(se);if(n.bootstrap.isIdentifiedID&&h!=null&&h!==y&&v===We)this.identify(y);else if(n.bootstrap.isIdentifiedID&&h!=null&&h!==y&&v===ot)D.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var x=this.config.get_device_id($n()),b=n.bootstrap.isIdentifiedID?x:y;this.persistence.set_property(se,n.bootstrap.isIdentifiedID?ot:We),this.register({distinct_id:y,$device_id:b})}}if(p)this.register_once({distinct_id:fs,$device_id:null},"");else if(!this.get_distinct_id()){var E=this.config.get_device_id($n());this.register_once({distinct_id:E,$device_id:E},""),this.persistence.set_property(se,We)}return Re(I,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),n.segment?function(S,P){var C=S.config.segment;if(!C)return P();(function(T,R){var N=T.config.segment;if(!N)return R();var M=F=>{var W=()=>F.anonymousId()||$n();T.config.get_device_id=W,F.id()&&(T.register({distinct_id:F.id(),$device_id:W()}),T.persistence.set_property(se,ot)),R()},z=N.user();"then"in z&&vt(z.then)?z.then(M):M(z)})(S,()=>{C.register((T=>{typeof Promise<"u"&&Promise.resolve||bf.warn("This browser does not have Promise support, and can not use the segment integration");var R=(N,M)=>{if(!M)return N;N.event.userId||N.event.anonymousId===T.get_distinct_id()||(bf.info("No userId set, resetting PostHog"),T.reset()),N.event.userId&&N.event.userId!==T.get_distinct_id()&&(bf.info("UserId set, identifying with PostHog"),T.identify(N.event.userId));var z=T.calculateEventProperties(M,N.event.properties);return N.event.properties=Object.assign({},z,N.event.properties),N};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:N=>R(N,N.event.event),page:N=>R(N,xs),identify:N=>R(N,gf),screen:N=>R(N,"$screen")}})(S)).then(()=>{P()})})}(this,()=>this.il()):this.il(),vt(this.config._onCapture)&&this.config._onCapture!==Ta&&(D.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",S=>this.config._onCapture(S.event,S))),this.config.ip&&D.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||function(){return eS.apply(this,arguments)}().then(S=>{S&&this.register({[pf]:S})}).catch(Ta),this}rl(t){var n=t;return ce(n.name)&&vt(n.setup)}nl(t,n){this.rl(t)?n.push(()=>{this.sl().add(t).catch(Ta)}):this.To.push(t)}tl(){var t,n,r,i,s,o,a=(t=(n=this.config.__extensionClasses)==null?void 0:n.featureFlags)!==null&&t!==void 0?t:(r=qt.__defaultExtensionClasses)==null?void 0:r.featureFlags;a&&(this.featureFlags&&this.featureFlags instanceof a||((i=this.al)==null||i.call(this),this.al=void 0,this.featureFlags=new a(this)),vt(this.featureFlags.onReloading)&&vt(this.featureFlags.setup)?this.al||(this.al=this.featureFlags.onReloading(()=>{this.Ro.emit("featureFlagsReloading",!0)}),this.sl().add(this.featureFlags)):(s=(o=this.featureFlags).initialize)==null||s.call(o))}el(t){var n,r,i,s,o,a,l,u=performance.now(),c=$({},qt.__defaultExtensionClasses,this.config.__extensionClasses),d=[];c.exceptions&&this.To.push(this.exceptions=(n=this.exceptions)!==null&&n!==void 0?n:new c.exceptions(this)),c.historyAutocapture&&this.To.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this.To.push(this.tracingHeaders=new c.tracingHeaders(this)),c.siteApps&&this.To.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!t&&this.To.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||d.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),c.autocapture&&this.nl(this.autocapture=new c.autocapture(this),d),c.surveys&&this.nl(this.surveys=(r=this.surveys)!==null&&r!==void 0?r:new c.surveys(this),d),c.logs&&this.To.push(this.logs=(i=this.logs)!==null&&i!==void 0?i:new c.logs(this)),c.metrics&&this.To.push(this.metrics=(s=this.metrics)!==null&&s!==void 0?s:new c.metrics(this)),c.conversations&&this.To.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new c.conversations(this)),c.productTours&&this.To.push(this.productTours=new c.productTours(this)),c.heatmaps&&this.To.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this.To.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this.To.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this.To.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,GI)),c.toolbar&&this.To.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new c.toolbar(this)),c.experiments&&this.To.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new c.experiments(this)),this.To.forEach(f=>{f.initialize&&d.push(()=>{f.initialize==null||f.initialize()})}),d.push(()=>{if(this.ol){var f=this.ol;this.ol=void 0,this.To.forEach(m=>m.onRemoteConfig==null?void 0:m.onRemoteConfig(f))}}),this.ll(d,u)}ll(t,n){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&t.length>0)return void setTimeout(()=>{this.ll(t,n)},0);var r=t.shift();if(r)try{r()}catch(s){D.error("Error initializing extension:",s)}}var i=Math.round(performance.now()-n);this.register_for_session({[hE]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[pE]:i}),this.config.__preview_deferred_init_extensions&&D.info("PostHog extensions initialized ("+i+"ms)")}pa(t){var n;if(!j||!j.body)return D.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.pa(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.ol=t),this.Io=t,this.compression=void 0,t.ok){var r,i=t.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=J(i.supportedCompression,Et.GZipJS)?Et.GZipJS:J(i.supportedCompression,Et.Base64)?Et.Base64:void 0),(r=i.analytics)!=null&&r.endpoint&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.Wo?this.Wo:bp}),(n=this.ul)==null||n.handleRemoteConfig(t),this.To.forEach(s=>s.onRemoteConfig==null?void 0:s.onRemoteConfig(t))}il(){try{this.config.loaded(this)}catch(r){D.critical("`loaded` function failed",r)}if(this.hl(),this.config.internal_or_test_user_hostname&&Ae!=null&&Ae.hostname){var t=Ae.hostname,n=this.config.internal_or_test_user_hostname;(typeof n=="string"?t===n:n.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.Lo())&&this.dl()},1),this.vl=new UE(this),this.vl.load()}hl(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.Jo)==null||t.enable())}_dom_loaded(){this.is_capturing()&&Ql(this.__request_queue,t=>this.Ko(t)),this.__request_queue=[],this.hl()}_handle_unload(){var t,n,r,i,s;(t=this.surveys)==null||t.handlePageUnload==null||t.handlePageUnload(),(n=this.metrics)==null||n.flush("sendBeacon"),this.config.request_batching?(this.cl()&&this.capture(vf),(r=this.logs)==null||r.flushLogs("sendBeacon"),(i=this.Jo)==null||i.unload(),(s=this.Yo)==null||s.unload()):this.cl()&&this.capture(vf,null,{transport:"sendBeacon"})}_send_request(t){this.__loaded?aS?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(t.callback==null||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=$({},this.config.request_headers,t.headers),t.compression=t.compression==="best-available"?this.compression:t.compression,(L(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(n=>{var r,i,s,o=$({},n);o.timeout=o.timeout||6e4;var a,l,u,c,d,f=(r=o.transport)!==null&&r!==void 0?r:"fetch";f==="sendBeacon"&&L(o.compression)&&o.data&&(o.compression=Et.Base64),o.method==="POST"&&o.data&&(o.timestampMode==="capture-body"?o.data={api_key:(l=(d=(c=(Z(a=o.data)?a:[a]).map(y=>$({},y,y.timestamp instanceof Date&&!isNaN(y.timestamp.getTime())?{timestamp:y.timestamp.toISOString()}:{})))[0])==null||(u=d.properties)==null?void 0:u.token)!==null&&l!==void 0?l:d==null?void 0:d.token,batch:c,sent_at:new Date().toISOString()}:o.timestampMode==="body"&&(o.data=function(y,h){return h===void 0&&(h=new Date().toISOString()),Z(y)?y.map(v=>$({},v,{sent_at:h})):$({},y,{sent_at:h})}(o.data))),o.url=x_(o.url,o.method,o.compression,o.timestampMode);var m=Mu.filter(y=>!o.disableTransport||!y.transport||!o.disableTransport.includes(y.transport)),_=(i=(s=function(y,h){for(var v=0;y.length>v;v++)if(y[v].transport===f)return y[v]}(m))==null?void 0:s.method)!==null&&i!==void 0?i:m[0].method;if(!_)throw new Error("No available transport method");var p=y=>{try{_(y)}catch(h){XE(h)?D.warn(h):D.error(h),o.callback==null||o.callback({statusCode:0,error:h})}};f!=="sendBeacon"&&o.data&&o.compression===Et.GZipJS&&ST&&typeof Promise<"u"&&!Ou?cO(o).then(y=>{p(y)}).catch(y=>{if(Ly(y))return Ou=!0,void p($({},o,{compression:void 0,url:x_(n.url,n.method,void 0,n.timestampMode)}));(h=>{if(!h||typeof h!="object")return!1;var v="name"in h?String(h.name):"";return Ly(h)||v===Eb})(y)&&(Ou=!0),p(o)}):_(o)})($({},t,{callback:n=>{var r,i;this.rateLimiter.checkForLimiting(n),400>n.statusCode||(r=(i=this.config).on_request_error)==null||r.call(i,n),t.callback==null||t.callback(n)}}))):t.fireCallbackOnDrop&&(t.callback==null||t.callback({statusCode:0}))}Ko(t){this.Yo?this.Yo.retriableRequest(t):this._send_request(t)}_execute_array(t){Of++;try{var n,r=[],i=[],s=[];Ql(t,a=>{if(a)if(Z(n=a[0]))s.push(a);else if(vt(a))try{a.call(this)}catch(l){D.error("Error executing queued PostHog call",a,l)}else Z(a)&&n==="alias"?r.push(a):Z(a)&&n.indexOf("capture")!==-1&&vt(this[n])?s.push(a):i.push(a)});var o=function(a,l){Ql(a,function(u){try{if(Z(u[0])){var c=l;ve(u,function(d){c=c[d[0]].apply(c,d.slice(1))})}else l[u[0]].apply(l,u.slice(1))}catch(d){D.error("Error executing queued PostHog call",u,d)}})};o(r,this),o(i,this),o(s,this)}finally{Of--}}push(t){if(Of>0&&Z(t)&&ce(t[0])){var n=qt.prototype[t[0]];vt(n)&&n.apply(this,t.slice(1))}else this._execute_array([t])}capture(t,n,r){var i,s,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Jo){if(this.is_capturing())if(!L(t)&&ce(t)){this.$o();var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){n!=null&&n.$current_url&&!ce(n==null?void 0:n.$current_url)&&(D.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),t!=="$exception"||r!=null&&r.fl||D.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var d=new Date,f=(r==null?void 0:r.timestamp)||d,m=Vy(r==null?void 0:r.uuid,$n),_={uuid:m,event:t,properties:this.calculateEventProperties(t,n||{},f,m)};t===xs&&this.config.__preview_capture_bot_pageviews&&u&&(_.event="$bot_pageview",_.properties.$browser_type="bot"),c&&(_.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens);var p=t==="$feature_flag_called"&&_.properties.$feature_flag_has_experiment===!1&&this.get_property(xc)===!0;r!=null&&r.$set&&!p&&(_.$set=r==null?void 0:r.$set);var y=r==null?void 0:r.$unset;y&&(_.$unset=y);var h,v,x,b=p?void 0:this.pl(r==null?void 0:r.$set_once,t!==Yy,t===gf);if(b&&(_.$set_once=b),r!=null&&r._noTruncate||(s=this.config.properties_string_max_length,o=_,a=M=>ce(M)?M.slice(0,s):M,l=new Set,_=function M(z,F){if(z!==Object(z))return a?a(z):z;if(!l.has(z)){var W;if(l.add(z),Z(z))W=[],Ql(z,Q=>{W.push(M(Q))});else{var B={};ve(z,(Q,O)=>{l.has(Q)||(B[O]=M(Q))}),W=B}return W}}(o)),_.timestamp=f,L(r==null?void 0:r.timestamp)||(_.properties.$event_time_override_provided=!0,_.properties.$event_time_override_system_time=d),p&&(_.properties=function(M,z){z===void 0&&(z=[]);var F={},W=B=>{M[B]!==void 0&&(F[B]=M[B])};return CT.forEach(W),z.forEach(W),F}(_.properties,RO)),t===ur.DISMISSED||t===ur.SENT){var E=n==null?void 0:n[kf.SURVEY_ID],S=n==null?void 0:n[kf.SURVEY_ITERATION];sS({id:E,current_iteration:S}),_.$set=$({},_.$set,{[(h={id:E,current_iteration:S},v=t===ur.SENT?"responded":"dismissed",x="$survey_"+v+"/"+h.id,h.current_iteration&&h.current_iteration>0&&(x="$survey_"+v+"/"+h.id+"/"+h.current_iteration),x)]:!0})}else t===ur.SHOWN&&(_.$set=$({},_.$set,{[kf.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(t===nO.SHOWN){var P=n==null?void 0:n[v_.TOUR_TYPE];P&&(_.$set=$({},_.$set,{[v_.TOUR_LAST_SEEN_DATE+"/"+P]:new Date().toISOString()}))}var C=$({},_.properties.$set,_.$set);if(En(C)||this.setPersonPropertiesForFlags(C),!ne(this.config.before_send)){var T=this.kn(_);if(!T)return;(_=T).uuid=Vy(_.uuid,$n)}this.Ro.emit("eventCaptured",_);var R=(i=r==null?void 0:r._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),N={method:"POST",url:R,data:_,compression:"best-available",timestampMode:(r==null?void 0:r._batchKey)==="recordings"||/\/s\/(?:\?|$)/.test(R)?"body":"capture-body",batchKey:r==null?void 0:r._batchKey,transport:r==null?void 0:r.transport};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.Ko(N):this.Jo.enqueue(N),_}D.critical("This capture call is ignored due to client rate limiting.")}}else D.error("No event name provided to posthog.capture")}else D.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",n=>t(n.event,n))}sl(){var t;return(t=this.ul)!==null&&t!==void 0?t:this.ul=new PO(this)}Ao(t){this.Ho.push(t);var n=!0;return()=>{if(n){n=!1;var r=this.Ho.indexOf(t);r!==-1&&this.Ho.splice(r,1)}}}gl(t){var n,r,i;return t===void 0&&(t=!0),!((n=this.persistence)==null||!n.consumeCookieIdentityChange())&&(this.Vo=null,this.persistence.get_property(se)===We&&((i=this.sessionPersistence)==null||i.clear(),this.jo.clear(),this.ml()),(r=this.featureFlags)==null||r.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,n,r,i,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;this.persistence.syncCookieProperties(),this.gl();var o=s?void 0:this.persistence.remove_event_timer(t),a=$({},n);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.Lo()&&(a[fE]=!0),t==="$snapshot"){var l=$({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!ce(a.distinct_id)&&!Ge(a.distinct_id)||cc(a.distinct_id))&&D.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,c=function(E,S,P,C){var T,R,N,M;if(C===void 0&&(C=!1),!Mt)return{};var z,F=E?[...Co,...S||[]]:[],W=function(us){for(var It=0;zy.length>It;It++){var cs=zy[It],Cr=cs[1],pn=cs[0].exec(us),Do=pn&&(vt(Cr)?Cr(pn,us):Cr);if(Do)return Do}return["",""]}(Mt),B=W[0],Q=W[1],O=(z=typeof navigator<"u"?navigator:void 0)!=null&&z.brave?{brave:!0}:{},A={};L(P)||(A.detectGoogleSearchApp=P);var V={},K=(T=navigator)==null||(T=T.userAgentData)==null?void 0:T.platform,te=(R=navigator)==null?void 0:R.maxTouchPoints,oe=I==null||(N=I.screen)==null?void 0:N.width,de=I==null||(M=I.screen)==null?void 0:M.height,be=I==null?void 0:I.devicePixelRatio;L(K)||(V.userAgentDataPlatform=K),L(te)||(V.maxTouchPoints=te),L(oe)||(V.screenWidth=oe),L(de)||(V.screenHeight=de),L(be)||(V.devicePixelRatio=be);var Pe,Be,ye,Fe,Tt,Sr,_t,Ye,gi=_e(Sg({$os:B,$os_version:Q,$browser:Yb(Mt,navigator.vendor,O,A),$device:Uy(Mt),$device_type:(Be=Mt,ye=V,Ye=Uy(Be),Ye===Mb||Ye===Ob||Ye==="Kobo"||Ye==="Kindle Fire"||Ye===Wb?wo:Ye===Ka||Ye===Hs||Ye===Qa||Ye===ip?"Console":Ye===Nb?"Wearable":Ye?Yt:(ye==null?void 0:ye.userAgentDataPlatform)==="Android"&&((Fe=ye==null?void 0:ye.maxTouchPoints)!==null&&Fe!==void 0?Fe:0)>0?600>Math.min((Tt=ye==null?void 0:ye.screenWidth)!==null&&Tt!==void 0?Tt:0,(Sr=ye==null?void 0:ye.screenHeight)!==null&&Sr!==void 0?Sr:0)/((_t=ye==null?void 0:ye.devicePixelRatio)!==null&&_t!==void 0?_t:1)?Yt:wo:"Desktop"),$timezone:zE(),$timezone_offset:ZI()}),{$current_url:Za(C?li(Ae==null?void 0:Ae.href):Ae==null?void 0:Ae.href,F,el),$host:Ae==null?void 0:Ae.host,$pathname:Ae==null?void 0:Ae.pathname,$raw_user_agent:Mt.length>1e3?Mt.substring(0,997)+"...":Mt,$browser_version:KT(Mt,navigator.vendor,O,A),$browser_language:h_(),$browser_language_prefix:(Pe=h_(),typeof Pe=="string"?Pe.split("-")[0]:void 0),$screen_height:I==null?void 0:I.screen.height,$screen_width:I==null?void 0:I.screen.width,$viewport_height:I==null?void 0:I.innerHeight,$viewport_width:I==null?void 0:I.innerWidth,$lib:Ee.LIB_NAME,$lib_version:Ee.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Ee.SDK_DIST_CHANNEL&&(gi.$sdk_dist_channel=Ee.SDK_DIST_CHANNEL),gi}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var d=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime(),!0),f=d.windowId;a.$session_id=d.sessionId,a.$window_id=f}this.sessionPropsManager&&_e(a,this.sessionPropsManager.getSessionProps());try{var m;this.sessionRecording&&_e(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(m=this.Yo)==null?void 0:m.length}catch(E){a.$sdk_debug_error_capturing_properties=String(E)}if(this.requestRouter.region===Ap&&(a.$lib_custom_api_host=this.config.api_host),u=t!==xs||s?t!==vf||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=_e(a,u),t===xs&&j&&(a.title=j.title),!L(o)){var _=r.getTime()-o;a.$duration=parseFloat((_/1e3).toFixed(3))}Mt&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");var p=this.persistence.properties(),y=this.sessionPersistence.properties();ve(["$referrer","$referring_domain"],E=>{E in p&&delete y[E]});var h={};if(this.Ho.length>0)for(var v of this.Ho.slice())try{_e(h,v())}catch(E){D.error("Failed to produce browser extension event properties",E)}(a=_e({},c,p,y,$({},h,a))).$is_identified=this._isIdentified(),Z(this.config.property_denylist)?ve(this.config.property_denylist,function(E){delete a[E]}):D.error(oS+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var x=this.config.sanitize_properties;x&&(D.error(R_),a=x(a,t));var b=this.yl();return a.$process_person_profile=b,b&&!s&&this.bl("_calculate_event_properties"),a}pl(t,n,r){var i;if(n===void 0&&(n=!0),r===void 0&&(r=!1),!this.persistence||!this.yl()||this.qo&&!r)return t;var s=this.persistence.get_initial_props(),o=(i=this.sessionPropsManager)==null?void 0:i.getSetOnceProps(),a=_e({},s,o||{},t||{}),l=this.config.sanitize_properties;return l&&(D.error(R_),a=l(a,"$set_once")),n&&(this.qo=!0),En(a)?void 0:a}register(t,n){var r;(r=this.persistence)==null||r.register(t,n)}register_once(t,n,r){var i;(i=this.persistence)==null||i.register_once(t,n,r)}register_for_session(t){var n,r;(n=this.persistence)==null||n.syncCookieProperties(),this.gl(),(r=this.sessionPersistence)==null||r.register(t),Object.keys(t).forEach(i=>this.jo.add(i)),this.ml()}unregister(t){var n;(n=this.persistence)==null||n.unregister(t)}unregister_for_session(t){var n;(n=this.sessionPersistence)==null||n.unregister(t),this.jo.delete(t),this.ml()}_l(t,n){this.register({[t]:n})}Xo(){this.jo.forEach(t=>{var n;(n=this.sessionPersistence)==null||n.unregister(t)}),this.jo.clear(),this.ml()}ml(){var t;if(this.Bo)if(this.config.persistence==="memory"||(t=this.sessionPersistence)!=null&&t.Hs||!we.Dr())we.qr(this.Bo);else{var n=[];this.jo.forEach(r=>n.push(r)),n.length>0?we.Nr(this.Bo,n):we.qr(this.Bo)}}getFeatureFlag(t,n){var r;return(r=this.featureFlags)==null?void 0:r.getFeatureFlag(t,n)}getFeatureFlagPayload(t){var n;return(n=this.featureFlags)==null?void 0:n.getFeatureFlagPayload(t)}getFeatureFlagResult(t,n){var r;return(r=this.featureFlags)==null?void 0:r.getFeatureFlagResult(t,n)}getAllFeatureFlags(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.getAllFeatureFlags())!==null&&t!==void 0?t:[]}isFeatureEnabled(t,n){var r,i;return(r=(i=this.featureFlags)==null?void 0:i.isFeatureEnabled(t,n))!==null&&r!==void 0?r:n==null?void 0:n.defaultValue}reloadFeatureFlags(){var t;(t=this.featureFlags)==null||t.reloadFeatureFlags()}updateFlags(t,n,r){var i;(i=this.featureFlags)==null||i.updateFlags(t,n,r)}updateEarlyAccessFeatureEnrollment(t,n,r){var i;(i=this.featureFlags)==null||i.updateEarlyAccessFeatureEnrollment(t,n,r)}getEarlyAccessFeatures(t,n,r){var i;return n===void 0&&(n=!1),(i=this.featureFlags)==null?void 0:i.getEarlyAccessFeatures(t,n,r)}on(t,n){return this.Ro.on(t,n)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:ea}),()=>{})}onSessionId(t){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(t))!==null&&n!==void 0?n:()=>{}}getSurveys(t,n){n===void 0&&(n=!1),this.surveys?this.surveys.getSurveys(t,n):t([],{isLoaded:!1,error:ea})}getActiveMatchingSurveys(t,n){n===void 0&&(n=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,n):t([],{isLoaded:!1,error:ea})}renderSurvey(t,n){var r;(r=this.surveys)==null||r.renderSurvey(t,n)}displaySurvey(t,n){var r;n===void 0&&(n=xO),(r=this.surveys)==null||r.displaySurvey(t,n)}cancelPendingSurvey(t){var n;(n=this.surveys)==null||n.cancelPendingSurvey(t)}canRenderSurvey(t){var n,r;return(n=(r=this.surveys)==null?void 0:r.canRenderSurvey(t))!==null&&n!==void 0?n:{visible:!1,disabledReason:ea}}canRenderSurveyAsync(t,n){var r,i;return n===void 0&&(n=!1),(r=(i=this.surveys)==null?void 0:i.canRenderSurveyAsync(t,n))!==null&&r!==void 0?r:Promise.resolve({visible:!1,disabledReason:ea})}wl(t){return!t||cc(t)?(D.critical("Unique user id has not been set in posthog.identify"),!1):t===fs?(D.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(D.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,n,r){if(!this.__loaded||!this.persistence)return D.uninitializedWarning("posthog.identify");if(Ge(t)&&(t=t.toString(),D.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.wl(t)&&this.bl("posthog.identify")){this.$o();var i=this.get_distinct_id(),s=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==i,o=this.gl(!1),a=this.persistence.Ws(),l=!1;try{var u=this.get_distinct_id();this.register({$user_id:t}),this.get_property(Ya)||this.register_once({$had_persisted_distinct_id:!0,$device_id:u},""),t!==u&&t!==this.get_property($s)&&(this.unregister($s),this.register({distinct_id:t}));var c,d=(this.persistence.get_property(se)||We)===We,f=t!==u,m=!f&&d;if(f&&d)this.persistence.set_property(se,ot),this.setPersonPropertiesForFlags({$set:n||{},$set_once:r||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Vs(),this.capture(gf,{distinct_id:t,$anon_distinct_id:u},{$set:n||{},$set_once:r||{}}),this.Vo=If(t,n,r),(c=this.featureFlags)==null||c.setAnonymousDistinctId(u);else if(m){this.persistence.set_property(se,ot);var _=n||{},p=r||{};this.setPersonPropertiesForFlags({$set:_,$set_once:p},!1),this.config.cookieWinsOnConflict&&this.persistence.Vs(),this.capture("$set",{$set:_,$set_once:p}),this.Vo=If(t,n,r)}else(n||r)&&this.setPersonProperties(n,r);f||s||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(ar)):m&&(n||r)&&this.reloadFeatureFlags(),l=!0}finally{a&&this.persistence.Qs(l)}}}setPersonProperties(t,n){if((t||n)&&this.bl("posthog.setPersonProperties")){var r=If(this.get_distinct_id(),t,n);this.Vo!==r?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!0),this.capture("$set",{$set:t||{},$set_once:n||{}}),this.Vo=r):D.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var n,r=(Z(t)?t:[t]).filter(i=>ce(i)&&i.length>0);r.length!==0&&this.bl("posthog.unsetPersonProperties")&&((n=this.featureFlags)==null||n.unsetPersonPropertiesForFlags(r,!0),this.capture("$set",{$unset:r}),this.Vo=null)}group(t,n,r){var i;if(t&&n){(i=this.persistence)==null||i.syncCookieProperties(),this.gl();var s=this.getGroups(),o=s[t]!==n;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:$({},s,{[t]:n})}),o||r){var a={$group_type:t,$group_key:n};r&&(a.$group_set=r),this.capture(Yy,a)}r&&this.setGroupPropertiesForFlags({[t]:r}),o&&!r&&this.reloadFeatureFlags()}else D.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,n){var r;n===void 0&&(n=!0),(r=this.featureFlags)==null||r.setPersonPropertiesForFlags(t,n)}resetPersonPropertiesForFlags(t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,n){var r;n===void 0&&(n=!0),this.bl("posthog.setGroupPropertiesForFlags")&&((r=this.featureFlags)==null||r.setGroupPropertiesForFlags(t,n))}resetGroupPropertiesForFlags(t){var n;(n=this.featureFlags)==null||n.resetGroupPropertiesForFlags(t)}reset(t){var n=$t(t)?t:t==null?void 0:t.resetDeviceID,r=$t(t)||t==null?void 0:t.bootstrap;this.kl(n,!1,r)}kl(t,n,r){var i,s,o;if(n===void 0&&(n=!1),D.info("reset"),!this.__loaded)return D.uninitializedWarning("posthog.reset");var a=r==null?void 0:r.sessionID;this.config.bootstrap=r||((i=this.Zo)==null?void 0:i.bootstrap)||{},(s=this.featureFlags)==null||s.updateConfig==null||s.updateConfig(this.config,this.ma());var l=this.get_property(Ya),u=this.get_property(pf),c=this.get_property(Oi),d=this.is_capturing();this.consent.reset(),n||!d||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");var f=(o=this.persistence)==null||o.Ws==null?void 0:o.Ws(),m=!1;try{var _,p,y,h,v,x,b,E,S,P,C,T,R,N;if((_=this.persistence)==null||_.clear(),(p=this.sessionPersistence)==null||p.clear(),this.jo.clear(),this.ml(),L(c)||(C=this.persistence)==null||C.register({[Oi]:c}),(y=this.surveys)==null||y.reset(),(h=this.vl)==null||h.stop(),(v=this.featureFlags)==null||v.reset(),(x=this.conversations)==null||x.reset(),(b=this.logs)==null||b.reset(),(E=this.metrics)==null||E.reset(),(S=this.persistence)==null||S.set_property(se,We),(P=this.sessionManager)==null||P.resetSessionId(),this.Vo=null,this.config.cookieless_mode===lr)this.register_once({distinct_id:fs,$device_id:null},"");else{var M=this.config.get_device_id($n());this.register_once({distinct_id:M,$device_id:t?M:l},""),t||L(u)||this.register({[pf]:u})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),r&&(r.distinctID===void 0||this.Lo()||((N=this.persistence)==null||N.set_property(se,r.isIdentifiedID?ot:We),this.register({distinct_id:r.distinctID})),(T=this.featureFlags)==null||T.initialize(),!(L(a)||(R=this.sessionManager)!=null&&R.setBootstrapSessionId(a,!0)))){var z=$({},r);delete z.sessionID,this.config.bootstrap=z}delete this.config.identity_distinct_id,delete this.config.identity_hash,m=!0}finally{var F;f&&((F=this.persistence)==null||F.Qs==null||F.Qs(m))}this.reloadFeatureFlags()}shutdown(t){var n=this;return Ce(function*(){var r,i,s,o,a,l;if(n.__loaded){(r=n.vl)==null||r.stop(),n.sl().dispose(),(i=n.sessionRecording)==null||i.dispose(),(s=n.logs)==null||s.flushLogs("sendBeacon"),(o=n.metrics)==null||o.flush("sendBeacon"),(a=n.Jo)==null||a.unload(),(l=n.Yo)==null||l.unload();try{var u;(u=n.featureFlags)==null||u.destroy()}catch(c){D.error("Error while destroying feature flags",c)}}else D.uninitializedWarning("posthog.shutdown")})()}setIdentity(t,n){var r;this.config.identity_distinct_id=t,this.config.identity_hash=n,this.alias(t),(r=this.conversations)==null||r.Sl()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,(t=this.conversations)==null||t.xl()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,n;return(t=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var n=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=n.sessionStartTimestamp,i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n.sessionId);if(t!=null&&t.withTimestamp&&r){var s,o=(s=t.timestampLookBack)!==null&&s!==void 0?s:10;if(!r)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-o,0)}return i}alias(t,n){return t===this.get_property(sE)?(D.critical("Attempting to create alias for existing People user - aborting."),-2):this.bl("posthog.alias")?(L(n)&&(n=this.get_distinct_id()),t!==n?(this._l($s,t),this.capture("$create_alias",{alias:t,distinct_id:n})):(D.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var n=$({},this.config);if(Se(t)){var r,i,s,o,a,l,u,c,d,f,m,_;_e(this.config,T_(t));var p=this.Do();(r=this.persistence)==null||r.update_config(this.config,n,p),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Sf($({},this.config,{persistence:"sessionStorage"}),p,!1);var y,h=this.Go(this.config.debug);$t(h)&&(this.config.debug=h),$t(this.config.debug)&&(this.config.debug?(Ee.DEBUG=!0,ge.Dr()&&ge.Nr("ph_debug",!0),D.info("set_config",{config:t,oldConfig:n,newConfig:$({},this.config)})):(Ee.DEBUG=!1,ge.Dr()&&ge.qr("ph_debug"))),(i=this.featureFlags)==null||i.updateConfig==null||i.updateConfig(this.config,this.ma()),(s=this.exceptionObserver)==null||s.onConfigChange(),(o=this.exceptions)==null||o.onConfigChange(),(a=this.sessionRecording)==null||a.startIfEnabledOrStop(),(l=this.tracingHeaders)==null||l.startIfEnabledOrStop(),(u=this.autocapture)==null||u.startIfEnabled(),(c=this.heatmaps)==null||c.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&((y=this.historyAutocapture)==null||y.startIfEnabledOrStop()),(d=this.exceptionObserver)==null||d.startIfEnabledOrStop(),(f=this.deadClicksAutocapture)==null||f.startIfEnabledOrStop(),(m=this.surveys)==null||m.loadIfEnabled(),this.No(),(_=this.externalIntegrations)==null||_.startIfEnabledOrStop()}}_overrideSDKInfo(t,n){Ee.LIB_NAME=t,Ee.LIB_VERSION=n}startSessionRecording(t){var n,r,i,s,o,a=t===!0,l={sampling:a||!(t==null||!t.sampling),linked_flag:a||!(t==null||!t.linked_flag),url_trigger:a||!(t==null||!t.url_trigger),event_trigger:a||!(t==null||!t.event_trigger)};Object.values(l).some(Boolean)&&((n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),l.sampling&&((r=this.sessionRecording)==null||r.overrideSampling()),l.linked_flag&&((i=this.sessionRecording)==null||i.overrideLinkedFlag()),l.url_trigger&&((s=this.sessionRecording)==null||s.overrideTrigger("url")),l.event_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!((t=this.sessionRecording)==null||!t.started)}captureException(t,n){if(this.exceptions){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(t,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent($({},i,n))}}addExceptionStep(t,n){var r;(r=this.exceptions)==null||r.addExceptionStep(t,n)}captureLog(t){var n;(n=this.logs)==null||n.captureLog(t)}get logger(){var t,n;return(t=(n=this.logs)==null?void 0:n.logger)!==null&&t!==void 0?t:qt.Cl}startExceptionAutocapture(t){this.set_config({capture_exceptions:t==null||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var n,r;return(n=(r=this.toolbar)==null?void 0:r.loadToolbar(t))!==null&&n!==void 0&&n}get_property(t){var n;return(n=this.persistence)==null?void 0:n.props[t]}getSessionProperty(t){var n;return(n=this.sessionPersistence)==null?void 0:n.props[t]}toString(){var t,n=(t=this.config.name)!==null&&t!==void 0?t:bs;return n!==bs&&(n=bs+"."+n),n}_isIdentified(){var t,n;return((t=this.persistence)==null?void 0:t.get_property(se))===ot||((n=this.sessionPersistence)==null?void 0:n.get_property(se))===ot}yl(){var t,n;return!(this.config.person_profiles==="never"||this.config.person_profiles===bp&&!this._isIdentified()&&En(this.getGroups())&&((t=this.persistence)==null||(t=t.props)==null||!t[$s])&&((n=this.persistence)==null||(n=n.props)==null||!n[Sc]))}cl(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.yl()||this.bl("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.bl("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}bl(t){return this.config.person_profiles==="never"?(D.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._l(Sc,!0),!0)}Do(){if(this.config.cookieless_mode==="always")return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==ki)}No(){var t,n,r,i,s=this.Do();return((t=this.persistence)==null?void 0:t.Hs)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((n=this.sessionPersistence)==null?void 0:n.Hs)!==s&&((i=this.sessionPersistence)==null||i.set_disabled(s)),s&&(this.jo.clear(),this.ml()),s}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==lr){if(this.Lo()){var r,i,s,o,a;this.kl(!0,!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new S_(this),this.pageViewManager=new f_(this),this.persistence&&(this.sessionPropsManager=new b_(this,this.sessionManager,this.persistence));var l,u=(s=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&s!==void 0?s:(a=qt.__defaultExtensionClasses)==null?void 0:a.sessionRecording;u&&(this.sessionRecording=this.Oo(this.sessionRecording,new u(this)),this.Io&&((l=this.sessionRecording)==null||l.onRemoteConfig==null||l.onRemoteConfig(this.Io)))}var c,d;this.consent.optInOut(!0),this.No(),this.hl(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==ki&&((c=this.surveys)==null||c.loadIfEnabled()),(L(t==null?void 0:t.captureEventName)||t!=null&&t.captureEventName)&&this.capture((d=t==null?void 0:t.captureEventName)!==null&&d!==void 0?d:"$opt_in",t==null?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.dl()}else D.warn(P_)}opt_out_capturing(){var t,n,r;this.config.cookieless_mode!==lr?(this.config.cookieless_mode===ki&&this.consent.isOptedIn()&&this.kl(!0,!0),this.consent.optInOut(!1),this.No(),this.config.cookieless_mode===ki&&(this.register({distinct_id:fs,$device_id:null}),(t=this.sessionRecording)==null||t.stopRecording(),this.sessionRecording=void 0,(n=this.sessionManager)==null||n.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.dl(),this.hl())):D.warn(P_)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return t===1?"granted":t===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===lr||(this.config.cookieless_mode===ki?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.No()}_is_bot(){return St?ZE(St,this.config.custom_blocked_useragents):void 0}dl(){j&&(j.visibilityState==="visible"?this.Uo||(this.Uo=!0,this.capture(xs,{title:j.title},{send_instantly:!0}),this.zo&&(j.removeEventListener(Cc,this.zo),this.zo=null)):this.zo||(this.zo=this.dl.bind(this),Re(j,Cc,this.zo)))}debug(t){t===!1?(I==null||I.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(I==null||I.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}ma(){var t=this.Zo||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(D.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(n,r,i,s,o){var a=r in n&&!ne(n[r]),l=i in n&&!ne(n[i]);return a?n[r]:!!l&&(o&&o.warn("Config field '"+i+"' is deprecated. Please use '"+r+"' instead. The old field will be removed in a future major version."),n[i])}(t,"advanced_disable_flags","advanced_disable_decide",0,D)}kn(t){var n;if(ne(this.config.before_send))return t;var r=Object.keys((n=t.properties)!==null&&n!==void 0?n:{}).filter(FT),i=Z(this.config.before_send)?this.config.before_send:[this.config.before_send],s=t;for(var o of i)try{if(s=o(s),ne(s)){var a="Event '"+t.event+"' was rejected in beforeSend function";return $T(t.event)?D.warn(a+". This can cause unexpected behavior."):D.info(a),null}s.properties&&!En(s.properties)||D.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}catch(u){return D.error("Error in beforeSend function for event '"+t.event+"':",u),null}for(var l of r)if(s.properties&&ne(s.properties[l]))return D.warn("Event '"+t.event+"' had its '"+l+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return s}getPageViewId(){var t;return(t=this.pageViewManager.Ss)==null?void 0:t.pageViewId}captureTraceFeedback(t,n){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:n})}captureTraceMetric(t,n,r){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:n,$ai_metric_value:String(r)})}Go(t){var n=$t(t)&&!t,r=ge.Dr()&&ge.Pr("ph_debug")==="true";return!n&&(!!r||t)}}qt.__defaultExtensionClasses={},qt.Cl=(()=>{var e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=kI(e.prototype[t[n]])}(qt,["identify"]);class lS{constructor(t){this.disabled=t===!1;var n=Se(t)?t:{};this.thresholdPx=n.threshold_px||30,this.timeoutMs=n.timeout_ms||1e3,this.clickCount=n.click_count||3,this.clicks=[]}isRageClick(t,n,r){if(this.disabled)return!1;var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(t-i.x)+Math.abs(n-i.y)r-i.timestamp){if(this.clicks.push({x:t,y:n,timestamp:r}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:n,timestamp:r}];return!1}}var Af="$copy_autocapture",nu=Ie("[AutoCapture]");function Nf(e,t){return t.length>e?t.slice(0,e)+"...":t}function OO(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!ui(t));return t}function MO(e,t){var n,r,i=t.e,s=t.maskAllElementAttributes,o=t.maskAllText,a=t.elementAttributeIgnoreList,l=t.elementsChainAsString,u=t.disableCaptureUrlHashes;if(!ui(e))return{props:{}};for(var c=[e],d=new Set([e]),f=e;f.parentNode&&!Kt(f,"body")&&bE>c.length;)if(xE(f.parentNode)){var m=f.parentNode.host;if(d.has(m))break;d.add(m),c.push(m),f=m}else{if(!ui(f.parentNode)||d.has(f.parentNode))break;d.add(f.parentNode),c.push(f.parentNode),f=f.parentNode}var _,p,y=[],h={},v=!1,x=!1;if(ve(c,C=>{var T=kp(C);if(Kt(C,"a")){var R=C.getAttribute("href");v=!!(T&&R&&ka(R))&&(u?li(R):R)}J(Tc(C),"ph-no-capture")&&(x=!0),y.push(function(M,z,F,W,B){B===void 0&&(B=!1);var Q=M.tagName.toLowerCase(),O={tag_name:Q};kg.indexOf(Q)>-1&&!F&&(O.$el_text=Q.toLowerCase()==="a"||Q.toLowerCase()==="button"?Nf(1024,u_(M)):Nf(1024,Ja(M)));var A=Tc(M);A.length>0&&(O.classes=A.filter(function(oe){return oe!==""})),ve(M.attributes,function(oe){var de;if((!RE(M)||["name","id","class","aria-label"].indexOf(oe.name)!==-1)&&(W==null||!W.includes(oe.name))&&!z&&ka(oe.value)&&(!ce(de=oe.name)||de.substring(0,10)!=="_ngcontent"&&de.substring(0,7)!=="_nghost")){var be=oe.value;oe.name==="class"&&(be=Cg(be).join(" ")),O["attr__"+oe.name]=Nf(1024,oe.name==="href"&&B?li(be):be)}});for(var V=1,K=1,te=M;te=OO(te);)V++,te.tagName===M.tagName&&K++;return O.nth_child=V,O.nth_of_type=K,O}(C,s,o,a,u));var N=function(M){if(!kp(M))return{};var z={};return ve(M.attributes,function(F){if(F.name&&F.name.indexOf("data-ph-capture-attribute")===0){var W=F.name.replace("data-ph-capture-attribute-",""),B=F.value;W&&B&&ka(B)&&(z[W]=B)}}),z}(C);_e(h,N)}),x)return{props:{},explicitNoCapture:x};if(o||(y[0].$el_text=Kt(e,"a")||Kt(e,"button")?u_(e):Ja(e)),v){var b,E;y[0].attr__href=v;var S=(b=Eo(v))==null?void 0:b.host,P=I==null||(E=I.location)==null?void 0:E.host;S&&P&&S!==P&&(_=v)}return{props:_e({$event_type:i.type,$ce_version:1},l?{}:{$elements:y},{$elements_chain:(p=y,function(C){return C.map(T=>{var R,N,M="";if(T.tag_name&&(M+=T.tag_name),T.attr_class)for(var z of(T.attr_class.sort(),T.attr_class))M+="."+z.replace(/"/g,"");var F=$({},T.text?{text:T.text}:{},{"nth-child":(R=T.nth_child)!==null&&R!==void 0?R:0,"nth-of-type":(N=T.nth_of_type)!==null&&N!==void 0?N:0},T.href?{href:T.href}:{},T.attr_id?{attr_id:T.attr_id}:{},T.attributes),W={};return Iu(F).sort((B,Q)=>B[0].localeCompare(Q[0])).forEach(B=>{var Q=B[1];return W[c_(B[0].toString())]=c_(Q.toString())}),(M+=":")+Iu(W).map(B=>B[0]+'="'+B[1]+'"').join("")}).join(";")}(function(C){return C.map(T=>{var R,N,M={text:(R=T.$el_text)==null?void 0:R.slice(0,400),tag_name:T.tag_name,href:(N=T.attr__href)==null?void 0:N.slice(0,2048),attr_class:WI(T),attr_id:T.attr__id,nth_child:T.nth_child,nth_of_type:T.nth_of_type,attributes:{}};return Iu(T).filter(z=>z[0].indexOf("attr__")===0).forEach(z=>M.attributes[z[0]]=z[1]),M})}(p)))},(n=y[0])!=null&&n.$el_text?{$el_text:(r=y[0])==null?void 0:r.$el_text}:{},_&&i.type==="click"?{$external_click_url:_}:{},h)}}class AO{constructor(t){this.name="autocapture",this.Qn=!1,this.Jn=null,this.Kn=!1,this.Yn=!1,this.qi={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Xn=!1,this.ts=t,this.ts.refresh(this.qi),this.rageclicks=new lS(this.qi.rageclick),this.es=null}setup(t){this.rs(),this.ns=t;var n=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Xn?n.dispose():(this.ss=n,this.startIfEnabled())}dispose(){var t;this.Xn||(this.Xn=!0,this.ns=void 0,(t=this.ss)==null||t.dispose(),this.ss=void 0,this.os())}ls(){return this.ts.refresh(this.qi),this.qi}rs(){var t,n;return this.ls(),this.qi.url_allowlist=(t=this.qi.url_allowlist)==null?void 0:t.map(r=>new RegExp(r)),this.qi.url_ignorelist=(n=this.qi.url_ignorelist)==null?void 0:n.map(r=>new RegExp(r)),this.qi}us(){if(this.isBrowserSupported()){if(I&&j){var t=this.hs=r=>{r=r||(I==null?void 0:I.event);try{this.ds(r)}catch(i){nu.error("Failed to capture event",i)}};if(Re(j,"submit",t,{capture:!0}),Re(j,"change",t,{capture:!0}),Re(j,"click",t,{capture:!0}),this.ls().capture_copied_text){var n=this.vs=r=>{r=r||(I==null?void 0:I.event);try{this.ds(r,Af)}catch(i){nu.error("Failed to capture copy/cut event",i)}};Re(j,"copy",n,{capture:!0}),Re(j,"cut",n,{capture:!0})}}}else nu.info("Disabling Automatic Event Collection because this browser is not supported")}os(){this.hs&&(j==null||j.removeEventListener("submit",this.hs,!0),j==null||j.removeEventListener("change",this.hs,!0),j==null||j.removeEventListener("click",this.hs,!0),this.hs=void 0),this.vs&&(j==null||j.removeEventListener("copy",this.vs,!0),j==null||j.removeEventListener("cut",this.vs,!0),this.vs=void 0),this.Qn=!1}startIfEnabled(){!this.Xn&&this.ns&&this.isEnabled&&!this.Qn&&(this.us(),this.Qn=!0)}onRemoteConfig(t){if(!this.Xn)if(this.Kn=!0,t.ok){var n=t.config;n.elementsChainAsString&&(this.Yn=n.elementsChainAsString);var r,i=n.autocapture_opt_out;$t(i)&&((r=this.ns)==null||r.kv.set(lp,i),this.Jn=i),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.es=t}getElementSelectors(t){var n,r=[];return(n=this.es)==null||n.forEach(i=>{var s=j==null?void 0:j.querySelectorAll(i);s==null||s.forEach(o=>{t===o&&r.push(i)})}),r}get isEnabled(){var t,n;if(this.Xn)return!1;var r=(t=this.ns)==null?void 0:t.kv.get(lp),i=this.Jn,s=this.ls(),o=s.remoteRequestsDisabled&&!this.Kn;if(rt(i)&&!$t(r)&&!o)return!1;var a=(n=this.Jn)!==null&&n!==void 0?n:!!r;return!!s.enabled&&!a}ds(t,n){if(n===void 0&&(n="$autocapture"),this.isEnabled){var r=Sp(t);wE(r)&&(r=r.parentNode||null);var i,s=this.rs();n==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&s.rageclick&&(i=this.rageclicks)!=null&&i.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&kE(r,s.rageclick)&&this.ds(t,"$rageclick");var o=n===Af;if(r&&function(_,p,y,h,v,x){var b;if(!I||Pg(_)||y!=null&&y.url_allowlist&&!n_(y.url_allowlist,x)||y!=null&&y.url_ignorelist&&n_(y.url_ignorelist,x))return!1;if(y!=null&&y.dom_event_allowlist){var E=y.dom_event_allowlist;if(E&&!E.some(N=>p.type===N))return!1}var S=PE(_,h),P=S.parentIsUsefulElement,C=S.targetElementList;if(!function(N,M){var z=M==null?void 0:M.element_allowlist;if(L(z))return!0;var F,W=function(Q){if(z.some(O=>Q.tagName.toLowerCase()===O))return{v:!0}};for(var B of N)if(F=W(B))return F.v;return!1}(C,y)||!Cp(C,y==null?void 0:y.css_selector_allowlist)||Cp(C,(b=y==null?void 0:y.css_selector_ignorelist)!==null&&b!==void 0?b:DI))return!1;try{var T=I.getComputedStyle(_);if(T&&T.getPropertyValue("cursor")==="pointer"&&p.type==="click")return!0}catch{}var R=_.tagName.toLowerCase();switch(R){case"html":return!1;case"form":return(v||["submit"]).indexOf(p.type)>=0;case"input":case"select":case"textarea":return(v||["change","click"]).indexOf(p.type)>=0;default:return P?(v||["click"]).indexOf(p.type)>=0:(v||["click"]).indexOf(p.type)>=0&&(kg.indexOf(R)>-1||_.getAttribute("contenteditable")==="true")}}(r,t,s,o,o?["copy","cut"]:void 0,{config:{get_current_url:s.getCurrentUrl}})){var a,l=MO(r,{e:t,maskAllElementAttributes:s.maskAllElementAttributes,maskAllText:s.maskAllText,elementAttributeIgnoreList:s.element_attribute_ignorelist,elementsChainAsString:this.Yn,disableCaptureUrlHashes:s.disableCaptureUrlHashes}),u=l.props;if(l.explicitNoCapture)return!1;var c=this.getElementSelectors(r);if(c&&c.length>0&&(u.$element_selectors=c),n===Af){var d,f=EE(I==null||(d=I.getSelection())==null?void 0:d.toString()),m=t.type||"clipboard";if(!f)return!1;u.$selected_content=f,u.$copy_type=m}return(a=this.ns)==null||a.capture(n,u).catch(_=>nu.error("Failed to capture event",_)),!0}}}isBrowserSupported(){return vt(j==null?void 0:j.querySelectorAll)}}class NO{constructor(t){this._instance=t}refresh(t){var n=this._instance.config,r=Se(n.autocapture)?n.autocapture:void 0;t.enabled=!!n.autocapture,t.rageclick=n.rageclick,t.maskAllElementAttributes=n.mask_all_element_attributes,t.maskAllText=n.mask_all_text,t.disableCaptureUrlHashes=n.disable_capture_url_hashes,t.getCurrentUrl=n.get_current_url,t.remoteRequestsDisabled=this._instance.ma(),t.url_allowlist=r==null?void 0:r.url_allowlist,t.url_ignorelist=r==null?void 0:r.url_ignorelist,t.dom_event_allowlist=r==null?void 0:r.dom_event_allowlist,t.element_allowlist=r==null?void 0:r.element_allowlist,t.css_selector_allowlist=r==null?void 0:r.css_selector_allowlist,t.css_selector_ignorelist=r==null?void 0:r.css_selector_ignorelist,t.element_attribute_ignorelist=r==null?void 0:r.element_attribute_ignorelist,t.capture_copied_text=r==null?void 0:r.capture_copied_text}}var ta=Ie("[ExceptionAutocapture]"),I_=()=>{},$O=Ie("[TracingHeaders]"),yi=Ie("[Web Vitals]"),O_=9e5,M_="disabled",A_="lazy_loading",na="awaiting_config",ru="missing_config";Ie("[SessionRecording]"),Ie("[SessionRecording]");var Np="[SessionRecording]",Yn=Ie(Np),FO=Ie("[Heatmaps]");function $f(e){return Se(e)&&"clientX"in e&&"clientY"in e&&Ge(e.clientX)&&Ge(e.clientY)}var iu=Ie("[Product Tours]"),Ff=e=>{var t;return!e.config.disable_product_tours&&!((t=e.persistence)==null||!t.get_property(xg))},LO=["$set_once","$set"],On=Ie("[SiteApps]"),N_="Error while initializing PostHog app with config id ",uS=(e,t)=>e!=null&&e.then?e.then(t):t(e),vs="SDK is not enabled or survey functionality is not yet loaded",$_="Disabled. Not loading surveys.";class jO{constructor(t,n){this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Tl=!1,this.Ml=[],this.El=null,this.Il=null,this.Xn=!1,this.Rl=new Set,this.onRemoteConfig=r=>{if(!this.Xn&&!this.qi.disableSurveys){if(!r.ok)return he.warn("Remote config unavailable. Not loading surveys.");var i=r.config.surveys;if(ne(i))return he.warn("Flags not loaded yet. Not loading surveys.");this.Pl=$t(i)?i:i.length>0,he.info("flags response received, isSurveysEnabled: "+this.Pl),this.loadIfEnabled()}},this.ts=t,this.Al=n}setup(t){if(!this.Xn)return this.Fl=t,uS(t.kv.initialize(),()=>{if(this.Fl===t&&!this.Xn){this.Fl=void 0,this.ns=t;var n=t.onRemoteConfig(this.onRemoteConfig);this.Xn?n.dispose():(this.ss=n,this.loadIfEnabled())}})}dispose(){var t,n,r;this.Xn||(this.Xn=!0,this.Fl=void 0,this.ns=void 0,(t=this.ss)==null||t.dispose(),this.ss=void 0,(n=this._surveyEventReceiver)==null||n.dispose(),this._surveyEventReceiver=null,(r=this._surveyManager)==null||r.dispose==null||r.dispose(),this._surveyManager=null,this.Ml=[],this.El=null,this.Rl.forEach(i=>clearTimeout(i)),this.Rl.clear())}get qi(){return this.ts.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;(t=this._surveyEventReceiver)==null||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var n=[],r=0;rlocalStorage.removeItem(s))}catch{}}loadIfEnabled(){if(!this.Xn&&this.ns){var t=this.qi;if(!this._surveyManager)if(this.Tl)he.info("Already initializing surveys, skipping...");else if(t.disableSurveys)he.info($_);else if(t.cookielessMode&&this.ts.isOptedOut())he.info("Not loading surveys in cookieless mode without consent.");else{var n=this.ts.getExtensions();if(n){if(!L(this.Pl)||t.advancedEnableSurveys){var r=this.Pl||t.advancedEnableSurveys;this.Tl=!0;try{var i=n.generateSurveys;if(i)return this.Ol(i,r),void(this.Tl=!1);var s=n.loadExternalDependency;if(!s)return this.Ll(Eg),void(this.Tl=!1);s(o=>{try{if(this.Xn)return;var a=this.ts.getExtensions();o||a==null||!a.generateSurveys?this.Ll("Could not load surveys script",o):this.Ol(a.generateSurveys,r)}finally{this.Tl=!1}})}catch(o){throw this.Tl=!1,this.Ll("Error initializing surveys",o),o}}}else he.error("PostHog Extensions not found.")}}}Ol(t,n){this.Xn||(this._surveyManager=t(n),this._surveyEventReceiver=this.ts.createEventReceiver(),he.info("Surveys loaded successfully"),this.$l({isLoaded:!0}))}Ll(t,n){he.error(t,n),this.$l({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ml.push(t),this._surveyManager&&this.$l({isLoaded:!0}),()=>{this.Ml=this.Ml.filter(n=>n!==t)}}getSurveys(t,n){var r;n===void 0&&(n=!1);var i=(r=this.ns)!==null&&r!==void 0?r:this.Al;if(i&&!this.Xn){if(this.qi.disableSurveys)return he.info($_),t([]);var s=i.kv.get(vp);if(s&&!n)return t(s,{isLoaded:!0}),void(this.Dl()&&this.getSurveys(()=>{},!0));if(this.El)this.El.then(l=>{this.Xn||t(l.surveys,l.context)}).catch(l=>he.error("Error in survey callback",l));else{var o=this.Nl("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.qi.requestTimeoutMs}).then(l=>{try{return this.ql(i,l)}catch(u){return he.error("Error processing surveys response",u),this.ql(i,{statusCode:0,error:u})}},l=>this.ql(i,{statusCode:0,error:l}));this.El=o;var a=()=>{this.El===o&&(this.El=null)};o.then(l=>{a(),this.Xn||t(l.surveys,l.context)},a).catch(l=>he.error("Error in survey callback",l))}}}Nl(t,n){var r=this.ns;return r?r.sendRequest(t,n):new Promise(i=>i({statusCode:0,error:new Error(vs)}))}ql(t,n){if(this.Xn)return{surveys:[],context:{isLoaded:!1,error:vs}};var r=n.statusCode;if(r!==200||!n.json){var i="Surveys API could not be loaded, status: "+r;return r!==0?he.error(i):n.error||he.warn(i),this.Il=Date.now(),{surveys:[],context:{isLoaded:!1,error:i}}}this.Il=null;var s,o=n.json.surveys||[],a=o.filter(l=>function(u){return!(!u.start_date||u.end_date)}(l)&&(rS(l)||function(u){var c;return!((c=u.conditions)==null||(c=c.actions)==null||(c=c.values)==null||!c.length)}(l)));return a.length>0&&((s=this._surveyEventReceiver)==null||s.register(a)),t.kv.set({[vp]:o,[bc]:Date.now()}),{surveys:o,context:{isLoaded:!0}}}Dl(){return this.jl()&&!this.El&&!this.Bl()}jl(){var t,n,r=(t=(n=this.ns)!==null&&n!==void 0?n:this.Al)==null?void 0:t.kv.get(bc);return Ge(r)&&Date.now()-r>3e5}Bl(){return Ge(this.Il)&&3e5>Date.now()-this.Il}markSurveyAsSeen(t,n){var r,i={id:t,current_iteration:(r=n==null?void 0:n.iteration)!==null&&r!==void 0?r:null};sS(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}}$l(t){for(var n of this.Ml)try{if(!t.isLoaded)return n([],t);this.getSurveys(n)}catch(r){he.error("Error in survey callback",r)}}getActiveMatchingSurveys(t,n){if(n===void 0&&(n=!1),!ne(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,n);he.warn("init was not called")}Hl(t){var n=null;return this.getSurveys(r=>{var i;n=(i=r.find(s=>s.id===t))!==null&&i!==void 0?i:null}),n}Ul(t){if(ne(this._surveyManager))return{eligible:!1,reason:vs};var n=typeof t=="string"?this.Hl(t):t;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}zl(t){if(ne(this._surveyManager))return{eligible:!1,reason:vs};var n=typeof t=="string"?this.Hl(t):t;return n?this._surveyManager.checkSurveyRenderability(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(ne(this._surveyManager))return he.warn("init was not called"),{visible:!1,disabledReason:vs};var n=this.zl(t);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(t,n){return ne(this._surveyManager)?(he.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:vs})):new Promise(r=>{this.getSurveys(i=>{var s,o=(s=i.find(l=>l.id===t))!==null&&s!==void 0?s:null;if(o){var a=this.zl(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})},n)})}renderSurvey(t,n,r){var i;if(ne(this._surveyManager))he.warn("init was not called");else{var s=typeof t=="string"?this.Hl(t):t;if(s!=null&&s.id)if(wO.includes(s.type)){var o=j==null?void 0:j.querySelector(n);if(o)if((i=s.appearance)!=null&&i.surveyPopupDelaySeconds){he.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds");var a=setTimeout(()=>{var l,u;this.Rl.delete(a),this.Xn||(he.info("Rendering survey "+s.id+" with delay of "+((l=s.appearance)==null?void 0:l.surveyPopupDelaySeconds)+" seconds"),(u=this._surveyManager)==null||u.renderSurvey(s,o,r),he.info("Survey "+s.id+" rendered"))},1e3*s.appearance.surveyPopupDelaySeconds);this.Rl.add(a)}else this._surveyManager.renderSurvey(s,o,r);else he.warn("Survey element not found")}else he.warn("Surveys of type "+s.type+" cannot be rendered in the app");else he.warn("Survey not found")}}displaySurvey(t,n){var r;if(ne(this._surveyManager))he.warn("init was not called");else{var i=this.Hl(t);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&n.ignoreDelay&&(s=$({},i,{appearance:$({},i.appearance,{surveyPopupDelaySeconds:0})})),n.displayType!==Pp.Popover&&n.initialResponses&&he.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),n.ignoreConditions===!1){var o=this.Ul(i);if(!o.eligible)return void he.warn("Survey is not eligible to be displayed: ",o.reason)}n.displayType!==Pp.Inline?this._surveyManager.handlePopoverSurvey(s,n):this.renderSurvey(s,n.selector,n.properties)}else he.warn("Survey not found")}}cancelPendingSurvey(t){ne(this._surveyManager)?he.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;(t=this._surveyManager)==null||t.handlePageUnload==null||t.handlePageUnload()}}function gs(e,t,n){if(ne(e))return!1;switch(n){case"exact":return e===t;case"contains":var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}class DO{constructor(t){this.Wl=new Set,this.Vl=new Set,this.Gl=new Ac,this.Zl=(n,r)=>this.Ql(n,r)&&this.Jl(n,r)&&this.Kl(n,r)&&this.Yl(n,r),this.Ql=(n,r)=>r==null||!r.event||(n==null?void 0:n.event)===(r==null?void 0:r.event),this._instance=t}init(){var t,n;L((t=this._instance)==null?void 0:t._addCaptureHook)||(this.Xl=(n=this._instance)==null?void 0:n._addCaptureHook((r,i)=>{this.on(r,i)}))}dispose(){var t;(t=this.Xl)==null||t.call(this),this.Xl=void 0,this.Gl=new Ac}register(t){var n,r;if(!L((n=this._instance)==null?void 0:n._addCaptureHook)&&(t.forEach(s=>{var o;this.Wl.add(s),(o=s.steps)==null||o.forEach(a=>{this.Vl.add((a==null?void 0:a.event)||"")})}),(r=this._instance)!=null&&r.autocapture)){var i=new Set;this.Wl.forEach(s=>{var o;(o=s.steps)==null||o.forEach(a=>{a!=null&&a.selector&&i.add(a.selector)})}),this._instance.autocapture.setElementSelectors(i)}}replace(t){this.Wl.clear(),this.Vl.clear(),this.register(t)}on(t,n){n!=null&&t.length!=0&&(this.Vl.has(t)||this.Vl.has(n.event))&&this.Wl.forEach(r=>{this.tu(n,r)&&this.Gl.emit("actionCaptured",r.name)})}eu(t){this.onAction("actionCaptured",n=>t(n))}tu(t,n){if((n==null?void 0:n.steps)==null)return!1;for(var r of n.steps)if(this.Zl(t,r))return!0;return!1}onAction(t,n){return this.Gl.on(t,n)}Jl(t,n){if(n!=null&&n.url){var r,i=t==null||(r=t.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!gs(i,n.url,n.url_matching||"contains"))return!1}return!0}Kl(t,n){return!!this.iu(t,n)&&!!this.ru(t,n)&&!!this.nu(t,n)}iu(t,n){var r;if(n==null||!n.href)return!0;var i=this.su(t);if(i.length>0)return i.some(a=>gs(a.href,n.href,n.href_matching||"exact"));var s,o=(t==null||(r=t.properties)==null?void 0:r.$elements_chain)||"";return!!o&&gs((s=o.match(/(?::|")href="(.*?)"/))?s[1]:"",n.href,n.href_matching||"exact")}ru(t,n){var r;if(n==null||!n.text)return!0;var i=this.su(t);if(i.length>0)return i.some(u=>gs(u.text,n.text,n.text_matching||"exact")||gs(u.$el_text,n.text,n.text_matching||"exact"));var s,o,a,l=(t==null||(r=t.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(s=function(u){for(var c,d=[],f=/(?::|")text="(.*?)"/g;!ne(c=f.exec(u));)d.includes(c[1])||d.push(c[1]);return d}(l),o=n.text,a=n.text_matching||"exact",s.some(u=>gs(u,o,a)))}nu(t,n){var r,i;if(n==null||!n.selector)return!0;var s=t==null||(r=t.properties)==null?void 0:r.$element_selectors;if(s!=null&&s.includes(n.selector))return!0;var o=(t==null||(i=t.properties)==null?void 0:i.$elements_chain)||"";if(n.selector_regex&&o)try{return new RegExp(n.selector_regex).test(o)}catch{return!1}return!1}su(t){var n;return(t==null||(n=t.properties)==null?void 0:n.$elements)==null?[]:t==null?void 0:t.properties.$elements}Yl(t,n){return n==null||!n.properties||n.properties.length===0||nS(n.properties.reduce((r,i)=>{var s=Z(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return r[i.key]={values:s,operator:i.operator||"exact"},r},{}),t==null?void 0:t.properties)}}class zO{constructor(t){var n;this.au=[],this._instance=t,this.ou=new Map,this.lu=new Map,this.uu=new Map,this.hu=(n=this._instance)==null||n.onSessionId==null?void 0:n.onSessionId(r=>this.du(r))}vu(t){return!1}cu(){return null}fu(t){}pu(){}gu(t,n){return!!t&&nS(t.propertyFilters,n==null?void 0:n.properties)}mu(t,n){var r=new Map;return t.forEach(i=>{var s;(s=i.conditions)==null||(s=s[n])==null||(s=s.values)==null||s.forEach(o=>{if(o!=null&&o.name){var a=r.get(o.name)||[];a.push(i.id),r.set(o.name,a)}})}),r}yu(t,n,r){var i=(r===Xo.Activation?this.ou:this.lu).get(t),s=[];return this.bu(o=>{s=o.filter(a=>i==null?void 0:i.includes(a.id))}),s.filter(o=>{var a,l=(a=o.conditions)==null||(a=a[r])==null||(a=a.values)==null?void 0:a.find(u=>u.name===t);return this.gu(l,n)})}register(t){this._u(t,!1)}replace(t){this._u(t,!0)}_u(t,n){var r;L((r=this._instance)==null?void 0:r._addCaptureHook)||(this.wu(t,n),this.ku(t,n))}ku(t,n){var r=t.filter(o=>{var a;return(a=o.conditions)==null||(a=a.actions)==null||(a=a.values)==null?void 0:a.length});if(n&&this.uu.clear(),r.length!==0){this.Su||(this.Su=new DO(this._instance),this.Su.init(),this.Su.eu(o=>this.onAction(o)));var i=[];r.forEach(o=>{var a;(a=o.conditions)==null||(a=a.actions)==null||a.values.forEach(l=>{if(i.push(l),l.name){var u,c=(u=this.uu.get(l.name))!==null&&u!==void 0?u:[];c.includes(o.id)||c.push(o.id),this.uu.set(l.name,c)}})}),n?this.Su.replace(i):this.Su.register(i)}else{var s;n&&((s=this.Su)==null||s.replace([]))}}xu(t,n){n.forEach((r,i)=>{var s,o=(s=t.get(i))!==null&&s!==void 0?s:[];r.forEach(a=>{o.includes(a)||o.push(a)}),t.set(i,o)})}wu(t,n){var r,i,s=t.filter(u=>{var c,d;return((c=u.conditions)==null?void 0:c.events)&&((d=u.conditions)==null||(d=d.events)==null||(d=d.values)==null?void 0:d.length)>0}),o=t.filter(u=>{var c,d;return((c=u.conditions)==null?void 0:c.cancelEvents)&&((d=u.conditions)==null||(d=d.cancelEvents)==null||(d=d.values)==null?void 0:d.length)>0}),a=this.mu(t,Xo.Activation),l=this.mu(t,Xo.Cancellation);n?(this.ou=a,this.lu=l):(this.xu(this.ou,a),this.xu(this.lu,l)),(s.length!==0||o.length!==0)&&((r=this.Xl)!==null&&r!==void 0||(this.Xl=(i=this._instance)==null?void 0:i._addCaptureHook((u,c)=>{this.onEvent(u,c)})))}onEvent(t,n){var r,i,s=this.Cu(),o=(n==null||(r=n.properties)==null?void 0:r.$survey_id)||(n==null||(i=n.properties)==null?void 0:i.$product_tour_id);if(o&&this.getActivatedIds().includes(o)){var a=this.Tu(t,o);if(a==="consume")return s.info("event consumed activated item, removing it",{event:t,itemId:o}),void this.Mu([o]);if(a==="persist")return s.info("shown item promoted to persisted activation",{event:t,itemId:o}),this.Eu(o),void this.Iu([o])}if(this.lu.has(t)){var l=this.yu(t,n,Xo.Cancellation);l.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:l.map(c=>c.id)}),this.Mu(l.map(c=>c.id)),l.forEach(c=>this.Ru(c.id)))}if(this.ou.has(t)){s.info("event name matched",{event:t,eventPayload:n,items:this.ou.get(t)});var u=this.yu(t,n,Xo.Activation);this.Pu(u.map(c=>c.id))}}onAction(t){this.uu.has(t)&&this.Pu(this.uu.get(t)||[])}Pu(t){var n;if(t.length!==0){var r=!((n=this._instance)==null||n.get_session_id==null||!n.get_session_id()),i=[];for(var s of t)r&&this.vu(s)?this.Eu(s)&&this.Au(s):i.push(s);i.length>0&&(this.au=[...new Set([...this.au,...i])]),this.Cu().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Eu(t){this.au=this.au.filter(r=>r!==t);var n=this.Fu();return!n.includes(t)&&(this.Ou([...n,t]),this.Lu(),!0)}Mu(t){var n=new Set(t);this.au=this.au.filter(s=>!n.has(s));var r=this.$u(),i=r.filter(s=>!n.has(s));i.length!==r.length&&(this.Ou(i),i.length===0&&this.Du()),this.Iu(t)}Nu(){var t,n=this.cu();if(!n)return{};var r=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n];return r&&typeof r=="object"?r:{}}Au(t){if(this.cu()){var n=this.Nu();this.fu($({},n,{[t]:Date.now()}))}}Iu(t){if(this.cu()){var n=this.Nu(),r={},i=!1;for(var s of Object.entries(n)){var o=s[0],a=s[1];t.includes(o)?i=!0:r[o]=a}i&&(En(r)?this.pu():this.fu(r))}}qu(){this.cu()&&this.pu()}getActivationTimestamp(t){if(this.Fu().includes(t)){var n=this.Nu()[t];return Ge(n)?n:void 0}}$u(){var t,n=this.ju();return((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n])||[]}Fu(){var t,n,r=this.$u();if(r.length===0)return[];var i=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.Bu()],s=(n=this._instance)==null||n.get_session_id==null?void 0:n.get_session_id();return s&&i===s?r:[]}Lu(){var t,n=(t=this._instance)==null||t.get_session_id==null?void 0:t.get_session_id();n&&this.Hu(n)}Du(){this.Uu()}du(t){var n,r=(n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[this.Bu()];if(r&&r!==t){var i=this.$u(),s=this.Nu();i.length>0&&(this.Ou([]),i.filter(o=>Ge(s[o])).forEach(o=>this.Ru(o))),this.Du(),this.qu()}}getActivatedIds(){return[...new Set([...this.Fu(),...this.au])].filter(t=>!this.zu(t))}dispose(){var t,n,r;(t=this.hu)==null||t.call(this),this.hu=void 0,(n=this.Xl)==null||n.call(this),this.Xl=void 0,(r=this.Su)==null||r.dispose(),this.Su=void 0}reset(){this.au=[],this.$u().length>0&&this.Ou([]),this.Du(),this.qu()}getEventToItemsMap(){return this.ou}Wu(){return this.Su}}class UO extends zO{constructor(t){super(t)}ju(){return gp}Bu(){return Ru}cu(){return Tu}fu(t){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Tu]:t})}pu(){var t;(t=this._instance)==null||(t=t.persistence)==null||t.unregister(Tu)}vu(t){var n,r;this.bu(s=>{r=s.find(o=>o.id===t)});var i=(n=r)==null||(n=n.appearance)==null?void 0:n.surveyPopupDelaySeconds;return Ge(i)&&i>0}Vu(){return ur.SHOWN}bu(t){var n;(n=this._instance)==null||n.getSurveys(t)}Ru(t){var n;(n=this._instance)==null||n.cancelPendingSurvey(t)}Cu(){return he}Ou(t){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[gp]:t})}Hu(t){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Ru]:t})}Uu(){var t;(t=this._instance)==null||(t=t.persistence)==null||t.unregister(Ru)}zu(){return!1}Tu(t,n){var r;this.bu(s=>{r=s.find(o=>o.id===n)});var i=!r||function(s){var o;return rS(s)&&!((o=s.conditions)==null||(o=o.events)==null||!o.repeatedActivation)||s.schedule==="always"}(r);return i?t===ur.SHOWN?"consume":"ignore":t===ur.SHOWN?"persist":t===ur.DISMISSED||t===ur.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class VO{constructor(t){this._instance=t}initialize(){}get(t){if(typeof t=="string")return this._instance.get_property(t);var n={};for(var r of t){var i=this._instance.get_property(r);L(i)||(n[r]=i)}return n}set(t,n){this._instance.register(typeof t=="string"?{[t]:n}:t)}remove(t){typeof t!="string"?t.forEach(n=>this._instance.unregister(n)):this._instance.unregister(t)}}class BO{constructor(t){this._instance=t}get(){var t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}getExtensions(){var t=Y==null?void 0:Y.__PosthogExtensions__;if(t){var n=t.generateSurveys,r=t.loadExternalDependency;return{generateSurveys:n?i=>n(this._instance,i):void 0,loadExternalDependency:r?i=>r(this._instance,"surveys",i):void 0}}}createEventReceiver(){return new UO(this._instance)}}var qO=I!=null&&I.location?Ic(I.location.hash,"__posthog")||Ic(location.hash,"state"):null,F_="_postHogToolbarParams",L_=Ie("[Toolbar]"),j_=Ie("[FeatureFlags]");class WO{constructor(t,n){n===void 0&&(n=!1),this.Gu=!1,this.update(t,n)}update(t,n){this.Zu=((r,i)=>{var s,o,a,l;return{bootstrap:{featureFlags:(s=r.bootstrap)==null?void 0:s.featureFlags,featureFlagPayloads:(o=r.bootstrap)==null?void 0:o.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!r.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!r.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!r.advanced_feature_flags_dedup_per_session,cacheTtlMs:r.feature_flag_cache_ttl_ms,requestTimeoutMs:r.feature_flag_request_timeout_ms,compression:r.disable_compression?"none":"base64",evaluationContexts:(a=(l=r.evaluation_contexts)!==null&&l!==void 0?l:r.evaluation_environments)!==null&&a!==void 0?a:[],flagKeys:Z(r.flag_keys)?r.flag_keys:void 0}})(t,n),!t.evaluation_environments||t.evaluation_contexts||this.Gu||(j_.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Gu=!0),L(t.flag_keys)||Z(t.flag_keys)||j_.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Zu}}var D_=Ie("[FeatureFlags]"),_i=Ie("[FeatureFlags]",{debugEnabled:!0}),Lf=`" failed. Feature flags didn't load in time.`,z_="connection_error",U_=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},V_=e=>{var t={};for(var n of Iu(e||{})){var r=n[1];r&&(t[n[0]]=r)}return t},gn=Ie("[Error tracking]"),HO=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:"],GO=["__firefox__","__gCrWeb"],B_="Refusing to render web experiment since the viewer is a likely bot",KO={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>Nc(t,e),not_regex:(e,t)=>!Nc(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e};class ht{get qi(){return this._instance.config}constructor(t){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments(i=>{ht.Qu("retrieved web experiments from the server"),n.Ju=new Map,i.forEach(s=>{if(s.feature_flag_key){var o;n.Ju&&(ht.Qu("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=n.Ju)==null||o.set(s.feature_flag_key,s));var a=n._instance.getFeatureFlag(s.feature_flag_key);ce(a)&&s.variants[a]&&n.Ku(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var u=s.variants[l];ht.Yu(u,n._instance)&&n.Ku(s.name,l,u.transforms)}})},r)},this._instance=t,this._instance.onFeatureFlags(r=>{this.onFeatureFlags(r)})}initialize(){}onFeatureFlags(t){if(this._is_bot())ht.Qu(B_);else if(!this.qi.disable_web_experiments){if(ne(this.Ju))return this.Ju=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ht.Qu("applying feature flags",t),t.forEach(n=>{var r;if(this.Ju&&(r=this.Ju)!=null&&r.has(n)){var i,s=this._instance.getFeatureFlag(n),o=(i=this.Ju)==null?void 0:i.get(n);s&&o!=null&&o.variants[s]&&this.Ku(o.name,s,o.variants[s].transforms)}})}}previewWebExperiment(){var t=ht.getWindowLocation();if(t!=null&&t.search){var n=So(t==null?void 0:t.search,"__experiment_id"),r=So(t==null?void 0:t.search,"__experiment_variant");n&&r&&(ht.Qu("previewing web experiments "+n+" && "+r),this.getWebExperiments(i=>{this.Xu(parseInt(n),r,i)},!1,!0))}}loadIfEnabled(){this.qi.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,n,r){if(this.qi.disable_web_experiments&&!r)return t([]);var i=this._instance.get_property("$web_experiments");if(i&&!n)return t(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.qi.token),method:"GET",timestampMode:"query",callback:s=>t(s.statusCode===200&&s.json&&s.json.experiments||[])})}Xu(t,n,r){var i=r.filter(s=>s.id===t);i&&i.length>0&&(ht.Qu("Previewing web experiment ["+i[0].name+"] with variant ["+n+"]"),this.Ku(i[0].name,n,i[0].variants[n].transforms))}static Yu(t,n){return!ne(t.conditions)&&ht.th(t,n)&&ht.eh(t)}static th(t,n){var r;if(ne(t.conditions)||ne((r=t.conditions)==null?void 0:r.url))return!0;var i=ht.getWindowLocation();if(i){var s,o,a,l=yE(n,i.href);return(s=t.conditions)==null||!s.url||KO[(o=(a=t.conditions)==null?void 0:a.urlMatchType)!==null&&o!==void 0?o:"icontains"](t.conditions.url,l)}return!1}static getWindowLocation(){return I==null?void 0:I.location}static eh(t){var n;if(ne(t.conditions)||ne((n=t.conditions)==null?void 0:n.utm))return!0;var r=NE();if(r.utm_source){var i,s,o,a,l,u,c,d,f=(i=t.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((s=t.conditions)==null||(s=s.utm)==null?void 0:s.utm_campaign)==r.utm_campaign,m=(o=t.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=t.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==r.utm_source,_=(l=t.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=t.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==r.utm_medium,p=(c=t.conditions)==null||(c=c.utm)==null||!c.utm_term||((d=t.conditions)==null||(d=d.utm)==null?void 0:d.utm_term)==r.utm_term;return f&&_&&p&&m}return!1}static Qu(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;n>i;i++)r[i-1]=arguments[i];D.info("[WebExperiments] "+t,r)}Ku(t,n,r){this._is_bot()?ht.Qu(B_):n!=="control"?r.forEach(i=>{if(i.selector){var s;ht.Qu("applying transform of variant "+n+" for experiment "+t+" ",i);var o=(s=document)==null?void 0:s.querySelectorAll(i.selector);o==null||o.forEach(a=>{var l=a;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)})}}):ht.Qu("Control variants leave the page unmodified.")}_is_bot(){return St&&this._instance?ZE(St,this.qi.custom_blocked_useragents):void 0}}var tn=Ie("[Conversations]"),wi="Conversations not available yet.",q_="console",cS="__posthogHandledLogsRequestError",jf=(e,t)=>{var n=e instanceof Error?e:new Error(t);return n[cS]=!0,n},W_=e=>!!e&&typeof e=="object"&&e[cS]===!0,hd={featureFlags:class{constructor(e){this.name="featureFlags",this.ih=!1,this.featureFlagEventHandlers=[],this.I=D_,this.rh={},this.nh={},this.sh=[],this.ah=!1,this.oh=!1,this.lh=0,this.uh=!1,this.hh=!1,this.dh=!1,this.fh=!1,this.ph=0,this.Tt=()=>{var t=this.gh();this.ph=0,t&&this.reloadFeatureFlags()},"get"in e?this.ts=e:(this.mh=new WO(e.config,e.ma()),this.ts=this.mh)}updateConfig(e,t){var n;(n=this.mh)==null||n.update(e,t)}setup(e){return this.Fl=e,this.I=e.logger.createLogger("[FeatureFlags]"),uS(e.kv.initialize(),()=>{this.Fl===e&&(this.Fl=void 0,this.ns=e,this.yh(e))})}yh(e){if(this.ns===e)return I&&Re(I,"online",this.Tt),this.bh=e.registerDynamicEventProperties(()=>this._h()?this.rh:this.nh),this.wh(),this.initialize()}destroy(){I==null||I.removeEventListener("online",this.Tt)}dispose(){var e;this.lh++,this.hh=!1,this.Fl=void 0,this.ns&&(this.kh(),(e=this.bh)==null||e.dispose(),this.bh=void 0,this.sh=[],I==null||I.removeEventListener("online",this.Tt),this.ns=void 0)}get qi(){return this.ts.get()}Sh(e){var t;return(t=this.ns)==null?void 0:t.kv.get(e)}Nr(e){this.xh(()=>{var t;return(t=this.ns)==null?void 0:t.kv.set(e)})}qr(e){this.xh(()=>{var t;return(t=this.ns)==null?void 0:t.kv.remove(e)})}xh(e){try{e()}catch(t){this.I.error("Failed to update feature flag persistence",t)}}wh(){var e={};for(var t of[Mi,Ai,Gs,Mn]){var n=this.Sh(t);L(n)||(e[t]=n)}this.rh=e;var r=$({},e),i=this.Sh(ir);if(i)for(var s of Object.entries(i))r["$feature/"+s[0]]=s[1];this.nh=r}_h(){var e=this.qi.cacheTtlMs;if(!e||0>=e)return!1;var t=this.Sh(Gi);return typeof t!="number"||Date.now()-t>e}Ch(){return!!this._h()&&(this.fh||this.oh||(this.fh=!0,this.I.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Th(){var e=this.qi.evaluationContexts;return e!=null&&e.length?e.filter(t=>{var n=t&&typeof t=="string"&&t.trim().length>0;return n||this.I.error("Invalid evaluation context found:",t,"Expected non-empty string"),n}):[]}Mh(){var e=this.qi.flagKeys;if(!L(e))return e.filter(t=>{var n=t&&typeof t=="string"&&t.trim().length>0;return n||this.I.error("Invalid flag key found:",t,"Expected non-empty string"),n})}initialize(){var e,t,n=this.qi,r=(e=(t=n.bootstrap)==null?void 0:t.featureFlags)!==null&&e!==void 0?e:{};if(Object.keys(r).length){var i,s,o=(i=(s=n.bootstrap)==null?void 0:s.featureFlagPayloads)!==null&&i!==void 0?i:{},a=Object.keys(r).filter(u=>!!r[u]).reduce((u,c)=>(u[c]=r[c]||!1,u),{}),l=Object.keys(o).filter(u=>a[u]).reduce((u,c)=>(u[c]=o[c],u),{});return this.Eh({featureFlags:a,featureFlagPayloads:l})}}updateFlags(e,t,n){var r,i,s=n!=null&&n.merge&&(r=this.Sh(ir))!==null&&r!==void 0?r:{},o=n!=null&&n.merge&&(i=this.Sh(Ai))!==null&&i!==void 0?i:{},a=$({},s,e),l=$({},o,t),u={};for(var c of Object.entries(a)){var d=c[0],f=c[1];u[d]={key:d,enabled:Ay(f),variant:Ny(f),reason:void 0,metadata:L(l==null?void 0:l[d])?void 0:{id:0,version:void 0,description:void 0,payload:l[d]}}}this.Eh({flags:u})}get hasLoadedFlags(){return this.ah}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.Sh(Xa),t=this.Sh(Mn),n=this.Sh(Ci);if(!n&&!t)return e||{};var r=_e({},e||{}),i=[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])];for(var s of i){var o,a,l=r[s],u=t==null?void 0:t[s],c=L(u)?(o=l==null?void 0:l.enabled)!==null&&o!==void 0&&o:!!u,d=L(u)?l==null?void 0:l.variant:typeof u=="string"?u:void 0,f=n==null?void 0:n[s],m=$({},l,{enabled:c,variant:c?d??(l==null?void 0:l.variant):void 0});c!==(l==null?void 0:l.enabled)&&(m.original_enabled=l==null?void 0:l.enabled),d!==(l==null?void 0:l.variant)&&(m.original_variant=l==null?void 0:l.variant),f&&(m.metadata=$({},l==null?void 0:l.metadata,{payload:f,original_payload:l==null||(a=l.metadata)==null?void 0:a.payload})),r[s]=m}return this.ih||(this.I.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:n,finalDetails:r}),this.ih=!0),r}getAllFeatureFlags(){var e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(n=>{var r=e[n];return{key:n,enabled:Ay(r),variant:Ny(r),payload:My(t[n])}})}getFlagVariants(){var e=this.Sh(ir),t=this.Sh(Mn);if(!t)return e||{};for(var n=_e({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.ih||(this.I.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:n}),this.ih=!0),n}getFlagPayloads(){var e=this.Sh(Ai),t=this.Sh(Ci);if(!t)return e||{};for(var n=_e({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.ih||(this.I.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),this.ih=!0),n}reloadFeatureFlags(){this.uh||this.qi.featureFlagsDisabled||this.gh()||this.Ih||(this.sh.slice().forEach(e=>{try{e()}catch(t){this.I.error("Error while running feature flags reloading callback",t)}}),this.Ih=setTimeout(()=>{this.Rh()},5))}kh(){clearTimeout(this.Ih),this.Ih=void 0}onReloading(e){return this.sh.push(e),()=>{this.sh=this.sh.filter(t=>t!==e)}}ensureFlagsLoaded(){this.ah||this.oh||this.Ih||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.uh=e}resetFlagCallReported(){this.qr(ar)}Rh(e){this.kh();var t=this.ns;if(t&&!this.qi.remoteRequestsDisabled&&!this.gh())if(this.oh)this.hh=!0;else{var n={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:$({},t.initialPersonProperties,this.Sh(yn)||{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this.Sh(Dn),timezone:zE()};L(t.deviceId)||(n.$device_id=t.deviceId),(e!=null&&e.disableFlags||this.qi.featureFlagsDisabled)&&(n.disable_flags=!0);var r=this.Th();r.length&&(n.evaluation_contexts=r);var i=this.Mh();L(i)||(n.flag_keys=i);var s=this.qi.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(s?"&only_evaluate_survey_feature_flags=true":""),a=this.lh;this.oh=!0;var l=()=>{this.hh&&(this.hh=!1,this.Rh())},u=c=>{this.oh=!1,a===this.lh&&(this.Nr({[Ks]:[z_]}),this.I.error("Feature flag request failed",c)),l()};try{t.sendRequest(o,{target:"flags",method:"POST",body:n,compression:this.qi.compression==="base64"?Et.Base64:void 0,sentAt:"body",timeoutMs:this.qi.requestTimeoutMs}).then(c=>{var d,f,m=(d=c.json)!==null&&d!==void 0?d:{},_=c.statusCode!==200;if(this.oh=!1,a===this.lh){if(this.Ph(c.statusCode),_||this.hh||(this.$anon_distinct_id=void 0),!n.disable_flags||this.hh){this.dh=!_;var p=[];c.error?p.push(c.error instanceof Error&&c.error.name==="AbortError"?"timeout":c.error instanceof Error?z_:"unknown_error"):c.statusCode!==200&&p.push("api_error_"+c.statusCode),m.errorsWhileComputingFlags&&p.push("errors_while_computing_flags");var y=!((f=m.quotaLimited)==null||!f.includes("feature_flags"));y&&p.push("quota_limited"),this.Nr({[Ks]:p}),y?this.I.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):n.disable_flags||this.Eh(m,_,{partialResponse:s}),l()}}else l()}).catch(u)}catch(c){u(c)}}}gh(){return ME(this.ph,3)}Ph(e){this.ph=AE(e,this.ph,3,()=>this.I.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t){var n;if(t===void 0&&(t={}),!t.fresh||this.dh)if(this.ah||this.getFlags()&&this.getFlags().length>0){if(!this.Ch()){var r=this.getFeatureFlagResult(e,t);return(n=r==null?void 0:r.variant)!==null&&n!==void 0?n:r==null?void 0:r.enabled}}else this.I.warn('getFeatureFlag for key "'+e+Lf)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t==null?void 0:t.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.dh)if(this.ah||this.getFlags()&&this.getFlags().length>0){if(!this.Ch()){var n,r=this.getFlagVariants(),i=e in r,s=r[e],o=this.getFlagPayloads()[e],a=String(s),l=this.Sh(Gs)||void 0,u=this.Sh(Gi)||void 0,c=this.Sh(ar)||{};if(this.qi.deduplicateCallsPerSession){var d,f=(d=this.ns)==null?void 0:d.session.sessionId,m=this.Sh(fa);f&&f!==m&&(c={},n=f)}if(t.send_event||!("send_event"in t))if(e in c&&c[e].includes(a))n&&this.Nr({[ar]:c,[fa]:n});else{var _,p,y,h,v,x,b,E,S,P,C,T;Z(c[e])?c[e].push(a):c[e]=[a],this.Nr($({[ar]:c},n?{[fa]:n}:{}));var R=this.getFeatureFlagDetails(e),N=[...(_=this.Sh(Ks))!==null&&_!==void 0?_:[]];L(s)&&N.push("flag_missing");var M={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:o??null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:(p=(y=this.qi.bootstrap)==null||(y=y.featureFlags)==null?void 0:y[e])!==null&&p!==void 0?p:null,$feature_flag_bootstrapped_payload:(h=(v=this.qi.bootstrap)==null||(v=v.featureFlagPayloads)==null?void 0:v[e])!==null&&h!==void 0?h:null,$used_bootstrap_value:!this.dh};L(R==null||(x=R.metadata)==null?void 0:x.has_experiment)||(M.$feature_flag_has_experiment=R.metadata.has_experiment),L(R==null||(b=R.metadata)==null?void 0:b.version)||(M.$feature_flag_version=R.metadata.version);var z,F=(E=R==null||(S=R.reason)==null?void 0:S.description)!==null&&E!==void 0?E:R==null||(P=R.reason)==null?void 0:P.code;F&&(M.$feature_flag_reason=F),R!=null&&(C=R.metadata)!=null&&C.id&&(M.$feature_flag_id=R.metadata.id),L(R==null?void 0:R.original_variant)&&L(R==null?void 0:R.original_enabled)||(M.$feature_flag_original_response=L(R.original_variant)?R.original_enabled:R.original_variant),R!=null&&(T=R.metadata)!=null&&T.original_payload&&(M.$feature_flag_original_payload=R==null||(z=R.metadata)==null?void 0:z.original_payload),N.length&&(M.$feature_flag_error=N.join(",")),this.Ah(M)}else n&&this.Nr({[ar]:c,[fa]:n});if(i)return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:My(o)}}}else this.I.warn('getFeatureFlagResult for key "'+e+Lf)}Ah(e){try{var t;(t=this.ns)==null||t.capture("$feature_flag_called",e).catch(n=>{this.I.error("Failed to capture feature flag call",n)})}catch(n){this.I.error("Failed to capture feature flag call",n)}}getRemoteConfigPayload(e,t){this.Fh(e,t)}Fh(e,t){var n=this;return Ce(function*(){var r=n.ns;if(r){var i={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},s=n.Th();s.length&&(i.evaluation_contexts=s);var o,a=n.Mh();L(a)||(i.flag_keys=a);try{var l,u=(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:i,compression:n.qi.compression==="base64"?Et.Base64:void 0,sentAt:"body",timeoutMs:n.qi.requestTimeoutMs})).json)==null?void 0:l.featureFlagPayloads;o=(u==null?void 0:u[e])||void 0}catch(c){return void n.I.error("Remote config feature flag request failed",c)}try{t(o)}catch(c){n.I.error("Remote config feature flag callback failed",c)}}})()}isFeatureEnabled(e,t){if(t===void 0&&(t={}),t.fresh&&!this.dh)return t.defaultValue;if(!(this.ah||this.getFlags()&&this.getFlags().length>0))return this.I.warn('isFeatureEnabled for key "'+e+Lf),t.defaultValue;var n=this.getFeatureFlag(e,t);return L(n)?t.defaultValue:!!n}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,n){this.Eh(e,t,n)}Eh(e,t,n){if(this.ns){this.ah=!0;var r=function(i,s,o,a,l,u){s===void 0&&(s={}),o===void 0&&(o={}),a===void 0&&(a={}),u===void 0&&(u=D_);var c=((S,P)=>{var C=S.flags;return C?$({},S,{featureFlags:Object.fromEntries(Object.keys(C).map(T=>{var R;return[T,(R=C[T].variant)!==null&&R!==void 0?R:C[T].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(C).filter(T=>C[T].enabled).filter(T=>{var R;return(R=C[T].metadata)==null?void 0:R.payload}).map(T=>{var R;return[T,(R=C[T].metadata)==null?void 0:R.payload]}))}):(S.featureFlags&&P.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),S)})(i,u),d=c.flags,f=c.featureFlags,m=c.featureFlagPayloads;if(f){var _=i.requestId,p=i.evaluatedAt;if(Z(f)){u.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var y={};if(f)for(var h=0;f.length>h;h++)y[f[h]]=!0;return{[Mi]:f,[ir]:y,[xc]:!1}}var v=f,x=m,b=d;if(l!=null&&l.partialResponse)v=$({},s,v),x=$({},o,x),b=$({},a,b);else if(i.errorsWhileComputingFlags)if(d){var E=new Set(Object.keys(d).filter(S=>{var P;return!((P=d[S])!=null&&P.failed)}));v=$({},s,Object.fromEntries(Object.entries(v).filter(S=>E.has(S[0])))),x=$({},o,Object.fromEntries(Object.entries(x||{}).filter(S=>E.has(S[0])))),b=$({},a,Object.fromEntries(Object.entries(b||{}).filter(S=>E.has(S[0]))))}else v=$({},s,v),x=$({},o,x),b=$({},a,b);return $({[Mi]:Object.keys(V_(v)),[ir]:v||{},[Ai]:x||{},[Xa]:b||{},[xc]:i.minimalFlagCalledEvents===!0},_?{[Gs]:_}:{},p?{[Gi]:p}:{})}}(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),n,this.I);r&&this.Nr(r),t||(this.fh=!1),this.Oh(t)}}override(e,t){t===void 0&&(t=!1),this.I.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.Lh(e)}Lh(e){if(this.ns){if(e===!1)return this.qr([Mn,Ci]),this.Oh(),void _i.info("All overrides cleared");if(Z(e))return this.Nr({[Mn]:U_(e)}),this.Oh(),void _i.info("Flag overrides set",{flags:e});if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,n=e;this.ih=!!((t=n.suppressWarning)!==null&&t!==void 0&&t);var r={},i=n.flags,s=n.payloads;return i&&(r[Mn]=Z(i)?U_(i):i),s&&(r[Ci]=s),Object.keys(r).length&&this.Nr(r),i===!1&&s===!1?this.qr([Mn,Ci]):i===!1?this.qr(Mn):s===!1&&this.qr(Ci),this.Oh(),i===!1?_i.info("Flag overrides cleared"):i&&_i.info("Flag overrides set",{flags:i}),void(s===!1?_i.info("Payload overrides cleared"):s&&_i.info("Payload overrides set",{payloads:s}))}if(e&&typeof e=="object")return this.Nr({[Mn]:e}),this.Oh(),void _i.info("Flag overrides set",{flags:e});this.I.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.I.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ah){var t=this.$h(),n=t.flags,r=t.flagVariants;try{e(n,r)}catch(i){this.I.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r=(this.Sh(Pu)||[]).find(l=>l.flagKey===e),i={["$feature_enrollment/"+e]:t},s={$feature_flag:e,$feature_enrollment:t,$set:i};r&&(s.$early_access_feature_name=r.name),n&&(s.$feature_enrollment_stage=n);var o=$({},this.getFlagVariants(),{[e]:t});this.Nr({[Mi]:Object.keys(V_(o)),[ir]:o,[yn]:$({},this.Sh(yn)||{},i)}),this.Oh();try{var a;(a=this.ns)==null||a.capture("$feature_enrollment_update",s).catch(l=>{this.I.error("Failed to capture early access feature enrollment",l)})}catch(l){this.I.error("Failed to capture early access feature enrollment",l)}}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var r=this.Sh(Pu);!r||t?this.Dh(e,n):e(r)}Dh(e,t){var n=this;return Ce(function*(){var r=n.ns;if(r){var i,s=t?"&"+t.map(a=>"stage="+a).join("&"):"";try{var o=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+s,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;n.Nr({[Pu]:i=o.json.earlyAccessFeatures})}catch(a){return void n.I.error("Early access feature request failed",a)}try{e(i)}catch(a){n.I.error("Early access feature callback failed",a)}}})()}$h(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(n=>t[n]),flagVariants:Object.keys(t).filter(n=>t[n]).reduce((n,r)=>(n[r]=t[r],n),{})}}Oh(e){this.wh();var t=this.$h(),n=t.flags,r=t.flagVariants;this.featureFlagEventHandlers.forEach(i=>{try{i(n,r,{errorsLoading:e})}catch(s){this.I.error("Error while running feature flags callback",s)}})}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.Nh(e,t)}Nh(e,t){t===void 0&&(t=!0);var n=this.Sh(yn)||{},r=(e==null?void 0:e.$set)||(e!=null&&e.$set_once?{}:e),i=e==null?void 0:e.$set_once,s={};if(i)for(var o in i)({}).hasOwnProperty.call(i,o)&&(o in n||(s[o]=i[o]));this.Nr({[yn]:$({},n,s,r)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=$({},this.Sh(yn)||{});e.forEach(r=>{delete n[r]}),this.Nr({[yn]:n}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){e===void 0&&(e=!0),this.qr(yn),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Sh(Dn)||{},r=$({},n);for(var i of Object.keys(e))r[i]=$({},n[i],e[i]);this.Nr({[Dn]:r}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.Sh(Dn)||{};this.Nr({[Dn]:$({},t,{[e]:{}})})}else this.qr(Dn)}reset(){this.lh++,this.hh=!1,this.rh={},this.nh={},this.ah=!1,this.uh=!1,this.dh=!1,this.$anon_distinct_id=void 0,this.kh(),this.ih=!1,this.ph=0}}},QO={sessionRecording:class{get qi(){return this._instance.config}get za(){return this._instance.persistence}get started(){var e;return!((e=this.qh)==null||!e.isStarted)}get status(){var e,t;return this.jh===na||this.jh===ru?this.jh:(e=(t=this.qh)==null?void 0:t.status)!==null&&e!==void 0?e:this.jh}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.jh=M_,this.Bh=void 0,this.Hh=!1,this.kt=(()=>{var t;if(j==null||!j.visibilityState||j.visibilityState==="visible")return!0;var n=I==null||(t=I.performance)==null||t.getEntriesByType==null?void 0:t.getEntriesByType("visibility-state");return!(n!=null&&n.length)||n.some(r=>r.name==="visible")})(),this.It=()=>{var t;(j==null?void 0:j.visibilityState)==="visible"&&(this.kt=!0,(t=this.qh)==null||t.setDocumentWasEverVisible==null||t.setDocumentWasEverVisible(!0))},this._instance=e,!this._instance.sessionManager)throw Yn.error("started without valid sessionManager"),new Error(Np+" started without valid sessionManager. This is a bug.");if(this.qi.cookieless_mode===lr)throw new Error(Np+' cannot be used with cookieless_mode="always"');j!=null&&j.addEventListener&&Re(j,"visibilitychange",this.It)}initialize(){this.startIfEnabledOrStop()}dispose(){this.Hh=!0,j==null||j.removeEventListener==null||j.removeEventListener("visibilitychange",this.It),this.stopRecording()}get Uh(){var e,t=!((e=this._instance.get_property(Oi))==null||!e.enabled),n=!this.qi.disable_session_recording,r=this.qi.disable_session_recording||this._instance.consent.isOptedOut();return I&&t&&n&&!r}startIfEnabledOrStop(e){var t;if(!(this.Hh||this.Uh&&(t=this.qh)!=null&&t.isStarted)){var n=!L(Object.assign)&&!L(Array.from);this.Uh&&n?(this.zh(e),Yn.info("starting")):(this.jh=M_,this.stopRecording())}}zh(e){var t,n,r;this.Uh&&(this.jh!==na&&this.jh!==ru&&(this.jh=A_),Y!=null&&(t=Y.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=Y.__PosthogExtensions__)!=null&&n.initSessionRecording?this.Wh(e):(r=Y.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.Vh,i=>{if(i)return this._instance.register_for_session({[xp]:!0}),Yn.error("could not load recorder",i);this.Wh(e)}))}stopRecording(){var e,t;(e=this.Bh)==null||e.call(this),this.Bh=void 0,(t=this.qh)==null||t.stop()}Gh(){var e,t;(e=this.Bh)==null||e.call(this),this.Bh=void 0,(t=this.qh)==null||t.discard()}Zh(){var e,t;(e=this.za)==null||e.unregister(bg),(t=this.za)==null||t.unregister(oE)}Qh(e,t){if(ne(e))return null;var n,r=Ge(e)?e:parseFloat(e);return typeof(n=r)!="number"||!Number.isFinite(n)||0>n||n>1?(Yn.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):r}Jh(e){if(this.za){var t,n,r=this.za,i=()=>{var s,o=e.sessionRecording===!1?void 0:e.sessionRecording,a=this.Qh((s=this.qi.session_recording)==null?void 0:s.sampleRate,"session_recording.sampleRate"),l=this.Qh(o==null?void 0:o.sampleRate,"remote config sampleRate"),u=a??l;ne(u)&&this.Zh();var c=o==null?void 0:o.minimumDurationMilliseconds;r.register({[Oi]:$({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:$({capturePerformance:e.capturePerformance},o==null?void 0:o.networkPayloadCapture),canvasRecording:{enabled:o==null?void 0:o.recordCanvas,fps:o==null?void 0:o.canvasFps,quality:o==null?void 0:o.canvasQuality},sampleRate:u,minimumDurationMilliseconds:L(c)?null:c,endpoint:o==null?void 0:o.endpoint,triggerMatchType:o==null?void 0:o.triggerMatchType,masking:o==null?void 0:o.masking,urlTriggers:o==null?void 0:o.urlTriggers,version:o==null?void 0:o.version,triggerGroups:o==null?void 0:o.triggerGroups})})};i(),(t=this.Bh)==null||t.call(this),this.Bh=(n=this._instance.sessionManager)==null?void 0:n.onSessionId(i)}}onRemoteConfig(e){var t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?t.sessionRecording===!1?(this.Jh(t),void this.Gh()):(this.Jh(t),void this.startIfEnabledOrStop()):(this.jh===na&&(this.jh=ru,Yn.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var n;t===void 0&&(t="log"),(n=this.qh)!=null&&n.log?this.qh.log(e,t):Yn.warn("log called before recorder was ready")}get Vh(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Oi);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Kh(){var e,t=this._instance.get_property(Oi);if(!t)return!1;try{e=typeof t=="object"?t:JSON.parse(t)}catch(n){return Yn.warn("persisted remote config for session recording is invalid and will be ignored",n),!1}return!ne(e.cache_timestamp)&&36e5>=Date.now()-e.cache_timestamp}Wh(e){var t,n,r;if(!this.Hh){if((t=Y.__PosthogExtensions__)==null||!t.initSessionRecording)return Yn.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[xp]:!0});var i;if(this.qh||(this.qh=(i=Y.__PosthogExtensions__)==null?void 0:i.initSessionRecording(this._instance,this.kt),this.qh._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Kh())return this.jh===ru||this.jh===na?void 0:(this.jh=na,Yn.info("persisted remote config is stale, requesting fresh config before starting"),void new UE(this._instance).load());this.jh=A_,(n=(r=this.qh).setDocumentWasEverVisible)==null||n.call(r,this.kt),this.qh.start(e)}}onRRwebEmit(e){var t;(t=this.qh)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.qh||(t=this.za)==null||t.register({[lE]:!0}),(e=this.qh)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.qh||(t=this.za)==null||t.register({[aE]:!0}),(e=this.qh)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.qh||(n=this.za)==null||n.register({[e==="url"?uE:cE]:!0}),(t=this.qh)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.qh)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.qh)==null||!n.tryAddCustomEvent(e,t))}}},YO={autocapture:class extends AO{constructor(e){super(new NO(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this.Yh=this.Xh()}initialize(){this.startIfEnabled()}get isEnabled(){var e=this.td();return!!(e.path||e.search||this.ed(e))}startIfEnabled(){this.isEnabled&&(D.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Yh=this.Xh(),this.startIfEnabled()}stop(){this.rd&&this.rd(),this.rd=void 0,this.nd&&this.nd(),this.nd=void 0,D.info("History API monitoring stopped")}monitorHistoryChanges(){I&&I.history&&(this.sd("pushState"),this.sd("replaceState"),this.ad(),this.ed()&&this.od())}sd(e){var t;if(I&&((t=I.history[e])==null||!t.__posthog_wrapped__)){var n=this;(function(r,i,s){try{if(!(i in r))return I_;var o={next:r[i]},a=s(function(){for(var l=arguments.length,u=new Array(l),c=0;l>c;c++)u[c]=arguments[c];return o.next.apply(this,u)});return vt(a)&&(a.prototype=a.prototype||{},Object.defineProperties(a,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:o}})),r[i]=a,()=>{if(r[i]!==a)for(var l=r[i];vt(l)&&l.__posthog_layer__;){var u=l.__posthog_layer__;if(u.next===a)return void(u.next=o.next);l=u.next}else r[i]=o.next}}catch{return I_}})(I.history,e,r=>function(i,s,o){r.call(this,i,s,o),n.ld(e)})}}Xh(){var e=I==null?void 0:I.location;if(e!=null&&e.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}td(){var e=this._instance.config.capture_pageview;return e==="history_change"?{path:!0}:Se(e)?e:{}}ed(e){return e===void 0&&(e=this.td()),!!e.hash&&!this._instance.config.disable_capture_url_hashes}ud(e){var t=this.td(),n=this.Yh;return!(!n||!(t.path&&e.pathname!==n.pathname||t.search&&e.search!==n.search||this.ed(t)&&e.hash!==n.hash))}ld(e){try{var t=this.Xh();if(!t)return;this.ud(t)&&this._instance.capture(xs,{navigation_type:e}),this.Yh=t}catch(n){D.error("Error capturing "+e+" pageview",n)}}ad(){if(!this.rd){var e=()=>{this.ld("popstate")};Re(I,"popstate",e),this.rd=()=>{I&&I.removeEventListener("popstate",e)}}}od(){if(!this.nd){var e=()=>{this.ld("hashchange")};Re(I,"hashchange",e),this.nd=()=>{I&&I.removeEventListener("hashchange",e)}}}},heatmaps:class{get qi(){return this.instance.config}constructor(e){var t;this.hd=!1,this.Qn=!1,this.dd=null,this.instance=e,this.hd=!((t=this.instance.persistence)==null||!t.props[up]),this.rageclicks=new lS(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return Se(this.qi.capture_heatmaps)&&this.qi.capture_heatmaps.flush_interval_milliseconds&&(e=this.qi.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return ne(this.qi.capture_heatmaps)?ne(this.qi.enable_heatmaps)?this.hd:this.qi.enable_heatmaps:this.qi.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Qn)return;FO.info("starting..."),this.vd(),this.It()}else{var e;clearInterval((e=this.dd)!==null&&e!==void 0?e:void 0),this.fd(),this.getAndClearBuffer()}}onRemoteConfig(e){if(e.ok){var t=e.config;if("heatmaps"in t){var n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[up]:n}),this.hd=n,this.startIfEnabled()}}}getAndClearBuffer(){var e=this.ft;return this.ft=void 0,e}pd(e){$f(e.originalEvent)&&this.ki(e.originalEvent,"deadclick")}It(){this.dd&&clearInterval(this.dd),this.dd=(j==null?void 0:j.visibilityState)==="visible"?setInterval(this.Oa.bind(this),this.flushIntervalMilliseconds):null}vd(){I&&j&&(this.gd=this.Oa.bind(this),Re(I,kc,this.gd),this.md=e=>this.ki(e||(I==null?void 0:I.event)),Re(j,"click",this.md,{capture:!0}),this.yd=e=>this.bd(e||(I==null?void 0:I.event)),Re(j,"mousemove",this.yd,{capture:!0}),this._d=new d_(this.instance,HI,this.pd.bind(this)),this._d.startIfEnabledOrStop(),this.wd=this.It.bind(this),Re(j,Cc,this.wd),this.Qn=!0)}fd(){var e;I&&j&&(this.gd&&I.removeEventListener(kc,this.gd),this.md&&j.removeEventListener("click",this.md,{capture:!0}),this.yd&&j.removeEventListener("mousemove",this.yd,{capture:!0}),this.wd&&j.removeEventListener(Cc,this.wd),clearTimeout(this.kd),(e=this._d)==null||e.stop(),this.Qn=!1)}Sd(e,t){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),s=function(o,a,l){for(var u=o;u&&ui(u)&&!Kt(u,"body");){if(u===l)return!1;var c=void 0;try{var d,f,m;c=(d=(f=(m=u.ownerDocument)==null?void 0:m.defaultView)!==null&&f!==void 0?f:I)==null?void 0:d.getComputedStyle(u).position}catch{return!1}if(J(a,c))return!0;u=SE(u)}return!1}(Sp(e),["fixed","sticky"],i);return{x:e.clientX+(s?0:r),y:e.clientY+(s?0:n),target_fixed:s,type:t}}ki(e,t){var n;if(t===void 0&&(t="click"),!t_(e.target)&&$f(e)){var r=this.Sd(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&kE(Sp(e),this.instance.config.rageclick)&&this.Nn($({},r,{type:"rageclick"})),this.Nn(r)}}bd(e){!t_(e.target)&&$f(e)&&(clearTimeout(this.kd),this.kd=setTimeout(()=>{this.Nn(this.Sd(e,"mousemove"))},500))}Nn(e){if(I){var t=this.qi.disable_capture_url_hashes?li(I.location.href):I.location.href,n=this.qi.custom_personal_data_properties,r=this.qi.mask_personal_data_properties?[...Co,...n||[]]:[],i=Za(t,r,el);this.ft=this.ft||{},this.ft[i]||(this.ft[i]=[]),this.ft[i].push(e)}}Oa(){this.ft&&!En(this.ft)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:d_,webVitalsAutocapture:class{constructor(e){var t;this.hd=!1,this.Qn=!1,this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.xd=()=>{clearTimeout(this.Cd),this.Cd=void 0,this.ft.metrics.length!==0&&(this._instance.capture("$web_vitals",$({$current_url:this.ft.url},this.ft.metrics.reduce((n,r)=>$({},n,{["$web_vitals_"+r.name+"_event"]:$({},r),["$web_vitals_"+r.name+"_value"]:r.value}),{}))),this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Td=n=>{var r;if(this.ft=this.ft||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},ne(n==null?void 0:n.name)||ne(n==null?void 0:n.value))yi.error("Invalid metric received",n);else{var i=typeof n.navigationURL=="string"?n.navigationURL:void 0,s=this.Md(i);if(!L(s)){var o=Ge(n.navigationId)||typeof n.navigationId=="string"?"navigation:"+n.navigationId:"url:"+s;if(!this.Ed||this.Ed>n.value){this.ft.navigationKey!==o&&(this.xd(),this.Cd=setTimeout(this.xd,this.flushToCaptureTimeoutMs)),L(this.ft.navigationKey)&&(this.ft.navigationKey=o,this.ft.url=s),this.ft.firstMetricTimestamp=L(this.ft.firstMetricTimestamp)?Date.now():this.ft.firstMetricTimestamp,n.attribution&&n.attribution.interactionTargetElement&&(n.attribution.interactionTargetElement=void 0);var a=(r=this._instance.sessionManager)==null?void 0:r.checkAndGetSessionAndWindowId(!0),l=$({},n,i?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});L(a)||(l.$session_id=a.sessionId,l.$window_id=a.windowId),this.ft.metrics.push(l),this.ft.metrics.length===this.allowedMetrics.length&&this.xd()}else yi.error("Ignoring metric with value >= "+this.Ed,n)}}},this.Id=()=>{if(!this.Qn){var n,r,i,s,o=Y.__PosthogExtensions__,a=o==null?void 0:o.postHogWebVitalsCallbacksByFlavor,l=(a==null?void 0:a[this.Rd])||(this.Rd==="web-vitals"&&L(a)?o==null?void 0:o.postHogWebVitalsCallbacks:void 0);if(L(l)||(n=l.onLCP,r=l.onCLS,i=l.onFCP,s=l.onINP),n&&r&&i&&s){var u={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&n(this.Td.bind(this),u),this.allowedMetrics.indexOf("CLS")>-1&&r(this.Td.bind(this),u),this.allowedMetrics.indexOf("FCP")>-1&&i(this.Td.bind(this),u),this.allowedMetrics.indexOf("INP")>-1&&s(this.Td.bind(this),u),this.Qn=!0}else yi.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.hd=!((t=this._instance.persistence)==null||!t.props[hp]),this.startIfEnabled()}get Pd(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,n=Se(this.Pd)?(e=this.Pd)==null?void 0:e.web_vitals_allowed_metrics:void 0;return ne(n)?((t=this._instance.persistence)==null?void 0:t.props[pp])||["CLS","FCP","INP","LCP"]:n}get flushToCaptureTimeoutMs(){return(Se(this.Pd)?this.Pd.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Se(this.Pd)?this.Pd.web_vitals_attribution:void 0;return e!=null&&e}get useSoftNavs(){var e=Se(this.Pd)?this.Pd.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get Ed(){var e=Se(this.Pd)&&Ge(this.Pd.__web_vitals_max_value)?this.Pd.__web_vitals_max_value:O_;return e>0&&6e4>=e?O_:e}get isEnabled(){var e=Ae==null?void 0:Ae.protocol;if(e!=="http:"&&e!=="https:")return yi.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=Se(this.Pd)?this.Pd.web_vitals:$t(this.Pd)?this.Pd:void 0;return $t(t)?t:this.hd}startIfEnabled(){this.isEnabled&&!this.Qn&&(yi.info("enabled, starting..."),this._s(this.Id))}onRemoteConfig(e){if(e.ok){var t=e.config;if("capturePerformance"in t){var n=Se(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=Se(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[hp]:n}),this._instance.persistence.register({[pp]:r})),this.hd=n,this.startIfEnabled()}}}get Rd(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}_s(e){var t=Y.__PosthogExtensions__,n=this.Rd,r=t==null?void 0:t.postHogWebVitalsCallbacksByFlavor;r!=null&&r[n]||n==="web-vitals"&&L(r)&&t!=null&&t.postHogWebVitalsCallbacks?e():t==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,n,i=>{i?yi.error("failed to load script",i):e()})}Md(e){var t=e||(I==null?void 0:I.location.href);if(t){var n=this._instance.config.disable_capture_url_hashes?li(t):t,r=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...Co,...r||[]]:[];return Za(n,i,el)}yi.error("Could not determine current URL")}}},XO={exceptionObserver:class{constructor(e){var t;this.Id=()=>{var n;if(I&&this.isEnabled&&(n=Y.__PosthogExtensions__)!=null&&n.errorWrappingFunctions){var r=Y.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Y.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=Y.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Ad&&this.qi.capture_unhandled_errors&&(this.Ad=r(this.captureException.bind(this))),!this.Fd&&this.qi.capture_unhandled_rejections&&(this.Fd=i(this.captureException.bind(this))),!this.Od&&this.qi.capture_console_errors&&(this.Od=s(this.captureException.bind(this)))}catch(o){ta.error("failed to start",o),this.Ld()}}},this._instance=e,this.$d=!((t=this._instance.persistence)==null||!t.props[cp]),this.oe=new DT($({},function(n){var r,i,s,o;return n===void 0&&(n={}),{refillRate:(r=(i=n.exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:n.__exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:1,bucketSize:(s=(o=n.exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:n.__exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:10}}(this._instance.config.error_tracking),{refillInterval:1e4,I:ta})),this.qi=this.Dd(),this.startIfEnabledOrStop()}Dd(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Se(e)?t=$({},t,e):(L(e)?this.$d:e)&&(t=$({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.qi.capture_console_errors||this.qi.capture_unhandled_errors||this.qi.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ta.info("enabled"),this.Ld(),this._s(this.Id)):this.Ld()}_s(e){var t,n;(t=Y.__PosthogExtensions__)!=null&&t.errorWrappingFunctions?e():(n=Y.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"exception-autocapture",r=>{if(r)return ta.error("failed to load script",r);e()})}Ld(){var e,t,n;(e=this.Ad)==null||e.call(this),this.Ad=void 0,(t=this.Fd)==null||t.call(this),this.Fd=void 0,(n=this.Od)==null||n.call(this),this.Od=void 0}onRemoteConfig(e){if(e.ok){var t=e.config;"autocaptureExceptions"in t&&(this.$d=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[cp]:this.$d}),this.qi=this.Dd(),this.startIfEnabledOrStop())}}onConfigChange(){this.qi=this.Dd()}captureException(e){var t,n,r,i=(t=e==null||(n=e.$exception_list)==null||(n=n[0])==null?void 0:n.type)!==null&&t!==void 0?t:"Exception";this.oe.consumeRateLimit(i)?ta.info("Skipping exception capture because of client rate limiting.",{exception:i}):(r=this._instance.exceptions)==null||r.sendExceptionEvent(e)}},exceptions:class{constructor(e){var t,n;this.Nd=[],this.qd=new iI([new fI,new xI,new pI,new hI,new _I,new yI,new gI,new wI],function(r){for(var i=arguments.length,s=new Array(i>1?i-1:0),o=1;i>o;o++)s[o-1]=arguments[o];return function(a,l){l===void 0&&(l=0);for(var u=[],c=a.split(` -`),d=l;c.length>d;d++){var f=c[d];if(1024>=f.length){var m=Ky.test(f)?f.replace(Ky,"$1"):f;if(!m.match(/\S*Error: /)){for(var _ of s){var p=_(m,r);if(p){u.push(p);break}}if(u.length>=50)break}}}return function(y){if(!y.length)return[];var h=Array.from(y);return h.reverse(),h.slice(0,50).map(v=>{return $({},v,{filename:v.filename||(x=h,x[x.length-1]||{}).filename,function:v.function||bo});var x})}(u)}}("web:javascript",lI,dI)),this._instance=e,this.Nd=(t=(n=this._instance.persistence)==null?void 0:n.get_property(dp))!==null&&t!==void 0?t:[],this.jd=_c(this.Bd()),this.Hd=new EI(this.jd)}onConfigChange(){this.jd=_c(this.Bd()),this.Hd.setConfig(this.jd)}onRemoteConfig(e){var t,n,r;if(e.ok){var i=e.config;if("errorTracking"in i){var s=(t=(n=i.errorTracking)==null?void 0:n.suppressionRules)!==null&&t!==void 0?t:[],o=(r=i.errorTracking)==null?void 0:r.captureExtensionExceptions;this.Nd=s,this._instance.persistence&&this._instance.persistence.register({[dp]:this.Nd,[fp]:o})}}}get Ud(){var e,t=!!this._instance.get_property(fp),n=this._instance.config.error_tracking.captureExtensionExceptions;return(e=n??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.qd.buildFromUnknown(e,{syntheticException:t==null?void 0:t.syntheticException,mechanism:{handled:t==null?void 0:t.handled}})}addExceptionStep(e,t){if(this.jd.enabled)try{if(!ce(e)||e.trim().length===0)return void gn.warn("Ignoring exception step because message must be a non-empty string");var n=function(s){if(!s)return{sanitizedProperties:{},droppedKeys:[]};var o=[];return{sanitizedProperties:Object.keys(s).reduce((a,l)=>bI.has(l)?(o.push(l),a):(a[l]=s[l],a),{}),droppedKeys:o}}(this.zd(t)),r=n.sanitizedProperties,i=n.droppedKeys;i.length>0&&gn.warn("Ignoring reserved exception step fields",{droppedKeys:i}),this.Hd.add($({[mc]:e,[yc]:new Date().toISOString()},r))}catch(s){gn.error("Failed to add exception step. Ignoring breadcrumb.",s)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this.Wd(t)){if(this.Vd(t))return this.Gd("Exception dropped: matched a suppression rule"),void gn.info("Skipping exception capture because a suppression rule matched");if(!this.Ud&&this.Zd(t))return this.Gd("Exception dropped: thrown by a browser extension"),void gn.info("Skipping exception capture because it was thrown by an extension");if(!this.Ud&&this.Qd(t))return this.Gd("Exception dropped: thrown by an injected browser script"),void gn.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Jd(t))return this.Gd("Exception dropped: thrown by the PostHog SDK"),void gn.info("Skipping exception capture because it was thrown by the PostHog SDK")}var n=this.jd.enabled&&ne(e.$exception_steps)?this.Kd(e):e,r=typeof(s=globalThis._posthogReleaseId)=="string"&&s.length>0?s:void 0;r&&(n.$release_id=r);try{var i=this._instance.capture("$exception",n,{_noTruncate:!0,_batchKey:"exceptionEvent",fl:!0});return i&&this.Hd.clear(),i}catch(o){return gn.error("Failed to capture exception event. Dropping this exception.",o),void this.Hd.clear()}}catch(o){return void gn.error("Failed to process exception event. Ignoring this exception.",o)}var s}Kd(e){try{var t=this.Hd.getAttachable();return t.length===0?e:$({},e,{$exception_steps:t})}catch(n){return gn.error("Failed to read buffered exception steps. Capturing exception without steps.",n),e}}Gd(e){this.jd.enabled&&this.Hd.add({[mc]:e,[yc]:new Date().toISOString()})}zd(e){return Se(e)?$({},e):{}}Bd(){var e,t;return(e=(t=this._instance.config.error_tracking)==null?void 0:t.exception_steps)!==null&&e!==void 0?e:{}}Vd(e){if(e.length===0)return!1;try{var t=e.reduce((n,r)=>{var i=r.type,s=r.value;return ce(i)&&i.length>0&&n.$exception_types.push(i),ce(s)&&s.length>0&&n.$exception_values.push(s),n},{$exception_types:[],$exception_values:[]});return this.Nd.some(n=>{var r=n.values.map(i=>{var s=tS[i.operator],o=t[i.key];if(!s||!o)return!1;var a=Z(i.value)?i.value:[i.value];return a.length>0&&s(a,o)});return n.type==="OR"?r.some(Boolean):r.every(Boolean)})}catch(n){return gn.warn("Failed to evaluate suppression rules. Capturing the exception.",n),!1}}Zd(e){return e.flatMap(t=>{var n,r;return(n=(r=t.stacktrace)==null?void 0:r.frames)!==null&&n!==void 0?n:[]}).some(t=>{var n=t.filename;return!!n&&HO.some(r=>n.startsWith(r))})}Qd(e){return e.some(t=>{var n=t.value;return ce(n)&&GO.some(r=>n.includes(r))})}Jd(e){if(e.length>0){var t,n,r,i,s=(t=(n=e[0].stacktrace)==null?void 0:n.frames)!==null&&t!==void 0?t:[],o=s[s.length-1];return(r=o==null||(i=o.filename)==null?void 0:i.includes("posthog.com/static"))!==null&&r!==void 0&&r}return!1}Wd(e){return!ne(e)&&Z(e)}}},JO=$({productTours:class{get za(){return this._instance.persistence}constructor(e){this.Yd=null,this.Xd=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(e.ok){var t=e.config;if("productTours"in t){var n,r;if(this.za&&this.za.register({[xg]:!!t.productTours}),!Ff(this._instance))return!this.Yd&&ne((n=this.za)==null?void 0:n.props[da])||iu.info("product tours disabled; stopping and clearing cached tours"),(r=this.Yd)==null||r.stop(),this.Yd=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Yd&&Ff(this._instance)&&this._s(()=>this.tv())}_s(e){var t,n;(t=Y.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=Y.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"product-tours",r=>{r?iu.error("Could not load product tours script",r):e()})}tv(){var e;!this.Yd&&(e=Y.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Yd=Y.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!Z(this.Xd)||t){var n=this.za;if(n){var r=n.props[da];if(Z(r)&&!t)return this.Xd=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:i=>{if(Ff(this._instance)){var s=i.statusCode;if(s!==200||!i.json){var o="Product Tours API could not be loaded, status: "+s;return s===0?i.error||iu.warn(o):iu.error(o),void e([],{isLoaded:!1,error:o})}var a=Z(i.json.product_tours)?i.json.product_tours:[];this.Xd=a,n&&n.register({[da]:a}),e(a,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this.Xd,{isLoaded:!0})}getActiveProductTours(e){ne(this.Yd)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Yd.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Yd)==null||t.showTourById(e)}previewTour(e){this.Yd?this.Yd.previewTour(e):this._s(()=>{var t;this.tv(),(t=this.Yd)==null||t.previewTour(e)})}dismissProductTour(){var e;(e=this.Yd)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Yd)==null||e.nextStep()}previousStep(){var e;(e=this.Yd)==null||e.previousStep()}clearCache(){var e;this.Xd=null,(e=this.za)==null||e.unregister(da)}resetTour(e){var t;(t=this.Yd)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Yd)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Yd)==null||t.cancelPendingTour(e)}}},hd),ZO={siteApps:class{constructor(e){this.ev=0,this._instance=e,this.iv=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}rv(e,t){if(t){var n=this.globalsForEvent(t);this.iv.push(n),this.iv.length>1e3&&(this.iv=this.iv.slice(10))}}get siteAppLoaders(){var e;return(e=Y._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.rv.bind(this));this.nv=()=>{e(),this.iv=[],this.nv=void 0}}}globalsForEvent(e){var t,n,r,i,s,o,a;if(!e)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(var d of Object.entries(c)){var f=d[0];l[f]={id:u[f],type:f,properties:d[1]}}var m=e.$set_once,_=e.$set;return{event:$({},bb(e,LO),{properties:$({},e.properties,_?{$set:$({},(t=(n=e.properties)==null?void 0:n.$set)!==null&&t!==void 0?t:{},_)}:{},m?{$set_once:$({},(r=(i=e.properties)==null?void 0:i.$set_once)!==null&&r!==void 0?r:{},m)}:{}),elements_chain:(s=(o=e.properties)==null?void 0:o.$elements_chain)!==null&&s!==void 0?s:"",distinct_id:(a=e.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}sv(e){var t,n=(t=e.tagName)==null?void 0:t.toLowerCase();return n==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(On.error("prepare_external_dependency_stylesheet returned null"),null):n==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(On.error("prepare_external_dependency_script returned null"),null):e}av(){var e,t,n,r,i,s,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=j==null?void 0:j.defaultView,u=l==null||(e=l.Node)==null?void 0:e.prototype;if(!l||!u)return()=>{};if(this.ev++,this.ov)return this.lv();var c=[],d=this,f=new WeakSet,m=(y,h,v)=>{if(y!=null&&y[h]){var x=y[h];y[h]=v(x),c.push(()=>{y[h]=x})}},_=y=>{if(f.has(y))return y;var h=d.sv(y);return h&&f.add(h),h},p=y=>y.map(h=>typeof h=="string"?h:_(h)).filter(h=>!rt(h));return m(u,"appendChild",y=>function(h){var v=_(h);return v?y.call(this,v):h}),m(u,"insertBefore",y=>function(h,v){var x=_(h);return x?y.call(this,x,v):h}),m(u,"replaceChild",y=>function(h,v){var x=_(h);return x?y.call(this,x,v):v}),[(t=l.Element)==null?void 0:t.prototype,(n=l.Document)==null?void 0:n.prototype,(r=l.DocumentFragment)==null?void 0:r.prototype].forEach(y=>{m(y,"append",h=>function(){for(var v=arguments.length,x=new Array(v),b=0;v>b;b++)x[b]=arguments[b];return h.apply(this,p(x))}),m(y,"prepend",h=>function(){for(var v=arguments.length,x=new Array(v),b=0;v>b;b++)x[b]=arguments[b];return h.apply(this,p(x))})}),[(i=l.Element)==null?void 0:i.prototype,(s=l.CharacterData)==null?void 0:s.prototype,(o=l.DocumentType)==null?void 0:o.prototype].forEach(y=>{m(y,"before",h=>function(){for(var v=arguments.length,x=new Array(v),b=0;v>b;b++)x[b]=arguments[b];return h.apply(this,p(x))}),m(y,"after",h=>function(){for(var v=arguments.length,x=new Array(v),b=0;v>b;b++)x[b]=arguments[b];return h.apply(this,p(x))}),m(y,"replaceWith",h=>function(){for(var v=arguments.length,x=new Array(v),b=0;v>b;b++)x[b]=arguments[b];var E=p(x);return x.length&&!E.length?void 0:h.apply(this,E)})}),m((a=l.Element)==null?void 0:a.prototype,"insertAdjacentElement",y=>function(h,v){var x=_(v);return x?y.call(this,h,x):null}),this.ov=()=>{c.forEach(y=>y()),this.ov=void 0},this.lv()}lv(){var e=!1;return()=>{var t;e||(e=!0,this.ev--,this.ev===0&&((t=this.ov)==null||t.call(this)))}}uv(e,t){t===void 0&&(t=!0);var n=this.av();try{var r=e(n);return t&&n(),r}catch(i){throw n(),i}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var o;!t.errored&&this.iv.length&&(On.info("Processing "+this.iv.length+" events for site app with id "+e.id),this.iv.forEach(a=>this.uv(()=>t.processEvent==null?void 0:t.processEvent(a))),t.processedBuffer=!0),Object.values(this.apps).every(a=>a.processedBuffer||a.errored)&&((o=this.nv)==null||o.call(this))},r=!1,i=o=>{t.errored=!o,t.loaded=!0,On.info("Site app with id "+e.id+" "+(o?"loaded":"errored")),r&&n()};try{var s=this.uv(o=>e.init({posthog:this._instance,callback(a){o(),i(a)}}),!1).processEvent;s&&(t.processEvent=s),r=!0}catch(o){On.error(N_+e.id,o),i(!1)}if(r&&t.loaded)try{n()}catch(o){On.error("Error while processing buffered events PostHog app with config id "+e.id,o),t.errored=!0}}hv(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}dv(e){var t=this;if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e),r=function(s){try{t.uv(()=>s.processEvent==null?void 0:s.processEvent(n))}catch(o){On.error("Error while processing event "+e.event+" for site app "+s.id,o)}};for(var i of Object.values(this.apps))r(i)}}onRemoteConfig(e){var t,n,r,i=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.hv(),void this._instance.on("eventCaptured",l=>this.dv(l))):void On.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this.nv)==null||n.call(this),e.ok){var s=e.config;if((r=s.siteApps)!=null&&r.length)if(this.isEnabled){var o=function(){var l,u=a.id,c=a.url;Y["__$$ph_site_app_"+u]=i._instance,(l=Y.__PosthogExtensions__)==null||l.loadSiteApp==null||l.loadSiteApp(i._instance,c,d=>{if(d)return On.error(N_+u,d)})};for(var a of s.siteApps)o()}else On.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},eM={tracingHeaders:class{constructor(e){this.vv=void 0,this.fv=void 0,this.pv=void 0,this.Id=()=>{var t,n,r=this.gv();r?(L(this.vv)&&(this.vv=(t=Y.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchXHR(r,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),L(this.fv)&&(this.fv=(n=Y.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null?void 0:n._patchFetch(r,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Ld()},this._instance=e}initialize(){this.startIfEnabledOrStop()}_s(e){var t,n;(t=Y.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns?e():(n=Y.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"tracing-headers",r=>{if(r)return $O.error("failed to load script",r);e()})}mv(){var e,t;return(e=(t=this._instance.config.tracing_headers)!==null&&t!==void 0?t:this._instance.config.addTracingHeaders)!==null&&e!==void 0?e:this._instance.config.__add_tracing_headers}gv(){var e=this.mv();return Z(e)?(Z(this.pv)?this.pv.splice(0,this.pv.length,...e):this.pv=[...e],e.length>0?this.pv:void 0):(Z(this.pv)&&this.pv.splice(0),this.pv=e||void 0,this.pv)}Ld(){var e,t;(e=this.vv)==null||e.call(this),(t=this.fv)==null||t.call(this),this.vv=void 0,this.fv=void 0}startIfEnabledOrStop(){this.gv()?this._s(this.Id):this.Ld()}}},tM=$({surveys:class extends jO{constructor(e){var t;super(new BO(e),{get projectToken(){return t.config.token},kv:new VO(t=e)}),this._instance=e}Nl(e,t){var n=t.query?bl(e,t.query):e;return new Promise(r=>{var i;this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor((i=t.target)!==null&&i!==void 0?i:"api",n),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:r})})}}},hd),nM={toolbar:class{constructor(e){this.instance=e}yv(e){Y.ph_toolbar_state=e}bv(){var e;return(e=Y.ph_toolbar_state)!==null&&e!==void 0?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,n){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),Ep(this.instance.config)||!I||!j)return!1;e=e??I.location,n=n??I.history;try{if(!t){try{I.localStorage.setItem("test","test"),I.localStorage.removeItem("test")}catch{return!1}t=I==null?void 0:I.localStorage}var r,i=qO||Ic(e.hash,"__posthog")||Ic(e.hash,"state"),s=i?Xy(()=>JSON.parse(atob(decodeURIComponent(i))))||Xy(()=>JSON.parse(decodeURIComponent(i))):null;return s&&s.action==="ph_authorize"?((r=s).source="url",r&&Object.keys(r).length>0&&(s.desiredHash?e.hash=s.desiredHash:n?n.replaceState(n.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem(F_)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}_v(e){var t=Y.ph_load_toolbar||Y.ph_load_editor;!ne(t)&&vt(t)?t(e,this.instance):L_.warn("No toolbar load function found")}loadToolbar(e){var t=!(j==null||!j.getElementById(_E));if(!I||t)return!1;var n=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,r=$({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(I.localStorage.setItem(F_,JSON.stringify($({},r,{source:void 0}))),this.bv()===2)this._v(r);else if(this.bv()===0){var i;this.yv(1),(i=Y.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"toolbar",s=>{if(s)return L_.error("[Toolbar] Failed to load",s),void this.yv(0);this.yv(2),this._v(r)}),Re(I,"turbolinks:load",()=>{this.yv(0),this.loadToolbar(r)})}return!0}wv(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}},rM=$({experiments:ht},hd),iM={conversations:class{constructor(e){this.Sv=void 0,this._conversationsManager=null,this.xv=!1,this.Me=null,this.Cv=!1,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations&&(this.Tv=e.ok,e.ok)){var t=e.config.conversations;ne(t)||($t(t)?this.Sv=t:(this.Sv=t.enabled,this.Me=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Sv=void 0,this.Me=null,this.Tv=void 0,this.Cv=!1}loadIfEnabled(){if(!(this._conversationsManager||this.xv||this._instance.config.disable_conversations||Ep(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=Y==null?void 0:Y.__PosthogExtensions__;if(e&&!L(this.Sv)&&this.Sv)if(this.Me&&this.Me.token){this.xv=!0;try{var t=e.initConversations;if(t)return this.Mv(t),void(this.xv=!1);var n=e.loadExternalDependency;if(!n)return void this.Ev(Eg);n(this._instance,"conversations",r=>{r||!e.initConversations?this.Ev("Could not load conversations script",r):this.Mv(e.initConversations),this.xv=!1})}catch(r){this.Ev("Error initializing conversations",r),this.xv=!1}}else tn.error("Conversations enabled but missing token in remote config.")}}Mv(e){if(this.Me)try{this._conversationsManager=e(this.Me,this._instance),this.Cv=!1,tn.info("Conversations loaded successfully")}catch(t){this.Ev("Error completing conversations initialization",t)}else tn.error("Cannot complete initialization: remote config is null")}Ev(e,t){tn.error(e,t),this._conversationsManager=null,this.xv=!1,this.Cv=!0}show(){this._conversationsManager?this._conversationsManager.show():tn.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Sv===!0&&!rt(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Ep(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.Tv===!1?"remote_config_failed":L(this.Sv)?this.Tv?"disabled_in_project":"remote_config_pending":this.Sv?ne(this.Me)||!this.Me.token?"missing_token":Y!=null&&Y.__PosthogExtensions__?this.xv?"initializing":this.Cv?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,n){var r=this;return Ce(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(tn.warn(wi),null)})()}getMessages(e,t){var n=this;return Ce(function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(tn.warn(wi),null)})()}markAsRead(e){var t=this;return Ce(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(tn.warn(wi),null)})()}getTickets(e){var t=this;return Ce(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(tn.warn(wi),null)})()}requestRestoreLink(e){var t=this;return Ce(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(tn.warn(wi),null)})()}restoreFromToken(e){var t=this;return Ce(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(tn.warn(wi),null)})()}restoreFromUrlToken(){var e=this;return Ce(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(tn.warn(wi),null)})()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}Sl(){var e;(e=this._conversationsManager)==null||e.setIdentity()}xl(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},sM={logs:class{constructor(e){var t,n=this;this.Iv=!1,this.Rv=!1,this.I=Ie("[logs]"),this.Pv=$({},this.I,{error(){for(var r=arguments.length,i=new Array(r),s=0;r>s;s++)i[s]=arguments[s];i.some(W_)||n.I.error(...i)}}),this.ka=[],this.Av=[],this.ph=0,this.Fv=()=>{var r,i;this.ph=0,(r=this.Ov)==null||r.onReconnect(),(i=this.Lv)==null||i.onReconnect()},this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Iv=!0),I&&Re(I,"online",this.Fv)}$v(e,t,n,r){var i,s=function(o,a){var l,u,c,d,f,m,_,p=(l=o==null?void 0:o.flushIntervalMs)!==null&&l!==void 0?l:3e3,y=(u=o==null?void 0:o.maxBufferSize)!==null&&u!==void 0?u:100,h=a!=null&&a.consoleCapture?void 0:(c=o==null?void 0:o.maxLogsPerInterval)!==null&&c!==void 0?c:1e3,v=L(h)?Math.max(y,2048):Math.max(y,h),x=o==null?void 0:o.resourceAttributes;return{serviceName:(d=(f=x==null?void 0:x["service.name"])!==null&&f!==void 0?f:o==null?void 0:o.serviceName)!==null&&d!==void 0?d:a==null?void 0:a.serviceNameDefault,serviceVersion:(m=x==null?void 0:x["service.version"])!==null&&m!==void 0?m:o==null?void 0:o.serviceVersion,environment:(_=x==null?void 0:x["deployment.environment"])!==null&&_!==void 0?_:o==null?void 0:o.environment,resourceAttributes:x,beforeSend:o==null?void 0:o.beforeSend,flushIntervalMs:p,maxBufferSize:y,maxQueueSize:v,maxBatchRecordsPerPost:100,rateCapWindowMs:p,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}((i=this._instance)==null||(i=i.config)==null?void 0:i.logs,n);return[new tI(this.Dv(e,t),s,this.Pv,()=>this.Nv(),o=>o(),void 0,r),s]}qv(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.Ov||this.jv!==t){var n;(n=this.Ov)==null||n.reset(),this.jv=t;var r=this.$v(()=>this.ka,i=>{this.ka=i});this.Ov=r[0],this.Bv=r[1]}return this.Ov}Hv(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.Lv||this.Uv!==t){var n;(n=this.Lv)==null||n.reset(),this.Uv=t;var r=this.$v(()=>this.Av,i=>{this.Av=i},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},q_);this.Lv=r[0],this.zv=r[1]}return this.Lv}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t;if(e.ok){var n=(t=e.config.logs)==null?void 0:t.captureConsoleLogs;!ne(n)&&n&&(this.Iv=!0,this.loadIfEnabled())}}reset(){var e,t;this.ka=[],(e=this.Ov)==null||e.reset(),this.Av=[],(t=this.Lv)==null||t.reset(),this.ph=0}captureLog(e){this.qv().captureLog(e)}vi(e){this.Hv().captureLog(e)}get logger(){return this.Wv||(this.Wv={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this.Wv}flushLogs(e){e?this.Vv(e):(this.Ov&&this.Ov.flush().catch(t=>this.Gv(t)),this.Lv&&this.Lv.flush().catch(t=>this.Gv(t)))}Gv(e){W_(e)||this.I.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this.Iv&&!this.Rv){var e=Y==null?void 0:Y.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",n=>{var r;n||(r=e.logs)==null||!r.initializeLogs?this.I.error("Could not load logs script",n):(e.logs.initializeLogs(this._instance),this.Rv=!0)}):this.I.error(Eg)}else this.I.error("PostHog Extensions not found.")}}Dv(e,t){var n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:r=>r===nr.LogsQueue?e():void 0,setPersistedProperty(r,i){var s;r===nr.LogsQueue&&t((s=i)!==null&&s!==void 0?s:[])},Mn:r=>this.Mn(r),getLibraryId:()=>Ee.LIB_NAME,getLibraryVersion:()=>Ee.LIB_VERSION}}Mn(e){return new Promise(t=>{if(ME(this.ph,3))t({kind:"fatal",error:jf(void 0,"logs endpoint is unreachable, dropping batch")});else{var n=!1,r=s=>{n||(n=!0,clearTimeout(i),t(s))},i=setTimeout(()=>{this.I.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:jf(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.Zv(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:s=>{var o=s.statusCode;if(this.Qv(o),o>=200&&300>o)r({kind:"ok"});else if(o===413)r({kind:"too-large"});else if(o!==0&&o!==408&&o!==429&&500>o)r({kind:"fatal",error:new Error("logs request failed with status "+o)});else{var a;o===0?(s.error||this.I.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:jf(s.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:(a=s.error)!==null&&a!==void 0?a:new Error("logs request failed with status "+o)})}}})}})}Qv(e){(e!==0||this._instance.__loaded)&&(this.ph=AE(e,this.ph,3,()=>this.I.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}Vv(e){this.ka.length>0&&this.Jv(e,this.ka,this.Bv,Ee.LIB_NAME,t=>{this.ka=t}),this.Av.length>0&&this.Jv(e,this.Av,this.zv,q_,t=>{this.Av=t})}Jv(e,t,n,r,i){if(t.length!==0){var s=t.map(a=>a.record);i([]);var o=tE(s,eE(n,Ee.LIB_NAME,Ee.LIB_VERSION),r,Ee.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Zv(),data:o,compression:"best-available",batchKey:"logs",transport:e})}}Zv(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Nv(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var n=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=n.windowId,i=n.sessionStartTimestamp,s=n.lastActivityTimestamp;t.sessionId=n.sessionId,t.windowId=r,ne(i)||(t.sessionStartTimestamp=i),ne(s)||(t.lastActivityTimestamp=s)}if(Y!=null&&(e=Y.location)!=null&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?li(Y.location.href):Y.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}},oM={metrics:class{constructor(e){this.I=Ie("[metrics]"),this._instance=e}initialize(){}qv(){var e,t,n=(e=this._instance)==null||(e=e.config)==null?void 0:e.metrics;return this.Ov&&this.jv===n||((t=this.Ov)==null||t.reset(),this.jv=n,this.Ov=new nI(this.Dv(),function(r){var i,s,o,a,l,u=r==null?void 0:r.resourceAttributes;return{serviceName:(i=u==null?void 0:u["service.name"])!==null&&i!==void 0?i:r==null?void 0:r.serviceName,serviceVersion:(s=u==null?void 0:u["service.version"])!==null&&s!==void 0?s:r==null?void 0:r.serviceVersion,environment:(o=u==null?void 0:u["deployment.environment"])!==null&&o!==void 0?o:r==null?void 0:r.environment,resourceAttributes:u,beforeSend:r==null?void 0:r.beforeSend,flushIntervalMs:(a=r==null?void 0:r.flushIntervalMs)!==null&&a!==void 0?a:1e4,maxSeriesPerFlush:(l=r==null?void 0:r.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}}(n),this.I)),this.Ov}count(e,t,n){t===void 0&&(t=1),this.qv().count(e,t,n)}gauge(e,t,n){this.qv().gauge(e,t,n)}histogram(e,t,n){this.qv().histogram(e,t,n)}flush(e){if(!this.Ov)return Promise.resolve();if(e){var t=this.Ov.drainWindow();return t&&this.Un(t,e),Promise.resolve()}return this.Ov.flush().catch(n=>this.I.error("PostHog metrics flush failed:",n))}reset(){var e;(e=this.Ov)==null||e.reset()}Dv(){var e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Un:n=>t.Un(n),getLibraryId:()=>Ee.LIB_NAME,getLibraryVersion:()=>Ee.LIB_VERSION}}Un(e,t){return new Promise(n=>{var r=!1,i=o=>{r||(r=!0,clearTimeout(s),n(o))},s=setTimeout(()=>i({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request($({method:"POST",url:this.Kv(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t},{fireCallbackOnDrop:!0,callback(o){var a=o.statusCode;if(a>=200&&300>a)i({kind:"ok"});else if(a===413)i({kind:"too-large"});else if(a!==0&&a!==408&&a!==429&&500>a)i({kind:"fatal",error:new Error("metrics request failed with status "+a)});else{var l;i({kind:"retry-later",error:(l=o.error)!==null&&l!==void 0?l:new Error("metrics request failed with status "+a)})}}}))})}Kv(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},aM=$({},hd,QO,YO,XO,JO,ZO,tM,eM,nM,rM,iM,sM,oM);qt.__defaultExtensionClasses=$({},aM);var lM=function(){Ee.SDK_DIST_CHANNEL="npm";var e=Ra[bs]=new qt;return function(){function t(){t.done||(t.done=!0,aS=!1,ve(Ra,function(n){n._dom_loaded()}))}j!=null&&j.addEventListener?j.readyState==="complete"?t():Re(j,"DOMContentLoaded",t,{capture:!1}):I&&D.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}(),dS;function uM(e){dS=e}function cM(){return dS}var dM=g.createContext({get client(){return cM()},bootstrap:void 0}),Df=function(e){return typeof e=="function"},fM=function(e){return e===void 0},$p=function(e,t){return $p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},$p(e,t)};function hM(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");$p(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Au=function(e){var t=Object.prototype.toString.call(e);return e instanceof Error||t==="[object Error]"||t==="[object Exception]"||t==="[object DOMException]"||t==="[object DOMError]"},pM=function(e,t){for(var n=new WeakSet,r=e;!n.has(r);){if(n.add(r),!Au(r.cause)){fM(r.cause)||(t.cause=r.cause),r.cause=t;return}r=r.cause}},vM=function(e,t){if(!t)return e;var n=new Error(Au(e)?e.message:"Primitive value captured as exception: ".concat(String(e)));return n.name="React ErrorBoundary ".concat(Au(e)?e.name:"Error"),n.stack=t,Au(e)?(pM(e,n),e):n},gM={componentStack:null,exceptionEvent:null,error:null},mM={INVALID_FALLBACK:"[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element."};(function(e){hM(t,e);function t(n){var r=e.call(this,n)||this;return r.state=gM,r}return t.prototype.componentDidCatch=function(n,r){var i=this.props.additionalProperties,s;Df(i)?s=i(n,r):typeof i=="object"&&(s=i);var o=this.context.client,a=r.componentStack,l=o.captureException(vM(n,a),s);this.setState({error:n,componentStack:a??null,exceptionEvent:l})},t.prototype.render=function(){var n=this.props,r=n.children,i=n.fallback,s=this.state;if(s.componentStack==null)return Df(r)?r():r;var o=Df(i)?q.createElement(i,{error:s.error,componentStack:s.componentStack,exceptionEvent:s.exceptionEvent}):i;return q.isValidElement(o)?o:(console.warn(mM.INVALID_FALLBACK),q.createElement(q.Fragment,null))},t.contextType=dM,t})(q.Component);uM(lM);class fS extends q.Component{constructor(){super(...arguments);kr(this,"state",{failed:!1,resetKey:this.props.resetKey})}static getDerivedStateFromError(){return{failed:!0}}static getDerivedStateFromProps(n,r){return n.resetKey===r.resetKey?null:{failed:!1,resetKey:n.resetKey}}componentDidCatch(n){console.error("The application could not render",n)}render(){if(!this.state.failed)return this.props.children;const n=w.jsxs("div",{className:"page",role:"alert",children:[w.jsx("h1",{children:"This page could not load"}),w.jsx("p",{children:"The site may have been updated while this tab was open."}),w.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>window.location.reload(),children:"Reload page"})]});return this.props.resetKey===void 0?w.jsx("main",{children:n}):n}}const zf="pwc:chunk-reload-at",hS=6e4;function yM(e,t){if(!e)return!0;const n=Number(e);return!Number.isFinite(n)||t-n>=hS}function _M(){if(typeof window>"u")return()=>{};const e=n=>{const r=Date.now();yM(sessionStorage.getItem(zf),r)&&(n.preventDefault(),sessionStorage.setItem(zf,String(r)),window.location.reload())};window.addEventListener("vite:preloadError",e);const t=window.setTimeout(()=>sessionStorage.removeItem(zf),hS);return()=>{window.removeEventListener("vite:preloadError",e),window.clearTimeout(t)}}const wM="modulepreload",xM=function(e){return"/"+e},H_={},ae=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(l=>{if(l=xM(l),l in H_)return;H_[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":wM,u||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((f,m)=>{d.addEventListener("load",f),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})};/** +`+s.stack}return{value:e,source:t,stack:i,digest:null}}function rf(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function jh(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var qR=typeof WeakMap=="function"?WeakMap:Map;function Hx(e,t,n){n=hr(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){sc||(sc=!0,Kh=r),jh(e,t)},n}function Gx(e,t,n){n=hr(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){jh(e,t)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){jh(e,t),typeof r!="function"&&(ti===null?ti=new Set([this]):ti.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function uy(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new qR;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=iT.bind(null,e,t,n),t.then(e,e))}function cy(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function dy(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=hr(-1,1),t.tag=2,ei(n,t,1))),n.lanes|=1),e)}var WR=wr.ReactCurrentOwner,Ft=!1;function bt(e,t,n,r){t.child=e===null?bx(t,null,n,r):go(t,e.child,n,r)}function fy(e,t,n,r,i){n=n.render;var s=t.ref;return Vs(t,i),r=Kv(e,t,n,r,s,i),n=Qv(),e!==null&&!Ft?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,mr(e,t,i)):(je&&n&&Fv(t),t.flags|=1,bt(e,t,r,i),t.child)}function hy(e,t,n,r,i){if(e===null){var s=n.type;return typeof s=="function"&&!sg(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=s,Kx(e,t,s,r,i)):(e=ku(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(s=e.child,!(e.lanes&i)){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:ja,n(o,r)&&e.ref===t.ref)return mr(e,t,i)}return t.flags|=1,e=ri(s,r),e.ref=t.ref,e.return=t,t.child=e}function Kx(e,t,n,r,i){if(e!==null){var s=e.memoizedProps;if(ja(s,r)&&e.ref===t.ref)if(Ft=!1,t.pendingProps=r=s,(e.lanes&i)!==0)e.flags&131072&&(Ft=!0);else return t.lanes=e.lanes,mr(e,t,i)}return Dh(e,t,n,r,i)}function Qx(e,t,n){var r=t.pendingProps,i=r.children,s=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Te(Ns,Vt),Vt|=n;else{if(!(n&1073741824))return e=s!==null?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Te(Ns,Vt),Vt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,Te(Ns,Vt),Vt|=r}else s!==null?(r=s.baseLanes|n,t.memoizedState=null):r=n,Te(Ns,Vt),Vt|=r;return bt(e,t,i,n),t.child}function Yx(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Dh(e,t,n,r,i){var s=Dt(n)?Ki:yt.current;return s=po(t,s),Vs(t,i),n=Kv(e,t,n,r,s,i),r=Qv(),e!==null&&!Ft?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,mr(e,t,i)):(je&&r&&Fv(t),t.flags|=1,bt(e,t,n,i),t.child)}function py(e,t,n,r,i){if(Dt(n)){var s=!0;Qu(t)}else s=!1;if(Vs(t,i),t.stateNode===null)Eu(e,t),Wx(t,n,r),Lh(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var l=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=cn(u):(u=Dt(n)?Ki:yt.current,u=po(t,u));var c=n.getDerivedStateFromProps,d=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==u)&&ly(t,o,r,u),Fr=!1;var f=t.memoizedState;o.state=f,ec(t,r,o,i),l=t.memoizedState,a!==r||f!==l||jt.current||Fr?(typeof c=="function"&&(Fh(t,n,c,r),l=t.memoizedState),(a=Fr||ay(t,n,a,r,f,l,u))?(d||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),o.props=r,o.state=l,o.context=u,r=a):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,Sx(e,t),a=t.memoizedProps,u=t.type===t.elementType?a:mn(t.type,a),o.props=u,d=t.pendingProps,f=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=cn(l):(l=Dt(n)?Ki:yt.current,l=po(t,l));var m=n.getDerivedStateFromProps;(c=typeof m=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==d||f!==l)&&ly(t,o,r,l),Fr=!1,f=t.memoizedState,o.state=f,ec(t,r,o,i);var _=t.memoizedState;a!==d||f!==_||jt.current||Fr?(typeof m=="function"&&(Fh(t,n,m,r),_=t.memoizedState),(u=Fr||ay(t,n,u,r,f,_,l)||!1)?(c||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,_,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,_,l)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=_),o.props=r,o.state=_,o.context=l,r=u):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return zh(e,t,n,r,s,i)}function zh(e,t,n,r,i,s){Yx(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return i&&Zm(t,n,!1),mr(e,t,s);r=t.stateNode,WR.current=t;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=go(t,e.child,null,s),t.child=go(t,null,a,s)):bt(e,t,a,s),t.memoizedState=r.state,i&&Zm(t,n,!0),t.child}function Xx(e){var t=e.stateNode;t.pendingContext?Jm(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Jm(e,t.context,!1),qv(e,t.containerInfo)}function vy(e,t,n,r,i){return vo(),jv(i),t.flags|=256,bt(e,t,n,r),t.child}var Uh={dehydrated:null,treeContext:null,retryLane:0};function Vh(e){return{baseLanes:e,cachePool:null,transitions:null}}function Jx(e,t,n){var r=t.pendingProps,i=De.current,s=!1,o=(t.flags&128)!==0,a;if((a=o)||(a=e!==null&&e.memoizedState===null?!1:(i&2)!==0),a?(s=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),Te(De,i&1),e===null)return Nh(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,s?(r=t.mode,s=t.child,o={mode:"hidden",children:o},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=o):s=sd(o,r,0,null),e=Wi(e,r,n,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=Vh(n),t.memoizedState=Uh,e):Jv(t,o));if(i=e.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return HR(e,t,o,r,a,i,n);if(s){s=r.fallback,o=t.mode,i=e.child,a=i.sibling;var l={mode:"hidden",children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=l,t.deletions=null):(r=ri(i,l),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?s=ri(a,s):(s=Wi(s,o,n,null),s.flags|=2),s.return=t,r.return=t,r.sibling=s,t.child=r,r=s,s=t.child,o=e.child.memoizedState,o=o===null?Vh(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=e.childLanes&~n,t.memoizedState=Uh,r}return s=e.child,e=s.sibling,r=ri(s,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Jv(e,t){return t=sd({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Bl(e,t,n,r){return r!==null&&jv(r),go(t,e.child,null,n),e=Jv(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function HR(e,t,n,r,i,s,o){if(n)return t.flags&256?(t.flags&=-257,r=rf(Error(U(422))),Bl(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(s=r.fallback,i=t.mode,r=sd({mode:"visible",children:r.children},i,0,null),s=Wi(s,i,o,null),s.flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,t.mode&1&&go(t,e.child,null,o),t.child.memoizedState=Vh(o),t.memoizedState=Uh,s);if(!(t.mode&1))return Bl(e,t,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(U(419)),r=rf(s,r,void 0),Bl(e,t,o,r)}if(a=(o&e.childLanes)!==0,Ft||a){if(r=it,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|o)?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,gr(e,i),Cn(r,e,i,-1))}return ig(),r=rf(Error(U(421))),Bl(e,t,o,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=sT.bind(null,e),i._reactRetry=t,null):(e=s.treeContext,Gt=Zr(i.nextSibling),Qt=t,je=!0,xn=null,e!==null&&(rn[sn++]=cr,rn[sn++]=dr,rn[sn++]=Qi,cr=e.id,dr=e.overflow,Qi=t),t=Jv(t,r.children),t.flags|=4096,t)}function gy(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),$h(e.return,t,n)}function sf(e,t,n,r,i){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function Zx(e,t,n){var r=t.pendingProps,i=r.revealOrder,s=r.tail;if(bt(e,t,r.children,n),r=De.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&gy(e,n,t);else if(e.tag===19)gy(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Te(De,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&tc(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),sf(t,!1,i,n,s);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&tc(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}sf(t,!0,n,null,s);break;case"together":sf(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Eu(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function mr(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Xi|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(U(153));if(t.child!==null){for(e=t.child,n=ri(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ri(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function GR(e,t,n){switch(t.tag){case 3:Xx(t),vo();break;case 5:Cx(t);break;case 1:Dt(t.type)&&Qu(t);break;case 4:qv(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Te(Ju,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Te(De,De.current&1),t.flags|=128,null):n&t.child.childLanes?Jx(e,t,n):(Te(De,De.current&1),e=mr(e,t,n),e!==null?e.sibling:null);Te(De,De.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Zx(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Te(De,De.current),r)break;return null;case 22:case 23:return t.lanes=0,Qx(e,t,n)}return mr(e,t,n)}var eb,Bh,tb,nb;eb=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Bh=function(){};tb=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Ii(Wn.current);var s=null;switch(n){case"input":i=dh(e,i),r=dh(e,r),s=[];break;case"select":i=Ve({},i,{value:void 0}),r=Ve({},r,{value:void 0}),s=[];break;case"textarea":i=ph(e,i),r=ph(e,r),s=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Gu)}gh(n,r);var o;n=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var a=i[u];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Oa.hasOwnProperty(u)?s||(s=[]):(s=s||[]).push(u,null));for(u in r){var l=r[u];if(a=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&l!==a&&(l!=null||a!=null))if(u==="style")if(a){for(o in a)!a.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in l)l.hasOwnProperty(o)&&a[o]!==l[o]&&(n||(n={}),n[o]=l[o])}else n||(s||(s=[]),s.push(u,n)),n=l;else u==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(s=s||[]).push(u,l)):u==="children"?typeof l!="string"&&typeof l!="number"||(s=s||[]).push(u,""+l):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Oa.hasOwnProperty(u)?(l!=null&&u==="onScroll"&&Me("scroll",e),s||a===l||(s=[])):(s=s||[]).push(u,l))}n&&(s=s||[]).push("style",n);var u=s;(t.updateQueue=u)&&(t.flags|=4)}};nb=function(e,t,n,r){n!==r&&(t.flags|=4)};function Ho(e,t){if(!je)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function ft(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function KR(e,t,n){var r=t.pendingProps;switch(Lv(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ft(t),null;case 1:return Dt(t.type)&&Ku(),ft(t),null;case 3:return r=t.stateNode,mo(),$e(jt),$e(yt),Hv(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Ul(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,xn!==null&&(Xh(xn),xn=null))),Bh(e,t),ft(t),null;case 5:Wv(t);var i=Ii(Ba.current);if(n=t.type,e!==null&&t.stateNode!=null)tb(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(U(166));return ft(t),null}if(e=Ii(Wn.current),Ul(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[zn]=t,r[Ua]=s,e=(t.mode&1)!==0,n){case"dialog":Me("cancel",r),Me("close",r);break;case"iframe":case"object":case"embed":Me("load",r);break;case"video":case"audio":for(i=0;i<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[zn]=t,e[Ua]=r,eb(e,t,!1,!1),t.stateNode=e;e:{switch(o=mh(n,r),n){case"dialog":Me("cancel",e),Me("close",e),i=r;break;case"iframe":case"object":case"embed":Me("load",e),i=r;break;case"video":case"audio":for(i=0;i_o&&(t.flags|=128,r=!0,Ho(s,!1),t.lanes=4194304)}else{if(!r)if(e=tc(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Ho(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!je)return ft(t),null}else 2*Qe()-s.renderingStartTime>_o&&n!==1073741824&&(t.flags|=128,r=!0,Ho(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(n=s.last,n!==null?n.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Qe(),t.sibling=null,n=De.current,Te(De,r?n&1|2:n&1),t):(ft(t),null);case 22:case 23:return rg(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Vt&1073741824&&(ft(t),t.subtreeFlags&6&&(t.flags|=8192)):ft(t),null;case 24:return null;case 25:return null}throw Error(U(156,t.tag))}function QR(e,t){switch(Lv(t),t.tag){case 1:return Dt(t.type)&&Ku(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return mo(),$e(jt),$e(yt),Hv(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Wv(t),null;case 13:if($e(De),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(U(340));vo()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return $e(De),null;case 4:return mo(),null;case 10:return Uv(t.type._context),null;case 22:case 23:return rg(),null;case 24:return null;default:return null}}var ql=!1,gt=!1,YR=typeof WeakSet=="function"?WeakSet:Set,G=null;function As(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){He(e,t,r)}else n.current=null}function qh(e,t,n){try{n()}catch(r){He(e,t,r)}}var my=!1;function XR(e,t){if(Ph=qu,e=ax(),$v(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,u=0,c=0,d=e,f=null;t:for(;;){for(var m;d!==n||i!==0&&d.nodeType!==3||(a=o+i),d!==s||r!==0&&d.nodeType!==3||(l=o+r),d.nodeType===3&&(o+=d.nodeValue.length),(m=d.firstChild)!==null;)f=d,d=m;for(;;){if(d===e)break t;if(f===n&&++u===i&&(a=o),f===s&&++c===r&&(l=o),(m=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=m}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(Rh={focusedElem:e,selectionRange:n},qu=!1,G=t;G!==null;)if(t=G,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,G=e;else for(;G!==null;){t=G;try{var _=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var p=_.memoizedProps,y=_.memoizedState,h=t.stateNode,v=h.getSnapshotBeforeUpdate(t.elementType===t.type?p:mn(t.type,p),y);h.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(U(163))}}catch(b){He(t,t.return,b)}if(e=t.sibling,e!==null){e.return=t.return,G=e;break}G=t.return}return _=my,my=!1,_}function xa(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var s=i.destroy;i.destroy=void 0,s!==void 0&&qh(t,n,s)}i=i.next}while(i!==r)}}function rd(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Wh(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function rb(e){var t=e.alternate;t!==null&&(e.alternate=null,rb(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[zn],delete t[Ua],delete t[Oh],delete t[AR],delete t[NR])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function ib(e){return e.tag===5||e.tag===3||e.tag===4}function yy(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ib(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Hh(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Gu));else if(r!==4&&(e=e.child,e!==null))for(Hh(e,t,n),e=e.sibling;e!==null;)Hh(e,t,n),e=e.sibling}function Gh(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Gh(e,t,n),e=e.sibling;e!==null;)Gh(e,t,n),e=e.sibling}var st=null,wn=!1;function Pr(e,t,n){for(n=n.child;n!==null;)sb(e,t,n),n=n.sibling}function sb(e,t,n){if(qn&&typeof qn.onCommitFiberUnmount=="function")try{qn.onCommitFiberUnmount(Qc,n)}catch{}switch(n.tag){case 5:gt||As(n,t);case 6:var r=st,i=wn;st=null,Pr(e,t,n),st=r,wn=i,st!==null&&(wn?(e=st,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):st.removeChild(n.stateNode));break;case 18:st!==null&&(wn?(e=st,n=n.stateNode,e.nodeType===8?Xd(e.parentNode,n):e.nodeType===1&&Xd(e,n),Fa(e)):Xd(st,n.stateNode));break;case 4:r=st,i=wn,st=n.stateNode.containerInfo,wn=!0,Pr(e,t,n),st=r,wn=i;break;case 0:case 11:case 14:case 15:if(!gt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&qh(n,t,o),i=i.next}while(i!==r)}Pr(e,t,n);break;case 1:if(!gt&&(As(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){He(n,t,a)}Pr(e,t,n);break;case 21:Pr(e,t,n);break;case 22:n.mode&1?(gt=(r=gt)||n.memoizedState!==null,Pr(e,t,n),gt=r):Pr(e,t,n);break;default:Pr(e,t,n)}}function _y(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new YR),t.forEach(function(r){var i=oT.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function vn(e,t){var n=t.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Qe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*ZR(r/1960))-r,10e?16:e,Kr===null)var r=!1;else{if(e=Kr,Kr=null,oc=0,pe&6)throw Error(U(331));var i=pe;for(pe|=4,G=e.current;G!==null;){var s=G,o=s.child;if(G.flags&16){var a=s.deletions;if(a!==null){for(var l=0;lQe()-tg?qi(e,0):eg|=n),zt(e,t)}function hb(e,t){t===0&&(e.mode&1?(t=$l,$l<<=1,!($l&130023424)&&($l=4194304)):t=1);var n=Ct();e=gr(e,t),e!==null&&(ml(e,t,n),zt(e,n))}function sT(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),hb(e,n)}function oT(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(U(314))}r!==null&&r.delete(t),hb(e,n)}var pb;pb=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||jt.current)Ft=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ft=!1,GR(e,t,n);Ft=!!(e.flags&131072)}else Ft=!1,je&&t.flags&1048576&&yx(t,Xu,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Eu(e,t),e=t.pendingProps;var i=po(t,yt.current);Vs(t,n),i=Kv(null,t,r,e,i,n);var s=Qv();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Dt(r)?(s=!0,Qu(t)):s=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Bv(t),i.updater=nd,t.stateNode=i,i._reactInternals=t,Lh(t,r,e,n),t=zh(null,t,r,!0,s,n)):(t.tag=0,je&&s&&Fv(t),bt(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Eu(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=lT(r),e=mn(r,e),i){case 0:t=Dh(null,t,r,e,n);break e;case 1:t=py(null,t,r,e,n);break e;case 11:t=fy(null,t,r,e,n);break e;case 14:t=hy(null,t,r,mn(r.type,e),n);break e}throw Error(U(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:mn(r,i),Dh(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:mn(r,i),py(e,t,r,i,n);case 3:e:{if(Xx(t),e===null)throw Error(U(387));r=t.pendingProps,s=t.memoizedState,i=s.element,Sx(e,t),ec(t,r,null,n);var o=t.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){i=yo(Error(U(423)),t),t=vy(e,t,r,n,i);break e}else if(r!==i){i=yo(Error(U(424)),t),t=vy(e,t,r,n,i);break e}else for(Gt=Zr(t.stateNode.containerInfo.firstChild),Qt=t,je=!0,xn=null,n=bx(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(vo(),r===i){t=mr(e,t,n);break e}bt(e,t,r,n)}t=t.child}return t;case 5:return Cx(t),e===null&&Nh(t),r=t.type,i=t.pendingProps,s=e!==null?e.memoizedProps:null,o=i.children,Th(r,i)?o=null:s!==null&&Th(r,s)&&(t.flags|=32),Yx(e,t),bt(e,t,o,n),t.child;case 6:return e===null&&Nh(t),null;case 13:return Jx(e,t,n);case 4:return qv(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=go(t,null,r,n):bt(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:mn(r,i),fy(e,t,r,i,n);case 7:return bt(e,t,t.pendingProps,n),t.child;case 8:return bt(e,t,t.pendingProps.children,n),t.child;case 12:return bt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,s=t.memoizedProps,o=i.value,Te(Ju,r._currentValue),r._currentValue=o,s!==null)if(kn(s.value,o)){if(s.children===i.children&&!jt.current){t=mr(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(s.tag===1){l=hr(-1,n&-n),l.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?l.next=l:(l.next=c.next,c.next=l),u.pending=l}}s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),$h(s.return,n,t),a.lanes|=n;break}l=l.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(U(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),$h(o,n,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}bt(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Vs(t,n),i=cn(i),r=r(i),t.flags|=1,bt(e,t,r,n),t.child;case 14:return r=t.type,i=mn(r,t.pendingProps),i=mn(r.type,i),hy(e,t,r,i,n);case 15:return Kx(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:mn(r,i),Eu(e,t),t.tag=1,Dt(r)?(e=!0,Qu(t)):e=!1,Vs(t,n),Wx(t,r,i),Lh(t,r,i,n),zh(null,t,r,!0,e,n);case 19:return Zx(e,t,n);case 22:return Qx(e,t,n)}throw Error(U(156,t.tag))};function vb(e,t){return Vw(e,t)}function aT(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function on(e,t,n,r){return new aT(e,t,n,r)}function sg(e){return e=e.prototype,!(!e||!e.isReactComponent)}function lT(e){if(typeof e=="function")return sg(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Sv)return 11;if(e===Cv)return 14}return 2}function ri(e,t){var n=e.alternate;return n===null?(n=on(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function ku(e,t,n,r,i,s){var o=2;if(r=e,typeof e=="function")sg(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Ss:return Wi(n.children,i,s,t);case Ev:o=8,i|=8;break;case ah:return e=on(12,n,t,i|2),e.elementType=ah,e.lanes=s,e;case lh:return e=on(13,n,t,i),e.elementType=lh,e.lanes=s,e;case uh:return e=on(19,n,t,i),e.elementType=uh,e.lanes=s,e;case Cw:return sd(n,i,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ew:o=10;break e;case Sw:o=9;break e;case Sv:o=11;break e;case Cv:o=14;break e;case $r:o=16,r=null;break e}throw Error(U(130,e==null?e:typeof e,""))}return t=on(o,n,t,i),t.elementType=e,t.type=r,t.lanes=s,t}function Wi(e,t,n,r){return e=on(7,e,r,t),e.lanes=n,e}function sd(e,t,n,r){return e=on(22,e,r,t),e.elementType=Cw,e.lanes=n,e.stateNode={isHidden:!1},e}function of(e,t,n){return e=on(6,e,null,t),e.lanes=n,e}function af(e,t,n){return t=on(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function uT(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=zd(0),this.expirationTimes=zd(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zd(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function og(e,t,n,r,i,s,o,a,l){return e=new uT(e,t,n,a,l),t===1?(t=1,s===!0&&(t|=8)):t=0,s=on(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Bv(s),e}function cT(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(_b)}catch(e){console.error(e)}}_b(),_w.exports=Zt;var xl=_w.exports;const vT=aw(xl);var wb,Py=xl;wb=Py.createRoot,Py.hydrateRoot;var uc=["light","dark"],cg="(prefers-color-scheme: dark)",gT=typeof window>"u",dg=g.createContext(void 0),mT={setTheme:e=>{},themes:[]},rz=()=>{var e;return(e=g.useContext(dg))!=null?e:mT},yT=e=>g.useContext(dg)?e.children:g.createElement(wT,{...e}),_T=["light","dark"],wT=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:n=!0,enableColorScheme:r=!0,storageKey:i="theme",themes:s=_T,defaultTheme:o=n?"system":"light",attribute:a="data-theme",value:l,children:u,nonce:c})=>{let[d,f]=g.useState(()=>Ry(i,o)),[m,_]=g.useState(()=>Ry(i)),p=l?Object.values(l):s,y=g.useCallback(b=>{let E=b;if(!E)return;b==="system"&&n&&(E=Ty());let S=l?l[E]:E,P=t?bT():null,C=document.documentElement;if(a==="class"?(C.classList.remove(...p),S&&C.classList.add(S)):S?C.setAttribute(a,S):C.removeAttribute(a),r){let T=uc.includes(o)?o:null,R=uc.includes(E)?E:T;C.style.colorScheme=R}P==null||P()},[]),h=g.useCallback(b=>{let E=typeof b=="function"?b(b):b;f(E);try{localStorage.setItem(i,E)}catch{}},[e]),v=g.useCallback(b=>{let E=Ty(b);_(E),d==="system"&&n&&!e&&y("system")},[d,e]);g.useEffect(()=>{let b=window.matchMedia(cg);return b.addListener(v),v(b),()=>b.removeListener(v)},[v]),g.useEffect(()=>{let b=E=>{if(E.key!==i)return;let S=E.newValue||o;h(S)};return window.addEventListener("storage",b),()=>window.removeEventListener("storage",b)},[h]),g.useEffect(()=>{y(e??d)},[e,d]);let x=g.useMemo(()=>({theme:d,setTheme:h,forcedTheme:e,resolvedTheme:d==="system"?m:d,themes:n?[...s,"system"]:s,systemTheme:n?m:void 0}),[d,h,e,m,n,s]);return g.createElement(dg.Provider,{value:x},g.createElement(xT,{forcedTheme:e,disableTransitionOnChange:t,enableSystem:n,enableColorScheme:r,storageKey:i,themes:s,defaultTheme:o,attribute:a,value:l,children:u,attrs:p,nonce:c}),u)},xT=g.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:s,value:o,attrs:a,nonce:l})=>{let u=s==="system",c=n==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${a.map(_=>`'${_}'`).join(",")})`};`:`var d=document.documentElement,n='${n}',s='setAttribute';`,d=i?uc.includes(s)&&s?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${s}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",f=(_,p=!1,y=!0)=>{let h=o?o[_]:_,v=p?_+"|| ''":`'${h}'`,x="";return i&&y&&!p&&uc.includes(_)&&(x+=`d.style.colorScheme = '${_}';`),n==="class"?p||h?x+=`c.add(${v})`:x+="null":h&&(x+=`d[s](n,${v})`),x},m=e?`!function(){${c}${f(e)}}()`:r?`!function(){try{${c}var e=localStorage.getItem('${t}');if('system'===e||(!e&&${u})){var t='${cg}',m=window.matchMedia(t);if(m.media!==t||m.matches){${f("dark")}}else{${f("light")}}}else if(e){${o?`var x=${JSON.stringify(o)};`:""}${f(o?"x[e]":"e",!0)}}${u?"":"else{"+f(s,!1,!1)+"}"}${d}}catch(e){}}()`:`!function(){try{${c}var e=localStorage.getItem('${t}');if(e){${o?`var x=${JSON.stringify(o)};`:""}${f(o?"x[e]":"e",!0)}}else{${f(s,!1,!1)};}${d}}catch(t){}}();`;return g.createElement("script",{nonce:l,dangerouslySetInnerHTML:{__html:m}})}),Ry=(e,t)=>{if(gT)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},bT=()=>{let e=document.createElement("style");return e.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(e),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(e)},1)}},Ty=e=>(e||(e=window.matchMedia(cg)),e.matches?"dark":"light"),I=typeof window<"u"?window:void 0,mt=typeof globalThis<"u"?globalThis:I,St=mt==null?void 0:mt.navigator,j=mt==null?void 0:mt.document,Ae=mt==null?void 0:mt.location,fg=mt==null?void 0:mt.fetch,Jh=mt!=null&&mt.XMLHttpRequest&&"withCredentials"in new mt.XMLHttpRequest?mt.XMLHttpRequest:void 0,Iy=mt==null?void 0:mt.AbortController,ET=mt==null?void 0:mt.CompressionStream,Mt=St==null?void 0:St.userAgent;function xb(){return!(!I||I.navigator.onLine===!1)}var Ko=typeof globalThis<"u"?globalThis:I;Ko&&typeof self>"u"&&(Ko.self=Ko),Ko&&typeof File>"u"&&(Ko.File=function(){});var Y=I??{},Ee={DEBUG:!1,LIB_VERSION:"0.5.1",LIB_NAME:"browser-common"};function Oy(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(u){return void n(u)}a.done?t(l):Promise.resolve(l).then(r,i)}function Ce(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var s=e.apply(t,n);function o(l){Oy(s,r,i,o,a,"next",l)}function a(l){Oy(s,r,i,o,a,"throw",l)}o(void 0)})}}function $(){return $=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},$.apply(null,arguments)}function bb(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var My=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};function Ay(e){return typeof e=="string"||e}function Ny(e){return typeof e=="string"?e:void 0}var Qo,ST=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],nr=function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.AiCaptureQueue="ai_capture_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e}({}),$y=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),CT=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],kT=["token"],Eb="NativeGzipValidationError",Zh=e=>e.length>=2&&e[0]===31&&e[1]===139,Fy=(e,t)=>e===$y.GZipJS||t===$y.GZipJS||t==="gzip",Ly=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError",Gl=e=>{var t=new Error("Native gzip produced invalid output: "+e);throw t.name=Eb,t},PT=function(){var e=Ce(function*(t,n){18>t.size&&Gl("too-short");var r=new Uint8Array(yield t.slice(0,10).arrayBuffer());Zh(r)&&r[2]===8||Gl("invalid-header");var i=new DataView(yield t.slice(t.size-8).arrayBuffer());i.getUint32(0,!0)!==(o=>{for(var a=(()=>{if(Qo)return Qo;Qo=[];for(var c=0;256>c;c++){for(var d=c,f=0;8>f;f++)d=1&d?3988292384^d>>>1:d>>>1;Qo[c]=d>>>0}return Qo})(),l=4294967295,u=0;o.length>u;u++)l=a[255&(l^o[u])]^l>>>8;return(4294967295^l)>>>0})(n)&&Gl("invalid-crc");var s=n.length>>>0;i.getUint32(4,!0)!==s&&Gl("invalid-size")});return function(t,n){return e.apply(this,arguments)}}();function ep(){return ep=Ce(function*(e,t,n){t===void 0&&(t=!0);try{var r=new TextEncoder().encode(e),i=new globalThis.CompressionStream("gzip"),s=i.writable.getWriter(),o=s.write(r).then(()=>s.close()).catch(function(){var u=Ce(function*(c){try{yield s.abort(c)}catch{}throw c});return function(c){return u.apply(this,arguments)}}()),a=new Response(i.readable).blob(),l=(yield Promise.all([a,o]))[0];return yield PT(l,r),l}catch(u){if(n!=null&&n.rethrow)throw u;return t&&console.error("Failed to gzip compress data",u),null}}),ep.apply(this,arguments)}var RT=20,Sb=1e3,TT=1e4,IT="[Circular]",tp="[Truncated]",cd="[Unserializable]",OT="[Function]";function qs(e){for(var t="",n=0;e.length>n;n++){var r=e.charCodeAt(n);if(55296>r||r>56319)t+=56320>r||r>57343?e[n]:"�";else{var i=e.charCodeAt(n+1);56320>i||i>57343?t+="�":(t+=e[n]+e[n+1],n++)}}return t}var MT=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],jy=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return MT.concat(t).some(r=>{var i=r.toLowerCase();return n.indexOf(i)!==-1})};function J(e,t){return e.indexOf(t)!==-1}var dd=function(e){return e.trim()},np=function(e){return e.replace(/^\$/,"")};function Cb(e){var t,n=[];return(t=JSON.stringify(e,function(r,i){if(typeof i=="bigint")return i.toString();if(typeof i!="function"&&typeof i!="symbol"){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&typeof i=="object"){for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(i))return"[Circular]";n.push(i)}return i}}))!==null&&t!==void 0?t:"null"}var kb=Object.prototype,Pb=kb.hasOwnProperty,fd=kb.toString,Z=Array.isArray||function(e){return fd.call(e)==="[object Array]"},vt=e=>typeof e=="function",Se=e=>e===Object(e)&&!Z(e),En=e=>{if(Se(e)){for(var t in e)if(Pb.call(e,t))return!1;return!0}return!1},L=e=>e===void 0,ce=e=>fd.call(e)=="[object String]",cc=e=>ce(e)&&e.trim().length===0,rt=e=>e===null,ne=e=>L(e)||rt(e),Ge=e=>fd.call(e)=="[object Number]"&&e==e,Jn=e=>Ge(e)&&e>0,$t=e=>fd.call(e)==="[object Boolean]",AT=e=>e instanceof FormData,NT=e=>J(CT,e),$T=e=>J(kT,e);function Rb(e){return e===null||typeof e!="object"}function dc(e,t){return{}.toString.call(e)==="[object "+t+"]"}function Tb(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Ib(e,Error)}}function hg(e){return typeof Event<"u"&&Ib(e,Event)}function Ib(e,t){try{return e instanceof t}catch{return!1}}var FT=[!0,"true",1,"1","yes"],lf=e=>J(FT,e),LT=[!1,"false",0,"0","no"];function Vn(e,t,n,r,i){return t>n&&(r.warn("min cannot be greater than max."),t=n),Ge(e)?e>n?(r.warn(" cannot be greater than max: "+n+". Using max value instead."),n):t>e?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+i),Vn(i||n,t,n,r))}class jT{constructor(t){this.k={},this.S=t.S,this.C=Vn(t.bucketSize,0,100,t.I),this.R=Vn(t.refillRate,0,this.C,t.I),this.A=Vn(t.refillInterval,0,864e5,t.I)}O(t,n){var r=Math.floor((n-t.lastAccess)/this.A);r>0&&(t.tokens=Math.min(t.tokens+r*this.R,this.C),t.lastAccess=t.lastAccess+r*this.A)}consumeRateLimit(t){var n,r=Date.now(),i=String(t),s=this.k[i];return s?this.O(s,r):this.k[i]=s={tokens:this.C,lastAccess:r},s.tokens===0||(s.tokens--,s.tokens===0&&((n=this.S)==null||n.call(this,t)),s.tokens===0)}stop(){this.k={}}}var Yt="Mobile",fc="iOS",fr="Android",wo="Tablet",Ob=fr+" "+wo,Mb="iPad",Ab="Apple",Nb=Ab+" Watch",Sa="Safari",xo="BlackBerry",$b="Samsung",Fb=$b+"Browser",Lb=$b+" Internet",Hi="Chrome",DT=Hi+" OS",jb=Hi+" "+fc,pg="Internet Explorer",Db=pg+" "+Yt,vg="Opera",zT=vg+" Mini",gg="Edge",zb="Microsoft "+gg,Ws="Firefox",Ub=Ws+" "+fc,Ka="Nintendo",Qa="PlayStation",Hs="Xbox",Vb=fr+" "+Yt,Bb=Yt+" "+Sa,ua="Windows",rp=ua+" Phone",Dy="Nokia",ip="Ouya",qb="Generic",UT=qb+" "+Yt.toLowerCase(),Wb=qb+" "+wo.toLowerCase(),sp="Konqueror",Hb="Oculus Browser",hc="Vivaldi",Gb="Yandex",pc="Whale",op="DuckDuckGo",Kb="Pale Moon",vc="Waterfox",Ca="Brave",Qb="Google Search App",Le="(\\d+(\\.\\d+)?)",uf=new RegExp("Version/"+Le),VT=new RegExp(Hs,"i"),BT=new RegExp(Qa+" \\w+","i"),qT=new RegExp(Ka+" \\w+","i"),mg=new RegExp(xo+"|PlayBook|BB10","i"),WT={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},Yb=function(e,t,n,r){t=t||"";var i=function(s){return s!=null&&s.brave?Ca:null}(n);return i||(r!=null&&r.detectGoogleSearchApp&&J(e,"GSA/")?Qb:J(e," OPR/")&&J(e,"Mini")?zT:J(e," OPR/")?vg:mg.test(e)?xo:J(e,"IE"+Yt)||J(e,"WPDesktop")?Db:J(e,"OculusBrowser")?Hb:J(e,Fb)?Lb:J(e,gg)||J(e,"Edg/")?zb:J(e,hc+"/")?hc:J(e,"YaBrowser/")?Gb:J(e,pc+"/")?pc:J(e,op+"/")||J(e,"Ddg/")?op:J(e,"FBIOS")?"Facebook "+Yt:J(e,"UCWEB")||J(e,"UCBrowser")?"UC Browser":J(e,"CriOS")?jb:J(e,"CrMo")||J(e,Hi)?Hi:J(e,fr)&&J(e,Sa)?Vb:J(e,"FxiOS")?Ub:J(e.toLowerCase(),sp.toLowerCase())?sp:J(e,Ca+"/")?Ca:((s,o)=>o&&J(o,Ab)||function(a){return J(a,Sa)&&!J(a,Hi)&&!J(a,fr)}(s))(e,t)?J(e,Yt)?Bb:Sa:J(e,"PaleMoon/")?Kb:J(e,vc+"/")?vc:J(e,Ws)?Ws:J(e,"MSIE")||J(e,"Trident/")?pg:J(e,"Gecko")?Ws:"")},HT={[Db]:[new RegExp("rv:"+Le)],[zb]:[new RegExp(gg+"?\\/"+Le)],[Hi]:[new RegExp("("+Hi+"|CrMo)\\/"+Le)],[jb]:[new RegExp("CriOS\\/"+Le)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Le)],[Sa]:[uf],[Bb]:[uf],[vg]:[new RegExp("(Opera|OPR)\\/"+Le)],[Ws]:[new RegExp(Ws+"\\/"+Le)],[Ub]:[new RegExp("FxiOS\\/"+Le)],[sp]:[new RegExp("Konqueror[:/]?"+Le,"i")],[xo]:[new RegExp(xo+" "+Le),uf],[Vb]:[new RegExp("android\\s"+Le,"i")],[Lb]:[new RegExp(Fb+"\\/"+Le)],[Hb]:[new RegExp("OculusBrowser\\/"+Le)],[hc]:[new RegExp(hc+"\\/"+Le)],[Gb]:[new RegExp("YaBrowser\\/"+Le)],[pc]:[new RegExp(pc+"\\/"+Le)],[Ca]:[new RegExp(Ca+"\\/"+Le)],[op]:[new RegExp("(DuckDuckGo|Ddg)\\/"+Le)],[Kb]:[new RegExp("PaleMoon\\/"+Le)],[vc]:[new RegExp(vc+"\\/"+Le)],[Qb]:[new RegExp("GSA\\/"+Le)],[pg]:[new RegExp("(rv:|MSIE )"+Le)],Mozilla:[new RegExp("rv:"+Le)]},GT=function(e,t,n,r){var i=Yb(e,t,n,r),s=HT[i];if(L(s))return null;for(var o=0;s.length>o;o++){var a=e.match(s[o]);if(a)return parseFloat(a[a.length-2])}return null},zy=[[new RegExp(Hs+"; "+Hs+" (.*?)[);]","i"),e=>[Hs,e&&e[1]||""]],[new RegExp(Ka,"i"),[Ka,""]],[new RegExp(Qa,"i"),[Qa,""]],[mg,[xo,""]],[new RegExp(ua,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[rp,""];if(new RegExp(Yt).test(t)&&!/IEMobile\b/.test(t))return[ua+" "+Yt,""];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=WT[n[1]]||"";return/arm/i.test(t)&&(r="RT"),[ua,r]}return[ua,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[fc,[e[3],e[4],e[5]||"0"].join(".")]:[fc,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=L(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+fr+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+fr+")","i"),e=>e&&e[2]?[fr,[e[2],e[3],e[4]||"0"].join(".")]:[fr,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[DT,""]],[/Linux|debian/i,["Linux",""]]],Uy=function(e){return qT.test(e)?Ka:BT.test(e)?Qa:VT.test(e)?Hs:new RegExp(ip,"i").test(e)?ip:new RegExp("("+rp+"|WPDesktop)","i").test(e)?rp:/iPad/.test(e)?Mb:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Nb:mg.test(e)?xo:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Dy,"i").test(e)?Dy:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(Yt).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?fr:Ob:new RegExp("(pda|"+Yt+")","i").test(e)?UT:new RegExp(wo,"i").test(e)&&!new RegExp(wo+" pc","i").test(e)?Wb:""},KT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Vy(e,t){return typeof(n=e)=="string"&&KT.test(n)?e:t();var n}function li(e){return e&&e.split("#")[0]}function yg(e,t){var n=setTimeout(e,t);return n!=null&&n.unref&&(n==null||n.unref()),n}function By(e,t,n){return Xb.apply(this,arguments)}function Xb(){return(Xb=Ce(function*(e,t,n){var r;try{return yield Promise.race([e,new Promise((i,s)=>{r=yg(()=>{try{n==null||n(),i()}catch(o){s(o)}},t)})])}finally{clearTimeout(r)}})).apply(this,arguments)}var Jb={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},QT=Jb.info,qy=9223372036854776e3,YT={}.propertyIsEnumerable;function gc(e,t){try{return Zb(e,t,{ancestors:new WeakSet,remainingNodes:TT},0)}catch{return[]}}function _g(e,t,n,r){if(0>=n.remainingNodes)return{stringValue:tp};if(n.remainingNodes--,$t(e))return{boolValue:e};if(typeof e=="number"){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>"u")return{stringValue:String(e)};var i=BigInt(e).toString();return e>=qy||-qy>e?(t==null||t.debug("Attribute "+i+" is outside the int64 range; encoding it as a string"),{stringValue:i}):{intValue:i}}return{doubleValue:e}}if(typeof e=="string")return{stringValue:qs(e)};if(typeof e=="function")return{stringValue:OT};if(typeof e=="symbol")return{stringValue:String(e)};if(typeof e=="object"&&e!==null){if(n.ancestors.has(e))return{stringValue:IT};if(r>=RT)return{stringValue:tp};if(e instanceof Date){var s=e.getTime(),o=Number.isFinite(s)?e.toISOString():String(e);return{stringValue:typeof o=="string"?qs(o):String(o)}}n.ancestors.add(e);try{try{var a=e.toJSON;if(typeof a=="function")return _g(a.call(e),t,n,r+1)}catch{}return Z(e)?{arrayValue:{values:XT(e,t,n,r+1)}}:{kvlistValue:{values:Zb(e,t,n,r+1)}}}finally{n.ancestors.delete(e)}}return{stringValue:qs(String(e))}}function XT(e,t,n,r){for(var i=[],s=Math.min(e.length,Sb),o=0;s>o&&n.remainingNodes>0;o++)try{var a=o in e?e[o]:void 0;if(ne(a))continue;i.push(_g(a,t,n,r))}catch{i.push({stringValue:cd})}return e.length>o&&i.push({stringValue:tp}),i}function Zb(e,t,n,r){var i=[];for(var s in e)if(YT.call(e,s)){if(i.length>=Sb||0>=n.remainingNodes){t==null||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=e[s];if(rt(o)||L(o))continue;i.push({key:qs(s),value:_g(o,t,n,r)})}catch{i.push({key:qs(s),value:{stringValue:cd}})}}return i}function JT(e){try{return qs(String(e))}catch{return cd}}function ZT(e,t,n){var r=Jb[e.level||"info"]||QT,i=r.text,s=r.number,o=String(Date.now())+"000000",a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.windowId&&(a["window.id"]=t.windowId),ne(t.sessionStartTimestamp)||(a.sessionStartTimestamp=String(t.sessionStartTimestamp)),ne(t.lastActivityTimestamp)||(a.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(a["url.full"]=t.currentUrl),t.screenName&&(a["screen.name"]=t.screenName),t.appState&&(a["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var l=$({},a),u=e.attributes;if(u){var c=[];try{c=Object.keys(u)}catch{c=[]}for(var d of c){var f=void 0;try{f=u[d]}catch{f=cd}Object.defineProperty(l,d,{value:f,enumerable:!0,writable:!0,configurable:!0})}}var m={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:s,severityText:i,body:{stringValue:JT(e.body)},attributes:gc(l,n)};return e.trace_id&&(m.traceId=e.trace_id),e.span_id&&(m.spanId=e.span_id),L(e.trace_flags)||(m.flags=e.trace_flags),m}function eE(e,t,n){return $({},e.resourceAttributes,{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment},e.serviceVersion&&{"service.version":e.serviceVersion},{"telemetry.sdk.name":t,"telemetry.sdk.version":n})}function tE(e,t,n,r){return{resourceLogs:[{resource:{attributes:gc(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}let eI=class{constructor(e,t,n,r,i,s,o){var a;s===void 0&&(s=()=>Promise.resolve()),this._instance=e,this.qi=t,this.I=n,this.rn=r,this.nn=i,this.sn=s,this.an=o,this.ln=null,this.un=0,this.hn=0,this.dn=0,this.vn=0,this.cn=!1,this.fn=t.maxBufferSize,this.pn=Math.max((a=t.maxQueueSize)!==null&&a!==void 0?a:t.maxBufferSize,t.maxBufferSize),this.gn=t.flushIntervalMs,this.mn=t.maxBatchRecordsPerPost,this.yn=t.rateCapWindowMs,this.bn=t.maxLogsPerInterval}reset(){this._n(),this.ln=null,this.dn=0,this.vn=0,this.cn=!1,this.un=0,this.hn=0,this.mn=this.qi.maxBatchRecordsPerPost}onReconnect(){this.hn=0,this.wn()}captureLog(e){if(!this._instance.isDisabled&&!this._instance.optedOut&&e!=null&&e.body){var t=this.kn(e);if(t!==null)if(t.body){if(this.Sn()){var n={record:ZT(t,this.rn(),this.I)};this.nn(()=>this.xn(n))}}else this.I.info("Log was rejected in beforeSend function")}}kn(e){var t=this.qi.beforeSend;if(!t)return e;var n=Z(t)?t:[t],r=e;for(var i of n)try{var s=i(r);if(!s)return this.I.info("Log was rejected in beforeSend function"),null;r=s}catch(o){return this.I.error("Error in beforeSend function for log:",o),null}return r}Sn(){if(this.bn===void 0)return!0;var e=Date.now(),t=e-this.dn;return this.yn>t&&t>=0||(this.dn=e,this.vn=0,this.cn=!1),this.bn>this.vn?(this.vn++,!0):(this.cn||(this.I.warn("captureLog dropping logs: exceeded "+this.bn+" logs per "+this.yn+"ms"),this.cn=!0),!1)}flush(){var e=this;return Ce(function*(){if(!e._instance.isDisabled)return e.ln||(e.ln=e.Cn().finally(()=>{e.ln=null})),e.ln})()}Cn(){var e=this;return Ce(function*(){var t;e._n();var n=(t=e._instance.getPersistedProperty(nr.LogsQueue))!==null&&t!==void 0?t:[];if(n.length!==0)for(var r=n.length,i=0;n.length>0&&r>i;){var s,o;e.un=0;var a=Math.min(n.length,e.mn),l=n.slice(0,a),u=tE(l.map(d=>d.record),e.Tn(),(s=e.an)!==null&&s!==void 0?s:e._instance.getLibraryId(),e._instance.getLibraryVersion()),c=yield e._instance.Mn(u);if(c.kind==="too-large"&&l.length>1)e.mn=Math.max(1,Math.floor(l.length/2)),e.I.warn("Received 413 when sending logs batch of size "+l.length+", reducing batch size to "+e.mn);else if(c.kind==="retry-later"||(c.kind==="too-large"?e.I.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):c.kind==="ok"&&e.qi.maxBatchRecordsPerPost>e.mn&&(e.mn=Math.min(e.qi.maxBatchRecordsPerPost,e.mn+1)),yield e.En(l.length),n=(o=e._instance.getPersistedProperty(nr.LogsQueue))!==null&&o!==void 0?o:[],i+=l.length,c.kind==="fatal"))throw c.error}})()}En(e){var t=this;return Ce(function*(){var n,r=Math.max(0,e-t.un),i=(n=t._instance.getPersistedProperty(nr.LogsQueue))!==null&&n!==void 0?n:[];t._instance.setPersistedProperty(nr.LogsQueue,i.slice(r)),yield t.sn()})()}Tn(){return eE(this.qi,this._instance.getLibraryId(),this._instance.getLibraryVersion())}xn(e){var t;if(!this._instance.optedOut){var n=(t=this._instance.getPersistedProperty(nr.LogsQueue))!==null&&t!==void 0?t:[];this.pn>n.length||(n.shift(),this.un++,this.I.info("Logs queue is full, dropping oldest record.")),n.push(e),this._instance.setPersistedProperty(nr.LogsQueue,n),this.fn>n.length?this.In():this.wn()}}In(e){e===void 0&&(e=this.gn),this.Rn||(this.Rn=yg(()=>{this.Rn=void 0,this.wn()},e))}Pn(){var e=Math.min(Math.max(0,this.hn-1),6);return this.gn*Math.pow(2,e)}An(){var e=this._instance.getPersistedProperty(nr.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return Ce(function*(){t._n();var n=t.flush().catch(()=>{});e!==void 0?yield By(n,e):yield n})()}flushWithTimeout(e){var t=this;return Ce(function*(){var n=t.flush();yield By(n,e,()=>{n.catch(()=>{})})})()}wn(){this.flush().then(()=>{this.hn=0},e=>{this.hn++,this.I.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.An()&&this.In(this.Pn())})}_n(){this.Rn&&(clearTimeout(this.Rn),this.Rn=void 0)}};var cf=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Wy(e){return String(e)+"000000"}function Hy(e,t,n,r){var i="";return r&&(i=Object.keys(r).sort().map(s=>JSON.stringify(s)+":"+JSON.stringify(r[s])).join(",")),e+"\0"+t+"\0"+(n??"")+"\0"+i}let tI=class{constructor(e,t,n){this._instance=e,this.qi=t,this.I=n,this.Fn=new Map,this.ln=null,this.On=!1,this.Ln=new Map,this.$n=new Set,this.Dn=0}count(e,t,n){t===void 0&&(t=1),this.Nn({name:e,type:"count",value:t,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}gauge(e,t,n){this.Nn({name:e,type:"gauge",value:t,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}histogram(e,t,n){this.Nn({name:e,type:"histogram",value:t,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}flush(){var e=this,t=this.ln,n=function(){var i=Ce(function*(){t&&(yield t.catch(()=>{})),yield e.qn()});return function(){return i.apply(this,arguments)}}(),r=n().finally(()=>{this.ln===r&&(this.ln=null)});return this.ln=r,r}drainWindow(){if(this.Fn.size===0)return null;var e=this.Fn;return this.Fn=new Map,this.On=!1,this.Ln=new Map,this.$n=new Set,this.jn(e)}reset(){this.Dn++,this._n(),this.Fn=new Map,this.ln=null,this.On=!1,this.Ln=new Map,this.$n=new Set}Nn(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var t=this.kn(e);if(t!==null)if(t.name&&typeof t.name=="string")if(typeof t.value=="number"&&Number.isFinite(t.value))if(t.type==="count"&&0>t.value)this.I.warn("Dropping count '"+t.name+"': counters are monotonic, value must be >= 0");else{var n,r;try{n=t.attributes?$({},t.attributes):void 0,r=Hy(t.type,t.name,t.unit,n)}catch(o){return void this.I.warn("Dropping metric '"+t.name+"': attributes could not be serialized",o)}var i=this.Fn.get(r);if(!i){if(!this.Bn())return;i={name:t.name,type:t.type,unit:t.unit,attributes:n,windowStartMs:Date.now()},this.Fn.set(r,i)}var s=this.Ln.get(t.name);s===void 0?this.Ln.set(t.name,t.type):s===t.type||this.$n.has(t.name)||(this.$n.add(t.name),this.I.warn("Metric name '"+t.name+"' is already used as a "+s+"; recording it as a "+t.type+" too will blend both series in charts. Use a distinct name.")),this.Hn(i,t.value),this.In()}else this.I.warn("Dropping metric '"+t.name+"': value must be a finite number");else this.I.warn("Dropping metric with empty name")}}Bn(){return this.qi.maxSeriesPerFlush>this.Fn.size||(this.On||(this.On=!0,this.I.warn("Metric series cap reached ("+this.qi.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Hn(e,t){var n;switch(e.type){case"count":e.total=((n=e.total)!==null&&n!==void 0?n:0)+t;break;case"gauge":e.last=t;break;case"histogram":e.hist||(e.hist={count:0,sum:0,min:t,max:t,bucketCounts:new Array(cf.length+1).fill(0)});var r=e.hist;r.count+=1,r.sum+=t,r.min=Math.min(r.min,t),r.max=Math.max(r.max,t),r.bucketCounts[function(i,s){for(var o=0;s.length>o;o++)if(s[o]>=i)return o;return s.length}(t,cf)]+=1}}kn(e){var t=this.qi.beforeSend;if(!t)return e;var n=Z(t)?t:[t],r=e;for(var i of n)try{var s=i(r);if(!s)return this.I.info("Metric was rejected in beforeSend function"),null;r=s}catch(o){return this.I.error("Error in beforeSend function for metric:",o),null}return r}In(){this.Rn||(this.Rn=yg(()=>{this.Rn=void 0,this.flush().catch(e=>{this.I.error("Metrics flush failed:",e)})},this.qi.flushIntervalMs))}_n(){this.Rn&&(clearTimeout(this.Rn),this.Rn=void 0)}qn(){var e=this;return Ce(function*(){if(e.Fn.size!==0){var t=e.Fn;e.Fn=new Map,e.On=!1,e.Ln=new Map,e.$n=new Set;var n=e.Dn,r=yield e._instance.Un(e.jn(t));if(n===e.Dn)switch(r.kind){case"ok":return;case"retry-later":return e.zn(t),void e.In();case"too-large":return void e.I.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.I.error("Failed to send metrics batch:",r.error)}}})()}jn(e){return t=this.Wn(e),n=function(s,o,a){return $({},s.resourceAttributes,{"service.name":s.serviceName||"unknown_service"},s.environment&&{"deployment.environment":s.environment},s.serviceVersion&&{"service.version":s.serviceVersion},{"telemetry.sdk.name":o,"telemetry.sdk.version":a})}(this.qi,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),i=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:gc(n)},scopeMetrics:[{scope:{name:r,version:i},metrics:t}]}]};var t,n,r,i}Wn(e){var t=Wy(Date.now()),n=new Map;for(var r of e.values()){var i,s=Hy(r.type,r.name,r.unit,void 0),o=n.get(s);o||(o=$({name:r.name},r.unit&&{unit:r.unit}),r.type==="count"?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:r.type==="gauge"?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},n.set(s,o));var a=gc((i=r.attributes)!==null&&i!==void 0?i:{},this.I),l=Wy(r.windowStartMs);if(r.type==="count"){var u,c={attributes:a,startTimeUnixNano:l,timeUnixNano:t,asDouble:(u=r.total)!==null&&u!==void 0?u:0};o.sum.dataPoints.push(c)}else if(r.type==="gauge"){var d,f={attributes:a,timeUnixNano:t,asDouble:(d=r.last)!==null&&d!==void 0?d:0};o.gauge.dataPoints.push(f)}else r.hist&&o.histogram.dataPoints.push({attributes:a,startTimeUnixNano:l,timeUnixNano:t,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:cf})}return Array.from(n.values())}zn(e){var t,n;for(var r of e){var i=r[0],s=r[1],o=this.Fn.get(i);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,s.windowStartMs),o.type){case"count":o.total=((t=o.total)!==null&&t!==void 0?t:0)+((n=s.total)!==null&&n!==void 0?n:0);break;case"gauge":break;case"histogram":if(s.hist)if(o.hist){o.hist.count+=s.hist.count,o.hist.sum+=s.hist.sum,o.hist.min=Math.min(o.hist.min,s.hist.min),o.hist.max=Math.max(o.hist.max,s.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=s.hist.bucketCounts[a]}else o.hist=s.hist}else this.Bn()&&this.Fn.set(i,s)}}};var Kl,Gy,df;function nI(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return df&&n.length===Gy||(Gy=n.length,df=n.reduce((r,i)=>{Kl||(Kl={});var s=Kl[i];if(s)r[s[0]]=s[1];else for(var o=e(i),a=o.length-1;a>=0;a--){var l=o[a],u=l==null?void 0:l.filename,c=t[i];if(u&&c){r[u]=c,Kl[i]=[u,c];break}}return r},{})),df}}class rI{constructor(t,n,r){r===void 0&&(r=[]),this.coercers=t,this.stackParser=n,this.modifiers=r}buildFromUnknown(t,n){n===void 0&&(n={});var r=n&&n.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(r,n,0).apply(t),s=this.buildParsingContext(n),o=this.parseStacktrace(i,s);return{$exception_list:this.convertToExceptionList(o,r),$exception_level:"error"}}modifyFrames(t){var n=this;return Ce(function*(){for(var r of t)r.stacktrace&&r.stacktrace.frames&&Z(r.stacktrace.frames)&&(r.stacktrace.frames=yield n.applyModifiers(r.stacktrace.frames));return t})()}coerceFallback(t){var n;return{type:"Error",value:"Unknown error",stack:(n=t.syntheticException)==null?void 0:n.stack,synthetic:!0}}parseStacktrace(t,n){var r,i;return t.cause!=null&&(r=this.parseStacktrace(t.cause,n)),t.stack!=""&&t.stack!=null&&(i=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?n.skipFirstLines:0),n.chunkIdMap)),$({},t,{cause:r,stack:i})}applyChunkIds(t,n){return t.map(r=>(r.filename&&n&&(r.chunk_id=n[r.filename]),r))}applyCoercers(t,n){for(var r of this.coercers)if(r.match(t))return r.coerce(t,n);return this.coerceFallback(n)}applyModifiers(t){var n=this;return Ce(function*(){var r=t;for(var i of n.modifiers)r=yield i(r);return r})()}convertToExceptionList(t,n){var r,i,s,o={type:t.type,value:t.value,mechanism:{type:(r=n.type)!==null&&r!==void 0?r:"generic",handled:(i=n.handled)===null||i===void 0||i,synthetic:(s=t.synthetic)!==null&&s!==void 0&&s}};t.stack&&(o.stacktrace={type:"raw",frames:t.stack});var a=[o];return t.cause!=null&&a.push(...this.convertToExceptionList(t.cause,$({},n,{handled:!0}))),a}buildParsingContext(t){var n;return{chunkIdMap:nI(this.stackParser),skipFirstLines:(n=t.skipFirstLines)!==null&&n!==void 0?n:1}}buildCoercingContext(t,n,r){r===void 0&&(r=0);var i=(s,o)=>{if(4>=o){var a=this.buildCoercingContext(t,n,o);return this.applyCoercers(s,a)}};return $({},n,{syntheticException:r==0?n.syntheticException:void 0,mechanism:t,apply:s=>i(s,r),next:s=>i(s,r+1)})}}var bo="?";function ap(e,t,n,r,i){var s={platform:e,filename:t,function:n===""?bo:n,in_app:!(t!=null&&t.startsWith("webkit-masked-url://"))&&t!==""};return L(r)||(s.lineno=r),L(i)||(s.colno=i),s}var nE=(e,t)=>{var n=e.indexOf("safari-extension")!==-1,r=e.indexOf("safari-web-extension")!==-1;return n||r?[e.indexOf("@")!==-1?e.split("@")[0]:bo,n?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},iI=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,sI=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,oI=/\((\S*)(?::(\d+))(?::(\d+))\)/,aI=(e,t)=>{var n=iI.exec(e);if(n)return ap(t,n[1],bo,+n[2],+n[3]);var r=sI.exec(e);if(r){if(r[2]&&r[2].indexOf("eval")===0){var i=oI.exec(r[2]);i&&(r[2]=i[1],r[3]=i[2],r[4]=i[3])}var s=nE(r[1]||bo,r[2]);return ap(t,s[1],s[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},lI=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,uI=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,cI=(e,t)=>{var n=lI.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var r=uI.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}var i=n[3],s=n[1]||bo,o=nE(s,i);return ap(t,i=o[1],s=o[0],n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},Ky=/\(error: (.*)\)/;class dI{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,n){var r=ce(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:r?t.stack:void 0,cause:t.cause?n.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var n=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?n+": "+t.message:n}isDOMException(t){return dc(t,"DOMException")}isDOMError(t){return dc(t,"DOMError")}}class fI{match(t){return Tb(t)}coerce(t,n){var r,i=this.getStack(t),s=i===void 0;return{type:this.getType(t),value:this.getMessage(t,n),stack:i??((r=n.syntheticException)==null?void 0:r.stack),cause:t.cause?n.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,n){var r=t.message;return String(r.error&&typeof r.error.message=="string"?r.error.message:r)}getStack(t){return t.stacktrace||t.stack||void 0}}class hI{constructor(){}match(t){return!!dc(t,"ErrorEvent")&&(t.error!=null||this.fi(t))}coerce(t,n){var r;if(t.error!=null)return n.apply(t.error);var i=n.apply(t.message);return $({},i,{stack:(r=this.pi(t))!==null&&r!==void 0?r:i.stack,synthetic:!0})}fi(t){return ce(t.message)&&t.message.length>0}pi(t){var n,r,i=t,s=(n=i.lineno)!==null&&n!==void 0?n:0,o=(r=i.colno)!==null&&r!==void 0?r:0;if(ce(i.filename)&&i.filename.length!==0&&s!==0)return`Error + at `+i.filename+":"+s+":"+o}}var pI=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class vI{match(t){return typeof t=="string"}coerce(t,n){var r,i=this.getInfos(t),s=i[0],o=i[1];return{type:s??"Error",value:o??t,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(t){var n="Error",r=t,i=t.match(pI);return i&&(n=i[1],r=i[2]),[n,r]}}var gI=["fatal","error","warning","log","info","debug"];function rE(e,t){t===void 0&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return"[object has no keys]";for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(", ");if(t>=i.length)return r===n.length?i:i.length>t?i.slice(0,t)+"...":i}return""}class mI{match(t){return typeof t=="object"&&t!==null}coerce(t,n){var r,i,s=this.getErrorPropertyFromObject(t);return s?n.apply(s):{type:this.getType(t),value:this.getValue(t),stack:(r=this.getStack(t))!==null&&r!==void 0?r:(i=n.syntheticException)==null?void 0:i.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(hg(t))return t.constructor.name;var n="name"in t?t.name:void 0;return ce(n)&&!cc(n)?n:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){var n="'"+t.name+"' captured as exception";return"message"in t&&typeof t.message=="string"&&(n+=" with message: '"+t.message+"'"),n}if("message"in t&&typeof t.message=="string")return t.message;var r=this.getObjectClassName(t);return(r&&r!=="Object"?"'"+r+"'":"Object")+" captured as exception with keys: "+rE(t)}isSeverityLevel(t){return ce(t)&&!cc(t)&&gI.indexOf(t)>=0}getStack(t){try{return ce(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:ce(t.stack)&&t.stack.length>0?t.stack:void 0}catch{return}}getErrorPropertyFromObject(t){for(var n in t)if({}.hasOwnProperty.call(t,n)){var r=t[n];if(Tb(r))return r}}getObjectClassName(t){try{var n=Object.getPrototypeOf(t);return n?n.constructor.name:void 0}catch{return}}}class yI{match(t){return hg(t)}coerce(t,n){var r,i=t.constructor.name;return{type:i,value:i+" captured as exception with keys: "+rE(t),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class _I{match(t){return Rb(t)}coerce(t,n){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class wI{match(t){return dc(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!hg(t))return!1;try{var n=t.detail;return n!=null&&typeof n=="object"&&"reason"in n}catch{return!1}}coerce(t,n){var r,i=this.getUnhandledRejectionReason(t);return Rb(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}:n.apply(i)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&t.detail!=null&&typeof t.detail=="object"&&"reason"in t.detail)return t.detail.reason}catch{}return t}}var mc="$message",yc="$timestamp",xI=new Set([mc,yc]),ff={enabled:!0,max_bytes:32768};function _c(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:ff.enabled,max_bytes:EI(e.max_bytes,ff.max_bytes)}:$({},ff)}class bI{constructor(t){this.Vn=[],this.Gn=0,this.qi=_c(t)}setConfig(t){this.qi=_c(t),this.Zn()}add(t){var n=function(i){var s;try{s=Cb(i)}catch{return}try{var o=JSON.parse(s);if(!Se(o))return;var a=o,l=a[mc],u=a[yc];return!ce(l)||l.trim().length===0||!ce(u)&&!Ge(u)?void 0:{step:a,json:s}}catch{return}}(t);if(n){var r=function(i){if(typeof TextEncoder<"u")return new TextEncoder().encode(i).length;for(var s=encodeURIComponent(i),o=0,a=0;s.length>a;a++)s[a]==="%"?(o+=1,a+=2):o+=1;return o}(n.json);r>this.qi.max_bytes||(this.Vn.push({step:n.step,bytes:r}),this.Gn+=r,this.Zn())}}getAttachable(){return this.Vn.map(t=>t.step)}clear(){this.Vn=[],this.Gn=0}size(){return this.Vn.length}Zn(){for(;this.Gn>this.qi.max_bytes&&this.Vn.length>0;){var t=this.Vn.shift();t&&(this.Gn-=t.bytes)}}}function EI(e,t){if(!Ge(e)||e===1/0||e===-1/0)return t;var n=Math.floor(e);return 0>n?t:n}var iE=function(e,t){var n=(t===void 0?{}:t).debugEnabled,r={F(i){if(I&&(Ee.DEBUG||I.POSTHOG_DEBUG||n)&&!L(I.console)&&I.console){for(var s=("__rrweb_original__"in I.console[i])?I.console[i].__rrweb_original__:I.console[i],o=arguments.length,a=new Array(o>1?o-1:0),l=1;o>l;l++)a[l-1]=arguments[l];s(e,...a)}},debug(){for(var i=arguments.length,s=new Array(i),o=0;i>o;o++)s[o]=arguments[o];r.F("debug",...s)},info(){for(var i=arguments.length,s=new Array(i),o=0;i>o;o++)s[o]=arguments[o];r.F("log",...s)},warn(){for(var i=arguments.length,s=new Array(i),o=0;i>o;o++)s[o]=arguments[o];r.F("warn",...s)},error(){for(var i=arguments.length,s=new Array(i),o=0;i>o;o++)s[o]=arguments[o];r.F("error",...s)},critical(){for(var i=arguments.length,s=new Array(i),o=0;i>o;o++)s[o]=arguments[o];console.error(e,...s)},uninitializedWarning(i){r.error("You must initialize PostHog before calling "+i)},createLogger:(i,s)=>iE(e+" "+i,s)};return r},D=iE("[PostHog.js]"),Ie=D.createLogger,SI=Ie("[ExternalScriptsLoader]"),wc=e=>{var t=j==null?void 0:j.querySelectorAll("script");if(t){for(var n=0;t.length>n;n++)if(t[n].src===e||t[n].getAttribute("src")===e)return t[n]}},Si=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return SI.warn(t+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var r=wc(t);if(r){if(r.__posthog_loading_callback_fired)return n();var i=r.__posthog_loading_error;return i?n(i):(r.addEventListener("load",o=>{r.__posthog_loading_callback_fired=!0,n(void 0,o)}),void r.addEventListener("error",o=>{r.__posthog_loading_error=o,n(o)}))}var s=()=>{if(!j)return n("document not found");if(wc(t))return Si(e,t,n);var o=j.createElement("script");if(o.type="text/javascript",o.crossOrigin="anonymous",o.src=t,o.onload=u=>{o.__posthog_loading_callback_fired=!0,n(void 0,u)},o.onerror=u=>{o.__posthog_loading_error=u,n(u)},e.config.prepare_external_dependency_script&&(o=e.config.prepare_external_dependency_script(o)),!o)return n("prepare_external_dependency_script returned null");if(e.config.external_scripts_inject_target==="head")j.head.appendChild(o);else{var a,l=j.querySelectorAll("body > script");l.length>0?(a=l[0].parentNode)==null||a.insertBefore(o,l[0]):j.body.appendChild(o)}};j!=null&&j.body?s():j==null||j.addEventListener("DOMContentLoaded",s)},hf={},Qy=(e,t)=>{var n="/static/"+t+".js?v="+e.version;if(t==="toolbar"){var r=3e5;n=n+"&t="+Math.floor(Date.now()/r)*r}return e.requestRouter.endpointFor("assets",n)};Y.__PosthogExtensions__=Y.__PosthogExtensions__||{},Y.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!=="remote-config"){var r=e.config.strict_script_versioning;if(r){var i=e.requestRouter.endpointFor("assets","/static/"+e.version+"/"+t+".js"),s=hf[i];if(r==="fallback"&&s){if(wc(s))return void Si(e,s,n);delete hf[i]}Si(e,i,r==="fallback"?(a,l)=>{if(a)if(typeof a=="string")n(a);else{var u,c=Qy(e,t);hf[i]=c;var d=wc(i);d==null||(u=d.parentNode)==null||u.removeChild(d),Si(e,c,n)}else n(void 0,l)}:n)}else Si(e,Qy(e,t),n)}else{var o=e.requestRouter.endpointFor("assets","/array/"+e.config.token+"/config.js");Si(e,o,n)}},Y.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var r=e.requestRouter.endpointFor("api",t);Si(e,r,n)};Ee.DEBUG=!1,Ee.LIB_VERSION="1.418.16",Ee.LIB_NAME="web";var sE="$people_distinct_id",wt="distinct_id",Ya="$device_id",pf="$device_model",$s="__alias",ca="__timers",lp="$autocapture_disabled_server_side",up="$heatmaps_enabled_server_side",cp="$exception_capture_enabled_server_side",dp="$error_tracking_suppression_rules",fp="$error_tracking_capture_extension_exceptions",hp="$web_vitals_enabled_server_side",wg="$dead_clicks_enabled_server_side",xg="$product_tours_enabled_server_side",pp="$web_vitals_allowed_metrics",Oi="$session_recording_remote_config",oE="$replay_sample_rate",aE="$replay_override_sampling",lE="$replay_override_linked_flag",uE="$replay_override_url_trigger",cE="$replay_override_event_trigger",Fs="$sesid",bg="$session_is_sampled",ir="$enabled_feature_flags",Mi="$active_feature_flags",Pu="$early_access_features",Xa="$feature_flag_details",Ai="$feature_flag_payloads",Gs="$feature_flag_request_id",xc="$minimal_flag_called_events",Mn="$override_feature_flags",Ci="$override_feature_flag_payloads",yn="$stored_person_properties",Dn="$stored_group_properties",dE="$groups",vp="$surveys",bc="$surveys_loaded_at",gp="$surveys_activated",Ru="$surveys_activated_session",Tu="$surveys_activated_timestamps",da="ph_product_tours",ar="$flag_call_reported",fa="$flag_call_reported_session_id",Ks="$feature_flag_errors",Gi="$feature_flag_evaluated_at",se="$user_state",mp="$client_session_props",yp="$capture_rate_limit",_p="$initial_campaign_params",wp="$initial_referrer_info",Ec="$initial_person_info",Sc="$epp",fs="$posthog_cookieless",fE="$cookieless_mode",hE="$sdk_debug_extensions_init_method",pE="$sdk_debug_extensions_init_time_ms",xp="$sdk_debug_recording_script_not_loaded",Eg="PostHog loadExternalDependency extension not found.",ki="on_reject",lr="always",We="anonymous",ot="identified",bp="identified_only",Cc="visibilitychange",kc="beforeunload",xs="$pageview",vf="$pageleave",gf="$identify",Yy="$groupidentify";function Ql(e,t){Z(e)&&e.forEach(t)}function ve(e,t){if(!ne(e))if(Z(e))e.forEach(t);else if(AT(e))e.forEach((r,i)=>t(r,i));else for(var n in e)Pb.call(e,n)&&t(e[n],n)}var _e=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];for(var i of n)for(var s in i)i[s]!==void 0&&(e[s]=i[s]);return e};function Iu(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var Xy=function(e){try{return e()}catch{return}},CI=function(e){return function(){try{for(var t=arguments.length,n=new Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,n)}catch(i){D.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),D.critical(i)}}},Sg=function(e){var t={};return ve(e,function(n,r){(ce(n)&&n.length>0||Ge(n))&&(t[r]=n)}),t},kI=["herokuapp.com","vercel.app","netlify.app"];function PI(e){var t=e==null?void 0:e.hostname;if(!ce(t))return!1;var n=t.split(".").slice(-2).join(".");for(var r of kI)if(n===r)return!1;return!0}function Re(e,t,n,r){var i=r??{},s=i.capture,o=i.passive;e==null||e.addEventListener(t,n,{capture:s!==void 0&&s,passive:o===void 0||o})}function Ep(e){return e.name==="ph_toolbar_internal"}var vE=e=>{if(j){try{for(var t=e+"=",n=j.cookie.split(";").filter(s=>s.length),r=0;n.length>r;r++){for(var i=n[r];i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(t)===0)return decodeURIComponent(i.substring(t.length,i.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Ge(e)&&isFinite(e)&&Math.floor(e)===e});class Pc{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/256,s[5]=t,s[6]=112|n>>>8,s[7]=n,s[8]=128|r>>>24,s[9]=r>>>16,s[10]=r>>>8,s[11]=r,s[12]=i>>>24,s[13]=i>>>16,s[14]=i>>>8,s[15]=i,new Pc(s)}toString(){for(var t="",n=0;this.bytes.length>n;n++)t=t+(this.bytes[n]>>>4).toString(16)+(15&this.bytes[n]).toString(16),n!==3&&n!==5&&n!==7&&n!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new Pc(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var n=0;16>n;n++){var r=this.bytes[n]-t.bytes[n];if(r!==0)return Math.sign(r)}return 0}}class RI{generate(){var t=this.generateOrAbort();if(!L(t))return t;this.Rr=0;var n=this.generateOrAbort();if(L(n))throw new Error("Could not generate UUID after timestamp reset");return n}generateOrAbort(){var t=Date.now();if(t>this.Rr)this.Rr=t,this.Ar();else{if(this.Rr>=t+1e4)return;this.Lr++,this.Lr>4398046511103&&(this.Rr++,this.Ar())}return Pc.fromFieldsV7(this.Rr,Math.trunc(this.Lr/Math.pow(2,30)),this.Lr&Math.pow(2,30)-1,this.Or.nextUint32())}Ar(){this.Lr=1024*this.Or.nextUint32()+(1023&this.Or.nextUint32())}constructor(){this.Rr=0,this.Lr=0,this.Or=new TI}}var Jy,gE=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};I&&!L(I.crypto)&&crypto.getRandomValues&&(gE=e=>crypto.getRandomValues(e));class TI{nextUint32(){return this.ft.length>this.Fr||(gE(this.ft),this.Fr=0),this.ft[this.Fr++]}constructor(){this.ft=new Uint32Array(8),this.Fr=1/0}}var $n=()=>II().toString(),II=()=>(Jy||(Jy=new RI)).generate(),Yo="",OI=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Ke={Dr:()=>!!j,jr(e){D.error("cookieStore error: "+e)},Pr:vE,Br(e){var t;try{t=JSON.parse(Ke.Pr(e))||{}}catch{}return t},Nr(e,t,n,r,i){if(!j)return!1;try{var s="",o="",a=function(c,d){if(d){var f=function(_,p){if(p===void 0&&(p=j),Yo)return Yo;if(!p||["localhost","127.0.0.1"].includes(_))return"";for(var y=_.split("."),h=Math.min(y.length,8),v="dmn_chk_"+$n();!Yo&&h--;){var x=y.slice(h).join("."),b=v+"=1;domain=."+x+";path=/";p.cookie=b+";max-age=3",p.cookie.includes(v)&&(p.cookie=b+";max-age=0",Yo=x)}return Yo}(c);if(!f){var m=(_=>{var p=_.match(OI);return p?p[0]:""})(c);m!==f&&D.info("Warning: cookie subdomain discovery mismatch",m,f),f=m}return f?"; domain=."+f:""}return""}(j.location.hostname,r);if(n){var l=new Date;l.setTime(l.getTime()+864e5*n),s="; expires="+l.toUTCString()}i&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+s+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&D.warn("cookieStore warning: large cookie, len="+u.length),j.cookie=u,!0}catch{return!1}},qr(e,t){if(j!=null&&j.cookie)try{Ke.Nr(e,"",-1,t)}catch{return}}},mf=null,ge={Dr(){if(!rt(mf))return mf;var e=!0;if(L(I))e=!1;else try{var t="__mplssupport__";ge.Nr(t,"xyz"),ge.Pr(t)!=='"xyz"'&&(e=!1),ge.qr(t)}catch{e=!1}return e||D.error("localStorage unsupported; falling back to cookie store"),mf=e,e},jr(e){D.error("localStorage error: "+e)},Pr(e){try{return I==null?void 0:I.localStorage.getItem(e)}catch(t){ge.jr(t)}return null},Br(e){try{return JSON.parse(ge.Pr(e))||{}}catch{}return null},Nr(e,t){try{return I==null||I.localStorage.setItem(e,JSON.stringify(t)),!0}catch(n){ge.jr(n)}return!1},qr(e){try{I==null||I.localStorage.removeItem(e)}catch(t){ge.jr(t)}}},yf=[yn,Mi,ir,Xa,Ai,Gs,Gi,Ks,ar],Pi=[Ya,wt,Fs,bg,Sc,Ec,se],Rc=e=>e+"_cpm",MI=["__proto__","constructor","prototype"],_f=e=>{if(!Se(e))return{};var t={};return Object.keys(e).forEach(n=>{MI.indexOf(n)===-1&&(t[n]=e[n])}),t},wf=function(e,t){t===void 0&&(t=[]);var n={};return[...Pi,...t].forEach(r=>{var i=e[r];L(i)||rt(i)||i===""||(n[r]=i)}),n},mE=e=>{for(var t=5381,n=2166136261,r=0;e.length>r;r++){var i=e.charCodeAt(r);t=33*t^i,n=Math.imul(n^i,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(n>>>0).toString(36)},Zy=(e,t)=>({p:t,f:mE(JSON.stringify(e))}),e_=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{var n=Ke.Br(Rc(e)),r=(n==null?void 0:n.f)===mE(t)&&Z(n.p);return{properties:r?n.p:[],isValid:r}}catch{return{properties:[],isValid:!1}}},xf=(e,t)=>t+"|"+(Ke.Pr(Rc(e))||""),Yl={},AI={Dr:()=>!0,jr(e){D.error("memoryStorage error: "+e)},Pr:e=>Yl[e]||null,Br:e=>Yl[e]||null,Nr:(e,t)=>(Yl[e]=t,!0),qr(e){delete Yl[e]}},mi=null,we={Dr(){if(!rt(mi))return mi;if(mi=!0,L(I))mi=!1;else try{var e="__support__";we.Nr(e,"xyz"),we.Pr(e)!=='"xyz"'&&(mi=!1),we.qr(e)}catch{mi=!1}return mi},jr(e){D.error("sessionStorage error: ",e)},Pr(e){try{return I==null?void 0:I.sessionStorage.getItem(e)}catch(t){we.jr(t)}return null},Br(e){try{return JSON.parse(we.Pr(e))||null}catch{}return null},Nr(e,t){try{return I==null||I.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(n){we.jr(n)}return!1},qr(e){try{I==null||I.sessionStorage.removeItem(e)}catch(t){we.jr(t)}}};class NI{constructor(t){this._instance=t}get qi(){return this._instance.config}get consent(){return this.cs()?0:this.fs}isOptedOut(){return this.qi.cookieless_mode===lr||this.isRejected()||this.consent===-1&&this.qi.cookieless_mode===ki}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.qi.opt_out_capturing_by_default}optInOut(t){this.ps.Nr(this.gs,t?1:0,this.qi.cookie_expiration,this.qi.cross_subdomain_cookie,this.qi.secure_cookie)}reset(){this.ps.qr(this.gs,this.qi.cross_subdomain_cookie)}get gs(){var t=this._instance.config,n=t.token,r=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(r?r+n:"__ph_opt_in_out_"+n)}get fs(){var t=this.ps.Pr(this.gs);return lf(t)?1:J(LT,t)?0:-1}get ps(){var t=this.qi.opt_out_capturing_persistence_type,n=t==="localStorage"?ge:Ke;if(!this.ys||this.ys!==n){this.ys=n;var r=t==="localStorage"?Ke:ge;r.Pr(this.gs)&&(this.ys.Pr(this.gs)||this.optInOut(lf(r.Pr(this.gs))),r.qr(this.gs,this.qi.cross_subdomain_cookie))}return this.ys}cs(){return!!this.qi.respect_dnt&&[St==null?void 0:St.doNotTrack,St==null?void 0:St.msDoNotTrack,Y.doNotTrack].some(t=>lf(t))}}function yE(e,t){var n,r=e==null||(n=e.config)==null?void 0:n.get_current_url;if(!vt(r))return t;try{var i=r(t);return ce(i)&&i?i:t}catch(s){return D.error("Error in get_current_url, falling back to window.location.href",s),t}}var _E="__POSTHOG_TOOLBAR__",$I=1,FI=3,LI=11;function t_(e){return e instanceof Element&&(e.id===_E||!(e.closest==null||!e.closest(".toolbar-global-fade-container")))}function ui(e){return!!e&&e.nodeType===$I}function Kt(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function wE(e){return!!e&&e.nodeType===FI}function xE(e){return!!e&&e.nodeType===LI&&ui(e.host)}var bE=1e3;function Cg(e){return e?dd(e).split(/\s+/):[]}function n_(e,t){var n=function(r){var i,s=I==null||(i=I.location)==null?void 0:i.href;return L(s)?void 0:yE(r,s)}(t);return!!(n&&e&&e.some(r=>n.match(r)))}function Tc(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Cg(t)}function EE(e){return ne(e)?null:dd(e).split(/(\s+)/).filter(t=>ka(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ja(e){var t="";return kp(e)&&!RE(e)&&e.childNodes&&e.childNodes.length&&ve(e.childNodes,function(n){var r;wE(n)&&n.textContent&&(t+=(r=EE(n.textContent))!==null&&r!==void 0?r:"")}),dd(t)}function Sp(e){var t;return L(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}var kg=["a","button","form","input","select","textarea","label"];function Cp(e,t){if(L(t))return!0;var n,r=function(s){if(t.some(o=>function(a,l){var u=a.matches||a.matchesSelector||a.msMatchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.oMatchesSelector;try{return!!u&&u.call(a,l)}catch{return!1}}(s,o)))return{v:!0}};for(var i of e)if(n=r(i))return n.v;return!1}function SE(e){var t=e.parentNode;return!(!t||!ui(t))&&t}var jI=[".ph-no-autocapture","[data-ph-no-autocapture]"],CE=["next","previous","prev",">","<"],DI=[...CE,"+","-","−","–"],r_=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,i_=[".ph-no-rageclick",".ph-no-capture"],zI=["","text","search","email","password","url","tel","number"];function kE(e,t){if(!I||Pg(e))return!1;var n,r,i,s,o;if($t(t)?(n=!!t&&i_,r=void 0,i=!1):(n=(s=t==null?void 0:t.css_selector_ignorelist)!==null&&s!==void 0?s:i_,r=t==null?void 0:t.content_ignorelist,i=(o=t==null?void 0:t.ignore_text_selection)!==null&&o!==void 0&&o),n===!1||i&&function(l){return!(!l||!ui(l))&&(!!Kt(l,"textarea")||(Kt(l,"input")?J(zI,(l.getAttribute("type")||"").toLowerCase()):function(u){if(u.isContentEditable)return!0;var c=u.getAttribute==null?void 0:u.getAttribute("contenteditable");return c==="true"||c===""}(l)))}(e))return!1;var a=PE(e,!1).targetElementList;return!function(l,u){if(l===!1||L(l))return!1;var c;if(l===!0)c=CE;else{if(!Z(l))return!1;if(l.length>10)return D.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;c=l.map(d=>d.toLowerCase())}return u.some(d=>{var f=d.safeText,m=d.ariaLabel;return c.some(_=>r_(f,_)||r_(m,_))})}(r,a.map(l=>{var u;return{safeText:Ja(l).toLowerCase(),ariaLabel:((u=l.getAttribute("aria-label"))==null?void 0:u.toLowerCase().trim())||""}}))&&!Cp(a,n)}var Pg=e=>!e||Kt(e,"html")||!ui(e),PE=(e,t)=>{if(!I||Pg(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[e],i=e;i.parentNode&&!Kt(i,"body");)if(xE(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=SE(i);if(!s)break;if(t||kg.indexOf(s.tagName.toLowerCase())>-1)n=!0;else try{var o=I.getComputedStyle(s);o&&o.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}r.push(s),i=s}return{parentIsUsefulElement:n,targetElementList:r}};function kp(e){for(var t=new Set,n=0,r=e;r.parentNode&&!Kt(r,"body");r=r.parentNode){if(n++>=bE||t.has(r))return!1;t.add(r);var i=Tc(r);if(J(i,"ph-sensitive")||J(i,"ph-no-capture"))return!1}if(J(Tc(e),"ph-include"))return!0;var s=e.type||"";if(ce(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var o=e.name||e.id||"";return!ce(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function RE(e){return!!(Kt(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Kt(e,"select")||Kt(e,"textarea")||e.getAttribute("contenteditable")==="true")}var s_=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),o_=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,UI=[16,15,14,13],VI=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),a_=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),l_=/[0-9A-Za-z_]/;function BI(e){for(var t=0,n=!1,r=e.length-1;r>=0;r--){var i=e.charCodeAt(r)-48;n&&(i*=2)>9&&(i-=9),t+=i,n=!n}return t%10==0}function ka(e,t){if(t===void 0&&(t=!0),ne(e))return!1;if(ce(e)){e=dd(e);var n=t?s_.test((e||"").replace(/[- ]/g,"")):function(i){var s;for(o_.lastIndex=0;s=o_.exec(i);){var o=s[2];if(o)for(var a=o.replace(/[- ]/g,""),l=0;a.length>l;l++)for(var u of UI){var c=l+u;if(a.length>=c){var d=a.slice(l,c);if(s_.test(d)&&BI(d))return!0}}}return!1}(e);if(n)return!1;var r=t?VI.test(e):function(i){var s;for(a_.lastIndex=0;s=a_.exec(i);){var o=s[1],a=s[3];if(!(o&&a&&l_.test(o)&&l_.test(a)))return!0}return!1}(e);if(r)return!1}return!0}function u_(e){var t=Ja(e);return ka(t=(t+" "+TE(e)).trim())?t:""}function TE(e){var t="";return e&&e.childNodes&&e.childNodes.length&&ve(e.childNodes,function(n){var r;if(n&&((r=n.tagName)==null?void 0:r.toLowerCase())==="span")try{var i=Ja(n);t=(t+" "+i).trim(),n.childNodes&&n.childNodes.length&&(t=(t+" "+TE(n)).trim())}catch(s){D.error("[AutoCapture]",s)}}),t}function c_(e){return e.replace(/"|\\"/g,'\\"')}function qI(e){var t=e.attr__class;if(t)return Z(t)?t:Cg(t)}var Xl=Ie("[Dead Clicks]"),WI=()=>!0,HI=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(wg)),r=e.instance.config.capture_dead_clicks;return $t(r)?r:!!Se(r)||n};class d_{get lazyLoadedDeadClicksAutocapture(){return this.bs}constructor(t,n,r){this.instance=t,this.isEnabled=n,this.onCapture=r,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var n=t.config;"captureDeadClicks"in n&&(this.instance.persistence&&this.instance.persistence.register({[wg]:n.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this._s(()=>{this.ws()}):this.stop()}_s(t){var n,r;(n=Y.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture?t():(r=Y.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?Xl.error("failed to load script",i):t()})}ws(){var t;if(j){if(!this.bs&&(t=Y.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture){var n=Se(this.instance.config.capture_dead_clicks)?$({},this.instance.config.capture_dead_clicks):{};n.__onCapture=this.onCapture,this.onCapture&&(n.capture_dead_swipes=!1),this.bs=Y.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.bs.start(j),Xl.info("starting...")}}else Xl.error("`document` not found. Cannot start.")}stop(){this.bs&&(this.bs.stop(),this.bs=void 0,Xl.info("stopping..."))}}var bf=Ie("[SegmentIntegration]"),IE="posthog-js";function OE(e,t){var n=t===void 0?{}:t,r=n.organization,i=n.projectId,s=n.prefix,o=n.severityAllowList,a=o===void 0?["error"]:o,l=n.sendExceptionsToPostHog,u=l===void 0||l;return c=>{var d,f,m,_,p;if(a!=="*"&&!a.includes(c.level)||!e.__loaded)return c;c.tags||(c.tags={});var y=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());c.tags["PostHog Person URL"]=y,e.sessionRecordingStarted()&&(c.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var h,v=((d=c.exception)==null?void 0:d.values)||[],x=v.map(E=>$({},E,{stacktrace:E.stacktrace?$({},E.stacktrace,{type:"raw",frames:(E.stacktrace.frames||[]).map(S=>$({},S,{platform:"web:javascript"}))}):void 0})),b={$exception_message:((f=v[0])==null?void 0:f.value)||c.message,$exception_type:(m=v[0])==null?void 0:m.type,$exception_level:c.level,$exception_list:x,$sentry_event_id:c.event_id,$sentry_exception:c.exception,$sentry_exception_message:((_=v[0])==null?void 0:_.value)||c.message,$sentry_exception_type:(p=v[0])==null?void 0:p.type,$sentry_tags:c.tags};return r&&i&&(b.$sentry_url=(s||"https://sentry.io/organizations/")+r+"/issues/?project="+i+"&query="+c.event_id),u&&((h=e.exceptions)==null||h.sendExceptionEvent(b)),c}}class GI{constructor(t,n,r,i,s,o){this.name=IE,this.setupOnce=function(a){a(OE(t,{organization:n,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}}class f_{constructor(t){this.ks=(n,r,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(D.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:n,changeReason:i}),this.Ss=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.xs()}xs(){var t;this.Cs=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(this.ks)}destroy(){var t;(t=this.Cs)==null||t.call(this),this.Cs=void 0}doPageView(t,n){var r,i=this.Ts(t,n);return this.Ss={pathname:(r=I==null?void 0:I.location.pathname)!==null&&r!==void 0?r:"",pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),i}doPageLeave(t){var n;return this.Ts(t,(n=this.Ss)==null?void 0:n.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this.Ss)==null?void 0:t.pageViewId}}Ts(t,n){var r=this.Ss;if(!r)return{$pageview_id:n};var i={$pageview_id:n,$prev_pageview_id:r.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var o=s.maxScrollHeight,a=s.lastScrollY,l=s.maxScrollY,u=s.maxContentHeight,c=s.lastContentY,d=s.maxContentY;if(!(L(o)||L(a)||L(l)||L(u)||L(c)||L(d))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c),d=Math.ceil(d);var f=o>1?Vn(a/o,0,1,D):1,m=o>1?Vn(l/o,0,1,D):1,_=u>1?Vn(c/u,0,1,D):1,p=u>1?Vn(d/u,0,1,D):1;i=_e(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:f,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:m,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:_,$prev_pageview_max_content:d,$prev_pageview_max_content_percentage:p})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(t.getTime()-r.timestamp.getTime())/1e3),i}}var Ef=["flags","surveys"],KI={[sE]:{exposure:"hidden"},[$s]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[ca]:{exposure:"hidden"},[lp]:{exposure:"event"},[up]:{exposure:"hidden"},[cp]:{exposure:"event"},[dp]:{exposure:"hidden"},[fp]:{exposure:"event"},[hp]:{exposure:"event"},[wg]:{exposure:"event"},[xg]:{exposure:"hidden"},[pp]:{exposure:"event"},[Oi]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[Fs]:{exposure:"hidden"},[bg]:{exposure:"event"},[oE]:{exposure:"event",shouldSkipFromEventProperties:e=>rt(e)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[ir]:{exposure:"hidden",storageGroup:"flags"},[Mi]:{exposure:"hidden",storageGroup:"flags"},[Pu]:{exposure:"hidden"},[Xa]:{exposure:"hidden",storageGroup:"flags"},[Ai]:{exposure:"hidden",storageGroup:"flags"},[Gs]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[xc]:{exposure:"hidden",storageGroup:"flags"},[Mn]:{exposure:"hidden"},[Ci]:{exposure:"hidden"},[yn]:{exposure:"hidden"},[Dn]:{exposure:"hidden"},[vp]:{exposure:"hidden",storageGroup:"surveys"},[bc]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[gp]:{exposure:"event"},[Ru]:{exposure:"hidden"},[Tu]:{exposure:"hidden"},[da]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$product_tours_activated_session:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[ar]:{exposure:"hidden"},[fa]:{exposure:"hidden"},[dE]:{exposure:"event"},[Ks]:{exposure:"hidden"},[Gi]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[se]:{exposure:"hidden"},[mp]:{exposure:"hidden"},[yp]:{exposure:"hidden"},[_p]:{exposure:"hidden"},[wp]:{exposure:"hidden"},[Ec]:{exposure:"hidden"},[Sc]:{exposure:"hidden"},[aE]:{exposure:"event"},[lE]:{exposure:"event"},[uE]:{exposure:"event"},[cE]:{exposure:"event"},[hE]:{exposure:"event"},[pE]:{exposure:"event"},[xp]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_pending_trigger_conditions:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},QI=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],An=e=>{var t=KI[e];if(t)return t;for(var n of QI){var r=n[1];if(e.indexOf(n[0])===0)return r}},Ls=(e,t)=>{try{return JSON.stringify(e,(n,r)=>typeof r=="bigint"?r.toString():r,t)}catch{return Cb(e)}},Eo=e=>{var t=j==null?void 0:j.createElement("a");return L(t)?null:(t.href=e,t)},So=function(e,t){for(var n,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;r.length>i;i++){var s=r[i].split("=");if(s[0]===t){n=s;break}}if(!Z(n)||2>n.length)return"";var o=n[1];try{o=decodeURIComponent(o)}catch{D.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Za=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split("#"),i=r[1],s=(r[0]||"").split("?"),o=s[1],a=s[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var d=l[c].split("=");Z(d)&&(t.includes(d[0])?u.push(d[0]+"="+n):u.push(l[c]))}var f=a;return o!=null&&(f+="?"+u.join("&")),i!=null&&(f+="#"+i),f},Ic=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},ME=(e,t)=>e>=t&&xb(),AE=(e,t,n,r)=>{if(e===0){if(xb()){var i=t+1;return i===n&&r(),i}return t}return 0},Jl="https?://(.*)",Co=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],YI=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Co],el="",XI=["li_fat_id"];function NE(e,t,n){if(!j)return{};var r,i=t?[...Co,...n||[]]:[],s=$E(Za(j.URL,i,el),e),o=(r={},ve(XI,function(a){var l=vE(a);r[a]=l||null}),r);return _e(o,s)}function $E(e,t){var n=YI.concat(t||[]),r={};return ve(n,function(i){var s=So(e,i);r[i]=s||null}),r}function FE(e){var t=function(s){return s?s.search(Jl+"google.([^/?]*)")===0?"google":s.search(Jl+"bing.com")===0?"bing":s.search(Jl+"yahoo.com")===0?"yahoo":s.search(Jl+"duckduckgo.com")===0?"duckduckgo":null:null}(e),n=t!="yahoo"?"q":"p",r={};if(!rt(t)){r.$search_engine=t;var i=j?So(j.referrer,n):"";i.length&&(r.ph_keyword=i)}return r}function h_(){return navigator.language||navigator.userLanguage}var Oc="$direct";function LE(){return(j==null?void 0:j.referrer)||Oc}function jE(e,t,n){n===void 0&&(n=!1);var r=e?[...Co,...t||[]]:[],i=n?li(Ae==null?void 0:Ae.href):Ae==null?void 0:Ae.href,s=i==null?void 0:i.substring(0,1e3);return{r:LE().substring(0,1e3),u:s?Za(s,r,el):void 0}}function DE(e,t){var n;t===void 0&&(t=!1);var r=e.r,i=e.u,s=t?li(i):i,o={$referrer:r,$referring_domain:r==null?void 0:r==Oc?Oc:(n=Eo(r))==null?void 0:n.host};if(s){o.$current_url=s;var a=Eo(s);o.$host=a==null?void 0:a.host,o.$pathname=a==null?void 0:a.pathname;var l=$E(s);_e(o,l)}if(r){var u=FE(r);_e(o,u)}return o}function zE(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function JI(){try{return new Date().getTimezoneOffset()}catch{return}}var ZI={flags:Gi,surveys:bc},eO=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Zl=e=>e+"_cookie_identity_change_pending",Rr="main",p_=(e,t)=>{ve(e,(n,r)=>{var i=An(r);i&&i.exposure!=="event"||{}.hasOwnProperty.call(t,r)||delete e[r]})};class Sf{constructor(t,n,r){if(r===void 0&&(r=!0),this.Ms={},this.Es=!1,this.Is=!1,this.Rs=!1,this.Ps=!1,this.qi=t,this.As=r,this.props={},this.Fs=void 0,this.Os=(s=>{var o="";return s.token&&(o=s.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),s.persistence_name?"ph_"+s.persistence_name:"ph_"+o+"_posthog"})(t),this.ps=this.Ls(t),this.Is=this.$s(t),this.load(),t.debug&&D.info("Persistence loaded",t.persistence,$({},this.props)),this.update_config(t,t,n),this.save(),I){var i=()=>this.flush();Re(I,"beforeunload",i,{capture:!1}),Re(I,"pagehide",i,{capture:!1})}}Ds(){var t,n=(t=this.qi)==null?void 0:t.persistence_save_debounce_ms;return Ge(n)&&n>0?n:0}Ns(t){if(this.qi.cookieWinsOnConflict&&this.qi.persistence.toLowerCase()==="localstorage+cookie")if(t)try{var n=wf(t,this.qi.cookie_persisted_properties||[]),r=Zy(n,this.qi.cookie_persisted_properties||[]),i=JSON.stringify(n)+"|"+JSON.stringify(r),s=Ke.Pr(this.Os)||void 0;s&&xf(this.Os,s)===i&&(this.qs=i,this.js=s)}catch{}else try{var o=Ke.Pr(this.Os)||void 0;this.qs=o?xf(this.Os,o):void 0,this.js=o}catch{}}syncCookieProperties(){return this.Bs(this.qi)}Bs(t,n){if(n===void 0&&(n=!1),this.Hs&&!n||this.Ps||!t.cookieWinsOnConflict||t.persistence.toLowerCase()!=="localstorage+cookie")return!1;var r;try{r=Ke.Pr(this.Os)||void 0}catch{}if(!r||r===this.js)return!1;var i,s=xf(this.Os,r);try{i=_f(JSON.parse(r))}catch{return!1}if((Ke.Pr(this.Os)||void 0)!==r)return!1;this.qs=s,this.js=r;var o=e_(this.Os,r),a=[...Pi,...o.properties],l={};if(Object.keys(i).forEach(p=>{var y=i[p];(L(y)||rt(y)||y===""||p===se&&y!==We&&y!==ot)&&(l[p]=!0,delete i[p])}),En(i))return!1;var u=wt in i||i[se]===We||i[se]===ot,c=this.props[wt],d=this.props[se],f=_e({},this.props);[...Pi,...t.cookie_persisted_properties||[]].forEach(p=>{if(a.indexOf(p)!==-1&&!(p in i)&&!l[p]&&(u||p!==wt&&p!==se)){var y=f[p];!o.isValid&&Pi.indexOf(p)!==-1&&(y===!1||y===0)||delete f[p]}}),this.props=_e(f,i),!u||se in i||se in this.props||this.Us(se,We);var m=this.props[wt],_=this.props[se];return!u||m===c&&_===d||(this.Rs=!0,we.Nr(Zl(this.Os),!0),this.zs(yn),this.zs(Mi),this.zs(ir),this.zs(Xa),this.zs(Ai),this.zs(Gs),this.zs(Gi),this.zs(Ks),this.zs(ar),_===We&&(d===ot||i[se]===We||!L(c)&&m!==c)&&(p_(this.props,i),this.zs(Dn)),_===ot?this.props.$user_id=m:delete this.props.$user_id,this.zs($s)),!0}consumeCookieIdentityChange(){var t=Zl(this.Os),n=this.Rs||!!we.Pr(t);return this.Rs=!1,n&&we.qr(t),n}Ws(t){return t===void 0&&(t=!1),!(this.Ps||this.Hs&&!t||!this.qi.cookieWinsOnConflict||this.qi.persistence.toLowerCase()!=="localstorage+cookie"||(this.Ps=!0,0))}Vs(){this.Ps&&(L(this.Gs)||(clearTimeout(this.Gs),this.Gs=void 0),delete this.Ms[Rr],this.Zs(!0))}Qs(t){if(t===void 0&&(t=!0),this.Ps)try{t?this.Vs():L(this.Gs)||(clearTimeout(this.Gs),this.Gs=void 0)}finally{this.Ps=!1}}isDisabled(){return!!this.Hs}Ls(t){eO.indexOf(t.persistence.toLowerCase())===-1&&(D.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var n,r=function(o,a){o===void 0&&(o=[]),a===void 0&&(a=!1);var l=[...Pi,...o];return $({},ge,{Br(u){try{var c,d={};try{c=Ke.Pr(u)||void 0,d=c?_f(JSON.parse(c)):{}}catch{}var f,m=JSON.parse(ge.Pr(u)||"{}");if(a){var _=e_(u,c),p=[...Pi,..._.properties],y={};Object.keys(d).forEach(E=>{var S=d[E];rt(S)||S===""||E===se&&S!==We&&S!==ot||(y[E]=S)});var h=wt in y||y[se]===We||y[se]===ot;if(Object.keys(y).length>0){var v,x=m[wt],b=(v=m[se])!==null&&v!==void 0?v:We;l.forEach(E=>{if(p.indexOf(E)!==-1&&!(E in d)&&(h||E!==wt&&E!==se)){var S=m[E];!_.isValid&&Pi.indexOf(E)!==-1&&(S===!1||S===0)||delete m[E]}}),!h||se in d||se in m||(m[se]=We),!h||(wt in y?y[wt]:m[wt])===x&&(se in y?y[se]:m[se])===b||(yf.forEach(E=>delete m[E]),y[se]===ot&&wt in y?m.$user_id=y[wt]:delete m.$user_id,y[se]!==ot&&(delete m[dE],delete m[Dn]),delete m.__alias)}f=_e(m,y)}else f=_e(d,m);return ge.Nr(u,f),f}catch{}return null},Nr(u,c,d,f,m,_){var p=ge.Nr(u,c,void 0,void 0,_);try{var y=wf(c,o);if(Object.keys(y).length){if(a){var h=Rc(u),v=Zy(y,o);if(Ke.Nr(h,v,d,f,m,_),Ke.Pr(h)!==JSON.stringify(v)){Ke.qr(h,f);var x=wf(c);return Ke.Nr(u,x,d,f,m,_),p}}Ke.Nr(u,y,d,f,m,_)}}catch(b){ge.jr(b)}return p},qr(u,c){try{I==null||I.localStorage.removeItem(u),Ke.qr(u,c),Ke.qr(Rc(u),c)}catch(d){ge.jr(d)}}})}(t.cookie_persisted_properties||[],t.cookieWinsOnConflict),i=!1,s=t.persistence.toLowerCase();return s==="localstorage"&&ge.Dr()?(n=ge,i=!0):s==="localstorage+cookie"&&r.Dr()?(n=r,i=!0):s==="sessionstorage"&&we.Dr()?n=we:s==="memory"?n=AI:s==="cookie"?n=Ke:r.Dr()?(n=r,i=!0):n=Ke,this.Es=i,n}Js(t){return this.Os+"__"+t}$s(t){return this.Es&&!!t.split_storage}properties(){var t={};return ve(this.props,(n,r)=>{var i=An(r);if(!i||i.exposure==="event"){if(i!=null&&i.shouldSkipFromEventProperties!=null&&i.shouldSkipFromEventProperties(n))return;t[r]=n}}),t}load(t){if(t===void 0&&(t=!1),!this.Hs||t){var n=this.qi.cookieWinsOnConflict&&this.qi.persistence.toLowerCase()==="localstorage+cookie",r=n?ge.Br(this.Os):null,i={};if(n)try{ve(i=_f(Ke.Br(this.Os)),(_,p)=>{(L(_)||rt(_)||_==="")&&delete i[p]})}catch{}var s=this.ps.Br(this.Os);if(s&&(this.props=_e({},s)),this.Is&&this.Ks(),n&&s){var o,a,l=r==null?void 0:r[wt],u=(o=r==null?void 0:r[se])!==null&&o!==void 0?o:We,c=s[wt],d=(a=s[se])!==null&&a!==void 0?a:We;if(c!==l||d!==u){this.Rs=!0,we.Nr(Zl(this.Os),!0);var f=_e({},this.props);yf.forEach(_=>delete f[_]),d===We&&(u===ot||i[se]===We||!L(l)&&c!==l)&&(p_(f,i),delete f[Dn]),this.props=f;var m=new Set;yf.forEach(_=>{var p,y=(p=An(_))==null?void 0:p.storageGroup;y&&m.add(y)}),m.forEach(_=>{var p={};ve(this.props,(y,h)=>{var v;((v=An(h))==null?void 0:v.storageGroup)===_&&(p[h]=y)}),En(p)?(ge.qr(this.Js(_)),this.Ms[_]={}):ge.Nr(this.Js(_),p)&&(this.Ms[_]={persisted:!0,fingerprint:this.Ys(p,_)})})}}we.Pr(Zl(this.Os))&&(this.Rs=!0)}}Ks(){for(var t of Ef){var n=ge.Br(this.Js(t));if(n&&!En(n)){var r=this.Xs(t);r.persisted=!0,this.ta(t)||(r.fingerprint=this.Ys(n,t)),this.ea(t,n)||_e(this.props,n)}}}ta(t){return Object.keys(this.props).some(n=>{var r;return((r=An(n))==null?void 0:r.storageGroup)===t})}ea(t,n){var r=ZI[t];if(!r)return!1;var i=n[r],s=this.props[r];return Ge(i)&&Ge(s)&&s>i}refreshKey(t){var n;if(!this.Hs){var r=this.Is?(n=An(t))==null?void 0:n.storageGroup:void 0,i=r?ge.Br(this.Js(r)):this.ps.Br(this.Os);if(i&&t in i)this.Us(t,i[t]);else{if(r){var s=this.ps.Br(this.Os);if(s&&t in s)return void this.Us(t,s[t])}this.zs(t)}}}save(){if(!this.Hs){var t=this.Ds();t>0?L(this.Gs)&&(this.Gs=setTimeout(()=>{this.Gs=void 0,this.Zs()},t)):this.Zs()}}flush(){L(this.Gs)||(clearTimeout(this.Gs),this.Gs=void 0,this.Zs())}Zs(t){t===void 0&&(t=!1),this.Hs||this.Ps&&!t||(t||this.syncCookieProperties(),this.Is?this.ia():this.ra(this.ps,this.Os,this.props,Rr)&&this.Ns(this.props))}ia(){var t=this.na(),n=t.main,r=t.groups;for(var i of(this.ra(this.ps,this.Os,n,Rr)&&this.Ns(n),Ef)){var s,o=r[i];(!En(o)||(s=this.Ms[i])!=null&&s.persisted)&&this.ra(ge,this.Js(i),o,i)}}na(){var t={},n={flags:{},surveys:{}};return ve(this.props,(r,i)=>{var s,o=(s=An(i))==null?void 0:s.storageGroup;o?n[o][i]=r:t[i]=r}),{main:t,groups:n}}Ys(t,n){if(n===Rr)return JSON.stringify(t)+"|"+this.sa+"|"+this.aa+"|"+this.oa;var r={};return ve(t,(i,s)=>{var o;r[s]=(o=An(s))!=null&&o.volatile?"__volatile__":i}),JSON.stringify(r)}ra(t,n,r,i){var s,o=this.Xs(i);if(i!==Rr&&!o.dirty&&!L(o.fingerprint))return!1;try{if((s=this.Ys(r,i))===o.fingerprint)return o.dirty=!1,!1}catch{s=void 0}return t.Nr(n,r,this.sa,this.aa,this.oa,this.qi.debug)?(o.dirty=!1,i!==Rr&&(o.persisted=!0),L(s)||(o.fingerprint=s),!0):(this.qi.debug&&D.warn('failed to persist storage entry "'+n+'"; will retry on next save'),!1)}remove(t){var n=(t===void 0?{}:t).keepGroupEntries,r=n!==void 0&&n;if(L(this.Gs)||(clearTimeout(this.Gs),this.Gs=void 0),this.ps.qr(this.Os,!1),this.ps.qr(this.Os,!0),!r&&this.As)for(var i of Ef)ge.qr(this.Js(i));r?delete this.Ms[Rr]:this.Ms={},this.qs=void 0,this.js=void 0}clear(){this.remove(),this.props={}}register_once(t,n,r){if(Se(t)){this.syncCookieProperties(),L(n)&&(n="None"),this.sa=L(r)?this.la:r;var i=!1;if(ve(t,(s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==n||(this.Us(o,s),i=!0)}),i)return this.save(),!0}return!1}register(t,n){if(Se(t)){this.syncCookieProperties(),this.sa=L(n)?this.la:n;var r=!1;if(ve(t,(i,s)=>{t.hasOwnProperty(s)&&(this.props[s]!==i||Se(i)||Z(i))&&(this.Us(s,i),r=!0)}),r)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();var n=typeof t=="string"?[t]:t,r=!1;for(var i of n)i in this.props&&(this.zs(i),r=!0);r&&this.save()}update_campaign_params(){var t=j==null?void 0:j.URL;if(t!==this.Fs){var n=NE(this.qi.custom_campaign_params,this.qi.mask_personal_data_properties,this.qi.custom_personal_data_properties);En(Sg(n))||this.register(n),this.Fs=t}}update_search_keyword(){var t;this.register((t=j==null?void 0:j.referrer)?FE(t):{})}update_referrer_info(){var t;this.register_once({$referrer:LE(),$referring_domain:j!=null&&j.referrer&&((t=Eo(j.referrer))==null?void 0:t.host)||Oc},void 0)}set_initial_person_info(){this.props[_p]||this.props[wp]||this.register_once({[Ec]:jE(this.qi.mask_personal_data_properties,this.qi.custom_personal_data_properties,this.qi.disable_capture_url_hashes)},void 0)}get_initial_props(){var t={};ve([wp,_p],i=>{var s=this.props[i];s&&ve(s,function(o,a){t["$initial_"+np(a)]=o})});var n=this.props[Ec];if(n){var r=function(i,s){s===void 0&&(s=!1);var o=DE(i,s),a={};return ve(o,function(l,u){a["$initial_"+np(u)]=l}),a}(n,this.qi.disable_capture_url_hashes);_e(t,r)}return t}safe_merge(t){return ve(this.props,function(n,r){r in t||(t[r]=n)}),t}update_config(t,n,r){var i=t.persistence!==n.persistence,s=!((p,y)=>{if(p.length!==y.length)return!1;var h=[...p].sort(),v=[...y].sort();return h.every((x,b)=>x===v[b])})(t.cookie_persisted_properties||[],n.cookie_persisted_properties||[]),o=i||s,a=t.cookieWinsOnConflict!==n.cookieWinsOnConflict,l=t.disable_persistence||!!r,u=!!this.Hs&&!l;l||this.Bs(n,u),this.qi=t,!l&&(i||s||a)&&(this.qs=void 0,this.js=void 0,this.Bs($({},t,{cookie_persisted_properties:n.cookie_persisted_properties}),u));var c=o||a?this.Ls(t):this.ps,d=this.$s(t),f=o||d!==this.Is,m=!l&&(f||t.cross_subdomain_cookie!==this.aa||t.secure_cookie!==this.oa)&&this.Ws(u);try{if(this.la=this.sa=t.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),f){var _=this.props;this.clear(),this.ps=c,this.Is=d,this.props=_,this.save()}else a&&(this.ps=c,l||(delete this.Ms[Rr],this.Zs()))}finally{m&&this.Qs()}}set_disabled(t){this.Hs=t,this.Hs?this.remove():this.save()}set_cross_subdomain(t){t!==this.aa&&(this.aa=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.oa&&(this.oa=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,n){var r=this.props[ca]||{};r[t]=n,this.Us(ca,r),this.save()}remove_event_timer(t){var n=this.props[ca]||{},r=n[t];return L(r)||(delete n[t],this.Us(ca,n),this.save()),r}get_property(t){return this.props[t]}set_property(t,n){this.Us(t,n),this.save()}Us(t,n){var r;this.props[t]=n,(r=An(t))!=null&&r.volatile||this.ua(t)}zs(t){delete this.props[t],this.ua(t)}ua(t){var n,r=(n=An(t))==null?void 0:n.storageGroup;r&&(this.Xs(r).dirty=!0)}Xs(t){return this.Ms[t]||(this.Ms[t]={})}}function eu(e){var t=!0;return{dispose(){if(t){t=!1;var n=e();n&&vt(n.then)&&n.then(void 0,()=>{})}}}}var Et={GZipJS:"gzip-js",Base64:"base64"},Xo={Activation:"events",Cancellation:"cancelEvents"},Cf={Popover:"popover",API:"api",Widget:"widget"},ur={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},kf={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},Pp={Popover:"popover",Inline:"inline"},tO={SHOWN:"product tour shown"},v_={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},g_=Ie("[RateLimiter]");class nO{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=n=>{var r=n.text;if(r&&r.length)try{(JSON.parse(r).quota_limited||[]).forEach(i=>{g_.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void g_.warn('could not rate limit - continuing. Error: "'+(i==null?void 0:i.message)+'"',{text:r})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return((t=this.instance.config.rate_limiting)==null?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max(((t=this.instance.config.rate_limiting)==null?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var n,r,i;t===void 0&&(t=!1);var s=this.captureEventsBurstLimit,o=this.captureEventsPerSecond,a=new Date().getTime(),l=(n=(r=this.instance.persistence)==null?void 0:r.get_property(yp))!==null&&n!==void 0?n:{tokens:s,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>s&&(l.tokens=s);var u=1>l.tokens;if(u||t||(l.tokens=Math.max(0,l.tokens-1)),u&&!t){var c=(Ge(l.dropped)?l.dropped:0)+1;l.dropped=c,!this.lastEventRateLimited&&this.ha(c)&&(l.dropped=0)}return this.lastEventRateLimited=u,(i=this.instance.persistence)==null||i.set_property(yp,l),{isRateLimited:u,remainingTokens:l.tokens}}da(t){var n=this.instance.config.property_denylist;return!Z(n)||!n.includes(t)}va(){var t;if(this.da("$current_url")&&this.da("$pathname")&&Ae!=null&&Ae.pathname)return""+((t=Ae.origin)!==null&&t!==void 0?t:"")+Ae.pathname}ha(t){var n,r,i=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,o=this.va(),a=this.da("$session_id")?(n=(r=this.instance).get_session_id)==null?void 0:n.call(r):void 0,l=[t+" event(s) dropped since the last warning",o?"triggered on "+o:void 0,a?"session "+a:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+l+". Config is set to "+s+" events per second and "+i+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var n=this.serverLimits[t||"events"]||!1;return n!==!1&&new Date().getTime()t(this.remoteConfig)):t()}fa(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return Tr.info("Using preloaded remote config",this.remoteConfig),this.pa(this.remoteConfig),void this.ga();if(this._instance.ma())return void Tr.warn("Remote config is disabled. Falling back to local config.");this.ca(t=>{if(!t)return Tr.info("No config found after loading remote JS config. Falling back to JSON."),void this.fa(n=>{this.pa(n.json,n),this.ga()});this.pa(t),this.ga()})}catch(t){Tr.error("Error loading remote config",t),this.pa()}}stop(){this.ya&&(clearInterval(this.ya),this.ya=void 0)}refresh(){!this._instance.ma()&&j&&j.visibilityState!=="hidden"&&this._instance.reloadFeatureFlags()}ga(){var t;if(!this.ya){var n=(t=this._instance.config.remote_config_refresh_interval_ms)!==null&&t!==void 0?t:3e5;n!==0&&(this.ya=setInterval(()=>{this.refresh()},n))}}pa(t,n){!t&&n&&(n.statusCode===0?n.error||Tr.warn("Failed to fetch remote config from PostHog."):Tr.error("Failed to fetch remote config from PostHog."));try{this._instance.pa(t?{ok:!0,config:t}:{ok:!1})}catch(i){Tr.error("Error applying remote config",i)}if((t==null?void 0:t.hasFeatureFlags)!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var r;(r=this._instance.featureFlags)==null||r.ensureFlagsLoaded()}catch(i){Tr.error("Error loading feature flags",i)}}}var ln=Uint8Array,Lt=Uint16Array,ko=Uint32Array,Rg=new ln([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Tg=new ln([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),m_=new ln([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),VE=function(e,t){for(var n=new Lt(31),r=0;31>r;++r)n[r]=t+=1<r;++r)for(var s=n[r];n[r+1]>s;++s)i[s]=s-n[r]<<5|r;return[n,i]},BE=VE(Rg,2),Rp=BE[1];BE[0][28]=258,Rp[258]=28;for(var y_=VE(Tg,0)[1],qE=new Lt(32768),Ne=0;32768>Ne;++Ne){var hs=(43690&Ne)>>>1|(21845&Ne)<<1;qE[Ne]=((65280&(hs=(61680&(hs=(52428&hs)>>>2|(13107&hs)<<2))>>>4|(3855&hs)<<4))>>>8|(255&hs)<<8)>>>1}var Pa=function(e,t,n){for(var r=e.length,i=0,s=new Lt(t);r>i;++i)++s[e[i]-1];var o,a=new Lt(t);for(i=0;t>i;++i)a[i]=a[i-1]+s[i-1]<<1;for(o=new Lt(r),i=0;r>i;++i)o[i]=qE[a[e[i]-1]++]>>>15-e[i];return o},Zi=new ln(288);for(Ne=0;144>Ne;++Ne)Zi[Ne]=8;for(Ne=144;256>Ne;++Ne)Zi[Ne]=9;for(Ne=256;280>Ne;++Ne)Zi[Ne]=7;for(Ne=280;288>Ne;++Ne)Zi[Ne]=8;var Mc=new ln(32);for(Ne=0;32>Ne;++Ne)Mc[Ne]=5;var rO=Pa(Zi,9),iO=Pa(Mc,5),WE=function(e){return(e/8>>0)+(7&e&&1)},HE=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof Lt?Lt:e instanceof ko?ko:ln)(n-t);return r.set(e.subarray(t,n)),r},Qn=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},Jo=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Pf=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,s=n.slice();if(!i)return[new ln(0),0];if(i==1){var o=new ln(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort(function(E,S){return E.f-S.f}),n.push({s:-1,f:25001});var a=n[0],l=n[1],u=0,c=1,d=2;for(n[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=i-1;)a=n[n[d].f>n[u].f?u++:d++],l=n[u!=c&&n[d].f>n[u].f?u++:d++],n[c++]={s:-1,f:a.f+l.f,l:a,r:l};var f=s[0].s;for(r=1;i>r;++r)s[r].s>f&&(f=s[r].s);var m=new Lt(f+1),_=Tp(n[c-1],m,0);if(_>t){r=0;var p=0,y=_-t,h=1<r;++r){var v=s[r].s;if(t>=m[v])break;p+=h-(1<<_-m[v]),m[v]=t}for(p>>>=y;p>0;){var x=s[r].s;t>m[x]?p-=1<=0&&p;--r){var b=s[r].s;m[b]==t&&(--m[b],++p)}_=t}return[new ln(m),_]},Tp=function(e,t,n){return e.s==-1?Math.max(Tp(e.l,t,n+1),Tp(e.r,t,n+1)):t[e.s]=n},__=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Lt(++t),r=0,i=e[0],s=1,o=function(l){n[r++]=l},a=1;t>=a;++a)if(e[a]==i&&a!=t)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=e[a]}return[n.subarray(0,r),t]},Zo=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},Ip=function(e,t,n){var r=n.length,i=WE(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var s=0;r>s;++s)e[i+s+4]=n[s];return 8*(i+4+r)},w_=function(e,t,n,r,i,s,o,a,l,u,c){Qn(t,c++,n),++i[256];for(var d=Pf(i,15),f=d[0],m=d[1],_=Pf(s,15),p=_[0],y=_[1],h=__(f),v=h[0],x=h[1],b=__(p),E=b[0],S=b[1],P=new Lt(19),C=0;v.length>C;++C)P[31&v[C]]++;for(C=0;E.length>C;++C)P[31&E[C]]++;for(var T=Pf(P,7),R=T[0],N=T[1],M=19;M>4&&!R[m_[M-1]];--M);var z,F,W,B,Q=u+5<<3,O=Zo(i,Zi)+Zo(s,Mc)+o,A=Zo(i,f)+Zo(s,p)+o+14+3*M+Zo(P,R)+(2*P[16]+3*P[17]+7*P[18]);if(O>=Q&&A>=Q)return Ip(t,c,e.subarray(l,l+u));if(Qn(t,c,1+(O>A)),c+=2,O>A){z=Pa(f,m),F=f,W=Pa(p,y),B=p;var V=Pa(R,N);for(Qn(t,c,x-257),Qn(t,c+5,S-1),Qn(t,c+10,M-4),c+=14,C=0;M>C;++C)Qn(t,c+3*C,R[m_[C]]);c+=3*M;for(var K=[v,E],te=0;2>te;++te){var oe=K[te];for(C=0;oe.length>C;++C)Qn(t,c,V[de=31&oe[C]]),c+=R[de],de>15&&(Qn(t,c,oe[C]>>>5&127),c+=oe[C]>>>12)}}else z=rO,F=Zi,W=iO,B=Mc;for(C=0;a>C;++C)if(r[C]>255){var de;Jo(t,c,z[257+(de=r[C]>>>18&31)]),c+=F[de+257],de>7&&(Qn(t,c,r[C]>>>23&31),c+=Rg[de]);var be=31&r[C];Jo(t,c,W[be]),c+=B[be],be>3&&(Jo(t,c,r[C]>>>5&8191),c+=Tg[be])}else Jo(t,c,z[r[C]]),c+=F[r[C]];return Jo(t,c,z[256]),c+F[256]},sO=new ko([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),oO=function(){for(var e=new ko(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),Rf=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function aO(e,t){t===void 0&&(t={});var n=function(){var d=4294967295;return{p(f){for(var m=d,_=0;f.length>_;++_)m=oO[255&m^f[_]]^m>>>8;d=m},d(){return 4294967295^d}}}(),r=e.length;n.p(e);var i,s,o,a,l,u=(a=10+((i=t).filename&&i.filename.length+1||0),l=8,function(d,f,m,_,p,y){var h=d.length,v=new ln(_+h+5*(1+Math.floor(h/7e3))+p),x=v.subarray(_,v.length-p),b=0;if(!f||8>h)for(var E=0;h>=E;E+=65535){var S=E+65535;h>S?b=Ip(x,b,d.subarray(E,S)):(x[E]=!0,b=Ip(x,b,d.subarray(E,h)))}else{for(var P=sO[f-1],C=P>>>13,T=8191&P,R=(1<E;++E){var de=W(E),be=32767&E,Pe=M[de];if(N[be]=Pe,M[de]=be,E>=te){var Be=h-E;if((A>7e3||K>24576)&&Be>423){b=w_(d,x,0,B,Q,O,V,K,oe,E-oe,b),K=A=V=0,oe=E;for(var ye=0;286>ye;++ye)Q[ye]=0;for(ye=0;30>ye;++ye)O[ye]=0}var Fe=2,Tt=0,Sr=T,_t=be-Pe&32767;if(Be>2&&de==W(E-_t))for(var Ye=Math.min(C,Be)-1,gi=Math.min(32767,E),us=Math.min(258,Be);gi>=_t&&--Sr&&be!=Pe;){if(d[E+Fe]==d[E+Fe-_t]){for(var It=0;us>It&&d[E+It]==d[E+It-_t];++It);if(It>Fe){if(Fe=It,Tt=_t,It>Ye)break;var cs=Math.min(_t,It-2),Cr=0;for(ye=0;cs>ye;++ye){var pn=E-_t+ye+32768&32767,Do=pn-N[pn]+32768&32767;Do>Cr&&(Cr=Do,Pe=pn)}}}_t+=(be=Pe)-(Pe=N[be])+32768&32767}if(Tt){B[K++]=268435456|Rp[Fe]<<18|y_[Tt];var gm=31&Rp[Fe],mm=31&y_[Tt];V+=Rg[gm]+Tg[mm],++Q[257+gm],++O[mm],te=E+Fe,++A}else B[K++]=d[E],++Q[d[E]]}}b=w_(d,x,!0,B,Q,O,V,K,oe,E-oe,b)}return HE(v,0,_+WE(b)+p)}(s=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(s.length)))):12+o.mem,a,l)),c=u.length;return function(d,f){var m=f.filename;if(d[0]=31,d[1]=139,d[2]=8,d[8]=2>f.level?4:f.level==9?2:0,d[9]=3,f.mtime!=0&&Rf(d,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),m){d[3]=8;for(var _=0;m.length>=_;++_)d[_+10]=m.charCodeAt(_)}}(u,t),Rf(u,c-8,n.d()),Rf(u,c-4,r),u}var lO=!!Jh||!!fg,GE="text/plain",Ou=!1,KE=(e,t)=>{var n=e.split("#"),r=n[1],i=n[0].split("?"),s=i[0],o=i[1];if(!o)return e;var a=o.split("&").filter(l=>l.split("=")[0]!==t).join("&");return s+(a?"?"+a:"")+(r?"#"+r:"")},bl=function(e,t,n){var r;n===void 0&&(n=!0);var i=e.split("?"),s=i[0],o=i[1],a=$({},t),l=(r=o==null?void 0:o.split("&").map(c=>{var d,f=c.split("="),m=f[0],_=n&&(d=a[m])!==null&&d!==void 0?d:f[1];return delete a[m],m+"="+_}))!==null&&r!==void 0?r:[],u=function(c,d){var f,m;d===void 0&&(d="&");var _=[];return ve(c,function(p,y){L(p)||L(y)||y==="undefined"||(f=encodeURIComponent((h=>h instanceof File)(p)?p.name:p.toString()),m=encodeURIComponent(y),_[_.length]=m+"="+f)}),_.join(d)}(a);return u&&l.push(u),l.length>0?s+"?"+l.join("&"):s},Tf=e=>{if(e.ba)return e.ba;var t=e.data,n=e.compression;if(t){if(n===Et.GZipJS){var r=aO(function(a,l){var u=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var c=new ln(a.length+(a.length>>>1)),d=0,f=function(y){c[d++]=y},m=0;u>m;++m){if(d+5>c.length){var _=new ln(d+8+(u-m<<1));_.set(c),c=_}var p=a.charCodeAt(m);128>p?f(p):2048>p?(f(192|p>>>6),f(128|63&p)):p>55295&&57344>p?(f(240|(p=65536+(1047552&p)|1023&a.charCodeAt(++m))>>>18),f(128|p>>>12&63),f(128|p>>>6&63),f(128|63&p)):(f(224|p>>>12),f(128|p>>>6&63),f(128|63&p))}return HE(c,0,d)}(Ls(t)),{mtime:0});return{contentType:GE,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===Et.Base64){var i=function(a){return a&&btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,(l,u)=>String.fromCharCode(parseInt(u,16))))}(Ls(t)),s=(a=>"data="+encodeURIComponent(typeof a=="string"?a:Ls(a)))(i);return{contentType:"application/x-www-form-urlencoded",body:s,estimatedSize:new Blob([s]).size}}var o=Ls(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},QE=e=>{var t,n,r=()=>e.transport==="sendBeacon"?{url:bl(e.url,{compression:Et.Base64}),encodedBody:Tf($({},e,{compression:Et.Base64,ba:void 0}))}:{url:KE(e.url,"compression"),encodedBody:Tf($({},e,{compression:void 0,ba:void 0}))};try{t=Tf(e)}catch(i){if(Fy(e.compression,So(e.url,"compression")))return D.error("Failed to gzip request body, sending uncompressed payload",i),r();throw i}return t&&Fy(e.compression,So(e.url,"compression"))&&!((n=t.body)instanceof ArrayBuffer?Zh(new Uint8Array(n)):ArrayBuffer.isView(n)&&Zh(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(Ou=!0,r()):{url:e.url,encodedBody:t}},YE=e=>{try{return QE(e)}catch(t){return D.error(t),void(e.callback==null||e.callback({statusCode:0,error:t}))}},uO=function(){var e=Ce(function*(t){var n=Ls(t.data),r=yield function(s,o,a){return ep.apply(this,arguments)}(n,Ee.DEBUG,{rethrow:!0});if(!r)return t;var i=yield r.arrayBuffer();return $({},t,{ba:{contentType:GE,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}}(),cO=/Failed to fetch|NetworkError|Load failed/i,XE=e=>(e==null?void 0:e.name)==="TypeError"&&cO.test((e==null?void 0:e.message)||""),JE=e=>{var t=YE(e);if(t){var n=t.url,r=t.encodedBody,i=r??{},s=i.contentType,o=i.body,a=i.estimatedSize,l=new Headers;ve(e.headers,function(_,p){l.append(p,_)}),s&&l.append("Content-Type",s);var u=null,c=!1;if(Iy){var d=new Iy;u={signal:d.signal,timeout:setTimeout(()=>{var _,p;c=!0,d.abort((_=e.timeout,(p=new Error("PostHog request timed out"+(_?" after "+_+"ms":""))).name="AbortError",p))},e.timeout)}}var f=_=>{c&&(_==null?void 0:_.name)==="AbortError"||XE(_)?D.warn(_):D.error(_),e.callback==null||e.callback({statusCode:0,error:_})};try{var m;fg(n,$({method:(e==null?void 0:e.method)||"GET",headers:l,keepalive:e.method==="POST"&&!e._a&&52428.8>(a||0),body:o,signal:(m=u)==null?void 0:m.signal},e.fetchOptions)).then(_=>_.text().then(p=>{var y={statusCode:_.status,text:p};if(_.status===200)try{y.json=JSON.parse(p)}catch(h){D.error(h)}e.callback==null||e.callback(y)})).catch(f).finally(()=>u?clearTimeout(u.timeout):null)}catch(_){u&&clearTimeout(u.timeout),f(_)}}},Op=e=>{try{var t,n=QE(e),r=n.url,i=n.encodedBody,s=i??{},o=s.body,a=s.estimatedSize;if(!o)return;var l=o instanceof Blob?o:new Blob([o],{type:s.contentType});if(St.sendBeacon(r,l))return;var u=Z(e.data)?e.data:(t=e.data)==null?void 0:t.batch;if(Z(u)&&u.length>1&&(a??0)>16384){var c=Math.ceil(u.length/2),d=f=>Z(e.data)?f:$({},e.data,{batch:f});return Op($({},e,{data:d(u.slice(0,c))})),void Op($({},e,{data:d(u.slice(c))}))}D.warn("Beacon of ~"+(a??0)+" bytes was rejected by the browser, falling back to fetch"),JE($({},e,{_a:!0}))}catch(f){D.warn("Beacon send failed",f)}},x_=(e,t,n,r)=>{var i=r==="query"?t==="POST"?"sent_at":"_":void 0;return bl(n===Et.GZipJS?KE(e,"compression"):e,$({},i?{[i]:Date.now().toString()}:{},n===Et.GZipJS?{}:{compression:n}))},Mu=[];fg&&Mu.push({transport:"fetch",method:JE}),Jh&&Mu.push({transport:"XHR",method(e){var t=YE(e);if(t){var n=new Jh,r=t.encodedBody;n.open(e.method||"GET",t.url,!0);var i=r??{},s=i.contentType,o=i.body;ve(e.headers,function(a,l){n.setRequestHeader(l,a)}),s&&n.setRequestHeader("Content-Type",s),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var a={statusCode:n.status,text:n.responseText};if(n.status===200)try{a.json=JSON.parse(n.responseText)}catch{}e.callback==null||e.callback(a)}},n.send(o)}}}),St!=null&&St.sendBeacon&&Mu.push({transport:"sendBeacon",method:Op});var Mp=3e3;class dO{constructor(t,n){this.wa=!0,this.ka=[],this.Sa=Vn((n==null?void 0:n.flush_interval_ms)||Mp,250,5e3,D.createLogger("flush interval"),Mp),this.xa=t}enqueue(t){this.ka.push(t),this.Ca||this.Ta()}unload(){this.Ma();var t=this.ka.length>0?this.Ea():{},n=Object.values(t);[...n.filter(r=>r.url.indexOf("/e")===0),...n.filter(r=>r.url.indexOf("/e")!==0)].map(r=>{this.Ia($({},r,{transport:"sendBeacon"}))})}enable(){this.wa=!1,this.Ta()}Ta(){var t=this;this.wa||(this.Ca=setTimeout(()=>{if(this.Ma(),this.ka.length>0){var n=this.Ea(),r=function(){var s=n[i],o=new Date().getTime();s.data&&Z(s.data)&&ve(s.data,a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp}),t.Ia(s)};for(var i in n)r()}},this.Sa))}Ia(t){try{this.xa(t)}catch(n){D.error(n)}}Ma(){clearTimeout(this.Ca),this.Ca=void 0}Ea(){var t={};return ve(this.ka,n=>{var r,i=n,s=(i?i.batchKey:null)||i.url;L(t[s])&&(t[s]=$({},i,{data:[]})),(r=t[s].data)==null||r.push(i.data)}),this.ka=[],t}}var fO=["retriesPerformedSoFar"];class hO{constructor(t){this.Ra=!1,this.Pa=3e3,this.ka=[],this._instance=t,this.ka=[],this.Aa=!0,!L(I)&&"onLine"in I.navigator&&(this.Aa=I.navigator.onLine,this.Fa=()=>{this.Aa=!0,this.Oa()},this.La=()=>{this.Aa=!1},Re(I,"online",this.Fa),Re(I,"offline",this.La))}get length(){return this.ka.length}retriableRequest(t){var n=t.retriesPerformedSoFar,r=bb(t,fO);Jn(n)&&(r.url=bl(r.url,{retry_count:n})),this._instance._send_request($({},r,{callback:i=>{if(i.statusCode!==200&&(400>i.statusCode||i.statusCode>=500)){if((i.statusCode===0?3:10)>(n??0))return void this.xn($({retriesPerformedSoFar:n},r));i.statusCode===0&&D.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(n??0)+" retries.")}r.callback==null||r.callback(i)}}))}xn(t){var n=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=n+1;var r=function(o){var a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),c=Math.random()-.5;return Math.ceil(u+c*(u-l))}(n),i=Date.now()+r;this.ka.push({retryAt:i,requestOptions:t});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),D.warn(s),this.Ra||(this.Ra=!0,this.$a())}$a(){if(this.Da&&clearTimeout(this.Da),this.ka.length===0)return this.Ra=!1,void(this.Da=void 0);this.Da=setTimeout(()=>{this.Aa&&this.ka.length>0&&this.Oa(),this.$a()},this.Pa)}Oa(){var t=Date.now(),n=[],r=this.ka.filter(s=>t>s.retryAt||(n.push(s),!1));if(this.ka=n,r.length>0)for(var i of r)this.retriableRequest(i.requestOptions)}unload(){for(var t of(this.Da&&(clearTimeout(this.Da),this.Da=void 0),this.Ra=!1,L(I)||(this.Fa&&(I.removeEventListener("online",this.Fa),this.Fa=void 0),this.La&&(I.removeEventListener("offline",this.La),this.La=void 0)),this.ka)){var n=t.requestOptions;try{this._instance._send_request($({},n,{transport:"sendBeacon"}))}catch(r){D.error(r)}}this.ka=[]}}class pO{constructor(t){this.Na=()=>{var n,r,i,s;this.qa||(this.qa={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=a+((o==null?void 0:o.clientHeight)||0),c=(o==null?void 0:o.scrollHeight)||0;this.qa.lastScrollY=Math.ceil(a),this.qa.maxScrollY=Math.max(a,(n=this.qa.maxScrollY)!==null&&n!==void 0?n:0),this.qa.maxScrollHeight=Math.max(l,(r=this.qa.maxScrollHeight)!==null&&r!==void 0?r:0),this.qa.lastContentY=u,this.qa.maxContentY=Math.max(u,(i=this.qa.maxContentY)!==null&&i!==void 0?i:0),this.qa.maxContentHeight=Math.max(c,(s=this.qa.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=t}get ja(){return this._instance.config.scroll_root_selector}getContext(){return this.qa}resetContext(){var t=this.qa;return setTimeout(this.Na,0),t}startMeasuringScrollPosition(){Re(I,"scroll",this.Na,{capture:!0}),Re(I,"scrollend",this.Na,{capture:!0}),Re(I,"resize",this.Na)}scrollElement(){if(!this.ja)return I==null?void 0:I.document.documentElement;var t=Z(this.ja)?this.ja:[this.ja];for(var n of t){var r=I==null?void 0:I.document.querySelector(n);if(r)return r}}Ba(t){var n=t==="y"?"scrollTop":"scrollLeft";if(this.ja){var r=this.scrollElement();return r&&r[n]||0}return I?t==="y"?I.scrollY||I.pageYOffset||I.document.documentElement.scrollTop||0:I.scrollX||I.pageXOffset||I.document.documentElement.scrollLeft||0:0}scrollY(){return this.Ba("y")}scrollX(){return this.Ba("x")}}var vO=e=>jE(e==null?void 0:e.config.mask_personal_data_properties,e==null?void 0:e.config.custom_personal_data_properties,e==null?void 0:e.config.disable_capture_url_hashes);class b_{constructor(t,n,r,i){this.ot=s=>{var o=this.Ha();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Ua(this._instance)};this.za.register({[mp]:a})}},this._instance=t,this.Wa=n,this.za=r,this.Ua=i||vO,this.Wa.onSessionId(this.ot)}Ha(){return this.za.props[mp]}getSetOnceProps(){var t,n=(t=this.Ha())==null?void 0:t.props;return n?"r"in n?DE(n,this._instance.config.disable_capture_url_hashes):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var t={};return ve(Sg(this.getSetOnceProps()),(n,r)=>{r==="$current_url"&&(r="url"),t["$session_entry_"+np(r)]=n}),t}}class Ac{on(t,n){return this.Va[t]||(this.Va[t]=[]),this.Va[t].push(n),()=>{this.Va[t]=this.Va[t].filter(r=>r!==n)}}emit(t,n){for(var r of this.Va[t]||[])r(n);for(var i of this.Va["*"]||[])i(t,n)}constructor(){this.Va={}}}var ps=Ie("[SessionId]"),E_=864e5;class S_{on(t,n){return this.Ga.on(t,n)}constructor(t,n,r){var i;if(this.Za=null,this.Qa=null,this.Ja=[],this.Ka=void 0,this.Ya=!1,this.Ga=new Ac,this.Xa=(l,u)=>!(!Jn(l)||!Jn(u))&&Math.abs(l-u)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode===lr)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.qi=t.config,this.za=t.persistence,this.st=void 0,this._e=void 0,this._sessionStartTimestamp=null,this.eo=void 0,this._sessionActivityTimestamp=null,this.io=n||$n,this.ro=r||$n;var s=this.qi.persistence_name||this.qi.token;if(this._sessionTimeoutMs=1e3*Vn(this.qi.session_idle_timeout_seconds||1800,60,36e3,ps.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.no(),this.so="ph_"+s+"_window_id",this.ao="ph_"+s+"_primary_window_exists",this.oo()){var o=we.Br(this.so),a=we.Br(this.ao);o&&!a?this.st=o:we.qr(this.so),we.Nr(this.ao,!0)}(i=this.qi.bootstrap)!=null&&i.sessionID&&this.setBootstrapSessionId(this.qi.bootstrap.sessionID),this.lo()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return L(this.Ja)&&(this.Ja=[]),this.Ja.push(t),this._e&&t(this._e,this.st),()=>{this.Ja=this.Ja.filter(n=>n!==t)}}oo(){return this.qi.persistence!=="memory"&&!this.za.Hs&&we.Dr()}uo(t){t!==this.st&&(this.st=t,this.oo()&&we.Nr(this.so,t))}ho(){return this.st?this.st:this.oo()?we.Br(this.so):null}do(t){var n=this.Za;return!rt(n)&&!rt(t)&&5e3>Math.abs(t-n)}vo(t,n,r){var i=n!==this._sessionActivityTimestamp,s=!(t!==this._e||r!==this._sessionStartTimestamp);this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this._e=t,s&&!i||s&&this.do(n)||(this.Za=n,this.za.register({[Fs]:[n,t,r]}))}co(){var t,n=(t=this.qi)==null?void 0:t.persistence_save_debounce_ms;return Jn(n)&&n>0}fo(){this.co()?this.za.refreshKey(Fs):(this.za.flush(),this.za.load())}po(){var t;if(!rt(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Za){this.fo();var n=this.mo();n[1]===this._e&&n[2]===this._sessionStartTimestamp&&(this.Za=this._sessionActivityTimestamp,this.za.register({[Fs]:[this._sessionActivityTimestamp,(t=this._e)!==null&&t!==void 0?t:null,this._sessionStartTimestamp]}),this.za.flush())}}yo(){var t=this.mo()[0],n=Jn(t)?t:0,r=Jn(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(n,r)}bo(t){return this.fo(),this.Xa(t,this.yo())}mo(){var t=this.za.props[Fs];return Z(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Za=null,this.eo=void 0,clearTimeout(this._o),this._o=void 0,this.vo(null,null,null)}setBootstrapSessionId(t,n){n===void 0&&(n=!1);var r=function(i,s){s===void 0&&(s=new Date().getTime());try{var o=(a=>{var l=a.replace(/-/g,"");if(l.length!==32)throw new Error("Not a valid UUID");if(l[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(l.substring(0,12),16)})(i);return o>s+6e4?void ps.error("Bootstrap sessionID cannot be in the future"):o}catch(a){return void ps.error("Invalid sessionID in bootstrap",a)}}(t);return!L(r)&&(n?this.eo={sessionId:t,sessionStartTimestamp:r}:this.vo(t,new Date().getTime(),r),!0)}destroy(){this.Ya=!0,this.po(),clearTimeout(this._o),this._o=void 0,this.Ka&&I&&(I.removeEventListener(kc,this.Ka,{capture:!1}),this.Ka=void 0),this.Ja=[]}lo(){this.Ka=()=>{this.po(),this.oo()&&we.qr(this.ao)},Re(I,kc,this.Ka,{capture:!1})}checkAndGetSessionAndWindowId(t,n,r){if(t===void 0&&(t=!1),n===void 0&&(n=null),r===void 0&&(r=!1),this.qi.cookieless_mode===lr)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=n||new Date().getTime(),s=this._e;if(r)this.Qa=i;else if(rt(this.Qa)||this.Qa>i||i-this.Qa>=1e3){var o,a;(o=(a=this.za).syncCookieProperties)==null||o.call(a),this.Qa=i}var l=this.mo(),u=l[1],c=l[2],d=!L(s)&&u!==s,f=this.yo(),m=this.ho(),_=this.eo,p=!!_&&(_.sessionStartTimestamp>i+6e4||i-_.sessionStartTimestamp>E_),y=_?p:Jn(c)&&Math.abs(i-c)>E_,h=!1,v=d,x=!u||!!_,b=u,E=!x&&!t&&this.Xa(i,f);if(E){(E=this.bo(i))||ps.info("cross-tab refresh kept the session alive",{sessionId:u});var S=this.mo();u=S[1],c=S[2]}if(x||E||y){v=!1;var P=_&&!p;u=P?_.sessionId:this.io(),m=this.ro(),ps.info("new session ID assigned",{sessionId:u,windowId:m,bootstrapped:!!P,changeReason:{noSessionId:x,activityTimeout:E,sessionPastMaximumLength:y}}),c=P?_.sessionStartTimestamp:i,this.eo=void 0,h=!0}else m||(m=this.ro(),h=!0),(v=v||u!==b)&&(ps.info("adopted cross-tab session id",{sessionId:u,windowId:m}),h=!0);var C=Jn(f)&&t&&!y?f:i,T=Jn(c)?c:new Date().getTime();this.uo(m),this.vo(u,C,T),t||this.no();var R={noSessionId:x,activityTimeout:E,sessionPastMaximumLength:y,crossTabAdoption:v};return h&&this.Ja.forEach(N=>N(u,m,R)),{sessionId:u,windowId:m,sessionStartTimestamp:T,changeReason:h?R:void 0,lastActivityTimestamp:f}}no(){this.Ya||(clearTimeout(this._o),this._o=setTimeout(()=>{if(!this.Ya)if(this.bo(new Date().getTime())){var t=this._e;this.resetSessionId(),this.Ga.emit("forcedIdleReset",{idleSessionId:t})}else this.no()},1.1*this.sessionTimeoutMs))}}var ZE=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&jy(n,t))return!0;try{var r=e==null?void 0:e.userAgentData;if(r!=null&&r.brands&&r.brands.some(i=>jy(i==null?void 0:i.brand,t)))return!0}catch{}return!!e.webdriver};function eS(){return(eS=Ce(function*(){var e=St==null?void 0:St.userAgentData;if(e!=null&&e.getHighEntropyValues)try{var t=yield e.getHighEntropyValues(["model"]),n=t==null?void 0:t.model;return ce(n)&&n.length>0?n:void 0}catch(r){return void D.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",r)}})).apply(this,arguments)}var Nc=function(e,t){if(!function(n){try{new RegExp(n)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function If(e,t,n){return Ls({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var tS={exact:(e,t)=>t.some(n=>e.some(r=>n===r)),is_not:(e,t)=>t.every(n=>e.every(r=>n!==r)),regex:(e,t)=>t.some(n=>e.some(r=>Nc(n,r))),not_regex:(e,t)=>t.every(n=>e.every(r=>!Nc(n,r))),icontains:(e,t)=>t.map(tu).some(n=>e.map(tu).some(r=>n.includes(r))),not_icontains:(e,t)=>t.map(tu).every(n=>e.map(tu).every(r=>!n.includes(r))),gt:(e,t)=>t.some(n=>{var r=parseFloat(n);return!isNaN(r)&&e.some(i=>r>parseFloat(i))}),lt:(e,t)=>t.some(n=>{var r=parseFloat(n);return!isNaN(r)&&e.some(i=>re.toLowerCase();function nS(e,t){return!e||Object.entries(e).every(n=>{var r=n[1],i=t==null?void 0:t[n[0]];if(L(i)||rt(i))return!1;var s=[String(i)],o=tS[r.operator];return!!o&&o(r.values,s)})}var Ap="custom",C_="i.posthog.com",gO=/^\/static\//,mO=["/s/","/e/","/i/"];class yO{constructor(t){this.wo={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,n=(t=this.instance.config.ui_host)==null?void 0:t.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+C_,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.wo[this.apiHost]||(this.wo[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":Ap),this.wo[this.apiHost]}ko(t){if(gO.test(t)){var n=this.instance.config.asset_host;if(typeof n=="string")return n.trim().replace(/\/$/,"")||void 0}}So(t){var n=Eo(t);return n?n.protocol+"//"+n.host+n.pathname:void 0}xo(t,n,r){if(t==="ui")return r;var i=r,s=this.instance.config.rewriteRequestPath;if(s){var o,a=((o=Eo(r))==null?void 0:o.href)||r;i=s(new URL(a)).toString()}if(s&&t==="api"&&mO.some(f=>n.indexOf(f)===0)){var l=this.So(i);if(l){var u,c=this.apiHost,d=this.Co;((u=d)==null?void 0:u.apiHost)===c&&d.rewriteRequestPath===s||(d={apiHost:c,rewriteRequestPath:s,urls:new Set},this.Co=d),d.urls.add(l)}}return i}isIngestionEndpoint(t){var n=this.Co,r=this.So(t);return(n==null?void 0:n.apiHost)===this.apiHost&&n.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!r&&n.urls.has(r)}endpointFor(t,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),t==="ui")return this.xo(t,n,this.uiHost+n);if(t==="flags")return this.xo(t,n,this.flagsApiHost+n);if(t==="assets"){var r=this.ko(n);if(r)return this.xo(t,n,""+r+n)}if(this.region===Ap)return this.xo(t,n,this.apiHost+n);var i=C_+n;switch(t){case"assets":return this.xo(t,n,"https://"+this.region+"-assets."+i);case"api":return this.xo(t,n,"https://"+this.region+"."+i)}}}function rS(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}var he=Ie("[Surveys]"),iS="seenSurvey_",sS=e=>{try{var t=(n=>((r,i)=>""+iS+function(s){return s.current_iteration&&s.current_iteration>0?s.id+"_"+s.current_iteration:s.id}(i))(0,n))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(n){he.error("Failed to persist survey seen state",n)}},_O=[Cf.Popover,Cf.Widget,Cf.API],wO={ignoreConditions:!1,ignoreDelay:!1,displayType:Pp.Popover},xO=Ie("[PostHog ExternalIntegrations]"),bO={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class EO{constructor(t){this._instance=t}_s(t,n){var r;(r=Y.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,t,i=>{if(i)return xO.error("failed to load script",i);n()})}startIfEnabledOrStop(){var t=this,n=function(){var s,o,a,l=r[0],u=r[1];!u||(s=Y.__PosthogExtensions__)!=null&&(s=s.integrations)!=null&&s[l]||t._s(bO[l],()=>{var c;(c=Y.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[l])==null||c.start(t._instance)}),!u&&(o=Y.__PosthogExtensions__)!=null&&(o=o.integrations)!=null&&o[l]&&((a=Y.__PosthogExtensions__)==null||(a=a.integrations)==null||(a=a[l])==null||a.stop())};for(var r of Object.entries((i=this._instance.config.integrations)!==null&&i!==void 0?i:{})){var i;n()}}}class SO{constructor(t,n){this.I=t,this.ns=n,this.To=new Map,this.Xn=!1}add(t){var n=this;return Ce(function*(){if(n.Xn)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(n.To.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');n.To.set(t.name,t);try{var r=t.setup(n.ns);r&&(yield r)}catch(s){var i=n.To.get(t.name)===t;i&&n.To.delete(t.name),n.I.error('Failed to set up browser extension "'+t.name+'"',s),i&&n.Mo(t)}})()}dispose(){if(!this.Xn){this.Xn=!0;var t=Array.from(this.To.values()).reverse();for(var n of(this.To.clear(),t))this.Mo(n)}}Mo(t){try{var n=t.dispose==null?void 0:t.dispose();n&&vt(n.then)&&n.then(void 0,r=>{this.I.error('Failed to dispose browser extension "'+t.name+'"',r)})}catch(r){this.I.error('Failed to dispose browser extension "'+t.name+'"',r)}}}class CO{constructor(t){this._instance=t}initialize(){}get(t){var n=this._instance.persistence;if(typeof t=="string")return n==null?void 0:n.get_property(t);var r={};for(var i of t){var s=n==null?void 0:n.get_property(i);L(s)||(r[i]=s)}return r}set(t,n){var r;(r=this._instance.persistence)==null||r.register(typeof t=="string"?{[t]:n}:t)}remove(t){var n;(n=this._instance.persistence)==null||n.unregister(t)}}var k_="extensionsRemoteConfig";class kO{constructor(t){this.Xn=!1,this.instance=t,this.I=D,this.Eo=t.Io,this.kv=new CO(t),this.onEvent=n=>eu(this.instance.on("eventCaptured",r=>{try{n({event:r.event,properties:r.properties})}catch(i){this.I.error("Browser extension event listener failed",i)}})),this.onRemoteConfig=n=>{if(this.Xn)return eu(()=>{});var r=s=>{try{n(s)}catch(o){this.I.error("Browser extension remote config listener failed",o)}},i=this.instance.Ro.on(k_,r);return this.Eo&&r(this.Eo),eu(i)},this.Po=new SO(D.createLogger("[BrowserExtensions]"),this)}get logger(){return this.I}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return(t=this.instance.get_property(Ya))!==null&&t!==void 0?t:this.distinctId}get deviceId(){var t=this.instance.get_property(Ya);return typeof t=="string"?t:void 0}get library(){return{name:Ee.LIB_NAME,version:Ee.LIB_VERSION}}get initialPersonProperties(){var t,n;return(t=(n=this.instance.persistence)==null?void 0:n.get_initial_props())!==null&&t!==void 0?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,n,r,i,s=(t=this.instance.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:(n=s==null?void 0:s.sessionId)!==null&&n!==void 0?n:"",windowId:(r=s==null?void 0:s.windowId)!==null&&r!==void 0?r:"",sessionStartTimestamp:(i=s==null?void 0:s.sessionStartTimestamp)!==null&&i!==void 0?i:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(t){return this.Po.add(t)}capture(t,n,r){var i=this;return Ce(function*(){r?i.instance.capture(t,n,{timestamp:r.timestamp,uuid:r.uuid,$set:r.set,$set_once:r.setOnce}):i.instance.capture(t,n)})()}registerDynamicEventProperties(t){return eu(this.instance.Ao(t))}handleRemoteConfig(t){this.Xn||(this.Eo=t,this.instance.Ro.emit(k_,t))}sendRequest(t,n){var r=this;return Ce(function*(){var i;n===void 0&&(n={});var s=r.instance.requestRouter.endpointFor((i=n.target)!==null&&i!==void 0?i:"api",t),o={method:n.method,url:n.query?bl(s,n.query):s,data:n.body,headers:n.headers,timeout:n.timeoutMs,fireCallbackOnDrop:!0,transport:n.transport,compression:n.compression,timestampMode:n.sentAt};return n.transport==="sendBeacon"?(r.instance._send_request(o),{statusCode:202}):new Promise(a=>{o.callback=a,r.instance._send_request(o)})})()}dispose(){this.Xn||(this.Xn=!0,this.Po.dispose())}}var Ra={},Of=0,Ta=()=>{},P_='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',ea="Surveys module not available",R_="sanitize_properties is deprecated. Use before_send instead",oS="Invalid value for property_denylist config: ",PO=["token","distinct_id",fE],bs="posthog",aS=!lO&&(Mt==null?void 0:Mt.indexOf("MSIE"))===-1&&(Mt==null?void 0:Mt.indexOf("Mozilla"))===-1,Mf=e=>{var t;return $({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:PI(j==null?void 0:j.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Ta,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:e??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Ae&&ce(Ae==null?void 0:Ae.search)&&Ae.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:(I==null||(t=I.location)==null?void 0:t.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(n){D.error("Bad HTTP status: "+n.statusCode+" "+n.text)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:bp,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Mp},error_tracking:{},_onCapture:Ta},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:DI,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:n&&n>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:n&&n>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:n&&n>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:n&&n>="2026-01-30"?"head":"body",internal_or_test_user_hostname:n&&n>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:n&&n>="2026-05-30"?250:0,split_storage:!(!n||"2026-05-30">n),detect_google_search_app:!(!n||"2026-05-30">n),disable_capture_url_hashes:!(!n||"2026-06-25">n),cookieWinsOnConflict:!(!n||n==="unset"||"2026-08-29">n)}))(e))},RO=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],T_=e=>{var t={};for(var n of RO){var r=n[0],i=n[1];L(e[r])||(t[i]=e[r])}var s=_e({},t,e),o=e.__preview_external_dependency_versioned_paths;return L(o)||(L(e.strict_script_versioning)&&(s.strict_script_versioning=!!o),ce(o)&&L(e.asset_host)&&(s.asset_host=o)),Z(e.property_blacklist)&&(L(e.property_denylist)?s.property_denylist=e.property_blacklist:Z(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:D.error(oS+e.property_denylist)),s};class TO{constructor(){this.__forceAllowLocalhost=!1}get Fo(){return this.__forceAllowLocalhost}set Fo(t){D.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class qt{Oo(t,n){if(t){var r=this.To.indexOf(t);r!==-1&&this.To.splice(r,1)}return this.To.push(n),n.initialize==null||n.initialize(),n}Lo(){return this.config.cookieless_mode===lr||this.config.cookieless_mode===ki&&this.consent.isRejected()}$o(){if(!this.Lo()&&this.get_distinct_id()===fs){var t=this.persistence;if(t){this.Do()||t.load(!0);var n=this.get_distinct_id();if(!n||n===fs){var r=this.config.get_device_id($n());this.register({distinct_id:r,$device_id:r}),t.set_property(se,We)}this.No()}}}get decideEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}get flagsEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){var t;this.webPerformance=new TO,this.qo=!1,this.version=Ee.LIB_VERSION,this.jo=new Set,this.Bo="",this.Ro=new Ac,this.To=[],this.Ho=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Mf(),this.SentryIntegration=GI,this.sentryIntegration=r=>function(i,s){var o=OE(i,s);return{name:IE,processEvent:a=>o(a)}}(this,r),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Uo=!1,this.zo=null,this.Wo=null,this.Vo=null,this.scrollManager=new pO(this),this.pageViewManager=new f_(this),this.rateLimiter=new nO(this),this.requestRouter=new yO(this),this.consent=new NI(this),this.externalIntegrations=new EO(this);var n=(t=qt.__defaultExtensionClasses)!==null&&t!==void 0?t:{};this.featureFlags=n.featureFlags&&new n.featureFlags(this),this.toolbar=n.toolbar&&new n.toolbar(this),this.surveys=n.surveys&&new n.surveys(this),this.conversations=n.conversations&&new n.conversations(this),this.logs=n.logs&&new n.logs(this),this.metrics=n.metrics&&new n.metrics(this),this.experiments=n.experiments&&new n.experiments(this),this.exceptions=n.exceptions&&new n.exceptions(this),this.people={set:(r,i,s)=>{var o=ce(r)?{[r]:i}:r;this.setPersonProperties(o),s==null||s({})},set_once:(r,i,s)=>{var o=ce(r)?{[r]:i}:r;this.setPersonProperties(void 0,o),s==null||s({})}},this.on("eventCaptured",r=>D.info('send "'+(r==null?void 0:r.event)+'"',r))}init(t,n,r){if(r&&r!==bs){var i,s=(i=Ra[r])!==null&&i!==void 0?i:new qt;return s._init(t,n,r),Ra[r]=s,Ra[bs][r]=s,s}return this._init(t,n,r)}_init(t,n,r){var i,s;n===void 0&&(n={});var o,a=ce(t)?t.trim():"";if(!a)return D.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return a!==((o=this.config)==null?void 0:o.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+a+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Mf(n.defaults),n.debug=this.Go(n.debug),this.Zo=n,this.Qo=[],n.person_profiles?this.Wo=n.person_profiles:n.process_person&&(this.Wo=n.process_person);var l=Mf(n.defaults),u=T_(n),c=_e({},l,u,{name:r,token:a});Se(l.rageclick)&&Se(u.rageclick)&&(c.rageclick=_e({},l.rageclick,u.rageclick)),Se(l.session_recording)&&Se(u.session_recording)&&(c.session_recording=_e({},l.session_recording,u.session_recording)),this.set_config(c),this.config.on_xhr_error&&D.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:Et.GZipJS;var d=this.Do();if(this.persistence=new Sf(this.config,d),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Sf($({},this.config,{persistence:"sessionStorage"}),d,!1),this.Bo="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!d&&we.Dr()){var f=we.Br(this.Bo);Z(f)&&f.forEach(S=>{ce(S)&&this.jo.add(S)})}else we.qr(this.Bo);var m=$({},this.persistence.props),_=$({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Jo=new dO(S=>this.Ko(S),this.config.request_queue_config),this.Yo=new hO(this),this.__request_queue=[];var p=this.Lo();if(p||(this.sessionManager=new S_(this),this.sessionPropsManager=new b_(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((S,P,C)=>{(C!=null&&C.activityTimeout||C!=null&&C.sessionPastMaximumLength||C!=null&&C.crossTabAdoption)&&this.Xo()})),this.tl(),this.config.__preview_deferred_init_extensions?(D.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.el(p)},0)):(D.info("Initializing extensions synchronously"),this.el(p)),Ee.DEBUG=Ee.DEBUG||this.config.debug,Ee.DEBUG&&D.info("Starting in debug mode",{this:this,config:n,thisC:$({},this.config),p:m,s:_}),!this.config.identity_distinct_id||(i=n.bootstrap)!=null&&i.distinctID||(n.bootstrap=$({},n.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((s=n.bootstrap)==null?void 0:s.distinctID)!==void 0){var y=n.bootstrap.distinctID,h=this.get_distinct_id(),v=this.persistence.get_property(se);if(n.bootstrap.isIdentifiedID&&h!=null&&h!==y&&v===We)this.identify(y);else if(n.bootstrap.isIdentifiedID&&h!=null&&h!==y&&v===ot)D.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var x=this.config.get_device_id($n()),b=n.bootstrap.isIdentifiedID?x:y;this.persistence.set_property(se,n.bootstrap.isIdentifiedID?ot:We),this.register({distinct_id:y,$device_id:b})}}if(p)this.register_once({distinct_id:fs,$device_id:null},"");else if(!this.get_distinct_id()){var E=this.config.get_device_id($n());this.register_once({distinct_id:E,$device_id:E},""),this.persistence.set_property(se,We)}return Re(I,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),n.segment?function(S,P){var C=S.config.segment;if(!C)return P();(function(T,R){var N=T.config.segment;if(!N)return R();var M=F=>{var W=()=>F.anonymousId()||$n();T.config.get_device_id=W,F.id()&&(T.register({distinct_id:F.id(),$device_id:W()}),T.persistence.set_property(se,ot)),R()},z=N.user();"then"in z&&vt(z.then)?z.then(M):M(z)})(S,()=>{C.register((T=>{typeof Promise<"u"&&Promise.resolve||bf.warn("This browser does not have Promise support, and can not use the segment integration");var R=(N,M)=>{if(!M)return N;N.event.userId||N.event.anonymousId===T.get_distinct_id()||(bf.info("No userId set, resetting PostHog"),T.reset()),N.event.userId&&N.event.userId!==T.get_distinct_id()&&(bf.info("UserId set, identifying with PostHog"),T.identify(N.event.userId));var z=T.calculateEventProperties(M,N.event.properties);return N.event.properties=Object.assign({},z,N.event.properties),N};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:N=>R(N,N.event.event),page:N=>R(N,xs),identify:N=>R(N,gf),screen:N=>R(N,"$screen")}})(S)).then(()=>{P()})})}(this,()=>this.il()):this.il(),vt(this.config._onCapture)&&this.config._onCapture!==Ta&&(D.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",S=>this.config._onCapture(S.event,S))),this.config.ip&&D.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||function(){return eS.apply(this,arguments)}().then(S=>{S&&this.register({[pf]:S})}).catch(Ta),this}rl(t){var n=t;return ce(n.name)&&vt(n.setup)}nl(t,n){this.rl(t)?n.push(()=>{this.sl().add(t).catch(Ta)}):this.To.push(t)}tl(){var t,n,r,i,s,o,a=(t=(n=this.config.__extensionClasses)==null?void 0:n.featureFlags)!==null&&t!==void 0?t:(r=qt.__defaultExtensionClasses)==null?void 0:r.featureFlags;a&&(this.featureFlags&&this.featureFlags instanceof a||((i=this.al)==null||i.call(this),this.al=void 0,this.featureFlags=new a(this)),vt(this.featureFlags.onReloading)&&vt(this.featureFlags.setup)?this.al||(this.al=this.featureFlags.onReloading(()=>{this.Ro.emit("featureFlagsReloading",!0)}),this.sl().add(this.featureFlags)):(s=(o=this.featureFlags).initialize)==null||s.call(o))}el(t){var n,r,i,s,o,a,l,u=performance.now(),c=$({},qt.__defaultExtensionClasses,this.config.__extensionClasses),d=[];c.exceptions&&this.To.push(this.exceptions=(n=this.exceptions)!==null&&n!==void 0?n:new c.exceptions(this)),c.historyAutocapture&&this.To.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this.To.push(this.tracingHeaders=new c.tracingHeaders(this)),c.siteApps&&this.To.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!t&&this.To.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||d.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),c.autocapture&&this.nl(this.autocapture=new c.autocapture(this),d),c.surveys&&this.nl(this.surveys=(r=this.surveys)!==null&&r!==void 0?r:new c.surveys(this),d),c.logs&&this.To.push(this.logs=(i=this.logs)!==null&&i!==void 0?i:new c.logs(this)),c.metrics&&this.To.push(this.metrics=(s=this.metrics)!==null&&s!==void 0?s:new c.metrics(this)),c.conversations&&this.To.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new c.conversations(this)),c.productTours&&this.To.push(this.productTours=new c.productTours(this)),c.heatmaps&&this.To.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this.To.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this.To.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this.To.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,HI)),c.toolbar&&this.To.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new c.toolbar(this)),c.experiments&&this.To.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new c.experiments(this)),this.To.forEach(f=>{f.initialize&&d.push(()=>{f.initialize==null||f.initialize()})}),d.push(()=>{if(this.ol){var f=this.ol;this.ol=void 0,this.To.forEach(m=>m.onRemoteConfig==null?void 0:m.onRemoteConfig(f))}}),this.ll(d,u)}ll(t,n){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&t.length>0)return void setTimeout(()=>{this.ll(t,n)},0);var r=t.shift();if(r)try{r()}catch(s){D.error("Error initializing extension:",s)}}var i=Math.round(performance.now()-n);this.register_for_session({[hE]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[pE]:i}),this.config.__preview_deferred_init_extensions&&D.info("PostHog extensions initialized ("+i+"ms)")}pa(t){var n;if(!j||!j.body)return D.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.pa(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.ol=t),this.Io=t,this.compression=void 0,t.ok){var r,i=t.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=J(i.supportedCompression,Et.GZipJS)?Et.GZipJS:J(i.supportedCompression,Et.Base64)?Et.Base64:void 0),(r=i.analytics)!=null&&r.endpoint&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.Wo?this.Wo:bp}),(n=this.ul)==null||n.handleRemoteConfig(t),this.To.forEach(s=>s.onRemoteConfig==null?void 0:s.onRemoteConfig(t))}il(){try{this.config.loaded(this)}catch(r){D.critical("`loaded` function failed",r)}if(this.hl(),this.config.internal_or_test_user_hostname&&Ae!=null&&Ae.hostname){var t=Ae.hostname,n=this.config.internal_or_test_user_hostname;(typeof n=="string"?t===n:n.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.Lo())&&this.dl()},1),this.vl=new UE(this),this.vl.load()}hl(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.Jo)==null||t.enable())}_dom_loaded(){this.is_capturing()&&Ql(this.__request_queue,t=>this.Ko(t)),this.__request_queue=[],this.hl()}_handle_unload(){var t,n,r,i,s;(t=this.surveys)==null||t.handlePageUnload==null||t.handlePageUnload(),(n=this.metrics)==null||n.flush("sendBeacon"),this.config.request_batching?(this.cl()&&this.capture(vf),(r=this.logs)==null||r.flushLogs("sendBeacon"),(i=this.Jo)==null||i.unload(),(s=this.Yo)==null||s.unload()):this.cl()&&this.capture(vf,null,{transport:"sendBeacon"})}_send_request(t){this.__loaded?aS?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(t.callback==null||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=$({},this.config.request_headers,t.headers),t.compression=t.compression==="best-available"?this.compression:t.compression,(L(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(n=>{var r,i,s,o=$({},n);o.timeout=o.timeout||6e4;var a,l,u,c,d,f=(r=o.transport)!==null&&r!==void 0?r:"fetch";f==="sendBeacon"&&L(o.compression)&&o.data&&(o.compression=Et.Base64),o.method==="POST"&&o.data&&(o.timestampMode==="capture-body"?o.data={api_key:(l=(d=(c=(Z(a=o.data)?a:[a]).map(y=>$({},y,y.timestamp instanceof Date&&!isNaN(y.timestamp.getTime())?{timestamp:y.timestamp.toISOString()}:{})))[0])==null||(u=d.properties)==null?void 0:u.token)!==null&&l!==void 0?l:d==null?void 0:d.token,batch:c,sent_at:new Date().toISOString()}:o.timestampMode==="body"&&(o.data=function(y,h){return h===void 0&&(h=new Date().toISOString()),Z(y)?y.map(v=>$({},v,{sent_at:h})):$({},y,{sent_at:h})}(o.data))),o.url=x_(o.url,o.method,o.compression,o.timestampMode);var m=Mu.filter(y=>!o.disableTransport||!y.transport||!o.disableTransport.includes(y.transport)),_=(i=(s=function(y,h){for(var v=0;y.length>v;v++)if(y[v].transport===f)return y[v]}(m))==null?void 0:s.method)!==null&&i!==void 0?i:m[0].method;if(!_)throw new Error("No available transport method");var p=y=>{try{_(y)}catch(h){XE(h)?D.warn(h):D.error(h),o.callback==null||o.callback({statusCode:0,error:h})}};f!=="sendBeacon"&&o.data&&o.compression===Et.GZipJS&&ET&&typeof Promise<"u"&&!Ou?uO(o).then(y=>{p(y)}).catch(y=>{if(Ly(y))return Ou=!0,void p($({},o,{compression:void 0,url:x_(n.url,n.method,void 0,n.timestampMode)}));(h=>{if(!h||typeof h!="object")return!1;var v="name"in h?String(h.name):"";return Ly(h)||v===Eb})(y)&&(Ou=!0),p(o)}):_(o)})($({},t,{callback:n=>{var r,i;this.rateLimiter.checkForLimiting(n),400>n.statusCode||(r=(i=this.config).on_request_error)==null||r.call(i,n),t.callback==null||t.callback(n)}}))):t.fireCallbackOnDrop&&(t.callback==null||t.callback({statusCode:0}))}Ko(t){this.Yo?this.Yo.retriableRequest(t):this._send_request(t)}_execute_array(t){Of++;try{var n,r=[],i=[],s=[];Ql(t,a=>{if(a)if(Z(n=a[0]))s.push(a);else if(vt(a))try{a.call(this)}catch(l){D.error("Error executing queued PostHog call",a,l)}else Z(a)&&n==="alias"?r.push(a):Z(a)&&n.indexOf("capture")!==-1&&vt(this[n])?s.push(a):i.push(a)});var o=function(a,l){Ql(a,function(u){try{if(Z(u[0])){var c=l;ve(u,function(d){c=c[d[0]].apply(c,d.slice(1))})}else l[u[0]].apply(l,u.slice(1))}catch(d){D.error("Error executing queued PostHog call",u,d)}})};o(r,this),o(i,this),o(s,this)}finally{Of--}}push(t){if(Of>0&&Z(t)&&ce(t[0])){var n=qt.prototype[t[0]];vt(n)&&n.apply(this,t.slice(1))}else this._execute_array([t])}capture(t,n,r){var i,s,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Jo){if(this.is_capturing())if(!L(t)&&ce(t)){this.$o();var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){n!=null&&n.$current_url&&!ce(n==null?void 0:n.$current_url)&&(D.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),t!=="$exception"||r!=null&&r.fl||D.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var d=new Date,f=(r==null?void 0:r.timestamp)||d,m=Vy(r==null?void 0:r.uuid,$n),_={uuid:m,event:t,properties:this.calculateEventProperties(t,n||{},f,m)};t===xs&&this.config.__preview_capture_bot_pageviews&&u&&(_.event="$bot_pageview",_.properties.$browser_type="bot"),c&&(_.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens);var p=t==="$feature_flag_called"&&_.properties.$feature_flag_has_experiment===!1&&this.get_property(xc)===!0;r!=null&&r.$set&&!p&&(_.$set=r==null?void 0:r.$set);var y=r==null?void 0:r.$unset;y&&(_.$unset=y);var h,v,x,b=p?void 0:this.pl(r==null?void 0:r.$set_once,t!==Yy,t===gf);if(b&&(_.$set_once=b),r!=null&&r._noTruncate||(s=this.config.properties_string_max_length,o=_,a=M=>ce(M)?M.slice(0,s):M,l=new Set,_=function M(z,F){if(z!==Object(z))return a?a(z):z;if(!l.has(z)){var W;if(l.add(z),Z(z))W=[],Ql(z,Q=>{W.push(M(Q))});else{var B={};ve(z,(Q,O)=>{l.has(Q)||(B[O]=M(Q))}),W=B}return W}}(o)),_.timestamp=f,L(r==null?void 0:r.timestamp)||(_.properties.$event_time_override_provided=!0,_.properties.$event_time_override_system_time=d),p&&(_.properties=function(M,z){z===void 0&&(z=[]);var F={},W=B=>{M[B]!==void 0&&(F[B]=M[B])};return ST.forEach(W),z.forEach(W),F}(_.properties,PO)),t===ur.DISMISSED||t===ur.SENT){var E=n==null?void 0:n[kf.SURVEY_ID],S=n==null?void 0:n[kf.SURVEY_ITERATION];sS({id:E,current_iteration:S}),_.$set=$({},_.$set,{[(h={id:E,current_iteration:S},v=t===ur.SENT?"responded":"dismissed",x="$survey_"+v+"/"+h.id,h.current_iteration&&h.current_iteration>0&&(x="$survey_"+v+"/"+h.id+"/"+h.current_iteration),x)]:!0})}else t===ur.SHOWN&&(_.$set=$({},_.$set,{[kf.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(t===tO.SHOWN){var P=n==null?void 0:n[v_.TOUR_TYPE];P&&(_.$set=$({},_.$set,{[v_.TOUR_LAST_SEEN_DATE+"/"+P]:new Date().toISOString()}))}var C=$({},_.properties.$set,_.$set);if(En(C)||this.setPersonPropertiesForFlags(C),!ne(this.config.before_send)){var T=this.kn(_);if(!T)return;(_=T).uuid=Vy(_.uuid,$n)}this.Ro.emit("eventCaptured",_);var R=(i=r==null?void 0:r._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),N={method:"POST",url:R,data:_,compression:"best-available",timestampMode:(r==null?void 0:r._batchKey)==="recordings"||/\/s\/(?:\?|$)/.test(R)?"body":"capture-body",batchKey:r==null?void 0:r._batchKey,transport:r==null?void 0:r.transport};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.Ko(N):this.Jo.enqueue(N),_}D.critical("This capture call is ignored due to client rate limiting.")}}else D.error("No event name provided to posthog.capture")}else D.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",n=>t(n.event,n))}sl(){var t;return(t=this.ul)!==null&&t!==void 0?t:this.ul=new kO(this)}Ao(t){this.Ho.push(t);var n=!0;return()=>{if(n){n=!1;var r=this.Ho.indexOf(t);r!==-1&&this.Ho.splice(r,1)}}}gl(t){var n,r,i;return t===void 0&&(t=!0),!((n=this.persistence)==null||!n.consumeCookieIdentityChange())&&(this.Vo=null,this.persistence.get_property(se)===We&&((i=this.sessionPersistence)==null||i.clear(),this.jo.clear(),this.ml()),(r=this.featureFlags)==null||r.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,n,r,i,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;this.persistence.syncCookieProperties(),this.gl();var o=s?void 0:this.persistence.remove_event_timer(t),a=$({},n);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.Lo()&&(a[fE]=!0),t==="$snapshot"){var l=$({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!ce(a.distinct_id)&&!Ge(a.distinct_id)||cc(a.distinct_id))&&D.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,c=function(E,S,P,C){var T,R,N,M;if(C===void 0&&(C=!1),!Mt)return{};var z,F=E?[...Co,...S||[]]:[],W=function(us){for(var It=0;zy.length>It;It++){var cs=zy[It],Cr=cs[1],pn=cs[0].exec(us),Do=pn&&(vt(Cr)?Cr(pn,us):Cr);if(Do)return Do}return["",""]}(Mt),B=W[0],Q=W[1],O=(z=typeof navigator<"u"?navigator:void 0)!=null&&z.brave?{brave:!0}:{},A={};L(P)||(A.detectGoogleSearchApp=P);var V={},K=(T=navigator)==null||(T=T.userAgentData)==null?void 0:T.platform,te=(R=navigator)==null?void 0:R.maxTouchPoints,oe=I==null||(N=I.screen)==null?void 0:N.width,de=I==null||(M=I.screen)==null?void 0:M.height,be=I==null?void 0:I.devicePixelRatio;L(K)||(V.userAgentDataPlatform=K),L(te)||(V.maxTouchPoints=te),L(oe)||(V.screenWidth=oe),L(de)||(V.screenHeight=de),L(be)||(V.devicePixelRatio=be);var Pe,Be,ye,Fe,Tt,Sr,_t,Ye,gi=_e(Sg({$os:B,$os_version:Q,$browser:Yb(Mt,navigator.vendor,O,A),$device:Uy(Mt),$device_type:(Be=Mt,ye=V,Ye=Uy(Be),Ye===Mb||Ye===Ob||Ye==="Kobo"||Ye==="Kindle Fire"||Ye===Wb?wo:Ye===Ka||Ye===Hs||Ye===Qa||Ye===ip?"Console":Ye===Nb?"Wearable":Ye?Yt:(ye==null?void 0:ye.userAgentDataPlatform)==="Android"&&((Fe=ye==null?void 0:ye.maxTouchPoints)!==null&&Fe!==void 0?Fe:0)>0?600>Math.min((Tt=ye==null?void 0:ye.screenWidth)!==null&&Tt!==void 0?Tt:0,(Sr=ye==null?void 0:ye.screenHeight)!==null&&Sr!==void 0?Sr:0)/((_t=ye==null?void 0:ye.devicePixelRatio)!==null&&_t!==void 0?_t:1)?Yt:wo:"Desktop"),$timezone:zE(),$timezone_offset:JI()}),{$current_url:Za(C?li(Ae==null?void 0:Ae.href):Ae==null?void 0:Ae.href,F,el),$host:Ae==null?void 0:Ae.host,$pathname:Ae==null?void 0:Ae.pathname,$raw_user_agent:Mt.length>1e3?Mt.substring(0,997)+"...":Mt,$browser_version:GT(Mt,navigator.vendor,O,A),$browser_language:h_(),$browser_language_prefix:(Pe=h_(),typeof Pe=="string"?Pe.split("-")[0]:void 0),$screen_height:I==null?void 0:I.screen.height,$screen_width:I==null?void 0:I.screen.width,$viewport_height:I==null?void 0:I.innerHeight,$viewport_width:I==null?void 0:I.innerWidth,$lib:Ee.LIB_NAME,$lib_version:Ee.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Ee.SDK_DIST_CHANNEL&&(gi.$sdk_dist_channel=Ee.SDK_DIST_CHANNEL),gi}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var d=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime(),!0),f=d.windowId;a.$session_id=d.sessionId,a.$window_id=f}this.sessionPropsManager&&_e(a,this.sessionPropsManager.getSessionProps());try{var m;this.sessionRecording&&_e(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(m=this.Yo)==null?void 0:m.length}catch(E){a.$sdk_debug_error_capturing_properties=String(E)}if(this.requestRouter.region===Ap&&(a.$lib_custom_api_host=this.config.api_host),u=t!==xs||s?t!==vf||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=_e(a,u),t===xs&&j&&(a.title=j.title),!L(o)){var _=r.getTime()-o;a.$duration=parseFloat((_/1e3).toFixed(3))}Mt&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");var p=this.persistence.properties(),y=this.sessionPersistence.properties();ve(["$referrer","$referring_domain"],E=>{E in p&&delete y[E]});var h={};if(this.Ho.length>0)for(var v of this.Ho.slice())try{_e(h,v())}catch(E){D.error("Failed to produce browser extension event properties",E)}(a=_e({},c,p,y,$({},h,a))).$is_identified=this._isIdentified(),Z(this.config.property_denylist)?ve(this.config.property_denylist,function(E){delete a[E]}):D.error(oS+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var x=this.config.sanitize_properties;x&&(D.error(R_),a=x(a,t));var b=this.yl();return a.$process_person_profile=b,b&&!s&&this.bl("_calculate_event_properties"),a}pl(t,n,r){var i;if(n===void 0&&(n=!0),r===void 0&&(r=!1),!this.persistence||!this.yl()||this.qo&&!r)return t;var s=this.persistence.get_initial_props(),o=(i=this.sessionPropsManager)==null?void 0:i.getSetOnceProps(),a=_e({},s,o||{},t||{}),l=this.config.sanitize_properties;return l&&(D.error(R_),a=l(a,"$set_once")),n&&(this.qo=!0),En(a)?void 0:a}register(t,n){var r;(r=this.persistence)==null||r.register(t,n)}register_once(t,n,r){var i;(i=this.persistence)==null||i.register_once(t,n,r)}register_for_session(t){var n,r;(n=this.persistence)==null||n.syncCookieProperties(),this.gl(),(r=this.sessionPersistence)==null||r.register(t),Object.keys(t).forEach(i=>this.jo.add(i)),this.ml()}unregister(t){var n;(n=this.persistence)==null||n.unregister(t)}unregister_for_session(t){var n;(n=this.sessionPersistence)==null||n.unregister(t),this.jo.delete(t),this.ml()}_l(t,n){this.register({[t]:n})}Xo(){this.jo.forEach(t=>{var n;(n=this.sessionPersistence)==null||n.unregister(t)}),this.jo.clear(),this.ml()}ml(){var t;if(this.Bo)if(this.config.persistence==="memory"||(t=this.sessionPersistence)!=null&&t.Hs||!we.Dr())we.qr(this.Bo);else{var n=[];this.jo.forEach(r=>n.push(r)),n.length>0?we.Nr(this.Bo,n):we.qr(this.Bo)}}getFeatureFlag(t,n){var r;return(r=this.featureFlags)==null?void 0:r.getFeatureFlag(t,n)}getFeatureFlagPayload(t){var n;return(n=this.featureFlags)==null?void 0:n.getFeatureFlagPayload(t)}getFeatureFlagResult(t,n){var r;return(r=this.featureFlags)==null?void 0:r.getFeatureFlagResult(t,n)}getAllFeatureFlags(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.getAllFeatureFlags())!==null&&t!==void 0?t:[]}isFeatureEnabled(t,n){var r,i;return(r=(i=this.featureFlags)==null?void 0:i.isFeatureEnabled(t,n))!==null&&r!==void 0?r:n==null?void 0:n.defaultValue}reloadFeatureFlags(){var t;(t=this.featureFlags)==null||t.reloadFeatureFlags()}updateFlags(t,n,r){var i;(i=this.featureFlags)==null||i.updateFlags(t,n,r)}updateEarlyAccessFeatureEnrollment(t,n,r){var i;(i=this.featureFlags)==null||i.updateEarlyAccessFeatureEnrollment(t,n,r)}getEarlyAccessFeatures(t,n,r){var i;return n===void 0&&(n=!1),(i=this.featureFlags)==null?void 0:i.getEarlyAccessFeatures(t,n,r)}on(t,n){return this.Ro.on(t,n)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:ea}),()=>{})}onSessionId(t){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(t))!==null&&n!==void 0?n:()=>{}}getSurveys(t,n){n===void 0&&(n=!1),this.surveys?this.surveys.getSurveys(t,n):t([],{isLoaded:!1,error:ea})}getActiveMatchingSurveys(t,n){n===void 0&&(n=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,n):t([],{isLoaded:!1,error:ea})}renderSurvey(t,n){var r;(r=this.surveys)==null||r.renderSurvey(t,n)}displaySurvey(t,n){var r;n===void 0&&(n=wO),(r=this.surveys)==null||r.displaySurvey(t,n)}cancelPendingSurvey(t){var n;(n=this.surveys)==null||n.cancelPendingSurvey(t)}canRenderSurvey(t){var n,r;return(n=(r=this.surveys)==null?void 0:r.canRenderSurvey(t))!==null&&n!==void 0?n:{visible:!1,disabledReason:ea}}canRenderSurveyAsync(t,n){var r,i;return n===void 0&&(n=!1),(r=(i=this.surveys)==null?void 0:i.canRenderSurveyAsync(t,n))!==null&&r!==void 0?r:Promise.resolve({visible:!1,disabledReason:ea})}wl(t){return!t||cc(t)?(D.critical("Unique user id has not been set in posthog.identify"),!1):t===fs?(D.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(D.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,n,r){if(!this.__loaded||!this.persistence)return D.uninitializedWarning("posthog.identify");if(Ge(t)&&(t=t.toString(),D.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.wl(t)&&this.bl("posthog.identify")){this.$o();var i=this.get_distinct_id(),s=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==i,o=this.gl(!1),a=this.persistence.Ws(),l=!1;try{var u=this.get_distinct_id();this.register({$user_id:t}),this.get_property(Ya)||this.register_once({$had_persisted_distinct_id:!0,$device_id:u},""),t!==u&&t!==this.get_property($s)&&(this.unregister($s),this.register({distinct_id:t}));var c,d=(this.persistence.get_property(se)||We)===We,f=t!==u,m=!f&&d;if(f&&d)this.persistence.set_property(se,ot),this.setPersonPropertiesForFlags({$set:n||{},$set_once:r||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Vs(),this.capture(gf,{distinct_id:t,$anon_distinct_id:u},{$set:n||{},$set_once:r||{}}),this.Vo=If(t,n,r),(c=this.featureFlags)==null||c.setAnonymousDistinctId(u);else if(m){this.persistence.set_property(se,ot);var _=n||{},p=r||{};this.setPersonPropertiesForFlags({$set:_,$set_once:p},!1),this.config.cookieWinsOnConflict&&this.persistence.Vs(),this.capture("$set",{$set:_,$set_once:p}),this.Vo=If(t,n,r)}else(n||r)&&this.setPersonProperties(n,r);f||s||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(ar)):m&&(n||r)&&this.reloadFeatureFlags(),l=!0}finally{a&&this.persistence.Qs(l)}}}setPersonProperties(t,n){if((t||n)&&this.bl("posthog.setPersonProperties")){var r=If(this.get_distinct_id(),t,n);this.Vo!==r?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!0),this.capture("$set",{$set:t||{},$set_once:n||{}}),this.Vo=r):D.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var n,r=(Z(t)?t:[t]).filter(i=>ce(i)&&i.length>0);r.length!==0&&this.bl("posthog.unsetPersonProperties")&&((n=this.featureFlags)==null||n.unsetPersonPropertiesForFlags(r,!0),this.capture("$set",{$unset:r}),this.Vo=null)}group(t,n,r){var i;if(t&&n){(i=this.persistence)==null||i.syncCookieProperties(),this.gl();var s=this.getGroups(),o=s[t]!==n;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:$({},s,{[t]:n})}),o||r){var a={$group_type:t,$group_key:n};r&&(a.$group_set=r),this.capture(Yy,a)}r&&this.setGroupPropertiesForFlags({[t]:r}),o&&!r&&this.reloadFeatureFlags()}else D.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,n){var r;n===void 0&&(n=!0),(r=this.featureFlags)==null||r.setPersonPropertiesForFlags(t,n)}resetPersonPropertiesForFlags(t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,n){var r;n===void 0&&(n=!0),this.bl("posthog.setGroupPropertiesForFlags")&&((r=this.featureFlags)==null||r.setGroupPropertiesForFlags(t,n))}resetGroupPropertiesForFlags(t){var n;(n=this.featureFlags)==null||n.resetGroupPropertiesForFlags(t)}reset(t){var n=$t(t)?t:t==null?void 0:t.resetDeviceID,r=$t(t)||t==null?void 0:t.bootstrap;this.kl(n,!1,r)}kl(t,n,r){var i,s,o;if(n===void 0&&(n=!1),D.info("reset"),!this.__loaded)return D.uninitializedWarning("posthog.reset");var a=r==null?void 0:r.sessionID;this.config.bootstrap=r||((i=this.Zo)==null?void 0:i.bootstrap)||{},(s=this.featureFlags)==null||s.updateConfig==null||s.updateConfig(this.config,this.ma());var l=this.get_property(Ya),u=this.get_property(pf),c=this.get_property(Oi),d=this.is_capturing();this.consent.reset(),n||!d||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");var f=(o=this.persistence)==null||o.Ws==null?void 0:o.Ws(),m=!1;try{var _,p,y,h,v,x,b,E,S,P,C,T,R,N;if((_=this.persistence)==null||_.clear(),(p=this.sessionPersistence)==null||p.clear(),this.jo.clear(),this.ml(),L(c)||(C=this.persistence)==null||C.register({[Oi]:c}),(y=this.surveys)==null||y.reset(),(h=this.vl)==null||h.stop(),(v=this.featureFlags)==null||v.reset(),(x=this.conversations)==null||x.reset(),(b=this.logs)==null||b.reset(),(E=this.metrics)==null||E.reset(),(S=this.persistence)==null||S.set_property(se,We),(P=this.sessionManager)==null||P.resetSessionId(),this.Vo=null,this.config.cookieless_mode===lr)this.register_once({distinct_id:fs,$device_id:null},"");else{var M=this.config.get_device_id($n());this.register_once({distinct_id:M,$device_id:t?M:l},""),t||L(u)||this.register({[pf]:u})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),r&&(r.distinctID===void 0||this.Lo()||((N=this.persistence)==null||N.set_property(se,r.isIdentifiedID?ot:We),this.register({distinct_id:r.distinctID})),(T=this.featureFlags)==null||T.initialize(),!(L(a)||(R=this.sessionManager)!=null&&R.setBootstrapSessionId(a,!0)))){var z=$({},r);delete z.sessionID,this.config.bootstrap=z}delete this.config.identity_distinct_id,delete this.config.identity_hash,m=!0}finally{var F;f&&((F=this.persistence)==null||F.Qs==null||F.Qs(m))}this.reloadFeatureFlags()}shutdown(t){var n=this;return Ce(function*(){var r,i,s,o,a,l;if(n.__loaded){(r=n.vl)==null||r.stop(),n.sl().dispose(),(i=n.sessionRecording)==null||i.dispose(),(s=n.logs)==null||s.flushLogs("sendBeacon"),(o=n.metrics)==null||o.flush("sendBeacon"),(a=n.Jo)==null||a.unload(),(l=n.Yo)==null||l.unload();try{var u;(u=n.featureFlags)==null||u.destroy()}catch(c){D.error("Error while destroying feature flags",c)}}else D.uninitializedWarning("posthog.shutdown")})()}setIdentity(t,n){var r;this.config.identity_distinct_id=t,this.config.identity_hash=n,this.alias(t),(r=this.conversations)==null||r.Sl()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,(t=this.conversations)==null||t.xl()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,n;return(t=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var n=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=n.sessionStartTimestamp,i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n.sessionId);if(t!=null&&t.withTimestamp&&r){var s,o=(s=t.timestampLookBack)!==null&&s!==void 0?s:10;if(!r)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-o,0)}return i}alias(t,n){return t===this.get_property(sE)?(D.critical("Attempting to create alias for existing People user - aborting."),-2):this.bl("posthog.alias")?(L(n)&&(n=this.get_distinct_id()),t!==n?(this._l($s,t),this.capture("$create_alias",{alias:t,distinct_id:n})):(D.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var n=$({},this.config);if(Se(t)){var r,i,s,o,a,l,u,c,d,f,m,_;_e(this.config,T_(t));var p=this.Do();(r=this.persistence)==null||r.update_config(this.config,n,p),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Sf($({},this.config,{persistence:"sessionStorage"}),p,!1);var y,h=this.Go(this.config.debug);$t(h)&&(this.config.debug=h),$t(this.config.debug)&&(this.config.debug?(Ee.DEBUG=!0,ge.Dr()&&ge.Nr("ph_debug",!0),D.info("set_config",{config:t,oldConfig:n,newConfig:$({},this.config)})):(Ee.DEBUG=!1,ge.Dr()&&ge.qr("ph_debug"))),(i=this.featureFlags)==null||i.updateConfig==null||i.updateConfig(this.config,this.ma()),(s=this.exceptionObserver)==null||s.onConfigChange(),(o=this.exceptions)==null||o.onConfigChange(),(a=this.sessionRecording)==null||a.startIfEnabledOrStop(),(l=this.tracingHeaders)==null||l.startIfEnabledOrStop(),(u=this.autocapture)==null||u.startIfEnabled(),(c=this.heatmaps)==null||c.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&((y=this.historyAutocapture)==null||y.startIfEnabledOrStop()),(d=this.exceptionObserver)==null||d.startIfEnabledOrStop(),(f=this.deadClicksAutocapture)==null||f.startIfEnabledOrStop(),(m=this.surveys)==null||m.loadIfEnabled(),this.No(),(_=this.externalIntegrations)==null||_.startIfEnabledOrStop()}}_overrideSDKInfo(t,n){Ee.LIB_NAME=t,Ee.LIB_VERSION=n}startSessionRecording(t){var n,r,i,s,o,a=t===!0,l={sampling:a||!(t==null||!t.sampling),linked_flag:a||!(t==null||!t.linked_flag),url_trigger:a||!(t==null||!t.url_trigger),event_trigger:a||!(t==null||!t.event_trigger)};Object.values(l).some(Boolean)&&((n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),l.sampling&&((r=this.sessionRecording)==null||r.overrideSampling()),l.linked_flag&&((i=this.sessionRecording)==null||i.overrideLinkedFlag()),l.url_trigger&&((s=this.sessionRecording)==null||s.overrideTrigger("url")),l.event_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!((t=this.sessionRecording)==null||!t.started)}captureException(t,n){if(this.exceptions){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(t,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent($({},i,n))}}addExceptionStep(t,n){var r;(r=this.exceptions)==null||r.addExceptionStep(t,n)}captureLog(t){var n;(n=this.logs)==null||n.captureLog(t)}get logger(){var t,n;return(t=(n=this.logs)==null?void 0:n.logger)!==null&&t!==void 0?t:qt.Cl}startExceptionAutocapture(t){this.set_config({capture_exceptions:t==null||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var n,r;return(n=(r=this.toolbar)==null?void 0:r.loadToolbar(t))!==null&&n!==void 0&&n}get_property(t){var n;return(n=this.persistence)==null?void 0:n.props[t]}getSessionProperty(t){var n;return(n=this.sessionPersistence)==null?void 0:n.props[t]}toString(){var t,n=(t=this.config.name)!==null&&t!==void 0?t:bs;return n!==bs&&(n=bs+"."+n),n}_isIdentified(){var t,n;return((t=this.persistence)==null?void 0:t.get_property(se))===ot||((n=this.sessionPersistence)==null?void 0:n.get_property(se))===ot}yl(){var t,n;return!(this.config.person_profiles==="never"||this.config.person_profiles===bp&&!this._isIdentified()&&En(this.getGroups())&&((t=this.persistence)==null||(t=t.props)==null||!t[$s])&&((n=this.persistence)==null||(n=n.props)==null||!n[Sc]))}cl(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.yl()||this.bl("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.bl("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}bl(t){return this.config.person_profiles==="never"?(D.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._l(Sc,!0),!0)}Do(){if(this.config.cookieless_mode==="always")return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==ki)}No(){var t,n,r,i,s=this.Do();return((t=this.persistence)==null?void 0:t.Hs)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((n=this.sessionPersistence)==null?void 0:n.Hs)!==s&&((i=this.sessionPersistence)==null||i.set_disabled(s)),s&&(this.jo.clear(),this.ml()),s}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==lr){if(this.Lo()){var r,i,s,o,a;this.kl(!0,!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new S_(this),this.pageViewManager=new f_(this),this.persistence&&(this.sessionPropsManager=new b_(this,this.sessionManager,this.persistence));var l,u=(s=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&s!==void 0?s:(a=qt.__defaultExtensionClasses)==null?void 0:a.sessionRecording;u&&(this.sessionRecording=this.Oo(this.sessionRecording,new u(this)),this.Io&&((l=this.sessionRecording)==null||l.onRemoteConfig==null||l.onRemoteConfig(this.Io)))}var c,d;this.consent.optInOut(!0),this.No(),this.hl(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==ki&&((c=this.surveys)==null||c.loadIfEnabled()),(L(t==null?void 0:t.captureEventName)||t!=null&&t.captureEventName)&&this.capture((d=t==null?void 0:t.captureEventName)!==null&&d!==void 0?d:"$opt_in",t==null?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.dl()}else D.warn(P_)}opt_out_capturing(){var t,n,r;this.config.cookieless_mode!==lr?(this.config.cookieless_mode===ki&&this.consent.isOptedIn()&&this.kl(!0,!0),this.consent.optInOut(!1),this.No(),this.config.cookieless_mode===ki&&(this.register({distinct_id:fs,$device_id:null}),(t=this.sessionRecording)==null||t.stopRecording(),this.sessionRecording=void 0,(n=this.sessionManager)==null||n.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.dl(),this.hl())):D.warn(P_)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return t===1?"granted":t===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===lr||(this.config.cookieless_mode===ki?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.No()}_is_bot(){return St?ZE(St,this.config.custom_blocked_useragents):void 0}dl(){j&&(j.visibilityState==="visible"?this.Uo||(this.Uo=!0,this.capture(xs,{title:j.title},{send_instantly:!0}),this.zo&&(j.removeEventListener(Cc,this.zo),this.zo=null)):this.zo||(this.zo=this.dl.bind(this),Re(j,Cc,this.zo)))}debug(t){t===!1?(I==null||I.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(I==null||I.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}ma(){var t=this.Zo||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(D.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(n,r,i,s,o){var a=r in n&&!ne(n[r]),l=i in n&&!ne(n[i]);return a?n[r]:!!l&&(o&&o.warn("Config field '"+i+"' is deprecated. Please use '"+r+"' instead. The old field will be removed in a future major version."),n[i])}(t,"advanced_disable_flags","advanced_disable_decide",0,D)}kn(t){var n;if(ne(this.config.before_send))return t;var r=Object.keys((n=t.properties)!==null&&n!==void 0?n:{}).filter($T),i=Z(this.config.before_send)?this.config.before_send:[this.config.before_send],s=t;for(var o of i)try{if(s=o(s),ne(s)){var a="Event '"+t.event+"' was rejected in beforeSend function";return NT(t.event)?D.warn(a+". This can cause unexpected behavior."):D.info(a),null}s.properties&&!En(s.properties)||D.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}catch(u){return D.error("Error in beforeSend function for event '"+t.event+"':",u),null}for(var l of r)if(s.properties&&ne(s.properties[l]))return D.warn("Event '"+t.event+"' had its '"+l+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return s}getPageViewId(){var t;return(t=this.pageViewManager.Ss)==null?void 0:t.pageViewId}captureTraceFeedback(t,n){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:n})}captureTraceMetric(t,n,r){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:n,$ai_metric_value:String(r)})}Go(t){var n=$t(t)&&!t,r=ge.Dr()&&ge.Pr("ph_debug")==="true";return!n&&(!!r||t)}}qt.__defaultExtensionClasses={},qt.Cl=(()=>{var e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=CI(e.prototype[t[n]])}(qt,["identify"]);class lS{constructor(t){this.disabled=t===!1;var n=Se(t)?t:{};this.thresholdPx=n.threshold_px||30,this.timeoutMs=n.timeout_ms||1e3,this.clickCount=n.click_count||3,this.clicks=[]}isRageClick(t,n,r){if(this.disabled)return!1;var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(t-i.x)+Math.abs(n-i.y)r-i.timestamp){if(this.clicks.push({x:t,y:n,timestamp:r}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:n,timestamp:r}];return!1}}var Af="$copy_autocapture",nu=Ie("[AutoCapture]");function Nf(e,t){return t.length>e?t.slice(0,e)+"...":t}function IO(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!ui(t));return t}function OO(e,t){var n,r,i=t.e,s=t.maskAllElementAttributes,o=t.maskAllText,a=t.elementAttributeIgnoreList,l=t.elementsChainAsString,u=t.disableCaptureUrlHashes;if(!ui(e))return{props:{}};for(var c=[e],d=new Set([e]),f=e;f.parentNode&&!Kt(f,"body")&&bE>c.length;)if(xE(f.parentNode)){var m=f.parentNode.host;if(d.has(m))break;d.add(m),c.push(m),f=m}else{if(!ui(f.parentNode)||d.has(f.parentNode))break;d.add(f.parentNode),c.push(f.parentNode),f=f.parentNode}var _,p,y=[],h={},v=!1,x=!1;if(ve(c,C=>{var T=kp(C);if(Kt(C,"a")){var R=C.getAttribute("href");v=!!(T&&R&&ka(R))&&(u?li(R):R)}J(Tc(C),"ph-no-capture")&&(x=!0),y.push(function(M,z,F,W,B){B===void 0&&(B=!1);var Q=M.tagName.toLowerCase(),O={tag_name:Q};kg.indexOf(Q)>-1&&!F&&(O.$el_text=Q.toLowerCase()==="a"||Q.toLowerCase()==="button"?Nf(1024,u_(M)):Nf(1024,Ja(M)));var A=Tc(M);A.length>0&&(O.classes=A.filter(function(oe){return oe!==""})),ve(M.attributes,function(oe){var de;if((!RE(M)||["name","id","class","aria-label"].indexOf(oe.name)!==-1)&&(W==null||!W.includes(oe.name))&&!z&&ka(oe.value)&&(!ce(de=oe.name)||de.substring(0,10)!=="_ngcontent"&&de.substring(0,7)!=="_nghost")){var be=oe.value;oe.name==="class"&&(be=Cg(be).join(" ")),O["attr__"+oe.name]=Nf(1024,oe.name==="href"&&B?li(be):be)}});for(var V=1,K=1,te=M;te=IO(te);)V++,te.tagName===M.tagName&&K++;return O.nth_child=V,O.nth_of_type=K,O}(C,s,o,a,u));var N=function(M){if(!kp(M))return{};var z={};return ve(M.attributes,function(F){if(F.name&&F.name.indexOf("data-ph-capture-attribute")===0){var W=F.name.replace("data-ph-capture-attribute-",""),B=F.value;W&&B&&ka(B)&&(z[W]=B)}}),z}(C);_e(h,N)}),x)return{props:{},explicitNoCapture:x};if(o||(y[0].$el_text=Kt(e,"a")||Kt(e,"button")?u_(e):Ja(e)),v){var b,E;y[0].attr__href=v;var S=(b=Eo(v))==null?void 0:b.host,P=I==null||(E=I.location)==null?void 0:E.host;S&&P&&S!==P&&(_=v)}return{props:_e({$event_type:i.type,$ce_version:1},l?{}:{$elements:y},{$elements_chain:(p=y,function(C){return C.map(T=>{var R,N,M="";if(T.tag_name&&(M+=T.tag_name),T.attr_class)for(var z of(T.attr_class.sort(),T.attr_class))M+="."+z.replace(/"/g,"");var F=$({},T.text?{text:T.text}:{},{"nth-child":(R=T.nth_child)!==null&&R!==void 0?R:0,"nth-of-type":(N=T.nth_of_type)!==null&&N!==void 0?N:0},T.href?{href:T.href}:{},T.attr_id?{attr_id:T.attr_id}:{},T.attributes),W={};return Iu(F).sort((B,Q)=>B[0].localeCompare(Q[0])).forEach(B=>{var Q=B[1];return W[c_(B[0].toString())]=c_(Q.toString())}),(M+=":")+Iu(W).map(B=>B[0]+'="'+B[1]+'"').join("")}).join(";")}(function(C){return C.map(T=>{var R,N,M={text:(R=T.$el_text)==null?void 0:R.slice(0,400),tag_name:T.tag_name,href:(N=T.attr__href)==null?void 0:N.slice(0,2048),attr_class:qI(T),attr_id:T.attr__id,nth_child:T.nth_child,nth_of_type:T.nth_of_type,attributes:{}};return Iu(T).filter(z=>z[0].indexOf("attr__")===0).forEach(z=>M.attributes[z[0]]=z[1]),M})}(p)))},(n=y[0])!=null&&n.$el_text?{$el_text:(r=y[0])==null?void 0:r.$el_text}:{},_&&i.type==="click"?{$external_click_url:_}:{},h)}}class MO{constructor(t){this.name="autocapture",this.Qn=!1,this.Jn=null,this.Kn=!1,this.Yn=!1,this.qi={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Xn=!1,this.ts=t,this.ts.refresh(this.qi),this.rageclicks=new lS(this.qi.rageclick),this.es=null}setup(t){this.rs(),this.ns=t;var n=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Xn?n.dispose():(this.ss=n,this.startIfEnabled())}dispose(){var t;this.Xn||(this.Xn=!0,this.ns=void 0,(t=this.ss)==null||t.dispose(),this.ss=void 0,this.os())}ls(){return this.ts.refresh(this.qi),this.qi}rs(){var t,n;return this.ls(),this.qi.url_allowlist=(t=this.qi.url_allowlist)==null?void 0:t.map(r=>new RegExp(r)),this.qi.url_ignorelist=(n=this.qi.url_ignorelist)==null?void 0:n.map(r=>new RegExp(r)),this.qi}us(){if(this.isBrowserSupported()){if(I&&j){var t=this.hs=r=>{r=r||(I==null?void 0:I.event);try{this.ds(r)}catch(i){nu.error("Failed to capture event",i)}};if(Re(j,"submit",t,{capture:!0}),Re(j,"change",t,{capture:!0}),Re(j,"click",t,{capture:!0}),this.ls().capture_copied_text){var n=this.vs=r=>{r=r||(I==null?void 0:I.event);try{this.ds(r,Af)}catch(i){nu.error("Failed to capture copy/cut event",i)}};Re(j,"copy",n,{capture:!0}),Re(j,"cut",n,{capture:!0})}}}else nu.info("Disabling Automatic Event Collection because this browser is not supported")}os(){this.hs&&(j==null||j.removeEventListener("submit",this.hs,!0),j==null||j.removeEventListener("change",this.hs,!0),j==null||j.removeEventListener("click",this.hs,!0),this.hs=void 0),this.vs&&(j==null||j.removeEventListener("copy",this.vs,!0),j==null||j.removeEventListener("cut",this.vs,!0),this.vs=void 0),this.Qn=!1}startIfEnabled(){!this.Xn&&this.ns&&this.isEnabled&&!this.Qn&&(this.us(),this.Qn=!0)}onRemoteConfig(t){if(!this.Xn)if(this.Kn=!0,t.ok){var n=t.config;n.elementsChainAsString&&(this.Yn=n.elementsChainAsString);var r,i=n.autocapture_opt_out;$t(i)&&((r=this.ns)==null||r.kv.set(lp,i),this.Jn=i),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.es=t}getElementSelectors(t){var n,r=[];return(n=this.es)==null||n.forEach(i=>{var s=j==null?void 0:j.querySelectorAll(i);s==null||s.forEach(o=>{t===o&&r.push(i)})}),r}get isEnabled(){var t,n;if(this.Xn)return!1;var r=(t=this.ns)==null?void 0:t.kv.get(lp),i=this.Jn,s=this.ls(),o=s.remoteRequestsDisabled&&!this.Kn;if(rt(i)&&!$t(r)&&!o)return!1;var a=(n=this.Jn)!==null&&n!==void 0?n:!!r;return!!s.enabled&&!a}ds(t,n){if(n===void 0&&(n="$autocapture"),this.isEnabled){var r=Sp(t);wE(r)&&(r=r.parentNode||null);var i,s=this.rs();n==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&s.rageclick&&(i=this.rageclicks)!=null&&i.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&kE(r,s.rageclick)&&this.ds(t,"$rageclick");var o=n===Af;if(r&&function(_,p,y,h,v,x){var b;if(!I||Pg(_)||y!=null&&y.url_allowlist&&!n_(y.url_allowlist,x)||y!=null&&y.url_ignorelist&&n_(y.url_ignorelist,x))return!1;if(y!=null&&y.dom_event_allowlist){var E=y.dom_event_allowlist;if(E&&!E.some(N=>p.type===N))return!1}var S=PE(_,h),P=S.parentIsUsefulElement,C=S.targetElementList;if(!function(N,M){var z=M==null?void 0:M.element_allowlist;if(L(z))return!0;var F,W=function(Q){if(z.some(O=>Q.tagName.toLowerCase()===O))return{v:!0}};for(var B of N)if(F=W(B))return F.v;return!1}(C,y)||!Cp(C,y==null?void 0:y.css_selector_allowlist)||Cp(C,(b=y==null?void 0:y.css_selector_ignorelist)!==null&&b!==void 0?b:jI))return!1;try{var T=I.getComputedStyle(_);if(T&&T.getPropertyValue("cursor")==="pointer"&&p.type==="click")return!0}catch{}var R=_.tagName.toLowerCase();switch(R){case"html":return!1;case"form":return(v||["submit"]).indexOf(p.type)>=0;case"input":case"select":case"textarea":return(v||["change","click"]).indexOf(p.type)>=0;default:return P?(v||["click"]).indexOf(p.type)>=0:(v||["click"]).indexOf(p.type)>=0&&(kg.indexOf(R)>-1||_.getAttribute("contenteditable")==="true")}}(r,t,s,o,o?["copy","cut"]:void 0,{config:{get_current_url:s.getCurrentUrl}})){var a,l=OO(r,{e:t,maskAllElementAttributes:s.maskAllElementAttributes,maskAllText:s.maskAllText,elementAttributeIgnoreList:s.element_attribute_ignorelist,elementsChainAsString:this.Yn,disableCaptureUrlHashes:s.disableCaptureUrlHashes}),u=l.props;if(l.explicitNoCapture)return!1;var c=this.getElementSelectors(r);if(c&&c.length>0&&(u.$element_selectors=c),n===Af){var d,f=EE(I==null||(d=I.getSelection())==null?void 0:d.toString()),m=t.type||"clipboard";if(!f)return!1;u.$selected_content=f,u.$copy_type=m}return(a=this.ns)==null||a.capture(n,u).catch(_=>nu.error("Failed to capture event",_)),!0}}}isBrowserSupported(){return vt(j==null?void 0:j.querySelectorAll)}}class AO{constructor(t){this._instance=t}refresh(t){var n=this._instance.config,r=Se(n.autocapture)?n.autocapture:void 0;t.enabled=!!n.autocapture,t.rageclick=n.rageclick,t.maskAllElementAttributes=n.mask_all_element_attributes,t.maskAllText=n.mask_all_text,t.disableCaptureUrlHashes=n.disable_capture_url_hashes,t.getCurrentUrl=n.get_current_url,t.remoteRequestsDisabled=this._instance.ma(),t.url_allowlist=r==null?void 0:r.url_allowlist,t.url_ignorelist=r==null?void 0:r.url_ignorelist,t.dom_event_allowlist=r==null?void 0:r.dom_event_allowlist,t.element_allowlist=r==null?void 0:r.element_allowlist,t.css_selector_allowlist=r==null?void 0:r.css_selector_allowlist,t.css_selector_ignorelist=r==null?void 0:r.css_selector_ignorelist,t.element_attribute_ignorelist=r==null?void 0:r.element_attribute_ignorelist,t.capture_copied_text=r==null?void 0:r.capture_copied_text}}var ta=Ie("[ExceptionAutocapture]"),I_=()=>{},NO=Ie("[TracingHeaders]"),yi=Ie("[Web Vitals]"),O_=9e5,M_="disabled",A_="lazy_loading",na="awaiting_config",ru="missing_config";Ie("[SessionRecording]"),Ie("[SessionRecording]");var Np="[SessionRecording]",Yn=Ie(Np),$O=Ie("[Heatmaps]");function $f(e){return Se(e)&&"clientX"in e&&"clientY"in e&&Ge(e.clientX)&&Ge(e.clientY)}var iu=Ie("[Product Tours]"),Ff=e=>{var t;return!e.config.disable_product_tours&&!((t=e.persistence)==null||!t.get_property(xg))},FO=["$set_once","$set"],On=Ie("[SiteApps]"),N_="Error while initializing PostHog app with config id ",uS=(e,t)=>e!=null&&e.then?e.then(t):t(e),vs="SDK is not enabled or survey functionality is not yet loaded",$_="Disabled. Not loading surveys.";class LO{constructor(t,n){this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Tl=!1,this.Ml=[],this.El=null,this.Il=null,this.Xn=!1,this.Rl=new Set,this.onRemoteConfig=r=>{if(!this.Xn&&!this.qi.disableSurveys){if(!r.ok)return he.warn("Remote config unavailable. Not loading surveys.");var i=r.config.surveys;if(ne(i))return he.warn("Flags not loaded yet. Not loading surveys.");this.Pl=$t(i)?i:i.length>0,he.info("flags response received, isSurveysEnabled: "+this.Pl),this.loadIfEnabled()}},this.ts=t,this.Al=n}setup(t){if(!this.Xn)return this.Fl=t,uS(t.kv.initialize(),()=>{if(this.Fl===t&&!this.Xn){this.Fl=void 0,this.ns=t;var n=t.onRemoteConfig(this.onRemoteConfig);this.Xn?n.dispose():(this.ss=n,this.loadIfEnabled())}})}dispose(){var t,n,r;this.Xn||(this.Xn=!0,this.Fl=void 0,this.ns=void 0,(t=this.ss)==null||t.dispose(),this.ss=void 0,(n=this._surveyEventReceiver)==null||n.dispose(),this._surveyEventReceiver=null,(r=this._surveyManager)==null||r.dispose==null||r.dispose(),this._surveyManager=null,this.Ml=[],this.El=null,this.Rl.forEach(i=>clearTimeout(i)),this.Rl.clear())}get qi(){return this.ts.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;(t=this._surveyEventReceiver)==null||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var n=[],r=0;rlocalStorage.removeItem(s))}catch{}}loadIfEnabled(){if(!this.Xn&&this.ns){var t=this.qi;if(!this._surveyManager)if(this.Tl)he.info("Already initializing surveys, skipping...");else if(t.disableSurveys)he.info($_);else if(t.cookielessMode&&this.ts.isOptedOut())he.info("Not loading surveys in cookieless mode without consent.");else{var n=this.ts.getExtensions();if(n){if(!L(this.Pl)||t.advancedEnableSurveys){var r=this.Pl||t.advancedEnableSurveys;this.Tl=!0;try{var i=n.generateSurveys;if(i)return this.Ol(i,r),void(this.Tl=!1);var s=n.loadExternalDependency;if(!s)return this.Ll(Eg),void(this.Tl=!1);s(o=>{try{if(this.Xn)return;var a=this.ts.getExtensions();o||a==null||!a.generateSurveys?this.Ll("Could not load surveys script",o):this.Ol(a.generateSurveys,r)}finally{this.Tl=!1}})}catch(o){throw this.Tl=!1,this.Ll("Error initializing surveys",o),o}}}else he.error("PostHog Extensions not found.")}}}Ol(t,n){this.Xn||(this._surveyManager=t(n),this._surveyEventReceiver=this.ts.createEventReceiver(),he.info("Surveys loaded successfully"),this.$l({isLoaded:!0}))}Ll(t,n){he.error(t,n),this.$l({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ml.push(t),this._surveyManager&&this.$l({isLoaded:!0}),()=>{this.Ml=this.Ml.filter(n=>n!==t)}}getSurveys(t,n){var r;n===void 0&&(n=!1);var i=(r=this.ns)!==null&&r!==void 0?r:this.Al;if(i&&!this.Xn){if(this.qi.disableSurveys)return he.info($_),t([]);var s=i.kv.get(vp);if(s&&!n)return t(s,{isLoaded:!0}),void(this.Dl()&&this.getSurveys(()=>{},!0));if(this.El)this.El.then(l=>{this.Xn||t(l.surveys,l.context)}).catch(l=>he.error("Error in survey callback",l));else{var o=this.Nl("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.qi.requestTimeoutMs}).then(l=>{try{return this.ql(i,l)}catch(u){return he.error("Error processing surveys response",u),this.ql(i,{statusCode:0,error:u})}},l=>this.ql(i,{statusCode:0,error:l}));this.El=o;var a=()=>{this.El===o&&(this.El=null)};o.then(l=>{a(),this.Xn||t(l.surveys,l.context)},a).catch(l=>he.error("Error in survey callback",l))}}}Nl(t,n){var r=this.ns;return r?r.sendRequest(t,n):new Promise(i=>i({statusCode:0,error:new Error(vs)}))}ql(t,n){if(this.Xn)return{surveys:[],context:{isLoaded:!1,error:vs}};var r=n.statusCode;if(r!==200||!n.json){var i="Surveys API could not be loaded, status: "+r;return r!==0?he.error(i):n.error||he.warn(i),this.Il=Date.now(),{surveys:[],context:{isLoaded:!1,error:i}}}this.Il=null;var s,o=n.json.surveys||[],a=o.filter(l=>function(u){return!(!u.start_date||u.end_date)}(l)&&(rS(l)||function(u){var c;return!((c=u.conditions)==null||(c=c.actions)==null||(c=c.values)==null||!c.length)}(l)));return a.length>0&&((s=this._surveyEventReceiver)==null||s.register(a)),t.kv.set({[vp]:o,[bc]:Date.now()}),{surveys:o,context:{isLoaded:!0}}}Dl(){return this.jl()&&!this.El&&!this.Bl()}jl(){var t,n,r=(t=(n=this.ns)!==null&&n!==void 0?n:this.Al)==null?void 0:t.kv.get(bc);return Ge(r)&&Date.now()-r>3e5}Bl(){return Ge(this.Il)&&3e5>Date.now()-this.Il}markSurveyAsSeen(t,n){var r,i={id:t,current_iteration:(r=n==null?void 0:n.iteration)!==null&&r!==void 0?r:null};sS(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}}$l(t){for(var n of this.Ml)try{if(!t.isLoaded)return n([],t);this.getSurveys(n)}catch(r){he.error("Error in survey callback",r)}}getActiveMatchingSurveys(t,n){if(n===void 0&&(n=!1),!ne(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,n);he.warn("init was not called")}Hl(t){var n=null;return this.getSurveys(r=>{var i;n=(i=r.find(s=>s.id===t))!==null&&i!==void 0?i:null}),n}Ul(t){if(ne(this._surveyManager))return{eligible:!1,reason:vs};var n=typeof t=="string"?this.Hl(t):t;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}zl(t){if(ne(this._surveyManager))return{eligible:!1,reason:vs};var n=typeof t=="string"?this.Hl(t):t;return n?this._surveyManager.checkSurveyRenderability(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(ne(this._surveyManager))return he.warn("init was not called"),{visible:!1,disabledReason:vs};var n=this.zl(t);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(t,n){return ne(this._surveyManager)?(he.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:vs})):new Promise(r=>{this.getSurveys(i=>{var s,o=(s=i.find(l=>l.id===t))!==null&&s!==void 0?s:null;if(o){var a=this.zl(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})},n)})}renderSurvey(t,n,r){var i;if(ne(this._surveyManager))he.warn("init was not called");else{var s=typeof t=="string"?this.Hl(t):t;if(s!=null&&s.id)if(_O.includes(s.type)){var o=j==null?void 0:j.querySelector(n);if(o)if((i=s.appearance)!=null&&i.surveyPopupDelaySeconds){he.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds");var a=setTimeout(()=>{var l,u;this.Rl.delete(a),this.Xn||(he.info("Rendering survey "+s.id+" with delay of "+((l=s.appearance)==null?void 0:l.surveyPopupDelaySeconds)+" seconds"),(u=this._surveyManager)==null||u.renderSurvey(s,o,r),he.info("Survey "+s.id+" rendered"))},1e3*s.appearance.surveyPopupDelaySeconds);this.Rl.add(a)}else this._surveyManager.renderSurvey(s,o,r);else he.warn("Survey element not found")}else he.warn("Surveys of type "+s.type+" cannot be rendered in the app");else he.warn("Survey not found")}}displaySurvey(t,n){var r;if(ne(this._surveyManager))he.warn("init was not called");else{var i=this.Hl(t);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&n.ignoreDelay&&(s=$({},i,{appearance:$({},i.appearance,{surveyPopupDelaySeconds:0})})),n.displayType!==Pp.Popover&&n.initialResponses&&he.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),n.ignoreConditions===!1){var o=this.Ul(i);if(!o.eligible)return void he.warn("Survey is not eligible to be displayed: ",o.reason)}n.displayType!==Pp.Inline?this._surveyManager.handlePopoverSurvey(s,n):this.renderSurvey(s,n.selector,n.properties)}else he.warn("Survey not found")}}cancelPendingSurvey(t){ne(this._surveyManager)?he.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;(t=this._surveyManager)==null||t.handlePageUnload==null||t.handlePageUnload()}}function gs(e,t,n){if(ne(e))return!1;switch(n){case"exact":return e===t;case"contains":var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}class jO{constructor(t){this.Wl=new Set,this.Vl=new Set,this.Gl=new Ac,this.Zl=(n,r)=>this.Ql(n,r)&&this.Jl(n,r)&&this.Kl(n,r)&&this.Yl(n,r),this.Ql=(n,r)=>r==null||!r.event||(n==null?void 0:n.event)===(r==null?void 0:r.event),this._instance=t}init(){var t,n;L((t=this._instance)==null?void 0:t._addCaptureHook)||(this.Xl=(n=this._instance)==null?void 0:n._addCaptureHook((r,i)=>{this.on(r,i)}))}dispose(){var t;(t=this.Xl)==null||t.call(this),this.Xl=void 0,this.Gl=new Ac}register(t){var n,r;if(!L((n=this._instance)==null?void 0:n._addCaptureHook)&&(t.forEach(s=>{var o;this.Wl.add(s),(o=s.steps)==null||o.forEach(a=>{this.Vl.add((a==null?void 0:a.event)||"")})}),(r=this._instance)!=null&&r.autocapture)){var i=new Set;this.Wl.forEach(s=>{var o;(o=s.steps)==null||o.forEach(a=>{a!=null&&a.selector&&i.add(a.selector)})}),this._instance.autocapture.setElementSelectors(i)}}replace(t){this.Wl.clear(),this.Vl.clear(),this.register(t)}on(t,n){n!=null&&t.length!=0&&(this.Vl.has(t)||this.Vl.has(n.event))&&this.Wl.forEach(r=>{this.tu(n,r)&&this.Gl.emit("actionCaptured",r.name)})}eu(t){this.onAction("actionCaptured",n=>t(n))}tu(t,n){if((n==null?void 0:n.steps)==null)return!1;for(var r of n.steps)if(this.Zl(t,r))return!0;return!1}onAction(t,n){return this.Gl.on(t,n)}Jl(t,n){if(n!=null&&n.url){var r,i=t==null||(r=t.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!gs(i,n.url,n.url_matching||"contains"))return!1}return!0}Kl(t,n){return!!this.iu(t,n)&&!!this.ru(t,n)&&!!this.nu(t,n)}iu(t,n){var r;if(n==null||!n.href)return!0;var i=this.su(t);if(i.length>0)return i.some(a=>gs(a.href,n.href,n.href_matching||"exact"));var s,o=(t==null||(r=t.properties)==null?void 0:r.$elements_chain)||"";return!!o&&gs((s=o.match(/(?::|")href="(.*?)"/))?s[1]:"",n.href,n.href_matching||"exact")}ru(t,n){var r;if(n==null||!n.text)return!0;var i=this.su(t);if(i.length>0)return i.some(u=>gs(u.text,n.text,n.text_matching||"exact")||gs(u.$el_text,n.text,n.text_matching||"exact"));var s,o,a,l=(t==null||(r=t.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(s=function(u){for(var c,d=[],f=/(?::|")text="(.*?)"/g;!ne(c=f.exec(u));)d.includes(c[1])||d.push(c[1]);return d}(l),o=n.text,a=n.text_matching||"exact",s.some(u=>gs(u,o,a)))}nu(t,n){var r,i;if(n==null||!n.selector)return!0;var s=t==null||(r=t.properties)==null?void 0:r.$element_selectors;if(s!=null&&s.includes(n.selector))return!0;var o=(t==null||(i=t.properties)==null?void 0:i.$elements_chain)||"";if(n.selector_regex&&o)try{return new RegExp(n.selector_regex).test(o)}catch{return!1}return!1}su(t){var n;return(t==null||(n=t.properties)==null?void 0:n.$elements)==null?[]:t==null?void 0:t.properties.$elements}Yl(t,n){return n==null||!n.properties||n.properties.length===0||nS(n.properties.reduce((r,i)=>{var s=Z(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return r[i.key]={values:s,operator:i.operator||"exact"},r},{}),t==null?void 0:t.properties)}}class DO{constructor(t){var n;this.au=[],this._instance=t,this.ou=new Map,this.lu=new Map,this.uu=new Map,this.hu=(n=this._instance)==null||n.onSessionId==null?void 0:n.onSessionId(r=>this.du(r))}vu(t){return!1}cu(){return null}fu(t){}pu(){}gu(t,n){return!!t&&nS(t.propertyFilters,n==null?void 0:n.properties)}mu(t,n){var r=new Map;return t.forEach(i=>{var s;(s=i.conditions)==null||(s=s[n])==null||(s=s.values)==null||s.forEach(o=>{if(o!=null&&o.name){var a=r.get(o.name)||[];a.push(i.id),r.set(o.name,a)}})}),r}yu(t,n,r){var i=(r===Xo.Activation?this.ou:this.lu).get(t),s=[];return this.bu(o=>{s=o.filter(a=>i==null?void 0:i.includes(a.id))}),s.filter(o=>{var a,l=(a=o.conditions)==null||(a=a[r])==null||(a=a.values)==null?void 0:a.find(u=>u.name===t);return this.gu(l,n)})}register(t){this._u(t,!1)}replace(t){this._u(t,!0)}_u(t,n){var r;L((r=this._instance)==null?void 0:r._addCaptureHook)||(this.wu(t,n),this.ku(t,n))}ku(t,n){var r=t.filter(o=>{var a;return(a=o.conditions)==null||(a=a.actions)==null||(a=a.values)==null?void 0:a.length});if(n&&this.uu.clear(),r.length!==0){this.Su||(this.Su=new jO(this._instance),this.Su.init(),this.Su.eu(o=>this.onAction(o)));var i=[];r.forEach(o=>{var a;(a=o.conditions)==null||(a=a.actions)==null||a.values.forEach(l=>{if(i.push(l),l.name){var u,c=(u=this.uu.get(l.name))!==null&&u!==void 0?u:[];c.includes(o.id)||c.push(o.id),this.uu.set(l.name,c)}})}),n?this.Su.replace(i):this.Su.register(i)}else{var s;n&&((s=this.Su)==null||s.replace([]))}}xu(t,n){n.forEach((r,i)=>{var s,o=(s=t.get(i))!==null&&s!==void 0?s:[];r.forEach(a=>{o.includes(a)||o.push(a)}),t.set(i,o)})}wu(t,n){var r,i,s=t.filter(u=>{var c,d;return((c=u.conditions)==null?void 0:c.events)&&((d=u.conditions)==null||(d=d.events)==null||(d=d.values)==null?void 0:d.length)>0}),o=t.filter(u=>{var c,d;return((c=u.conditions)==null?void 0:c.cancelEvents)&&((d=u.conditions)==null||(d=d.cancelEvents)==null||(d=d.values)==null?void 0:d.length)>0}),a=this.mu(t,Xo.Activation),l=this.mu(t,Xo.Cancellation);n?(this.ou=a,this.lu=l):(this.xu(this.ou,a),this.xu(this.lu,l)),(s.length!==0||o.length!==0)&&((r=this.Xl)!==null&&r!==void 0||(this.Xl=(i=this._instance)==null?void 0:i._addCaptureHook((u,c)=>{this.onEvent(u,c)})))}onEvent(t,n){var r,i,s=this.Cu(),o=(n==null||(r=n.properties)==null?void 0:r.$survey_id)||(n==null||(i=n.properties)==null?void 0:i.$product_tour_id);if(o&&this.getActivatedIds().includes(o)){var a=this.Tu(t,o);if(a==="consume")return s.info("event consumed activated item, removing it",{event:t,itemId:o}),void this.Mu([o]);if(a==="persist")return s.info("shown item promoted to persisted activation",{event:t,itemId:o}),this.Eu(o),void this.Iu([o])}if(this.lu.has(t)){var l=this.yu(t,n,Xo.Cancellation);l.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:l.map(c=>c.id)}),this.Mu(l.map(c=>c.id)),l.forEach(c=>this.Ru(c.id)))}if(this.ou.has(t)){s.info("event name matched",{event:t,eventPayload:n,items:this.ou.get(t)});var u=this.yu(t,n,Xo.Activation);this.Pu(u.map(c=>c.id))}}onAction(t){this.uu.has(t)&&this.Pu(this.uu.get(t)||[])}Pu(t){var n;if(t.length!==0){var r=!((n=this._instance)==null||n.get_session_id==null||!n.get_session_id()),i=[];for(var s of t)r&&this.vu(s)?this.Eu(s)&&this.Au(s):i.push(s);i.length>0&&(this.au=[...new Set([...this.au,...i])]),this.Cu().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Eu(t){this.au=this.au.filter(r=>r!==t);var n=this.Fu();return!n.includes(t)&&(this.Ou([...n,t]),this.Lu(),!0)}Mu(t){var n=new Set(t);this.au=this.au.filter(s=>!n.has(s));var r=this.$u(),i=r.filter(s=>!n.has(s));i.length!==r.length&&(this.Ou(i),i.length===0&&this.Du()),this.Iu(t)}Nu(){var t,n=this.cu();if(!n)return{};var r=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n];return r&&typeof r=="object"?r:{}}Au(t){if(this.cu()){var n=this.Nu();this.fu($({},n,{[t]:Date.now()}))}}Iu(t){if(this.cu()){var n=this.Nu(),r={},i=!1;for(var s of Object.entries(n)){var o=s[0],a=s[1];t.includes(o)?i=!0:r[o]=a}i&&(En(r)?this.pu():this.fu(r))}}qu(){this.cu()&&this.pu()}getActivationTimestamp(t){if(this.Fu().includes(t)){var n=this.Nu()[t];return Ge(n)?n:void 0}}$u(){var t,n=this.ju();return((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n])||[]}Fu(){var t,n,r=this.$u();if(r.length===0)return[];var i=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.Bu()],s=(n=this._instance)==null||n.get_session_id==null?void 0:n.get_session_id();return s&&i===s?r:[]}Lu(){var t,n=(t=this._instance)==null||t.get_session_id==null?void 0:t.get_session_id();n&&this.Hu(n)}Du(){this.Uu()}du(t){var n,r=(n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[this.Bu()];if(r&&r!==t){var i=this.$u(),s=this.Nu();i.length>0&&(this.Ou([]),i.filter(o=>Ge(s[o])).forEach(o=>this.Ru(o))),this.Du(),this.qu()}}getActivatedIds(){return[...new Set([...this.Fu(),...this.au])].filter(t=>!this.zu(t))}dispose(){var t,n,r;(t=this.hu)==null||t.call(this),this.hu=void 0,(n=this.Xl)==null||n.call(this),this.Xl=void 0,(r=this.Su)==null||r.dispose(),this.Su=void 0}reset(){this.au=[],this.$u().length>0&&this.Ou([]),this.Du(),this.qu()}getEventToItemsMap(){return this.ou}Wu(){return this.Su}}class zO extends DO{constructor(t){super(t)}ju(){return gp}Bu(){return Ru}cu(){return Tu}fu(t){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Tu]:t})}pu(){var t;(t=this._instance)==null||(t=t.persistence)==null||t.unregister(Tu)}vu(t){var n,r;this.bu(s=>{r=s.find(o=>o.id===t)});var i=(n=r)==null||(n=n.appearance)==null?void 0:n.surveyPopupDelaySeconds;return Ge(i)&&i>0}Vu(){return ur.SHOWN}bu(t){var n;(n=this._instance)==null||n.getSurveys(t)}Ru(t){var n;(n=this._instance)==null||n.cancelPendingSurvey(t)}Cu(){return he}Ou(t){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[gp]:t})}Hu(t){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Ru]:t})}Uu(){var t;(t=this._instance)==null||(t=t.persistence)==null||t.unregister(Ru)}zu(){return!1}Tu(t,n){var r;this.bu(s=>{r=s.find(o=>o.id===n)});var i=!r||function(s){var o;return rS(s)&&!((o=s.conditions)==null||(o=o.events)==null||!o.repeatedActivation)||s.schedule==="always"}(r);return i?t===ur.SHOWN?"consume":"ignore":t===ur.SHOWN?"persist":t===ur.DISMISSED||t===ur.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class UO{constructor(t){this._instance=t}initialize(){}get(t){if(typeof t=="string")return this._instance.get_property(t);var n={};for(var r of t){var i=this._instance.get_property(r);L(i)||(n[r]=i)}return n}set(t,n){this._instance.register(typeof t=="string"?{[t]:n}:t)}remove(t){typeof t!="string"?t.forEach(n=>this._instance.unregister(n)):this._instance.unregister(t)}}class VO{constructor(t){this._instance=t}get(){var t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}getExtensions(){var t=Y==null?void 0:Y.__PosthogExtensions__;if(t){var n=t.generateSurveys,r=t.loadExternalDependency;return{generateSurveys:n?i=>n(this._instance,i):void 0,loadExternalDependency:r?i=>r(this._instance,"surveys",i):void 0}}}createEventReceiver(){return new zO(this._instance)}}var BO=I!=null&&I.location?Ic(I.location.hash,"__posthog")||Ic(location.hash,"state"):null,F_="_postHogToolbarParams",L_=Ie("[Toolbar]"),j_=Ie("[FeatureFlags]");class qO{constructor(t,n){n===void 0&&(n=!1),this.Gu=!1,this.update(t,n)}update(t,n){this.Zu=((r,i)=>{var s,o,a,l;return{bootstrap:{featureFlags:(s=r.bootstrap)==null?void 0:s.featureFlags,featureFlagPayloads:(o=r.bootstrap)==null?void 0:o.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!r.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!r.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!r.advanced_feature_flags_dedup_per_session,cacheTtlMs:r.feature_flag_cache_ttl_ms,requestTimeoutMs:r.feature_flag_request_timeout_ms,compression:r.disable_compression?"none":"base64",evaluationContexts:(a=(l=r.evaluation_contexts)!==null&&l!==void 0?l:r.evaluation_environments)!==null&&a!==void 0?a:[],flagKeys:Z(r.flag_keys)?r.flag_keys:void 0}})(t,n),!t.evaluation_environments||t.evaluation_contexts||this.Gu||(j_.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Gu=!0),L(t.flag_keys)||Z(t.flag_keys)||j_.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Zu}}var D_=Ie("[FeatureFlags]"),_i=Ie("[FeatureFlags]",{debugEnabled:!0}),Lf=`" failed. Feature flags didn't load in time.`,z_="connection_error",U_=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},V_=e=>{var t={};for(var n of Iu(e||{})){var r=n[1];r&&(t[n[0]]=r)}return t},gn=Ie("[Error tracking]"),WO=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:"],HO=["__firefox__","__gCrWeb"],B_="Refusing to render web experiment since the viewer is a likely bot",GO={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>Nc(t,e),not_regex:(e,t)=>!Nc(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e};class ht{get qi(){return this._instance.config}constructor(t){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments(i=>{ht.Qu("retrieved web experiments from the server"),n.Ju=new Map,i.forEach(s=>{if(s.feature_flag_key){var o;n.Ju&&(ht.Qu("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=n.Ju)==null||o.set(s.feature_flag_key,s));var a=n._instance.getFeatureFlag(s.feature_flag_key);ce(a)&&s.variants[a]&&n.Ku(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var u=s.variants[l];ht.Yu(u,n._instance)&&n.Ku(s.name,l,u.transforms)}})},r)},this._instance=t,this._instance.onFeatureFlags(r=>{this.onFeatureFlags(r)})}initialize(){}onFeatureFlags(t){if(this._is_bot())ht.Qu(B_);else if(!this.qi.disable_web_experiments){if(ne(this.Ju))return this.Ju=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ht.Qu("applying feature flags",t),t.forEach(n=>{var r;if(this.Ju&&(r=this.Ju)!=null&&r.has(n)){var i,s=this._instance.getFeatureFlag(n),o=(i=this.Ju)==null?void 0:i.get(n);s&&o!=null&&o.variants[s]&&this.Ku(o.name,s,o.variants[s].transforms)}})}}previewWebExperiment(){var t=ht.getWindowLocation();if(t!=null&&t.search){var n=So(t==null?void 0:t.search,"__experiment_id"),r=So(t==null?void 0:t.search,"__experiment_variant");n&&r&&(ht.Qu("previewing web experiments "+n+" && "+r),this.getWebExperiments(i=>{this.Xu(parseInt(n),r,i)},!1,!0))}}loadIfEnabled(){this.qi.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,n,r){if(this.qi.disable_web_experiments&&!r)return t([]);var i=this._instance.get_property("$web_experiments");if(i&&!n)return t(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.qi.token),method:"GET",timestampMode:"query",callback:s=>t(s.statusCode===200&&s.json&&s.json.experiments||[])})}Xu(t,n,r){var i=r.filter(s=>s.id===t);i&&i.length>0&&(ht.Qu("Previewing web experiment ["+i[0].name+"] with variant ["+n+"]"),this.Ku(i[0].name,n,i[0].variants[n].transforms))}static Yu(t,n){return!ne(t.conditions)&&ht.th(t,n)&&ht.eh(t)}static th(t,n){var r;if(ne(t.conditions)||ne((r=t.conditions)==null?void 0:r.url))return!0;var i=ht.getWindowLocation();if(i){var s,o,a,l=yE(n,i.href);return(s=t.conditions)==null||!s.url||GO[(o=(a=t.conditions)==null?void 0:a.urlMatchType)!==null&&o!==void 0?o:"icontains"](t.conditions.url,l)}return!1}static getWindowLocation(){return I==null?void 0:I.location}static eh(t){var n;if(ne(t.conditions)||ne((n=t.conditions)==null?void 0:n.utm))return!0;var r=NE();if(r.utm_source){var i,s,o,a,l,u,c,d,f=(i=t.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((s=t.conditions)==null||(s=s.utm)==null?void 0:s.utm_campaign)==r.utm_campaign,m=(o=t.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=t.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==r.utm_source,_=(l=t.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=t.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==r.utm_medium,p=(c=t.conditions)==null||(c=c.utm)==null||!c.utm_term||((d=t.conditions)==null||(d=d.utm)==null?void 0:d.utm_term)==r.utm_term;return f&&_&&p&&m}return!1}static Qu(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;n>i;i++)r[i-1]=arguments[i];D.info("[WebExperiments] "+t,r)}Ku(t,n,r){this._is_bot()?ht.Qu(B_):n!=="control"?r.forEach(i=>{if(i.selector){var s;ht.Qu("applying transform of variant "+n+" for experiment "+t+" ",i);var o=(s=document)==null?void 0:s.querySelectorAll(i.selector);o==null||o.forEach(a=>{var l=a;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)})}}):ht.Qu("Control variants leave the page unmodified.")}_is_bot(){return St&&this._instance?ZE(St,this.qi.custom_blocked_useragents):void 0}}var tn=Ie("[Conversations]"),wi="Conversations not available yet.",q_="console",cS="__posthogHandledLogsRequestError",jf=(e,t)=>{var n=e instanceof Error?e:new Error(t);return n[cS]=!0,n},W_=e=>!!e&&typeof e=="object"&&e[cS]===!0,hd={featureFlags:class{constructor(e){this.name="featureFlags",this.ih=!1,this.featureFlagEventHandlers=[],this.I=D_,this.rh={},this.nh={},this.sh=[],this.ah=!1,this.oh=!1,this.lh=0,this.uh=!1,this.hh=!1,this.dh=!1,this.fh=!1,this.ph=0,this.Tt=()=>{var t=this.gh();this.ph=0,t&&this.reloadFeatureFlags()},"get"in e?this.ts=e:(this.mh=new qO(e.config,e.ma()),this.ts=this.mh)}updateConfig(e,t){var n;(n=this.mh)==null||n.update(e,t)}setup(e){return this.Fl=e,this.I=e.logger.createLogger("[FeatureFlags]"),uS(e.kv.initialize(),()=>{this.Fl===e&&(this.Fl=void 0,this.ns=e,this.yh(e))})}yh(e){if(this.ns===e)return I&&Re(I,"online",this.Tt),this.bh=e.registerDynamicEventProperties(()=>this._h()?this.rh:this.nh),this.wh(),this.initialize()}destroy(){I==null||I.removeEventListener("online",this.Tt)}dispose(){var e;this.lh++,this.hh=!1,this.Fl=void 0,this.ns&&(this.kh(),(e=this.bh)==null||e.dispose(),this.bh=void 0,this.sh=[],I==null||I.removeEventListener("online",this.Tt),this.ns=void 0)}get qi(){return this.ts.get()}Sh(e){var t;return(t=this.ns)==null?void 0:t.kv.get(e)}Nr(e){this.xh(()=>{var t;return(t=this.ns)==null?void 0:t.kv.set(e)})}qr(e){this.xh(()=>{var t;return(t=this.ns)==null?void 0:t.kv.remove(e)})}xh(e){try{e()}catch(t){this.I.error("Failed to update feature flag persistence",t)}}wh(){var e={};for(var t of[Mi,Ai,Gs,Mn]){var n=this.Sh(t);L(n)||(e[t]=n)}this.rh=e;var r=$({},e),i=this.Sh(ir);if(i)for(var s of Object.entries(i))r["$feature/"+s[0]]=s[1];this.nh=r}_h(){var e=this.qi.cacheTtlMs;if(!e||0>=e)return!1;var t=this.Sh(Gi);return typeof t!="number"||Date.now()-t>e}Ch(){return!!this._h()&&(this.fh||this.oh||(this.fh=!0,this.I.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Th(){var e=this.qi.evaluationContexts;return e!=null&&e.length?e.filter(t=>{var n=t&&typeof t=="string"&&t.trim().length>0;return n||this.I.error("Invalid evaluation context found:",t,"Expected non-empty string"),n}):[]}Mh(){var e=this.qi.flagKeys;if(!L(e))return e.filter(t=>{var n=t&&typeof t=="string"&&t.trim().length>0;return n||this.I.error("Invalid flag key found:",t,"Expected non-empty string"),n})}initialize(){var e,t,n=this.qi,r=(e=(t=n.bootstrap)==null?void 0:t.featureFlags)!==null&&e!==void 0?e:{};if(Object.keys(r).length){var i,s,o=(i=(s=n.bootstrap)==null?void 0:s.featureFlagPayloads)!==null&&i!==void 0?i:{},a=Object.keys(r).filter(u=>!!r[u]).reduce((u,c)=>(u[c]=r[c]||!1,u),{}),l=Object.keys(o).filter(u=>a[u]).reduce((u,c)=>(u[c]=o[c],u),{});return this.Eh({featureFlags:a,featureFlagPayloads:l})}}updateFlags(e,t,n){var r,i,s=n!=null&&n.merge&&(r=this.Sh(ir))!==null&&r!==void 0?r:{},o=n!=null&&n.merge&&(i=this.Sh(Ai))!==null&&i!==void 0?i:{},a=$({},s,e),l=$({},o,t),u={};for(var c of Object.entries(a)){var d=c[0],f=c[1];u[d]={key:d,enabled:Ay(f),variant:Ny(f),reason:void 0,metadata:L(l==null?void 0:l[d])?void 0:{id:0,version:void 0,description:void 0,payload:l[d]}}}this.Eh({flags:u})}get hasLoadedFlags(){return this.ah}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.Sh(Xa),t=this.Sh(Mn),n=this.Sh(Ci);if(!n&&!t)return e||{};var r=_e({},e||{}),i=[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])];for(var s of i){var o,a,l=r[s],u=t==null?void 0:t[s],c=L(u)?(o=l==null?void 0:l.enabled)!==null&&o!==void 0&&o:!!u,d=L(u)?l==null?void 0:l.variant:typeof u=="string"?u:void 0,f=n==null?void 0:n[s],m=$({},l,{enabled:c,variant:c?d??(l==null?void 0:l.variant):void 0});c!==(l==null?void 0:l.enabled)&&(m.original_enabled=l==null?void 0:l.enabled),d!==(l==null?void 0:l.variant)&&(m.original_variant=l==null?void 0:l.variant),f&&(m.metadata=$({},l==null?void 0:l.metadata,{payload:f,original_payload:l==null||(a=l.metadata)==null?void 0:a.payload})),r[s]=m}return this.ih||(this.I.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:n,finalDetails:r}),this.ih=!0),r}getAllFeatureFlags(){var e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(n=>{var r=e[n];return{key:n,enabled:Ay(r),variant:Ny(r),payload:My(t[n])}})}getFlagVariants(){var e=this.Sh(ir),t=this.Sh(Mn);if(!t)return e||{};for(var n=_e({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.ih||(this.I.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:n}),this.ih=!0),n}getFlagPayloads(){var e=this.Sh(Ai),t=this.Sh(Ci);if(!t)return e||{};for(var n=_e({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.ih||(this.I.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),this.ih=!0),n}reloadFeatureFlags(){this.uh||this.qi.featureFlagsDisabled||this.gh()||this.Ih||(this.sh.slice().forEach(e=>{try{e()}catch(t){this.I.error("Error while running feature flags reloading callback",t)}}),this.Ih=setTimeout(()=>{this.Rh()},5))}kh(){clearTimeout(this.Ih),this.Ih=void 0}onReloading(e){return this.sh.push(e),()=>{this.sh=this.sh.filter(t=>t!==e)}}ensureFlagsLoaded(){this.ah||this.oh||this.Ih||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.uh=e}resetFlagCallReported(){this.qr(ar)}Rh(e){this.kh();var t=this.ns;if(t&&!this.qi.remoteRequestsDisabled&&!this.gh())if(this.oh)this.hh=!0;else{var n={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:$({},t.initialPersonProperties,this.Sh(yn)||{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this.Sh(Dn),timezone:zE()};L(t.deviceId)||(n.$device_id=t.deviceId),(e!=null&&e.disableFlags||this.qi.featureFlagsDisabled)&&(n.disable_flags=!0);var r=this.Th();r.length&&(n.evaluation_contexts=r);var i=this.Mh();L(i)||(n.flag_keys=i);var s=this.qi.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(s?"&only_evaluate_survey_feature_flags=true":""),a=this.lh;this.oh=!0;var l=()=>{this.hh&&(this.hh=!1,this.Rh())},u=c=>{this.oh=!1,a===this.lh&&(this.Nr({[Ks]:[z_]}),this.I.error("Feature flag request failed",c)),l()};try{t.sendRequest(o,{target:"flags",method:"POST",body:n,compression:this.qi.compression==="base64"?Et.Base64:void 0,sentAt:"body",timeoutMs:this.qi.requestTimeoutMs}).then(c=>{var d,f,m=(d=c.json)!==null&&d!==void 0?d:{},_=c.statusCode!==200;if(this.oh=!1,a===this.lh){if(this.Ph(c.statusCode),_||this.hh||(this.$anon_distinct_id=void 0),!n.disable_flags||this.hh){this.dh=!_;var p=[];c.error?p.push(c.error instanceof Error&&c.error.name==="AbortError"?"timeout":c.error instanceof Error?z_:"unknown_error"):c.statusCode!==200&&p.push("api_error_"+c.statusCode),m.errorsWhileComputingFlags&&p.push("errors_while_computing_flags");var y=!((f=m.quotaLimited)==null||!f.includes("feature_flags"));y&&p.push("quota_limited"),this.Nr({[Ks]:p}),y?this.I.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):n.disable_flags||this.Eh(m,_,{partialResponse:s}),l()}}else l()}).catch(u)}catch(c){u(c)}}}gh(){return ME(this.ph,3)}Ph(e){this.ph=AE(e,this.ph,3,()=>this.I.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t){var n;if(t===void 0&&(t={}),!t.fresh||this.dh)if(this.ah||this.getFlags()&&this.getFlags().length>0){if(!this.Ch()){var r=this.getFeatureFlagResult(e,t);return(n=r==null?void 0:r.variant)!==null&&n!==void 0?n:r==null?void 0:r.enabled}}else this.I.warn('getFeatureFlag for key "'+e+Lf)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t==null?void 0:t.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.dh)if(this.ah||this.getFlags()&&this.getFlags().length>0){if(!this.Ch()){var n,r=this.getFlagVariants(),i=e in r,s=r[e],o=this.getFlagPayloads()[e],a=String(s),l=this.Sh(Gs)||void 0,u=this.Sh(Gi)||void 0,c=this.Sh(ar)||{};if(this.qi.deduplicateCallsPerSession){var d,f=(d=this.ns)==null?void 0:d.session.sessionId,m=this.Sh(fa);f&&f!==m&&(c={},n=f)}if(t.send_event||!("send_event"in t))if(e in c&&c[e].includes(a))n&&this.Nr({[ar]:c,[fa]:n});else{var _,p,y,h,v,x,b,E,S,P,C,T;Z(c[e])?c[e].push(a):c[e]=[a],this.Nr($({[ar]:c},n?{[fa]:n}:{}));var R=this.getFeatureFlagDetails(e),N=[...(_=this.Sh(Ks))!==null&&_!==void 0?_:[]];L(s)&&N.push("flag_missing");var M={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:o??null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:(p=(y=this.qi.bootstrap)==null||(y=y.featureFlags)==null?void 0:y[e])!==null&&p!==void 0?p:null,$feature_flag_bootstrapped_payload:(h=(v=this.qi.bootstrap)==null||(v=v.featureFlagPayloads)==null?void 0:v[e])!==null&&h!==void 0?h:null,$used_bootstrap_value:!this.dh};L(R==null||(x=R.metadata)==null?void 0:x.has_experiment)||(M.$feature_flag_has_experiment=R.metadata.has_experiment),L(R==null||(b=R.metadata)==null?void 0:b.version)||(M.$feature_flag_version=R.metadata.version);var z,F=(E=R==null||(S=R.reason)==null?void 0:S.description)!==null&&E!==void 0?E:R==null||(P=R.reason)==null?void 0:P.code;F&&(M.$feature_flag_reason=F),R!=null&&(C=R.metadata)!=null&&C.id&&(M.$feature_flag_id=R.metadata.id),L(R==null?void 0:R.original_variant)&&L(R==null?void 0:R.original_enabled)||(M.$feature_flag_original_response=L(R.original_variant)?R.original_enabled:R.original_variant),R!=null&&(T=R.metadata)!=null&&T.original_payload&&(M.$feature_flag_original_payload=R==null||(z=R.metadata)==null?void 0:z.original_payload),N.length&&(M.$feature_flag_error=N.join(",")),this.Ah(M)}else n&&this.Nr({[ar]:c,[fa]:n});if(i)return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:My(o)}}}else this.I.warn('getFeatureFlagResult for key "'+e+Lf)}Ah(e){try{var t;(t=this.ns)==null||t.capture("$feature_flag_called",e).catch(n=>{this.I.error("Failed to capture feature flag call",n)})}catch(n){this.I.error("Failed to capture feature flag call",n)}}getRemoteConfigPayload(e,t){this.Fh(e,t)}Fh(e,t){var n=this;return Ce(function*(){var r=n.ns;if(r){var i={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},s=n.Th();s.length&&(i.evaluation_contexts=s);var o,a=n.Mh();L(a)||(i.flag_keys=a);try{var l,u=(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:i,compression:n.qi.compression==="base64"?Et.Base64:void 0,sentAt:"body",timeoutMs:n.qi.requestTimeoutMs})).json)==null?void 0:l.featureFlagPayloads;o=(u==null?void 0:u[e])||void 0}catch(c){return void n.I.error("Remote config feature flag request failed",c)}try{t(o)}catch(c){n.I.error("Remote config feature flag callback failed",c)}}})()}isFeatureEnabled(e,t){if(t===void 0&&(t={}),t.fresh&&!this.dh)return t.defaultValue;if(!(this.ah||this.getFlags()&&this.getFlags().length>0))return this.I.warn('isFeatureEnabled for key "'+e+Lf),t.defaultValue;var n=this.getFeatureFlag(e,t);return L(n)?t.defaultValue:!!n}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,n){this.Eh(e,t,n)}Eh(e,t,n){if(this.ns){this.ah=!0;var r=function(i,s,o,a,l,u){s===void 0&&(s={}),o===void 0&&(o={}),a===void 0&&(a={}),u===void 0&&(u=D_);var c=((S,P)=>{var C=S.flags;return C?$({},S,{featureFlags:Object.fromEntries(Object.keys(C).map(T=>{var R;return[T,(R=C[T].variant)!==null&&R!==void 0?R:C[T].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(C).filter(T=>C[T].enabled).filter(T=>{var R;return(R=C[T].metadata)==null?void 0:R.payload}).map(T=>{var R;return[T,(R=C[T].metadata)==null?void 0:R.payload]}))}):(S.featureFlags&&P.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),S)})(i,u),d=c.flags,f=c.featureFlags,m=c.featureFlagPayloads;if(f){var _=i.requestId,p=i.evaluatedAt;if(Z(f)){u.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var y={};if(f)for(var h=0;f.length>h;h++)y[f[h]]=!0;return{[Mi]:f,[ir]:y,[xc]:!1}}var v=f,x=m,b=d;if(l!=null&&l.partialResponse)v=$({},s,v),x=$({},o,x),b=$({},a,b);else if(i.errorsWhileComputingFlags)if(d){var E=new Set(Object.keys(d).filter(S=>{var P;return!((P=d[S])!=null&&P.failed)}));v=$({},s,Object.fromEntries(Object.entries(v).filter(S=>E.has(S[0])))),x=$({},o,Object.fromEntries(Object.entries(x||{}).filter(S=>E.has(S[0])))),b=$({},a,Object.fromEntries(Object.entries(b||{}).filter(S=>E.has(S[0]))))}else v=$({},s,v),x=$({},o,x),b=$({},a,b);return $({[Mi]:Object.keys(V_(v)),[ir]:v||{},[Ai]:x||{},[Xa]:b||{},[xc]:i.minimalFlagCalledEvents===!0},_?{[Gs]:_}:{},p?{[Gi]:p}:{})}}(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),n,this.I);r&&this.Nr(r),t||(this.fh=!1),this.Oh(t)}}override(e,t){t===void 0&&(t=!1),this.I.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.Lh(e)}Lh(e){if(this.ns){if(e===!1)return this.qr([Mn,Ci]),this.Oh(),void _i.info("All overrides cleared");if(Z(e))return this.Nr({[Mn]:U_(e)}),this.Oh(),void _i.info("Flag overrides set",{flags:e});if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,n=e;this.ih=!!((t=n.suppressWarning)!==null&&t!==void 0&&t);var r={},i=n.flags,s=n.payloads;return i&&(r[Mn]=Z(i)?U_(i):i),s&&(r[Ci]=s),Object.keys(r).length&&this.Nr(r),i===!1&&s===!1?this.qr([Mn,Ci]):i===!1?this.qr(Mn):s===!1&&this.qr(Ci),this.Oh(),i===!1?_i.info("Flag overrides cleared"):i&&_i.info("Flag overrides set",{flags:i}),void(s===!1?_i.info("Payload overrides cleared"):s&&_i.info("Payload overrides set",{payloads:s}))}if(e&&typeof e=="object")return this.Nr({[Mn]:e}),this.Oh(),void _i.info("Flag overrides set",{flags:e});this.I.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.I.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ah){var t=this.$h(),n=t.flags,r=t.flagVariants;try{e(n,r)}catch(i){this.I.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r=(this.Sh(Pu)||[]).find(l=>l.flagKey===e),i={["$feature_enrollment/"+e]:t},s={$feature_flag:e,$feature_enrollment:t,$set:i};r&&(s.$early_access_feature_name=r.name),n&&(s.$feature_enrollment_stage=n);var o=$({},this.getFlagVariants(),{[e]:t});this.Nr({[Mi]:Object.keys(V_(o)),[ir]:o,[yn]:$({},this.Sh(yn)||{},i)}),this.Oh();try{var a;(a=this.ns)==null||a.capture("$feature_enrollment_update",s).catch(l=>{this.I.error("Failed to capture early access feature enrollment",l)})}catch(l){this.I.error("Failed to capture early access feature enrollment",l)}}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var r=this.Sh(Pu);!r||t?this.Dh(e,n):e(r)}Dh(e,t){var n=this;return Ce(function*(){var r=n.ns;if(r){var i,s=t?"&"+t.map(a=>"stage="+a).join("&"):"";try{var o=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+s,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;n.Nr({[Pu]:i=o.json.earlyAccessFeatures})}catch(a){return void n.I.error("Early access feature request failed",a)}try{e(i)}catch(a){n.I.error("Early access feature callback failed",a)}}})()}$h(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(n=>t[n]),flagVariants:Object.keys(t).filter(n=>t[n]).reduce((n,r)=>(n[r]=t[r],n),{})}}Oh(e){this.wh();var t=this.$h(),n=t.flags,r=t.flagVariants;this.featureFlagEventHandlers.forEach(i=>{try{i(n,r,{errorsLoading:e})}catch(s){this.I.error("Error while running feature flags callback",s)}})}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.Nh(e,t)}Nh(e,t){t===void 0&&(t=!0);var n=this.Sh(yn)||{},r=(e==null?void 0:e.$set)||(e!=null&&e.$set_once?{}:e),i=e==null?void 0:e.$set_once,s={};if(i)for(var o in i)({}).hasOwnProperty.call(i,o)&&(o in n||(s[o]=i[o]));this.Nr({[yn]:$({},n,s,r)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=$({},this.Sh(yn)||{});e.forEach(r=>{delete n[r]}),this.Nr({[yn]:n}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){e===void 0&&(e=!0),this.qr(yn),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Sh(Dn)||{},r=$({},n);for(var i of Object.keys(e))r[i]=$({},n[i],e[i]);this.Nr({[Dn]:r}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.Sh(Dn)||{};this.Nr({[Dn]:$({},t,{[e]:{}})})}else this.qr(Dn)}reset(){this.lh++,this.hh=!1,this.rh={},this.nh={},this.ah=!1,this.uh=!1,this.dh=!1,this.$anon_distinct_id=void 0,this.kh(),this.ih=!1,this.ph=0}}},KO={sessionRecording:class{get qi(){return this._instance.config}get za(){return this._instance.persistence}get started(){var e;return!((e=this.qh)==null||!e.isStarted)}get status(){var e,t;return this.jh===na||this.jh===ru?this.jh:(e=(t=this.qh)==null?void 0:t.status)!==null&&e!==void 0?e:this.jh}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.jh=M_,this.Bh=void 0,this.Hh=!1,this.kt=(()=>{var t;if(j==null||!j.visibilityState||j.visibilityState==="visible")return!0;var n=I==null||(t=I.performance)==null||t.getEntriesByType==null?void 0:t.getEntriesByType("visibility-state");return!(n!=null&&n.length)||n.some(r=>r.name==="visible")})(),this.It=()=>{var t;(j==null?void 0:j.visibilityState)==="visible"&&(this.kt=!0,(t=this.qh)==null||t.setDocumentWasEverVisible==null||t.setDocumentWasEverVisible(!0))},this._instance=e,!this._instance.sessionManager)throw Yn.error("started without valid sessionManager"),new Error(Np+" started without valid sessionManager. This is a bug.");if(this.qi.cookieless_mode===lr)throw new Error(Np+' cannot be used with cookieless_mode="always"');j!=null&&j.addEventListener&&Re(j,"visibilitychange",this.It)}initialize(){this.startIfEnabledOrStop()}dispose(){this.Hh=!0,j==null||j.removeEventListener==null||j.removeEventListener("visibilitychange",this.It),this.stopRecording()}get Uh(){var e,t=!((e=this._instance.get_property(Oi))==null||!e.enabled),n=!this.qi.disable_session_recording,r=this.qi.disable_session_recording||this._instance.consent.isOptedOut();return I&&t&&n&&!r}startIfEnabledOrStop(e){var t;if(!(this.Hh||this.Uh&&(t=this.qh)!=null&&t.isStarted)){var n=!L(Object.assign)&&!L(Array.from);this.Uh&&n?(this.zh(e),Yn.info("starting")):(this.jh=M_,this.stopRecording())}}zh(e){var t,n,r;this.Uh&&(this.jh!==na&&this.jh!==ru&&(this.jh=A_),Y!=null&&(t=Y.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=Y.__PosthogExtensions__)!=null&&n.initSessionRecording?this.Wh(e):(r=Y.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.Vh,i=>{if(i)return this._instance.register_for_session({[xp]:!0}),Yn.error("could not load recorder",i);this.Wh(e)}))}stopRecording(){var e,t;(e=this.Bh)==null||e.call(this),this.Bh=void 0,(t=this.qh)==null||t.stop()}Gh(){var e,t;(e=this.Bh)==null||e.call(this),this.Bh=void 0,(t=this.qh)==null||t.discard()}Zh(){var e,t;(e=this.za)==null||e.unregister(bg),(t=this.za)==null||t.unregister(oE)}Qh(e,t){if(ne(e))return null;var n,r=Ge(e)?e:parseFloat(e);return typeof(n=r)!="number"||!Number.isFinite(n)||0>n||n>1?(Yn.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):r}Jh(e){if(this.za){var t,n,r=this.za,i=()=>{var s,o=e.sessionRecording===!1?void 0:e.sessionRecording,a=this.Qh((s=this.qi.session_recording)==null?void 0:s.sampleRate,"session_recording.sampleRate"),l=this.Qh(o==null?void 0:o.sampleRate,"remote config sampleRate"),u=a??l;ne(u)&&this.Zh();var c=o==null?void 0:o.minimumDurationMilliseconds;r.register({[Oi]:$({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:$({capturePerformance:e.capturePerformance},o==null?void 0:o.networkPayloadCapture),canvasRecording:{enabled:o==null?void 0:o.recordCanvas,fps:o==null?void 0:o.canvasFps,quality:o==null?void 0:o.canvasQuality},sampleRate:u,minimumDurationMilliseconds:L(c)?null:c,endpoint:o==null?void 0:o.endpoint,triggerMatchType:o==null?void 0:o.triggerMatchType,masking:o==null?void 0:o.masking,urlTriggers:o==null?void 0:o.urlTriggers,version:o==null?void 0:o.version,triggerGroups:o==null?void 0:o.triggerGroups})})};i(),(t=this.Bh)==null||t.call(this),this.Bh=(n=this._instance.sessionManager)==null?void 0:n.onSessionId(i)}}onRemoteConfig(e){var t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?t.sessionRecording===!1?(this.Jh(t),void this.Gh()):(this.Jh(t),void this.startIfEnabledOrStop()):(this.jh===na&&(this.jh=ru,Yn.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var n;t===void 0&&(t="log"),(n=this.qh)!=null&&n.log?this.qh.log(e,t):Yn.warn("log called before recorder was ready")}get Vh(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Oi);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Kh(){var e,t=this._instance.get_property(Oi);if(!t)return!1;try{e=typeof t=="object"?t:JSON.parse(t)}catch(n){return Yn.warn("persisted remote config for session recording is invalid and will be ignored",n),!1}return!ne(e.cache_timestamp)&&36e5>=Date.now()-e.cache_timestamp}Wh(e){var t,n,r;if(!this.Hh){if((t=Y.__PosthogExtensions__)==null||!t.initSessionRecording)return Yn.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[xp]:!0});var i;if(this.qh||(this.qh=(i=Y.__PosthogExtensions__)==null?void 0:i.initSessionRecording(this._instance,this.kt),this.qh._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Kh())return this.jh===ru||this.jh===na?void 0:(this.jh=na,Yn.info("persisted remote config is stale, requesting fresh config before starting"),void new UE(this._instance).load());this.jh=A_,(n=(r=this.qh).setDocumentWasEverVisible)==null||n.call(r,this.kt),this.qh.start(e)}}onRRwebEmit(e){var t;(t=this.qh)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.qh||(t=this.za)==null||t.register({[lE]:!0}),(e=this.qh)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.qh||(t=this.za)==null||t.register({[aE]:!0}),(e=this.qh)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.qh||(n=this.za)==null||n.register({[e==="url"?uE:cE]:!0}),(t=this.qh)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.qh)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.qh)==null||!n.tryAddCustomEvent(e,t))}}},QO={autocapture:class extends MO{constructor(e){super(new AO(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this.Yh=this.Xh()}initialize(){this.startIfEnabled()}get isEnabled(){var e=this.td();return!!(e.path||e.search||this.ed(e))}startIfEnabled(){this.isEnabled&&(D.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Yh=this.Xh(),this.startIfEnabled()}stop(){this.rd&&this.rd(),this.rd=void 0,this.nd&&this.nd(),this.nd=void 0,D.info("History API monitoring stopped")}monitorHistoryChanges(){I&&I.history&&(this.sd("pushState"),this.sd("replaceState"),this.ad(),this.ed()&&this.od())}sd(e){var t;if(I&&((t=I.history[e])==null||!t.__posthog_wrapped__)){var n=this;(function(r,i,s){try{if(!(i in r))return I_;var o={next:r[i]},a=s(function(){for(var l=arguments.length,u=new Array(l),c=0;l>c;c++)u[c]=arguments[c];return o.next.apply(this,u)});return vt(a)&&(a.prototype=a.prototype||{},Object.defineProperties(a,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:o}})),r[i]=a,()=>{if(r[i]!==a)for(var l=r[i];vt(l)&&l.__posthog_layer__;){var u=l.__posthog_layer__;if(u.next===a)return void(u.next=o.next);l=u.next}else r[i]=o.next}}catch{return I_}})(I.history,e,r=>function(i,s,o){r.call(this,i,s,o),n.ld(e)})}}Xh(){var e=I==null?void 0:I.location;if(e!=null&&e.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}td(){var e=this._instance.config.capture_pageview;return e==="history_change"?{path:!0}:Se(e)?e:{}}ed(e){return e===void 0&&(e=this.td()),!!e.hash&&!this._instance.config.disable_capture_url_hashes}ud(e){var t=this.td(),n=this.Yh;return!(!n||!(t.path&&e.pathname!==n.pathname||t.search&&e.search!==n.search||this.ed(t)&&e.hash!==n.hash))}ld(e){try{var t=this.Xh();if(!t)return;this.ud(t)&&this._instance.capture(xs,{navigation_type:e}),this.Yh=t}catch(n){D.error("Error capturing "+e+" pageview",n)}}ad(){if(!this.rd){var e=()=>{this.ld("popstate")};Re(I,"popstate",e),this.rd=()=>{I&&I.removeEventListener("popstate",e)}}}od(){if(!this.nd){var e=()=>{this.ld("hashchange")};Re(I,"hashchange",e),this.nd=()=>{I&&I.removeEventListener("hashchange",e)}}}},heatmaps:class{get qi(){return this.instance.config}constructor(e){var t;this.hd=!1,this.Qn=!1,this.dd=null,this.instance=e,this.hd=!((t=this.instance.persistence)==null||!t.props[up]),this.rageclicks=new lS(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return Se(this.qi.capture_heatmaps)&&this.qi.capture_heatmaps.flush_interval_milliseconds&&(e=this.qi.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return ne(this.qi.capture_heatmaps)?ne(this.qi.enable_heatmaps)?this.hd:this.qi.enable_heatmaps:this.qi.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Qn)return;$O.info("starting..."),this.vd(),this.It()}else{var e;clearInterval((e=this.dd)!==null&&e!==void 0?e:void 0),this.fd(),this.getAndClearBuffer()}}onRemoteConfig(e){if(e.ok){var t=e.config;if("heatmaps"in t){var n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[up]:n}),this.hd=n,this.startIfEnabled()}}}getAndClearBuffer(){var e=this.ft;return this.ft=void 0,e}pd(e){$f(e.originalEvent)&&this.ki(e.originalEvent,"deadclick")}It(){this.dd&&clearInterval(this.dd),this.dd=(j==null?void 0:j.visibilityState)==="visible"?setInterval(this.Oa.bind(this),this.flushIntervalMilliseconds):null}vd(){I&&j&&(this.gd=this.Oa.bind(this),Re(I,kc,this.gd),this.md=e=>this.ki(e||(I==null?void 0:I.event)),Re(j,"click",this.md,{capture:!0}),this.yd=e=>this.bd(e||(I==null?void 0:I.event)),Re(j,"mousemove",this.yd,{capture:!0}),this._d=new d_(this.instance,WI,this.pd.bind(this)),this._d.startIfEnabledOrStop(),this.wd=this.It.bind(this),Re(j,Cc,this.wd),this.Qn=!0)}fd(){var e;I&&j&&(this.gd&&I.removeEventListener(kc,this.gd),this.md&&j.removeEventListener("click",this.md,{capture:!0}),this.yd&&j.removeEventListener("mousemove",this.yd,{capture:!0}),this.wd&&j.removeEventListener(Cc,this.wd),clearTimeout(this.kd),(e=this._d)==null||e.stop(),this.Qn=!1)}Sd(e,t){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),s=function(o,a,l){for(var u=o;u&&ui(u)&&!Kt(u,"body");){if(u===l)return!1;var c=void 0;try{var d,f,m;c=(d=(f=(m=u.ownerDocument)==null?void 0:m.defaultView)!==null&&f!==void 0?f:I)==null?void 0:d.getComputedStyle(u).position}catch{return!1}if(J(a,c))return!0;u=SE(u)}return!1}(Sp(e),["fixed","sticky"],i);return{x:e.clientX+(s?0:r),y:e.clientY+(s?0:n),target_fixed:s,type:t}}ki(e,t){var n;if(t===void 0&&(t="click"),!t_(e.target)&&$f(e)){var r=this.Sd(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&kE(Sp(e),this.instance.config.rageclick)&&this.Nn($({},r,{type:"rageclick"})),this.Nn(r)}}bd(e){!t_(e.target)&&$f(e)&&(clearTimeout(this.kd),this.kd=setTimeout(()=>{this.Nn(this.Sd(e,"mousemove"))},500))}Nn(e){if(I){var t=this.qi.disable_capture_url_hashes?li(I.location.href):I.location.href,n=this.qi.custom_personal_data_properties,r=this.qi.mask_personal_data_properties?[...Co,...n||[]]:[],i=Za(t,r,el);this.ft=this.ft||{},this.ft[i]||(this.ft[i]=[]),this.ft[i].push(e)}}Oa(){this.ft&&!En(this.ft)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:d_,webVitalsAutocapture:class{constructor(e){var t;this.hd=!1,this.Qn=!1,this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.xd=()=>{clearTimeout(this.Cd),this.Cd=void 0,this.ft.metrics.length!==0&&(this._instance.capture("$web_vitals",$({$current_url:this.ft.url},this.ft.metrics.reduce((n,r)=>$({},n,{["$web_vitals_"+r.name+"_event"]:$({},r),["$web_vitals_"+r.name+"_value"]:r.value}),{}))),this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Td=n=>{var r;if(this.ft=this.ft||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},ne(n==null?void 0:n.name)||ne(n==null?void 0:n.value))yi.error("Invalid metric received",n);else{var i=typeof n.navigationURL=="string"?n.navigationURL:void 0,s=this.Md(i);if(!L(s)){var o=Ge(n.navigationId)||typeof n.navigationId=="string"?"navigation:"+n.navigationId:"url:"+s;if(!this.Ed||this.Ed>n.value){this.ft.navigationKey!==o&&(this.xd(),this.Cd=setTimeout(this.xd,this.flushToCaptureTimeoutMs)),L(this.ft.navigationKey)&&(this.ft.navigationKey=o,this.ft.url=s),this.ft.firstMetricTimestamp=L(this.ft.firstMetricTimestamp)?Date.now():this.ft.firstMetricTimestamp,n.attribution&&n.attribution.interactionTargetElement&&(n.attribution.interactionTargetElement=void 0);var a=(r=this._instance.sessionManager)==null?void 0:r.checkAndGetSessionAndWindowId(!0),l=$({},n,i?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});L(a)||(l.$session_id=a.sessionId,l.$window_id=a.windowId),this.ft.metrics.push(l),this.ft.metrics.length===this.allowedMetrics.length&&this.xd()}else yi.error("Ignoring metric with value >= "+this.Ed,n)}}},this.Id=()=>{if(!this.Qn){var n,r,i,s,o=Y.__PosthogExtensions__,a=o==null?void 0:o.postHogWebVitalsCallbacksByFlavor,l=(a==null?void 0:a[this.Rd])||(this.Rd==="web-vitals"&&L(a)?o==null?void 0:o.postHogWebVitalsCallbacks:void 0);if(L(l)||(n=l.onLCP,r=l.onCLS,i=l.onFCP,s=l.onINP),n&&r&&i&&s){var u={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&n(this.Td.bind(this),u),this.allowedMetrics.indexOf("CLS")>-1&&r(this.Td.bind(this),u),this.allowedMetrics.indexOf("FCP")>-1&&i(this.Td.bind(this),u),this.allowedMetrics.indexOf("INP")>-1&&s(this.Td.bind(this),u),this.Qn=!0}else yi.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.hd=!((t=this._instance.persistence)==null||!t.props[hp]),this.startIfEnabled()}get Pd(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,n=Se(this.Pd)?(e=this.Pd)==null?void 0:e.web_vitals_allowed_metrics:void 0;return ne(n)?((t=this._instance.persistence)==null?void 0:t.props[pp])||["CLS","FCP","INP","LCP"]:n}get flushToCaptureTimeoutMs(){return(Se(this.Pd)?this.Pd.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Se(this.Pd)?this.Pd.web_vitals_attribution:void 0;return e!=null&&e}get useSoftNavs(){var e=Se(this.Pd)?this.Pd.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get Ed(){var e=Se(this.Pd)&&Ge(this.Pd.__web_vitals_max_value)?this.Pd.__web_vitals_max_value:O_;return e>0&&6e4>=e?O_:e}get isEnabled(){var e=Ae==null?void 0:Ae.protocol;if(e!=="http:"&&e!=="https:")return yi.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=Se(this.Pd)?this.Pd.web_vitals:$t(this.Pd)?this.Pd:void 0;return $t(t)?t:this.hd}startIfEnabled(){this.isEnabled&&!this.Qn&&(yi.info("enabled, starting..."),this._s(this.Id))}onRemoteConfig(e){if(e.ok){var t=e.config;if("capturePerformance"in t){var n=Se(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=Se(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[hp]:n}),this._instance.persistence.register({[pp]:r})),this.hd=n,this.startIfEnabled()}}}get Rd(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}_s(e){var t=Y.__PosthogExtensions__,n=this.Rd,r=t==null?void 0:t.postHogWebVitalsCallbacksByFlavor;r!=null&&r[n]||n==="web-vitals"&&L(r)&&t!=null&&t.postHogWebVitalsCallbacks?e():t==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,n,i=>{i?yi.error("failed to load script",i):e()})}Md(e){var t=e||(I==null?void 0:I.location.href);if(t){var n=this._instance.config.disable_capture_url_hashes?li(t):t,r=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...Co,...r||[]]:[];return Za(n,i,el)}yi.error("Could not determine current URL")}}},YO={exceptionObserver:class{constructor(e){var t;this.Id=()=>{var n;if(I&&this.isEnabled&&(n=Y.__PosthogExtensions__)!=null&&n.errorWrappingFunctions){var r=Y.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Y.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=Y.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Ad&&this.qi.capture_unhandled_errors&&(this.Ad=r(this.captureException.bind(this))),!this.Fd&&this.qi.capture_unhandled_rejections&&(this.Fd=i(this.captureException.bind(this))),!this.Od&&this.qi.capture_console_errors&&(this.Od=s(this.captureException.bind(this)))}catch(o){ta.error("failed to start",o),this.Ld()}}},this._instance=e,this.$d=!((t=this._instance.persistence)==null||!t.props[cp]),this.oe=new jT($({},function(n){var r,i,s,o;return n===void 0&&(n={}),{refillRate:(r=(i=n.exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:n.__exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:1,bucketSize:(s=(o=n.exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:n.__exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:10}}(this._instance.config.error_tracking),{refillInterval:1e4,I:ta})),this.qi=this.Dd(),this.startIfEnabledOrStop()}Dd(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Se(e)?t=$({},t,e):(L(e)?this.$d:e)&&(t=$({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.qi.capture_console_errors||this.qi.capture_unhandled_errors||this.qi.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ta.info("enabled"),this.Ld(),this._s(this.Id)):this.Ld()}_s(e){var t,n;(t=Y.__PosthogExtensions__)!=null&&t.errorWrappingFunctions?e():(n=Y.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"exception-autocapture",r=>{if(r)return ta.error("failed to load script",r);e()})}Ld(){var e,t,n;(e=this.Ad)==null||e.call(this),this.Ad=void 0,(t=this.Fd)==null||t.call(this),this.Fd=void 0,(n=this.Od)==null||n.call(this),this.Od=void 0}onRemoteConfig(e){if(e.ok){var t=e.config;"autocaptureExceptions"in t&&(this.$d=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[cp]:this.$d}),this.qi=this.Dd(),this.startIfEnabledOrStop())}}onConfigChange(){this.qi=this.Dd()}captureException(e){var t,n,r,i=(t=e==null||(n=e.$exception_list)==null||(n=n[0])==null?void 0:n.type)!==null&&t!==void 0?t:"Exception";this.oe.consumeRateLimit(i)?ta.info("Skipping exception capture because of client rate limiting.",{exception:i}):(r=this._instance.exceptions)==null||r.sendExceptionEvent(e)}},exceptions:class{constructor(e){var t,n;this.Nd=[],this.qd=new rI([new dI,new wI,new hI,new fI,new yI,new mI,new vI,new _I],function(r){for(var i=arguments.length,s=new Array(i>1?i-1:0),o=1;i>o;o++)s[o-1]=arguments[o];return function(a,l){l===void 0&&(l=0);for(var u=[],c=a.split(` +`),d=l;c.length>d;d++){var f=c[d];if(1024>=f.length){var m=Ky.test(f)?f.replace(Ky,"$1"):f;if(!m.match(/\S*Error: /)){for(var _ of s){var p=_(m,r);if(p){u.push(p);break}}if(u.length>=50)break}}}return function(y){if(!y.length)return[];var h=Array.from(y);return h.reverse(),h.slice(0,50).map(v=>{return $({},v,{filename:v.filename||(x=h,x[x.length-1]||{}).filename,function:v.function||bo});var x})}(u)}}("web:javascript",aI,cI)),this._instance=e,this.Nd=(t=(n=this._instance.persistence)==null?void 0:n.get_property(dp))!==null&&t!==void 0?t:[],this.jd=_c(this.Bd()),this.Hd=new bI(this.jd)}onConfigChange(){this.jd=_c(this.Bd()),this.Hd.setConfig(this.jd)}onRemoteConfig(e){var t,n,r;if(e.ok){var i=e.config;if("errorTracking"in i){var s=(t=(n=i.errorTracking)==null?void 0:n.suppressionRules)!==null&&t!==void 0?t:[],o=(r=i.errorTracking)==null?void 0:r.captureExtensionExceptions;this.Nd=s,this._instance.persistence&&this._instance.persistence.register({[dp]:this.Nd,[fp]:o})}}}get Ud(){var e,t=!!this._instance.get_property(fp),n=this._instance.config.error_tracking.captureExtensionExceptions;return(e=n??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.qd.buildFromUnknown(e,{syntheticException:t==null?void 0:t.syntheticException,mechanism:{handled:t==null?void 0:t.handled}})}addExceptionStep(e,t){if(this.jd.enabled)try{if(!ce(e)||e.trim().length===0)return void gn.warn("Ignoring exception step because message must be a non-empty string");var n=function(s){if(!s)return{sanitizedProperties:{},droppedKeys:[]};var o=[];return{sanitizedProperties:Object.keys(s).reduce((a,l)=>xI.has(l)?(o.push(l),a):(a[l]=s[l],a),{}),droppedKeys:o}}(this.zd(t)),r=n.sanitizedProperties,i=n.droppedKeys;i.length>0&&gn.warn("Ignoring reserved exception step fields",{droppedKeys:i}),this.Hd.add($({[mc]:e,[yc]:new Date().toISOString()},r))}catch(s){gn.error("Failed to add exception step. Ignoring breadcrumb.",s)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this.Wd(t)){if(this.Vd(t))return this.Gd("Exception dropped: matched a suppression rule"),void gn.info("Skipping exception capture because a suppression rule matched");if(!this.Ud&&this.Zd(t))return this.Gd("Exception dropped: thrown by a browser extension"),void gn.info("Skipping exception capture because it was thrown by an extension");if(!this.Ud&&this.Qd(t))return this.Gd("Exception dropped: thrown by an injected browser script"),void gn.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Jd(t))return this.Gd("Exception dropped: thrown by the PostHog SDK"),void gn.info("Skipping exception capture because it was thrown by the PostHog SDK")}var n=this.jd.enabled&&ne(e.$exception_steps)?this.Kd(e):e,r=typeof(s=globalThis._posthogReleaseId)=="string"&&s.length>0?s:void 0;r&&(n.$release_id=r);try{var i=this._instance.capture("$exception",n,{_noTruncate:!0,_batchKey:"exceptionEvent",fl:!0});return i&&this.Hd.clear(),i}catch(o){return gn.error("Failed to capture exception event. Dropping this exception.",o),void this.Hd.clear()}}catch(o){return void gn.error("Failed to process exception event. Ignoring this exception.",o)}var s}Kd(e){try{var t=this.Hd.getAttachable();return t.length===0?e:$({},e,{$exception_steps:t})}catch(n){return gn.error("Failed to read buffered exception steps. Capturing exception without steps.",n),e}}Gd(e){this.jd.enabled&&this.Hd.add({[mc]:e,[yc]:new Date().toISOString()})}zd(e){return Se(e)?$({},e):{}}Bd(){var e,t;return(e=(t=this._instance.config.error_tracking)==null?void 0:t.exception_steps)!==null&&e!==void 0?e:{}}Vd(e){if(e.length===0)return!1;try{var t=e.reduce((n,r)=>{var i=r.type,s=r.value;return ce(i)&&i.length>0&&n.$exception_types.push(i),ce(s)&&s.length>0&&n.$exception_values.push(s),n},{$exception_types:[],$exception_values:[]});return this.Nd.some(n=>{var r=n.values.map(i=>{var s=tS[i.operator],o=t[i.key];if(!s||!o)return!1;var a=Z(i.value)?i.value:[i.value];return a.length>0&&s(a,o)});return n.type==="OR"?r.some(Boolean):r.every(Boolean)})}catch(n){return gn.warn("Failed to evaluate suppression rules. Capturing the exception.",n),!1}}Zd(e){return e.flatMap(t=>{var n,r;return(n=(r=t.stacktrace)==null?void 0:r.frames)!==null&&n!==void 0?n:[]}).some(t=>{var n=t.filename;return!!n&&WO.some(r=>n.startsWith(r))})}Qd(e){return e.some(t=>{var n=t.value;return ce(n)&&HO.some(r=>n.includes(r))})}Jd(e){if(e.length>0){var t,n,r,i,s=(t=(n=e[0].stacktrace)==null?void 0:n.frames)!==null&&t!==void 0?t:[],o=s[s.length-1];return(r=o==null||(i=o.filename)==null?void 0:i.includes("posthog.com/static"))!==null&&r!==void 0&&r}return!1}Wd(e){return!ne(e)&&Z(e)}}},XO=$({productTours:class{get za(){return this._instance.persistence}constructor(e){this.Yd=null,this.Xd=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(e.ok){var t=e.config;if("productTours"in t){var n,r;if(this.za&&this.za.register({[xg]:!!t.productTours}),!Ff(this._instance))return!this.Yd&&ne((n=this.za)==null?void 0:n.props[da])||iu.info("product tours disabled; stopping and clearing cached tours"),(r=this.Yd)==null||r.stop(),this.Yd=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Yd&&Ff(this._instance)&&this._s(()=>this.tv())}_s(e){var t,n;(t=Y.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=Y.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"product-tours",r=>{r?iu.error("Could not load product tours script",r):e()})}tv(){var e;!this.Yd&&(e=Y.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Yd=Y.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!Z(this.Xd)||t){var n=this.za;if(n){var r=n.props[da];if(Z(r)&&!t)return this.Xd=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:i=>{if(Ff(this._instance)){var s=i.statusCode;if(s!==200||!i.json){var o="Product Tours API could not be loaded, status: "+s;return s===0?i.error||iu.warn(o):iu.error(o),void e([],{isLoaded:!1,error:o})}var a=Z(i.json.product_tours)?i.json.product_tours:[];this.Xd=a,n&&n.register({[da]:a}),e(a,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this.Xd,{isLoaded:!0})}getActiveProductTours(e){ne(this.Yd)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Yd.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Yd)==null||t.showTourById(e)}previewTour(e){this.Yd?this.Yd.previewTour(e):this._s(()=>{var t;this.tv(),(t=this.Yd)==null||t.previewTour(e)})}dismissProductTour(){var e;(e=this.Yd)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Yd)==null||e.nextStep()}previousStep(){var e;(e=this.Yd)==null||e.previousStep()}clearCache(){var e;this.Xd=null,(e=this.za)==null||e.unregister(da)}resetTour(e){var t;(t=this.Yd)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Yd)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Yd)==null||t.cancelPendingTour(e)}}},hd),JO={siteApps:class{constructor(e){this.ev=0,this._instance=e,this.iv=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}rv(e,t){if(t){var n=this.globalsForEvent(t);this.iv.push(n),this.iv.length>1e3&&(this.iv=this.iv.slice(10))}}get siteAppLoaders(){var e;return(e=Y._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.rv.bind(this));this.nv=()=>{e(),this.iv=[],this.nv=void 0}}}globalsForEvent(e){var t,n,r,i,s,o,a;if(!e)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(var d of Object.entries(c)){var f=d[0];l[f]={id:u[f],type:f,properties:d[1]}}var m=e.$set_once,_=e.$set;return{event:$({},bb(e,FO),{properties:$({},e.properties,_?{$set:$({},(t=(n=e.properties)==null?void 0:n.$set)!==null&&t!==void 0?t:{},_)}:{},m?{$set_once:$({},(r=(i=e.properties)==null?void 0:i.$set_once)!==null&&r!==void 0?r:{},m)}:{}),elements_chain:(s=(o=e.properties)==null?void 0:o.$elements_chain)!==null&&s!==void 0?s:"",distinct_id:(a=e.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}sv(e){var t,n=(t=e.tagName)==null?void 0:t.toLowerCase();return n==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(On.error("prepare_external_dependency_stylesheet returned null"),null):n==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(On.error("prepare_external_dependency_script returned null"),null):e}av(){var e,t,n,r,i,s,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=j==null?void 0:j.defaultView,u=l==null||(e=l.Node)==null?void 0:e.prototype;if(!l||!u)return()=>{};if(this.ev++,this.ov)return this.lv();var c=[],d=this,f=new WeakSet,m=(y,h,v)=>{if(y!=null&&y[h]){var x=y[h];y[h]=v(x),c.push(()=>{y[h]=x})}},_=y=>{if(f.has(y))return y;var h=d.sv(y);return h&&f.add(h),h},p=y=>y.map(h=>typeof h=="string"?h:_(h)).filter(h=>!rt(h));return m(u,"appendChild",y=>function(h){var v=_(h);return v?y.call(this,v):h}),m(u,"insertBefore",y=>function(h,v){var x=_(h);return x?y.call(this,x,v):h}),m(u,"replaceChild",y=>function(h,v){var x=_(h);return x?y.call(this,x,v):v}),[(t=l.Element)==null?void 0:t.prototype,(n=l.Document)==null?void 0:n.prototype,(r=l.DocumentFragment)==null?void 0:r.prototype].forEach(y=>{m(y,"append",h=>function(){for(var v=arguments.length,x=new Array(v),b=0;v>b;b++)x[b]=arguments[b];return h.apply(this,p(x))}),m(y,"prepend",h=>function(){for(var v=arguments.length,x=new Array(v),b=0;v>b;b++)x[b]=arguments[b];return h.apply(this,p(x))})}),[(i=l.Element)==null?void 0:i.prototype,(s=l.CharacterData)==null?void 0:s.prototype,(o=l.DocumentType)==null?void 0:o.prototype].forEach(y=>{m(y,"before",h=>function(){for(var v=arguments.length,x=new Array(v),b=0;v>b;b++)x[b]=arguments[b];return h.apply(this,p(x))}),m(y,"after",h=>function(){for(var v=arguments.length,x=new Array(v),b=0;v>b;b++)x[b]=arguments[b];return h.apply(this,p(x))}),m(y,"replaceWith",h=>function(){for(var v=arguments.length,x=new Array(v),b=0;v>b;b++)x[b]=arguments[b];var E=p(x);return x.length&&!E.length?void 0:h.apply(this,E)})}),m((a=l.Element)==null?void 0:a.prototype,"insertAdjacentElement",y=>function(h,v){var x=_(v);return x?y.call(this,h,x):null}),this.ov=()=>{c.forEach(y=>y()),this.ov=void 0},this.lv()}lv(){var e=!1;return()=>{var t;e||(e=!0,this.ev--,this.ev===0&&((t=this.ov)==null||t.call(this)))}}uv(e,t){t===void 0&&(t=!0);var n=this.av();try{var r=e(n);return t&&n(),r}catch(i){throw n(),i}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var o;!t.errored&&this.iv.length&&(On.info("Processing "+this.iv.length+" events for site app with id "+e.id),this.iv.forEach(a=>this.uv(()=>t.processEvent==null?void 0:t.processEvent(a))),t.processedBuffer=!0),Object.values(this.apps).every(a=>a.processedBuffer||a.errored)&&((o=this.nv)==null||o.call(this))},r=!1,i=o=>{t.errored=!o,t.loaded=!0,On.info("Site app with id "+e.id+" "+(o?"loaded":"errored")),r&&n()};try{var s=this.uv(o=>e.init({posthog:this._instance,callback(a){o(),i(a)}}),!1).processEvent;s&&(t.processEvent=s),r=!0}catch(o){On.error(N_+e.id,o),i(!1)}if(r&&t.loaded)try{n()}catch(o){On.error("Error while processing buffered events PostHog app with config id "+e.id,o),t.errored=!0}}hv(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}dv(e){var t=this;if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e),r=function(s){try{t.uv(()=>s.processEvent==null?void 0:s.processEvent(n))}catch(o){On.error("Error while processing event "+e.event+" for site app "+s.id,o)}};for(var i of Object.values(this.apps))r(i)}}onRemoteConfig(e){var t,n,r,i=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.hv(),void this._instance.on("eventCaptured",l=>this.dv(l))):void On.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this.nv)==null||n.call(this),e.ok){var s=e.config;if((r=s.siteApps)!=null&&r.length)if(this.isEnabled){var o=function(){var l,u=a.id,c=a.url;Y["__$$ph_site_app_"+u]=i._instance,(l=Y.__PosthogExtensions__)==null||l.loadSiteApp==null||l.loadSiteApp(i._instance,c,d=>{if(d)return On.error(N_+u,d)})};for(var a of s.siteApps)o()}else On.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},ZO={tracingHeaders:class{constructor(e){this.vv=void 0,this.fv=void 0,this.pv=void 0,this.Id=()=>{var t,n,r=this.gv();r?(L(this.vv)&&(this.vv=(t=Y.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchXHR(r,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),L(this.fv)&&(this.fv=(n=Y.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null?void 0:n._patchFetch(r,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Ld()},this._instance=e}initialize(){this.startIfEnabledOrStop()}_s(e){var t,n;(t=Y.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns?e():(n=Y.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"tracing-headers",r=>{if(r)return NO.error("failed to load script",r);e()})}mv(){var e,t;return(e=(t=this._instance.config.tracing_headers)!==null&&t!==void 0?t:this._instance.config.addTracingHeaders)!==null&&e!==void 0?e:this._instance.config.__add_tracing_headers}gv(){var e=this.mv();return Z(e)?(Z(this.pv)?this.pv.splice(0,this.pv.length,...e):this.pv=[...e],e.length>0?this.pv:void 0):(Z(this.pv)&&this.pv.splice(0),this.pv=e||void 0,this.pv)}Ld(){var e,t;(e=this.vv)==null||e.call(this),(t=this.fv)==null||t.call(this),this.vv=void 0,this.fv=void 0}startIfEnabledOrStop(){this.gv()?this._s(this.Id):this.Ld()}}},eM=$({surveys:class extends LO{constructor(e){var t;super(new VO(e),{get projectToken(){return t.config.token},kv:new UO(t=e)}),this._instance=e}Nl(e,t){var n=t.query?bl(e,t.query):e;return new Promise(r=>{var i;this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor((i=t.target)!==null&&i!==void 0?i:"api",n),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:r})})}}},hd),tM={toolbar:class{constructor(e){this.instance=e}yv(e){Y.ph_toolbar_state=e}bv(){var e;return(e=Y.ph_toolbar_state)!==null&&e!==void 0?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,n){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),Ep(this.instance.config)||!I||!j)return!1;e=e??I.location,n=n??I.history;try{if(!t){try{I.localStorage.setItem("test","test"),I.localStorage.removeItem("test")}catch{return!1}t=I==null?void 0:I.localStorage}var r,i=BO||Ic(e.hash,"__posthog")||Ic(e.hash,"state"),s=i?Xy(()=>JSON.parse(atob(decodeURIComponent(i))))||Xy(()=>JSON.parse(decodeURIComponent(i))):null;return s&&s.action==="ph_authorize"?((r=s).source="url",r&&Object.keys(r).length>0&&(s.desiredHash?e.hash=s.desiredHash:n?n.replaceState(n.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem(F_)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}_v(e){var t=Y.ph_load_toolbar||Y.ph_load_editor;!ne(t)&&vt(t)?t(e,this.instance):L_.warn("No toolbar load function found")}loadToolbar(e){var t=!(j==null||!j.getElementById(_E));if(!I||t)return!1;var n=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,r=$({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(I.localStorage.setItem(F_,JSON.stringify($({},r,{source:void 0}))),this.bv()===2)this._v(r);else if(this.bv()===0){var i;this.yv(1),(i=Y.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"toolbar",s=>{if(s)return L_.error("[Toolbar] Failed to load",s),void this.yv(0);this.yv(2),this._v(r)}),Re(I,"turbolinks:load",()=>{this.yv(0),this.loadToolbar(r)})}return!0}wv(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}},nM=$({experiments:ht},hd),rM={conversations:class{constructor(e){this.Sv=void 0,this._conversationsManager=null,this.xv=!1,this.Me=null,this.Cv=!1,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations&&(this.Tv=e.ok,e.ok)){var t=e.config.conversations;ne(t)||($t(t)?this.Sv=t:(this.Sv=t.enabled,this.Me=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Sv=void 0,this.Me=null,this.Tv=void 0,this.Cv=!1}loadIfEnabled(){if(!(this._conversationsManager||this.xv||this._instance.config.disable_conversations||Ep(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=Y==null?void 0:Y.__PosthogExtensions__;if(e&&!L(this.Sv)&&this.Sv)if(this.Me&&this.Me.token){this.xv=!0;try{var t=e.initConversations;if(t)return this.Mv(t),void(this.xv=!1);var n=e.loadExternalDependency;if(!n)return void this.Ev(Eg);n(this._instance,"conversations",r=>{r||!e.initConversations?this.Ev("Could not load conversations script",r):this.Mv(e.initConversations),this.xv=!1})}catch(r){this.Ev("Error initializing conversations",r),this.xv=!1}}else tn.error("Conversations enabled but missing token in remote config.")}}Mv(e){if(this.Me)try{this._conversationsManager=e(this.Me,this._instance),this.Cv=!1,tn.info("Conversations loaded successfully")}catch(t){this.Ev("Error completing conversations initialization",t)}else tn.error("Cannot complete initialization: remote config is null")}Ev(e,t){tn.error(e,t),this._conversationsManager=null,this.xv=!1,this.Cv=!0}show(){this._conversationsManager?this._conversationsManager.show():tn.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Sv===!0&&!rt(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Ep(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.Tv===!1?"remote_config_failed":L(this.Sv)?this.Tv?"disabled_in_project":"remote_config_pending":this.Sv?ne(this.Me)||!this.Me.token?"missing_token":Y!=null&&Y.__PosthogExtensions__?this.xv?"initializing":this.Cv?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,n){var r=this;return Ce(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(tn.warn(wi),null)})()}getMessages(e,t){var n=this;return Ce(function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(tn.warn(wi),null)})()}markAsRead(e){var t=this;return Ce(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(tn.warn(wi),null)})()}getTickets(e){var t=this;return Ce(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(tn.warn(wi),null)})()}requestRestoreLink(e){var t=this;return Ce(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(tn.warn(wi),null)})()}restoreFromToken(e){var t=this;return Ce(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(tn.warn(wi),null)})()}restoreFromUrlToken(){var e=this;return Ce(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(tn.warn(wi),null)})()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}Sl(){var e;(e=this._conversationsManager)==null||e.setIdentity()}xl(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},iM={logs:class{constructor(e){var t,n=this;this.Iv=!1,this.Rv=!1,this.I=Ie("[logs]"),this.Pv=$({},this.I,{error(){for(var r=arguments.length,i=new Array(r),s=0;r>s;s++)i[s]=arguments[s];i.some(W_)||n.I.error(...i)}}),this.ka=[],this.Av=[],this.ph=0,this.Fv=()=>{var r,i;this.ph=0,(r=this.Ov)==null||r.onReconnect(),(i=this.Lv)==null||i.onReconnect()},this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Iv=!0),I&&Re(I,"online",this.Fv)}$v(e,t,n,r){var i,s=function(o,a){var l,u,c,d,f,m,_,p=(l=o==null?void 0:o.flushIntervalMs)!==null&&l!==void 0?l:3e3,y=(u=o==null?void 0:o.maxBufferSize)!==null&&u!==void 0?u:100,h=a!=null&&a.consoleCapture?void 0:(c=o==null?void 0:o.maxLogsPerInterval)!==null&&c!==void 0?c:1e3,v=L(h)?Math.max(y,2048):Math.max(y,h),x=o==null?void 0:o.resourceAttributes;return{serviceName:(d=(f=x==null?void 0:x["service.name"])!==null&&f!==void 0?f:o==null?void 0:o.serviceName)!==null&&d!==void 0?d:a==null?void 0:a.serviceNameDefault,serviceVersion:(m=x==null?void 0:x["service.version"])!==null&&m!==void 0?m:o==null?void 0:o.serviceVersion,environment:(_=x==null?void 0:x["deployment.environment"])!==null&&_!==void 0?_:o==null?void 0:o.environment,resourceAttributes:x,beforeSend:o==null?void 0:o.beforeSend,flushIntervalMs:p,maxBufferSize:y,maxQueueSize:v,maxBatchRecordsPerPost:100,rateCapWindowMs:p,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}((i=this._instance)==null||(i=i.config)==null?void 0:i.logs,n);return[new eI(this.Dv(e,t),s,this.Pv,()=>this.Nv(),o=>o(),void 0,r),s]}qv(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.Ov||this.jv!==t){var n;(n=this.Ov)==null||n.reset(),this.jv=t;var r=this.$v(()=>this.ka,i=>{this.ka=i});this.Ov=r[0],this.Bv=r[1]}return this.Ov}Hv(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.Lv||this.Uv!==t){var n;(n=this.Lv)==null||n.reset(),this.Uv=t;var r=this.$v(()=>this.Av,i=>{this.Av=i},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},q_);this.Lv=r[0],this.zv=r[1]}return this.Lv}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t;if(e.ok){var n=(t=e.config.logs)==null?void 0:t.captureConsoleLogs;!ne(n)&&n&&(this.Iv=!0,this.loadIfEnabled())}}reset(){var e,t;this.ka=[],(e=this.Ov)==null||e.reset(),this.Av=[],(t=this.Lv)==null||t.reset(),this.ph=0}captureLog(e){this.qv().captureLog(e)}vi(e){this.Hv().captureLog(e)}get logger(){return this.Wv||(this.Wv={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this.Wv}flushLogs(e){e?this.Vv(e):(this.Ov&&this.Ov.flush().catch(t=>this.Gv(t)),this.Lv&&this.Lv.flush().catch(t=>this.Gv(t)))}Gv(e){W_(e)||this.I.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this.Iv&&!this.Rv){var e=Y==null?void 0:Y.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",n=>{var r;n||(r=e.logs)==null||!r.initializeLogs?this.I.error("Could not load logs script",n):(e.logs.initializeLogs(this._instance),this.Rv=!0)}):this.I.error(Eg)}else this.I.error("PostHog Extensions not found.")}}Dv(e,t){var n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:r=>r===nr.LogsQueue?e():void 0,setPersistedProperty(r,i){var s;r===nr.LogsQueue&&t((s=i)!==null&&s!==void 0?s:[])},Mn:r=>this.Mn(r),getLibraryId:()=>Ee.LIB_NAME,getLibraryVersion:()=>Ee.LIB_VERSION}}Mn(e){return new Promise(t=>{if(ME(this.ph,3))t({kind:"fatal",error:jf(void 0,"logs endpoint is unreachable, dropping batch")});else{var n=!1,r=s=>{n||(n=!0,clearTimeout(i),t(s))},i=setTimeout(()=>{this.I.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:jf(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.Zv(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:s=>{var o=s.statusCode;if(this.Qv(o),o>=200&&300>o)r({kind:"ok"});else if(o===413)r({kind:"too-large"});else if(o!==0&&o!==408&&o!==429&&500>o)r({kind:"fatal",error:new Error("logs request failed with status "+o)});else{var a;o===0?(s.error||this.I.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:jf(s.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:(a=s.error)!==null&&a!==void 0?a:new Error("logs request failed with status "+o)})}}})}})}Qv(e){(e!==0||this._instance.__loaded)&&(this.ph=AE(e,this.ph,3,()=>this.I.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}Vv(e){this.ka.length>0&&this.Jv(e,this.ka,this.Bv,Ee.LIB_NAME,t=>{this.ka=t}),this.Av.length>0&&this.Jv(e,this.Av,this.zv,q_,t=>{this.Av=t})}Jv(e,t,n,r,i){if(t.length!==0){var s=t.map(a=>a.record);i([]);var o=tE(s,eE(n,Ee.LIB_NAME,Ee.LIB_VERSION),r,Ee.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Zv(),data:o,compression:"best-available",batchKey:"logs",transport:e})}}Zv(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Nv(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var n=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=n.windowId,i=n.sessionStartTimestamp,s=n.lastActivityTimestamp;t.sessionId=n.sessionId,t.windowId=r,ne(i)||(t.sessionStartTimestamp=i),ne(s)||(t.lastActivityTimestamp=s)}if(Y!=null&&(e=Y.location)!=null&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?li(Y.location.href):Y.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}},sM={metrics:class{constructor(e){this.I=Ie("[metrics]"),this._instance=e}initialize(){}qv(){var e,t,n=(e=this._instance)==null||(e=e.config)==null?void 0:e.metrics;return this.Ov&&this.jv===n||((t=this.Ov)==null||t.reset(),this.jv=n,this.Ov=new tI(this.Dv(),function(r){var i,s,o,a,l,u=r==null?void 0:r.resourceAttributes;return{serviceName:(i=u==null?void 0:u["service.name"])!==null&&i!==void 0?i:r==null?void 0:r.serviceName,serviceVersion:(s=u==null?void 0:u["service.version"])!==null&&s!==void 0?s:r==null?void 0:r.serviceVersion,environment:(o=u==null?void 0:u["deployment.environment"])!==null&&o!==void 0?o:r==null?void 0:r.environment,resourceAttributes:u,beforeSend:r==null?void 0:r.beforeSend,flushIntervalMs:(a=r==null?void 0:r.flushIntervalMs)!==null&&a!==void 0?a:1e4,maxSeriesPerFlush:(l=r==null?void 0:r.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}}(n),this.I)),this.Ov}count(e,t,n){t===void 0&&(t=1),this.qv().count(e,t,n)}gauge(e,t,n){this.qv().gauge(e,t,n)}histogram(e,t,n){this.qv().histogram(e,t,n)}flush(e){if(!this.Ov)return Promise.resolve();if(e){var t=this.Ov.drainWindow();return t&&this.Un(t,e),Promise.resolve()}return this.Ov.flush().catch(n=>this.I.error("PostHog metrics flush failed:",n))}reset(){var e;(e=this.Ov)==null||e.reset()}Dv(){var e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Un:n=>t.Un(n),getLibraryId:()=>Ee.LIB_NAME,getLibraryVersion:()=>Ee.LIB_VERSION}}Un(e,t){return new Promise(n=>{var r=!1,i=o=>{r||(r=!0,clearTimeout(s),n(o))},s=setTimeout(()=>i({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request($({method:"POST",url:this.Kv(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t},{fireCallbackOnDrop:!0,callback(o){var a=o.statusCode;if(a>=200&&300>a)i({kind:"ok"});else if(a===413)i({kind:"too-large"});else if(a!==0&&a!==408&&a!==429&&500>a)i({kind:"fatal",error:new Error("metrics request failed with status "+a)});else{var l;i({kind:"retry-later",error:(l=o.error)!==null&&l!==void 0?l:new Error("metrics request failed with status "+a)})}}}))})}Kv(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},oM=$({},hd,KO,QO,YO,XO,JO,eM,ZO,tM,nM,rM,iM,sM);qt.__defaultExtensionClasses=$({},oM);var aM=function(){Ee.SDK_DIST_CHANNEL="npm";var e=Ra[bs]=new qt;return function(){function t(){t.done||(t.done=!0,aS=!1,ve(Ra,function(n){n._dom_loaded()}))}j!=null&&j.addEventListener?j.readyState==="complete"?t():Re(j,"DOMContentLoaded",t,{capture:!1}):I&&D.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}(),dS;function lM(e){dS=e}function uM(){return dS}var cM=g.createContext({get client(){return uM()},bootstrap:void 0}),Df=function(e){return typeof e=="function"},dM=function(e){return e===void 0},$p=function(e,t){return $p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},$p(e,t)};function fM(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");$p(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Au=function(e){var t=Object.prototype.toString.call(e);return e instanceof Error||t==="[object Error]"||t==="[object Exception]"||t==="[object DOMException]"||t==="[object DOMError]"},hM=function(e,t){for(var n=new WeakSet,r=e;!n.has(r);){if(n.add(r),!Au(r.cause)){dM(r.cause)||(t.cause=r.cause),r.cause=t;return}r=r.cause}},pM=function(e,t){if(!t)return e;var n=new Error(Au(e)?e.message:"Primitive value captured as exception: ".concat(String(e)));return n.name="React ErrorBoundary ".concat(Au(e)?e.name:"Error"),n.stack=t,Au(e)?(hM(e,n),e):n},vM={componentStack:null,exceptionEvent:null,error:null},gM={INVALID_FALLBACK:"[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element."};(function(e){fM(t,e);function t(n){var r=e.call(this,n)||this;return r.state=vM,r}return t.prototype.componentDidCatch=function(n,r){var i=this.props.additionalProperties,s;Df(i)?s=i(n,r):typeof i=="object"&&(s=i);var o=this.context.client,a=r.componentStack,l=o.captureException(pM(n,a),s);this.setState({error:n,componentStack:a??null,exceptionEvent:l})},t.prototype.render=function(){var n=this.props,r=n.children,i=n.fallback,s=this.state;if(s.componentStack==null)return Df(r)?r():r;var o=Df(i)?q.createElement(i,{error:s.error,componentStack:s.componentStack,exceptionEvent:s.exceptionEvent}):i;return q.isValidElement(o)?o:(console.warn(gM.INVALID_FALLBACK),q.createElement(q.Fragment,null))},t.contextType=cM,t})(q.Component);lM(aM);class fS extends q.Component{constructor(){super(...arguments);kr(this,"state",{failed:!1,resetKey:this.props.resetKey})}static getDerivedStateFromError(){return{failed:!0}}static getDerivedStateFromProps(n,r){return n.resetKey===r.resetKey?null:{failed:!1,resetKey:n.resetKey}}componentDidCatch(n){console.error("The application could not render",n)}render(){if(!this.state.failed)return this.props.children;const n=w.jsxs("div",{className:"page",role:"alert",children:[w.jsx("h1",{children:"This page could not load"}),w.jsx("p",{children:"The site may have been updated while this tab was open."}),w.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>window.location.reload(),children:"Reload page"})]});return this.props.resetKey===void 0?w.jsx("main",{children:n}):n}}const zf="pwc:chunk-reload-at",hS=6e4;function mM(e,t){if(!e)return!0;const n=Number(e);return!Number.isFinite(n)||t-n>=hS}function yM(){if(typeof window>"u")return()=>{};const e=n=>{const r=Date.now();mM(sessionStorage.getItem(zf),r)&&(n.preventDefault(),sessionStorage.setItem(zf,String(r)),window.location.reload())};window.addEventListener("vite:preloadError",e);const t=window.setTimeout(()=>sessionStorage.removeItem(zf),hS);return()=>{window.removeEventListener("vite:preloadError",e),window.clearTimeout(t)}}const _M="modulepreload",wM=function(e){return"/"+e},H_={},ae=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(l=>{if(l=wM(l),l in H_)return;H_[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":_M,u||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((f,m)=>{d.addEventListener("load",f),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})};/** * @remix-run/router v1.23.2 * * Copyright (c) Remix Software Inc. @@ -49,7 +49,7 @@ Error generating stack: `+s.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function tl(){return tl=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function pd(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function SM(){return Math.random().toString(36).substr(2,8)}function K_(e,t){return{usr:e.state,key:e.key,idx:t}}function $c(e,t,n,r){return n===void 0&&(n=null),tl({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?is(t):t,{state:n,key:t&&t.key||r||SM()})}function nl(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function is(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function pS(e,t,n,r){r===void 0&&(r={});let{window:i=document.defaultView,v5Compat:s=!1}=r,o=i.history,a=Qr.Pop,l=null,u=c();u==null&&(u=0,o.replaceState(tl({},o.state,{idx:u}),""));function c(){return(o.state||{idx:null}).idx}function d(){a=Qr.Pop;let y=c(),h=y==null?null:y-u;u=y,l&&l({action:a,location:p.location,delta:h})}function f(y,h){a=Qr.Push;let v=$c(p.location,y,h);n&&n(v,y),u=c()+1;let x=K_(v,u),b=p.createHref(v);try{o.pushState(x,"",b)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;i.location.assign(b)}s&&l&&l({action:a,location:p.location,delta:1})}function m(y,h){a=Qr.Replace;let v=$c(p.location,y,h);n&&n(v,y),u=c();let x=K_(v,u),b=p.createHref(v);o.replaceState(x,"",b),s&&l&&l({action:a,location:p.location,delta:0})}function _(y){let h=i.location.origin!=="null"?i.location.origin:i.location.href,v=typeof y=="string"?y:nl(y);return v=v.replace(/ $/,"%20"),Ue(h,"No window.location.(origin|href) available to create URL for href: "+v),new URL(v,h)}let p={get action(){return a},get location(){return e(i,o)},listen(y){if(l)throw new Error("A history only accepts one active listener");return i.addEventListener(G_,d),l=y,()=>{i.removeEventListener(G_,d),l=null}},createHref(y){return t(i,y)},createURL:_,encodeLocation(y){let h=_(y);return{pathname:h.pathname,search:h.search,hash:h.hash}},push:f,replace:m,go(y){return o.go(y)}};return p}var Q_;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Q_||(Q_={}));function CM(e,t,n){return n===void 0&&(n="/"),kM(e,t,n)}function kM(e,t,n,r){let i=typeof t=="string"?is(t):t,s=Po(i.pathname||"/",n);if(s==null)return null;let o=vS(e);PM(o);let a=null;for(let l=0;a==null&&l{let l={relativePath:a===void 0?s.path||"":a,caseSensitive:s.caseSensitive===!0,childrenIndex:o,route:s};l.relativePath.startsWith("/")&&(Ue(l.relativePath.startsWith(r),'Absolute route path "'+l.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),l.relativePath=l.relativePath.slice(r.length));let u=ii([r,l.relativePath]),c=n.concat(l);s.children&&s.children.length>0&&(Ue(s.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),vS(s.children,t,c,u)),!(s.path==null&&!s.index)&&t.push({path:u,score:NM(u,s.index),routesMeta:c})};return e.forEach((s,o)=>{var a;if(s.path===""||!((a=s.path)!=null&&a.includes("?")))i(s,o);else for(let l of gS(s.path))i(s,o,l)}),t}function gS(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let o=gS(r.join("/")),a=[];return a.push(...o.map(l=>l===""?s:[s,l].join("/"))),i&&a.push(...o),a.map(l=>e.startsWith("/")&&l===""?"/":l)}function PM(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:$M(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const RM=/^:[\w-]+$/,TM=3,IM=2,OM=1,MM=10,AM=-2,Y_=e=>e==="*";function NM(e,t){let n=e.split("/"),r=n.length;return n.some(Y_)&&(r+=AM),t&&(r+=IM),n.filter(i=>!Y_(i)).reduce((i,s)=>i+(RM.test(s)?TM:s===""?OM:MM),r)}function $M(e,t){return e.length===t.length&&e.slice(0,-1).every((r,i)=>r===t[i])?e[e.length-1]-t[t.length-1]:0}function FM(e,t,n){let{routesMeta:r}=e,i={},s="/",o=[];for(let a=0;a{let{paramName:f,isOptional:m}=c;if(f==="*"){let p=a[d]||"";o=s.slice(0,s.length-p.length).replace(/(.)\/+$/,"$1")}const _=a[d];return m&&!_?u[f]=void 0:u[f]=(_||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:o,pattern:e}}function LM(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),pd(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],i="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,a,l)=>(r.push({paramName:a,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),i+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":e!==""&&e!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,t?void 0:"i"),r]}function jM(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return pd(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Po(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const DM=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,zM=e=>DM.test(e);function UM(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:i=""}=typeof e=="string"?is(e):e,s;if(n)if(zM(n))s=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),pd(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?s=X_(n.substring(1),"/"):s=X_(n,t)}else s=t;return{pathname:s,search:qM(r),hash:WM(i)}}function X_(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function Uf(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function VM(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Ig(e,t){let n=VM(e);return t?n.map((r,i)=>i===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Og(e,t,n,r){r===void 0&&(r=!1);let i;typeof e=="string"?i=is(e):(i=tl({},e),Ue(!i.pathname||!i.pathname.includes("?"),Uf("?","pathname","search",i)),Ue(!i.pathname||!i.pathname.includes("#"),Uf("#","pathname","hash",i)),Ue(!i.search||!i.search.includes("#"),Uf("#","search","hash",i)));let s=e===""||i.pathname==="",o=s?"/":i.pathname,a;if(o==null)a=n;else{let d=t.length-1;if(!r&&o.startsWith("..")){let f=o.split("/");for(;f[0]==="..";)f.shift(),d-=1;i.pathname=f.join("/")}a=d>=0?t[d]:"/"}let l=UM(i,a),u=o&&o!=="/"&&o.endsWith("/"),c=(s||o===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(u||c)&&(l.pathname+="/"),l}const ii=e=>e.join("/").replace(/\/\/+/g,"/"),BM=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),qM=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,WM=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function HM(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const mS=["post","put","patch","delete"];new Set(mS);const GM=["get",...mS];new Set(GM);/** + */function tl(){return tl=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function pd(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function EM(){return Math.random().toString(36).substr(2,8)}function K_(e,t){return{usr:e.state,key:e.key,idx:t}}function $c(e,t,n,r){return n===void 0&&(n=null),tl({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?is(t):t,{state:n,key:t&&t.key||r||EM()})}function nl(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function is(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function pS(e,t,n,r){r===void 0&&(r={});let{window:i=document.defaultView,v5Compat:s=!1}=r,o=i.history,a=Qr.Pop,l=null,u=c();u==null&&(u=0,o.replaceState(tl({},o.state,{idx:u}),""));function c(){return(o.state||{idx:null}).idx}function d(){a=Qr.Pop;let y=c(),h=y==null?null:y-u;u=y,l&&l({action:a,location:p.location,delta:h})}function f(y,h){a=Qr.Push;let v=$c(p.location,y,h);n&&n(v,y),u=c()+1;let x=K_(v,u),b=p.createHref(v);try{o.pushState(x,"",b)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;i.location.assign(b)}s&&l&&l({action:a,location:p.location,delta:1})}function m(y,h){a=Qr.Replace;let v=$c(p.location,y,h);n&&n(v,y),u=c();let x=K_(v,u),b=p.createHref(v);o.replaceState(x,"",b),s&&l&&l({action:a,location:p.location,delta:0})}function _(y){let h=i.location.origin!=="null"?i.location.origin:i.location.href,v=typeof y=="string"?y:nl(y);return v=v.replace(/ $/,"%20"),Ue(h,"No window.location.(origin|href) available to create URL for href: "+v),new URL(v,h)}let p={get action(){return a},get location(){return e(i,o)},listen(y){if(l)throw new Error("A history only accepts one active listener");return i.addEventListener(G_,d),l=y,()=>{i.removeEventListener(G_,d),l=null}},createHref(y){return t(i,y)},createURL:_,encodeLocation(y){let h=_(y);return{pathname:h.pathname,search:h.search,hash:h.hash}},push:f,replace:m,go(y){return o.go(y)}};return p}var Q_;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Q_||(Q_={}));function SM(e,t,n){return n===void 0&&(n="/"),CM(e,t,n)}function CM(e,t,n,r){let i=typeof t=="string"?is(t):t,s=Po(i.pathname||"/",n);if(s==null)return null;let o=vS(e);kM(o);let a=null;for(let l=0;a==null&&l{let l={relativePath:a===void 0?s.path||"":a,caseSensitive:s.caseSensitive===!0,childrenIndex:o,route:s};l.relativePath.startsWith("/")&&(Ue(l.relativePath.startsWith(r),'Absolute route path "'+l.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),l.relativePath=l.relativePath.slice(r.length));let u=ii([r,l.relativePath]),c=n.concat(l);s.children&&s.children.length>0&&(Ue(s.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),vS(s.children,t,c,u)),!(s.path==null&&!s.index)&&t.push({path:u,score:AM(u,s.index),routesMeta:c})};return e.forEach((s,o)=>{var a;if(s.path===""||!((a=s.path)!=null&&a.includes("?")))i(s,o);else for(let l of gS(s.path))i(s,o,l)}),t}function gS(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let o=gS(r.join("/")),a=[];return a.push(...o.map(l=>l===""?s:[s,l].join("/"))),i&&a.push(...o),a.map(l=>e.startsWith("/")&&l===""?"/":l)}function kM(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:NM(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const PM=/^:[\w-]+$/,RM=3,TM=2,IM=1,OM=10,MM=-2,Y_=e=>e==="*";function AM(e,t){let n=e.split("/"),r=n.length;return n.some(Y_)&&(r+=MM),t&&(r+=TM),n.filter(i=>!Y_(i)).reduce((i,s)=>i+(PM.test(s)?RM:s===""?IM:OM),r)}function NM(e,t){return e.length===t.length&&e.slice(0,-1).every((r,i)=>r===t[i])?e[e.length-1]-t[t.length-1]:0}function $M(e,t,n){let{routesMeta:r}=e,i={},s="/",o=[];for(let a=0;a{let{paramName:f,isOptional:m}=c;if(f==="*"){let p=a[d]||"";o=s.slice(0,s.length-p.length).replace(/(.)\/+$/,"$1")}const _=a[d];return m&&!_?u[f]=void 0:u[f]=(_||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:o,pattern:e}}function FM(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),pd(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],i="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,a,l)=>(r.push({paramName:a,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),i+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":e!==""&&e!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,t?void 0:"i"),r]}function LM(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return pd(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Po(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const jM=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,DM=e=>jM.test(e);function zM(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:i=""}=typeof e=="string"?is(e):e,s;if(n)if(DM(n))s=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),pd(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?s=X_(n.substring(1),"/"):s=X_(n,t)}else s=t;return{pathname:s,search:BM(r),hash:qM(i)}}function X_(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function Uf(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function UM(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Ig(e,t){let n=UM(e);return t?n.map((r,i)=>i===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Og(e,t,n,r){r===void 0&&(r=!1);let i;typeof e=="string"?i=is(e):(i=tl({},e),Ue(!i.pathname||!i.pathname.includes("?"),Uf("?","pathname","search",i)),Ue(!i.pathname||!i.pathname.includes("#"),Uf("#","pathname","hash",i)),Ue(!i.search||!i.search.includes("#"),Uf("#","search","hash",i)));let s=e===""||i.pathname==="",o=s?"/":i.pathname,a;if(o==null)a=n;else{let d=t.length-1;if(!r&&o.startsWith("..")){let f=o.split("/");for(;f[0]==="..";)f.shift(),d-=1;i.pathname=f.join("/")}a=d>=0?t[d]:"/"}let l=zM(i,a),u=o&&o!=="/"&&o.endsWith("/"),c=(s||o===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(u||c)&&(l.pathname+="/"),l}const ii=e=>e.join("/").replace(/\/\/+/g,"/"),VM=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),BM=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,qM=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function WM(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const mS=["post","put","patch","delete"];new Set(mS);const HM=["get",...mS];new Set(HM);/** * React Router v6.30.3 * * Copyright (c) Remix Software Inc. @@ -58,7 +58,7 @@ Error generating stack: `+s.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function rl(){return rl=Object.assign?Object.assign.bind():function(e){for(var t=1;t{a.current=!0}),g.useCallback(function(u,c){if(c===void 0&&(c={}),!a.current)return;if(typeof u=="number"){r.go(u);return}let d=Og(u,JSON.parse(o),s,c.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:ii([t,d.pathname])),(c.replace?r.replace:r.push)(d,c.state,c)},[t,r,o,s,e])}const YM=g.createContext(null);function XM(e){let t=g.useContext(Gn).outlet;return t&&g.createElement(YM.Provider,{value:e},t)}function xS(){let{matches:e}=g.useContext(Gn),t=e[e.length-1];return t?t.params:{}}function md(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=g.useContext(xr),{matches:i}=g.useContext(Gn),{pathname:s}=hn(),o=JSON.stringify(Ig(i,r.v7_relativeSplatPath));return g.useMemo(()=>Og(e,JSON.parse(o),s,n==="path"),[e,o,s,n])}function JM(e,t){return ZM(e,t)}function ZM(e,t,n,r){No()||Ue(!1);let{navigator:i}=g.useContext(xr),{matches:s}=g.useContext(Gn),o=s[s.length-1],a=o?o.params:{};o&&o.pathname;let l=o?o.pathnameBase:"/";o&&o.route;let u=hn(),c;if(t){var d;let y=typeof t=="string"?is(t):t;l==="/"||(d=y.pathname)!=null&&d.startsWith(l)||Ue(!1),c=y}else c=u;let f=c.pathname||"/",m=f;if(l!=="/"){let y=l.replace(/^\//,"").split("/");m="/"+f.replace(/^\//,"").split("/").slice(y.length).join("/")}let _=CM(e,{pathname:m}),p=iA(_&&_.map(y=>Object.assign({},y,{params:Object.assign({},a,y.params),pathname:ii([l,i.encodeLocation?i.encodeLocation(y.pathname).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?l:ii([l,i.encodeLocation?i.encodeLocation(y.pathnameBase).pathname:y.pathnameBase])})),s,n,r);return t&&p?g.createElement(gd.Provider,{value:{location:rl({pathname:"/",search:"",hash:"",state:null,key:"default"},c),navigationType:Qr.Pop}},p):p}function eA(){let e=lA(),t=HM(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,i={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},t),n?g.createElement("pre",{style:i},n):null,null)}const tA=g.createElement(eA,null);class nA extends g.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?g.createElement(Gn.Provider,{value:this.props.routeContext},g.createElement(_S.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function rA(e){let{routeContext:t,match:n,children:r}=e,i=g.useContext(vd);return i&&i.static&&i.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(Gn.Provider,{value:t},r)}function iA(e,t,n,r){var i;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var s;if(!n)return null;if(n.errors)e=n.matches;else if((s=r)!=null&&s.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,a=(i=n)==null?void 0:i.errors;if(a!=null){let c=o.findIndex(d=>d.route.id&&(a==null?void 0:a[d.route.id])!==void 0);c>=0||Ue(!1),o=o.slice(0,Math.min(o.length,c+1))}let l=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let c=0;c=0?o=o.slice(0,u+1):o=[o[0]];break}}}return o.reduceRight((c,d,f)=>{let m,_=!1,p=null,y=null;n&&(m=a&&d.route.id?a[d.route.id]:void 0,p=d.route.errorElement||tA,l&&(u<0&&f===0?(cA("route-fallback"),_=!0,y=null):u===f&&(_=!0,y=d.route.hydrateFallbackElement||null)));let h=t.concat(o.slice(0,f+1)),v=()=>{let x;return m?x=p:_?x=y:d.route.Component?x=g.createElement(d.route.Component,null):d.route.element?x=d.route.element:x=c,g.createElement(rA,{match:d,routeContext:{outlet:c,matches:h,isDataRoute:n!=null},children:x})};return n&&(d.route.ErrorBoundary||d.route.errorElement||f===0)?g.createElement(nA,{location:n.location,revalidation:n.revalidation,component:p,error:m,children:v(),routeContext:{outlet:null,matches:h,isDataRoute:!0}}):v()},null)}var bS=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(bS||{}),ES=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(ES||{});function sA(e){let t=g.useContext(vd);return t||Ue(!1),t}function oA(e){let t=g.useContext(yS);return t||Ue(!1),t}function aA(e){let t=g.useContext(Gn);return t||Ue(!1),t}function SS(e){let t=aA(),n=t.matches[t.matches.length-1];return n.route.id||Ue(!1),n.route.id}function lA(){var e;let t=g.useContext(_S),n=oA(),r=SS();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function uA(){let{router:e}=sA(bS.UseNavigateStable),t=SS(ES.UseNavigateStable),n=g.useRef(!1);return wS(()=>{n.current=!0}),g.useCallback(function(i,s){s===void 0&&(s={}),n.current&&(typeof i=="number"?e.navigate(i):e.navigate(i,rl({fromRouteId:t},s)))},[e,t])}const J_={};function cA(e,t,n){J_[e]||(J_[e]=!0)}function CS(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function Ro(e){let{to:t,replace:n,state:r,relative:i}=e;No()||Ue(!1);let{future:s,static:o}=g.useContext(xr),{matches:a}=g.useContext(Gn),{pathname:l}=hn(),u=Mg(),c=Og(t,Ig(a,s.v7_relativeSplatPath),l,i==="path"),d=JSON.stringify(c);return g.useEffect(()=>u(JSON.parse(d),{replace:n,state:r,relative:i}),[u,d,i,n,r]),null}function dA(e){return XM(e.context)}function re(e){Ue(!1)}function kS(e){let{basename:t="/",children:n=null,location:r,navigationType:i=Qr.Pop,navigator:s,static:o=!1,future:a}=e;No()&&Ue(!1);let l=t.replace(/^\/*/,"/"),u=g.useMemo(()=>({basename:l,navigator:s,static:o,future:rl({v7_relativeSplatPath:!1},a)}),[l,a,s,o]);typeof r=="string"&&(r=is(r));let{pathname:c="/",search:d="",hash:f="",state:m=null,key:_="default"}=r,p=g.useMemo(()=>{let y=Po(c,l);return y==null?null:{location:{pathname:y,search:d,hash:f,state:m,key:_},navigationType:i}},[l,c,d,f,m,_,i]);return p==null?null:g.createElement(xr.Provider,{value:u},g.createElement(gd.Provider,{children:n,value:p}))}function fA(e){let{children:t,location:n}=e;return JM(Lp(t),n)}new Promise(()=>{});function Lp(e,t){t===void 0&&(t=[]);let n=[];return g.Children.forEach(e,(r,i)=>{if(!g.isValidElement(r))return;let s=[...t,i];if(r.type===g.Fragment){n.push.apply(n,Lp(r.props.children,s));return}r.type!==re&&Ue(!1),!r.props.index||!r.props.children||Ue(!1);let o={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Lp(r.props.children,s)),n.push(o)}),n}/** + */function rl(){return rl=Object.assign?Object.assign.bind():function(e){for(var t=1;t{a.current=!0}),g.useCallback(function(u,c){if(c===void 0&&(c={}),!a.current)return;if(typeof u=="number"){r.go(u);return}let d=Og(u,JSON.parse(o),s,c.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:ii([t,d.pathname])),(c.replace?r.replace:r.push)(d,c.state,c)},[t,r,o,s,e])}const QM=g.createContext(null);function YM(e){let t=g.useContext(Gn).outlet;return t&&g.createElement(QM.Provider,{value:e},t)}function xS(){let{matches:e}=g.useContext(Gn),t=e[e.length-1];return t?t.params:{}}function md(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=g.useContext(xr),{matches:i}=g.useContext(Gn),{pathname:s}=hn(),o=JSON.stringify(Ig(i,r.v7_relativeSplatPath));return g.useMemo(()=>Og(e,JSON.parse(o),s,n==="path"),[e,o,s,n])}function XM(e,t){return JM(e,t)}function JM(e,t,n,r){No()||Ue(!1);let{navigator:i}=g.useContext(xr),{matches:s}=g.useContext(Gn),o=s[s.length-1],a=o?o.params:{};o&&o.pathname;let l=o?o.pathnameBase:"/";o&&o.route;let u=hn(),c;if(t){var d;let y=typeof t=="string"?is(t):t;l==="/"||(d=y.pathname)!=null&&d.startsWith(l)||Ue(!1),c=y}else c=u;let f=c.pathname||"/",m=f;if(l!=="/"){let y=l.replace(/^\//,"").split("/");m="/"+f.replace(/^\//,"").split("/").slice(y.length).join("/")}let _=SM(e,{pathname:m}),p=rA(_&&_.map(y=>Object.assign({},y,{params:Object.assign({},a,y.params),pathname:ii([l,i.encodeLocation?i.encodeLocation(y.pathname).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?l:ii([l,i.encodeLocation?i.encodeLocation(y.pathnameBase).pathname:y.pathnameBase])})),s,n,r);return t&&p?g.createElement(gd.Provider,{value:{location:rl({pathname:"/",search:"",hash:"",state:null,key:"default"},c),navigationType:Qr.Pop}},p):p}function ZM(){let e=aA(),t=WM(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,i={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},t),n?g.createElement("pre",{style:i},n):null,null)}const eA=g.createElement(ZM,null);class tA extends g.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?g.createElement(Gn.Provider,{value:this.props.routeContext},g.createElement(_S.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function nA(e){let{routeContext:t,match:n,children:r}=e,i=g.useContext(vd);return i&&i.static&&i.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(Gn.Provider,{value:t},r)}function rA(e,t,n,r){var i;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var s;if(!n)return null;if(n.errors)e=n.matches;else if((s=r)!=null&&s.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,a=(i=n)==null?void 0:i.errors;if(a!=null){let c=o.findIndex(d=>d.route.id&&(a==null?void 0:a[d.route.id])!==void 0);c>=0||Ue(!1),o=o.slice(0,Math.min(o.length,c+1))}let l=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let c=0;c=0?o=o.slice(0,u+1):o=[o[0]];break}}}return o.reduceRight((c,d,f)=>{let m,_=!1,p=null,y=null;n&&(m=a&&d.route.id?a[d.route.id]:void 0,p=d.route.errorElement||eA,l&&(u<0&&f===0?(uA("route-fallback"),_=!0,y=null):u===f&&(_=!0,y=d.route.hydrateFallbackElement||null)));let h=t.concat(o.slice(0,f+1)),v=()=>{let x;return m?x=p:_?x=y:d.route.Component?x=g.createElement(d.route.Component,null):d.route.element?x=d.route.element:x=c,g.createElement(nA,{match:d,routeContext:{outlet:c,matches:h,isDataRoute:n!=null},children:x})};return n&&(d.route.ErrorBoundary||d.route.errorElement||f===0)?g.createElement(tA,{location:n.location,revalidation:n.revalidation,component:p,error:m,children:v(),routeContext:{outlet:null,matches:h,isDataRoute:!0}}):v()},null)}var bS=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(bS||{}),ES=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(ES||{});function iA(e){let t=g.useContext(vd);return t||Ue(!1),t}function sA(e){let t=g.useContext(yS);return t||Ue(!1),t}function oA(e){let t=g.useContext(Gn);return t||Ue(!1),t}function SS(e){let t=oA(),n=t.matches[t.matches.length-1];return n.route.id||Ue(!1),n.route.id}function aA(){var e;let t=g.useContext(_S),n=sA(),r=SS();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function lA(){let{router:e}=iA(bS.UseNavigateStable),t=SS(ES.UseNavigateStable),n=g.useRef(!1);return wS(()=>{n.current=!0}),g.useCallback(function(i,s){s===void 0&&(s={}),n.current&&(typeof i=="number"?e.navigate(i):e.navigate(i,rl({fromRouteId:t},s)))},[e,t])}const J_={};function uA(e,t,n){J_[e]||(J_[e]=!0)}function CS(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function Ro(e){let{to:t,replace:n,state:r,relative:i}=e;No()||Ue(!1);let{future:s,static:o}=g.useContext(xr),{matches:a}=g.useContext(Gn),{pathname:l}=hn(),u=Mg(),c=Og(t,Ig(a,s.v7_relativeSplatPath),l,i==="path"),d=JSON.stringify(c);return g.useEffect(()=>u(JSON.parse(d),{replace:n,state:r,relative:i}),[u,d,i,n,r]),null}function cA(e){return YM(e.context)}function re(e){Ue(!1)}function kS(e){let{basename:t="/",children:n=null,location:r,navigationType:i=Qr.Pop,navigator:s,static:o=!1,future:a}=e;No()&&Ue(!1);let l=t.replace(/^\/*/,"/"),u=g.useMemo(()=>({basename:l,navigator:s,static:o,future:rl({v7_relativeSplatPath:!1},a)}),[l,a,s,o]);typeof r=="string"&&(r=is(r));let{pathname:c="/",search:d="",hash:f="",state:m=null,key:_="default"}=r,p=g.useMemo(()=>{let y=Po(c,l);return y==null?null:{location:{pathname:y,search:d,hash:f,state:m,key:_},navigationType:i}},[l,c,d,f,m,_,i]);return p==null?null:g.createElement(xr.Provider,{value:u},g.createElement(gd.Provider,{children:n,value:p}))}function dA(e){let{children:t,location:n}=e;return XM(Lp(t),n)}new Promise(()=>{});function Lp(e,t){t===void 0&&(t=[]);let n=[];return g.Children.forEach(e,(r,i)=>{if(!g.isValidElement(r))return;let s=[...t,i];if(r.type===g.Fragment){n.push.apply(n,Lp(r.props.children,s));return}r.type!==re&&Ue(!1),!r.props.index||!r.props.children||Ue(!1);let o={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Lp(r.props.children,s)),n.push(o)}),n}/** * React Router DOM v6.30.3 * * Copyright (c) Remix Software Inc. @@ -67,8 +67,8 @@ Error generating stack: `+s.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function Fc(){return Fc=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[i]=e[i]);return n}function hA(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function pA(e,t){return e.button===0&&(!t||t==="_self")&&!hA(e)}function jp(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function vA(e,t){let n=jp(e);return t&&t.forEach((r,i)=>{n.has(i)||t.getAll(i).forEach(s=>{n.append(i,s)})}),n}const gA=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],mA=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],yA="6";try{window.__reactRouterVersion=yA}catch{}const _A=g.createContext({isTransitioning:!1}),wA="startTransition",Lc=Kc[wA];function xA(e){let{basename:t,children:n,future:r,window:i}=e,s=g.useRef();s.current==null&&(s.current=bM({window:i,v5Compat:!0}));let o=s.current,[a,l]=g.useState({action:o.action,location:o.location}),{v7_startTransition:u}=r||{},c=g.useCallback(d=>{u&&Lc?Lc(()=>l(d)):l(d)},[l,u]);return g.useLayoutEffect(()=>o.listen(c),[o,c]),g.useEffect(()=>CS(r),[r]),g.createElement(kS,{basename:t,children:n,location:a.location,navigationType:a.action,navigator:o,future:r})}function bA(e){let{basename:t,children:n,future:r,window:i}=e,s=g.useRef();s.current==null&&(s.current=EM({window:i,v5Compat:!0}));let o=s.current,[a,l]=g.useState({action:o.action,location:o.location}),{v7_startTransition:u}=r||{},c=g.useCallback(d=>{u&&Lc?Lc(()=>l(d)):l(d)},[l,u]);return g.useLayoutEffect(()=>o.listen(c),[o,c]),g.useEffect(()=>CS(r),[r]),g.createElement(kS,{basename:t,children:n,location:a.location,navigationType:a.action,navigator:o,future:r})}const EA=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",SA=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,bn=g.forwardRef(function(t,n){let{onClick:r,relative:i,reloadDocument:s,replace:o,state:a,target:l,to:u,preventScrollReset:c,viewTransition:d}=t,f=PS(t,gA),{basename:m}=g.useContext(xr),_,p=!1;if(typeof u=="string"&&SA.test(u)&&(_=u,EA))try{let x=new URL(window.location.href),b=u.startsWith("//")?new URL(x.protocol+u):new URL(u),E=Po(b.pathname,m);b.origin===x.origin&&E!=null?u=E+b.search+b.hash:p=!0}catch{}let y=KM(u,{relative:i}),h=kA(u,{replace:o,state:a,target:l,preventScrollReset:c,relative:i,viewTransition:d});function v(x){r&&r(x),x.defaultPrevented||h(x)}return g.createElement("a",Fc({},f,{href:_||y,onClick:p||s?r:v,ref:n,target:l}))}),ms=g.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:i=!1,className:s="",end:o=!1,style:a,to:l,viewTransition:u,children:c}=t,d=PS(t,mA),f=md(l,{relative:d.relative}),m=hn(),_=g.useContext(yS),{navigator:p,basename:y}=g.useContext(xr),h=_!=null&&PA(f)&&u===!0,v=p.encodeLocation?p.encodeLocation(f).pathname:f.pathname,x=m.pathname,b=_&&_.navigation&&_.navigation.location?_.navigation.location.pathname:null;i||(x=x.toLowerCase(),b=b?b.toLowerCase():null,v=v.toLowerCase()),b&&y&&(b=Po(b,y)||b);const E=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let S=x===v||!o&&x.startsWith(v)&&x.charAt(E)==="/",P=b!=null&&(b===v||!o&&b.startsWith(v)&&b.charAt(v.length)==="/"),C={isActive:S,isPending:P,isTransitioning:h},T=S?r:void 0,R;typeof s=="function"?R=s(C):R=[s,S?"active":null,P?"pending":null,h?"transitioning":null].filter(Boolean).join(" ");let N=typeof a=="function"?a(C):a;return g.createElement(bn,Fc({},d,{"aria-current":T,className:R,ref:n,style:N,to:l,viewTransition:u}),typeof c=="function"?c(C):c)});var Dp;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Dp||(Dp={}));var Z_;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Z_||(Z_={}));function CA(e){let t=g.useContext(vd);return t||Ue(!1),t}function kA(e,t){let{target:n,replace:r,state:i,preventScrollReset:s,relative:o,viewTransition:a}=t===void 0?{}:t,l=Mg(),u=hn(),c=md(e,{relative:o});return g.useCallback(d=>{if(pA(d,n)){d.preventDefault();let f=r!==void 0?r:nl(u)===nl(c);l(e,{replace:f,state:i,preventScrollReset:s,relative:o,viewTransition:a})}},[u,l,c,r,i,n,e,s,o,a])}function iz(e){let t=g.useRef(jp(e)),n=g.useRef(!1),r=hn(),i=g.useMemo(()=>vA(r.search,n.current?null:t.current),[r.search]),s=Mg(),o=g.useCallback((a,l)=>{const u=jp(typeof a=="function"?a(i):a);n.current=!0,s("?"+u,l)},[s,i]);return[i,o]}function PA(e,t){t===void 0&&(t={});let n=g.useContext(_A);n==null&&Ue(!1);let{basename:r}=CA(Dp.useViewTransitionState),i=md(e,{relative:t.relative});if(!n.isTransitioning)return!1;let s=Po(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Po(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Fp(i.pathname,o)!=null||Fp(i.pathname,s)!=null}var El=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},$i,Dr,Zs,X0,RA=(X0=class extends El{constructor(){super();X(this,$i);X(this,Dr);X(this,Zs);H(this,Zs,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){k(this,Dr)||this.setEventListener(k(this,Zs))}onUnsubscribe(){var t;this.hasListeners()||((t=k(this,Dr))==null||t.call(this),H(this,Dr,void 0))}setEventListener(t){var n;H(this,Zs,t),(n=k(this,Dr))==null||n.call(this),H(this,Dr,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){k(this,$i)!==t&&(H(this,$i,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof k(this,$i)=="boolean"?k(this,$i):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},$i=new WeakMap,Dr=new WeakMap,Zs=new WeakMap,X0),Ag=new RA,TA={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},zr,vv,J0,IA=(J0=class{constructor(){X(this,zr,TA);X(this,vv,!1)}setTimeoutProvider(e){H(this,zr,e)}setTimeout(e,t){return k(this,zr).setTimeout(e,t)}clearTimeout(e){k(this,zr).clearTimeout(e)}setInterval(e,t){return k(this,zr).setInterval(e,t)}clearInterval(e){k(this,zr).clearInterval(e)}},zr=new WeakMap,vv=new WeakMap,J0),Ni=new IA;function OA(e){setTimeout(e,0)}var MA=typeof window>"u"||"Deno"in globalThis;function At(){}function AA(e,t){return typeof e=="function"?e(t):e}function zp(e){return typeof e=="number"&&e>=0&&e!==1/0}function RS(e,t){return Math.max(e+(t||0)-Date.now(),0)}function si(e,t){return typeof e=="function"?e(t):e}function Wt(e,t){return typeof e=="function"?e(t):e}function e0(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:a}=e;if(o){if(r){if(t.queryHash!==Ng(o,t.options))return!1}else if(!sl(t.queryKey,o))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||i&&i!==t.state.fetchStatus||s&&!s(t))}function t0(e,t){const{exact:n,status:r,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(il(t.options.mutationKey)!==il(s))return!1}else if(!sl(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Ng(e,t){return((t==null?void 0:t.queryKeyHashFn)||il)(e)}function il(e){return JSON.stringify(e,(t,n)=>Vp(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function sl(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>sl(e[n],t[n])):!1}var NA=Object.prototype.hasOwnProperty;function TS(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=n0(e)&&n0(t);if(!r&&!(Vp(e)&&Vp(t)))return t;const s=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),a=o.length,l=r?new Array(a):{};let u=0;for(let c=0;c{Ni.setTimeout(t,e)})}function Bp(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?TS(e,t):t}function FA(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function LA(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var $g=Symbol();function IS(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===$g?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function OS(e,t){return typeof e=="function"?e(...t):!!e}function jA(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??(i=t()),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),e}var ol=(()=>{let e=()=>MA;return{isServer(){return e()},setIsServer(t){e=t}}})();function qp(){let e,t;const n=new Promise((i,s)=>{e=i,t=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},n.reject=i=>{r({status:"rejected",reason:i}),t(i)},n}var DA=OA;function zA(){let e=[],t=0,n=a=>{a()},r=a=>{a()},i=DA;const s=a=>{t?e.push(a):i(()=>{n(a)})},o=()=>{const a=e;e=[],a.length&&i(()=>{r(()=>{a.forEach(l=>{n(l)})})})};return{batch:a=>{let l;t++;try{l=a()}finally{t--,t||o()}return l},batchCalls:a=>(...l)=>{s(()=>{a(...l)})},schedule:s,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{i=a}}}var at=zA(),eo,Ur,to,Z0,UA=(Z0=class extends El{constructor(){super();X(this,eo,!0);X(this,Ur);X(this,to);H(this,to,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){k(this,Ur)||this.setEventListener(k(this,to))}onUnsubscribe(){var t;this.hasListeners()||((t=k(this,Ur))==null||t.call(this),H(this,Ur,void 0))}setEventListener(t){var n;H(this,to,t),(n=k(this,Ur))==null||n.call(this),H(this,Ur,t(this.setOnline.bind(this)))}setOnline(t){k(this,eo)!==t&&(H(this,eo,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return k(this,eo)}},eo=new WeakMap,Ur=new WeakMap,to=new WeakMap,Z0),jc=new UA;function VA(e){return Math.min(1e3*2**e,3e4)}function MS(e){return(e??"online")==="online"?jc.isOnline():!0}var Wp=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function AS(e){let t=!1,n=0,r;const i=qp(),s=()=>i.status!=="pending",o=p=>{var y;if(!s()){const h=new Wp(p);f(h),(y=e.onCancel)==null||y.call(e,h)}},a=()=>{t=!0},l=()=>{t=!1},u=()=>Ag.isFocused()&&(e.networkMode==="always"||jc.isOnline())&&e.canRun(),c=()=>MS(e.networkMode)&&e.canRun(),d=p=>{s()||(r==null||r(),i.resolve(p))},f=p=>{s()||(r==null||r(),i.reject(p))},m=()=>new Promise(p=>{var y;r=h=>{(s()||u())&&p(h)},(y=e.onPause)==null||y.call(e)}).then(()=>{var p;r=void 0,s()||(p=e.onContinue)==null||p.call(e)}),_=()=>{if(s())return;let p;const y=n===0?e.initialPromise:void 0;try{p=y??e.fn()}catch(h){p=Promise.reject(h)}Promise.resolve(p).then(d).catch(h=>{var S;if(s())return;const v=e.retry??(ol.isServer()?0:3),x=e.retryDelay??VA,b=typeof x=="function"?x(n,h):x,E=v===!0||typeof v=="number"&&nu()?void 0:m()).then(()=>{t?f(h):_()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r==null||r(),i),cancelRetry:a,continueRetry:l,canStart:c,start:()=>(c()?_():m().then(_),i)}}var Fi,ew,NS=(ew=class{constructor(){X(this,Fi)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),zp(this.gcTime)&&H(this,Fi,Ni.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ol.isServer()?1/0:5*60*1e3))}clearGcTimeout(){k(this,Fi)!==void 0&&(Ni.clearTimeout(k(this,Fi)),H(this,Fi,void 0))}},Fi=new WeakMap,ew);function BA(e){return{onFetch:(t,n)=>{var c,d,f,m,_;const r=t.options,i=(f=(d=(c=t.fetchOptions)==null?void 0:c.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,s=((m=t.state.data)==null?void 0:m.pages)||[],o=((_=t.state.data)==null?void 0:_.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const u=async()=>{let p=!1;const y=x=>{jA(x,()=>t.signal,()=>p=!0)},h=IS(t.options,t.fetchOptions),v=async(x,b,E)=>{if(p)return Promise.reject(t.signal.reason);if(b==null&&x.pages.length)return Promise.resolve(x);const P=(()=>{const N={client:t.client,queryKey:t.queryKey,pageParam:b,direction:E?"backward":"forward",meta:t.options.meta};return y(N),N})(),C=await h(P),{maxPages:T}=t.options,R=E?LA:FA;return{pages:R(x.pages,C,T),pageParams:R(x.pageParams,b,T)}};if(i&&s.length){const x=i==="backward",b=x?$S:Hp,E={pages:s,pageParams:o},S=b(r,E);a=await v(E,S,x)}else{const x=e??s.length;do{const b=l===0?o[0]??r.initialPageParam:Hp(r,a);if(l>0&&b==null)break;a=await v(a,b),l++}while(l{var p,y;return(y=(p=t.options).persister)==null?void 0:y.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Hp(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function $S(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}function sz(e,t){return t?Hp(e,t)!=null:!1}function oz(e,t){return!t||!e.getPreviousPageParam?!1:$S(e,t)!=null}var no,Li,ro,nn,ji,tt,dl,Di,Bt,FS,Zn,tw,qA=(tw=class extends NS{constructor(t){super();X(this,Bt);X(this,no);X(this,Li);X(this,ro);X(this,nn);X(this,ji);X(this,tt);X(this,dl);X(this,Di);H(this,Di,!1),H(this,dl,t.defaultOptions),this.setOptions(t.options),this.observers=[],H(this,ji,t.client),H(this,nn,k(this,ji).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,H(this,Li,s0(this.options)),this.state=t.state??k(this,Li),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return k(this,no)}get promise(){var t;return(t=k(this,tt))==null?void 0:t.promise}setOptions(t){if(this.options={...k(this,dl),...t},t!=null&&t._type&&H(this,no,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=s0(this.options);n.data!==void 0&&(this.setState(i0(n.data,n.dataUpdatedAt)),H(this,Li,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&k(this,nn).remove(this)}setData(t,n){const r=Bp(this.state.data,t,this.options);return ue(this,Bt,Zn).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){ue(this,Bt,Zn).call(this,{type:"setState",state:t})}cancel(t){var r,i;const n=(r=k(this,tt))==null?void 0:r.promise;return(i=k(this,tt))==null||i.cancel(t),n?n.then(At).catch(At):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return k(this,Li)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Wt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===$g||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>si(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!RS(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=k(this,tt))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=k(this,tt))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),k(this,nn).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(k(this,tt)&&(k(this,Di)||ue(this,Bt,FS).call(this)?k(this,tt).cancel({revert:!0}):k(this,tt).cancelRetry()),this.scheduleGc()),k(this,nn).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ue(this,Bt,Zn).call(this,{type:"invalidate"})}async fetch(t,n){var u,c,d,f,m,_,p,y,h,v,x;if(this.state.fetchStatus!=="idle"&&((u=k(this,tt))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(k(this,tt))return k(this,tt).continueRetry(),k(this,tt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const b=this.observers.find(E=>E.options.queryFn);b&&this.setOptions(b.options)}const r=new AbortController,i=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(H(this,Di,!0),r.signal)})},s=()=>{const b=IS(this.options,n),S=(()=>{const P={client:k(this,ji),queryKey:this.queryKey,meta:this.meta};return i(P),P})();return H(this,Di,!1),this.options.persister?this.options.persister(b,S,this):b(S)},a=(()=>{const b={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:k(this,ji),state:this.state,fetchFn:s};return i(b),b})(),l=k(this,no)==="infinite"?BA(this.options.pages):this.options.behavior;l==null||l.onFetch(a,this),H(this,ro,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((c=a.fetchOptions)==null?void 0:c.meta))&&ue(this,Bt,Zn).call(this,{type:"fetch",meta:(d=a.fetchOptions)==null?void 0:d.meta}),H(this,tt,AS({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:b=>{b instanceof Wp&&b.revert&&this.setState({...k(this,ro),fetchStatus:"idle"}),r.abort()},onFail:(b,E)=>{ue(this,Bt,Zn).call(this,{type:"failed",failureCount:b,error:E})},onPause:()=>{ue(this,Bt,Zn).call(this,{type:"pause"})},onContinue:()=>{ue(this,Bt,Zn).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const b=await k(this,tt).start();if(b===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(b),(m=(f=k(this,nn).config).onSuccess)==null||m.call(f,b,this),(p=(_=k(this,nn).config).onSettled)==null||p.call(_,b,this.state.error,this),b}catch(b){if(b instanceof Wp){if(b.silent)return k(this,tt).promise;if(b.revert){if(this.state.data===void 0)throw b;return this.state.data}}throw ue(this,Bt,Zn).call(this,{type:"error",error:b}),(h=(y=k(this,nn).config).onError)==null||h.call(y,b,this),(x=(v=k(this,nn).config).onSettled)==null||x.call(v,this.state.data,b,this),b}finally{this.scheduleGc()}}},no=new WeakMap,Li=new WeakMap,ro=new WeakMap,nn=new WeakMap,ji=new WeakMap,tt=new WeakMap,dl=new WeakMap,Di=new WeakMap,Bt=new WeakSet,FS=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Zn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...LS(r.data,this.options),fetchMeta:t.meta??null};case"success":const i={...r,...i0(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return H(this,ro,t.manual?i:void 0),i;case"error":const s=t.error;return{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),at.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),k(this,nn).notify({query:this,type:"updated",action:t})})},tw);function LS(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:MS(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function i0(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function s0(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Ot,fe,fl,xt,zi,io,sr,Vr,hl,so,oo,Ui,Vi,Br,ao,me,ha,Gp,Kp,Qp,Yp,Xp,Jp,Zp,jS,nw,WA=(nw=class extends El{constructor(t,n){super();X(this,me);X(this,Ot);X(this,fe);X(this,fl);X(this,xt);X(this,zi);X(this,io);X(this,sr);X(this,Vr);X(this,hl);X(this,so);X(this,oo);X(this,Ui);X(this,Vi);X(this,Br);X(this,ao,new Set);this.options=n,H(this,Ot,t),H(this,Vr,null),H(this,sr,qp()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(k(this,fe).addObserver(this),o0(k(this,fe),this.options)?ue(this,me,ha).call(this):this.updateResult(),ue(this,me,Yp).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ev(k(this,fe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ev(k(this,fe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ue(this,me,Xp).call(this),ue(this,me,Jp).call(this),k(this,fe).removeObserver(this)}setOptions(t){const n=this.options,r=k(this,fe);if(this.options=k(this,Ot).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Wt(this.options.enabled,k(this,fe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ue(this,me,Zp).call(this),k(this,fe).setOptions(this.options),n._defaulted&&!Up(this.options,n)&&k(this,Ot).getQueryCache().notify({type:"observerOptionsUpdated",query:k(this,fe),observer:this});const i=this.hasListeners();i&&a0(k(this,fe),r,this.options,n)&&ue(this,me,ha).call(this),this.updateResult(),i&&(k(this,fe)!==r||Wt(this.options.enabled,k(this,fe))!==Wt(n.enabled,k(this,fe))||si(this.options.staleTime,k(this,fe))!==si(n.staleTime,k(this,fe)))&&ue(this,me,Gp).call(this);const s=ue(this,me,Kp).call(this);i&&(k(this,fe)!==r||Wt(this.options.enabled,k(this,fe))!==Wt(n.enabled,k(this,fe))||s!==k(this,Br))&&ue(this,me,Qp).call(this,s)}getOptimisticResult(t){const n=k(this,Ot).getQueryCache().build(k(this,Ot),t),r=this.createResult(n,t);return GA(this,r)&&(H(this,xt,r),H(this,io,this.options),H(this,zi,k(this,fe).state)),r}getCurrentResult(){return k(this,xt)}trackResult(t,n){return new Proxy(t,{get:(r,i)=>(this.trackProp(i),n==null||n(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&k(this,sr).status==="pending"&&k(this,sr).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,i))})}trackProp(t){k(this,ao).add(t)}getCurrentQuery(){return k(this,fe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=k(this,Ot).defaultQueryOptions(t),r=k(this,Ot).getQueryCache().build(k(this,Ot),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return ue(this,me,ha).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),k(this,xt)))}createResult(t,n){var T;const r=k(this,fe),i=this.options,s=k(this,xt),o=k(this,zi),a=k(this,io),u=t!==r?t.state:k(this,fl),{state:c}=t;let d={...c},f=!1,m;if(n._optimisticResults){const R=this.hasListeners(),N=!R&&o0(t,n),M=R&&a0(t,r,n,i);(N||M)&&(d={...d,...LS(c.data,t.options)}),n._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:_,errorUpdatedAt:p,status:y}=d;m=d.data;let h=!1;if(n.placeholderData!==void 0&&m===void 0&&y==="pending"){let R;s!=null&&s.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(R=s.data,h=!0):R=typeof n.placeholderData=="function"?n.placeholderData((T=k(this,oo))==null?void 0:T.state.data,k(this,oo)):n.placeholderData,R!==void 0&&(y="success",m=Bp(s==null?void 0:s.data,R,n),f=!0)}if(n.select&&m!==void 0&&!h)if(s&&m===(o==null?void 0:o.data)&&n.select===k(this,hl))m=k(this,so);else try{H(this,hl,n.select),m=n.select(m),m=Bp(s==null?void 0:s.data,m,n),H(this,so,m),H(this,Vr,null)}catch(R){H(this,Vr,R)}k(this,Vr)&&(_=k(this,Vr),m=k(this,so),p=Date.now(),y="error");const v=d.fetchStatus==="fetching",x=y==="pending",b=y==="error",E=x&&v,S=m!==void 0,C={status:y,fetchStatus:d.fetchStatus,isPending:x,isSuccess:y==="success",isError:b,isInitialLoading:E,isLoading:E,data:m,dataUpdatedAt:d.dataUpdatedAt,error:_,errorUpdatedAt:p,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:v,isRefetching:v&&!x,isLoadingError:b&&!S,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:b&&S,isStale:Fg(t,n),refetch:this.refetch,promise:k(this,sr),isEnabled:Wt(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=C.data!==void 0,N=C.status==="error"&&!R,M=W=>{N?W.reject(C.error):R&&W.resolve(C.data)},z=()=>{const W=H(this,sr,C.promise=qp());M(W)},F=k(this,sr);switch(F.status){case"pending":t.queryHash===r.queryHash&&M(F);break;case"fulfilled":(N||C.data!==F.value)&&z();break;case"rejected":(!N||C.error!==F.reason)&&z();break}}return C}updateResult(){const t=k(this,xt),n=this.createResult(k(this,fe),this.options);if(H(this,zi,k(this,fe).state),H(this,io,this.options),k(this,zi).data!==void 0&&H(this,oo,k(this,fe)),Up(n,t))return;H(this,xt,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,s=typeof i=="function"?i():i;if(s==="all"||!s&&!k(this,ao).size)return!0;const o=new Set(s??k(this,ao));return this.options.throwOnError&&o.add("error"),Object.keys(k(this,xt)).some(a=>{const l=a;return k(this,xt)[l]!==t[l]&&o.has(l)})};ue(this,me,jS).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ue(this,me,Yp).call(this)}},Ot=new WeakMap,fe=new WeakMap,fl=new WeakMap,xt=new WeakMap,zi=new WeakMap,io=new WeakMap,sr=new WeakMap,Vr=new WeakMap,hl=new WeakMap,so=new WeakMap,oo=new WeakMap,Ui=new WeakMap,Vi=new WeakMap,Br=new WeakMap,ao=new WeakMap,me=new WeakSet,ha=function(t){ue(this,me,Zp).call(this);let n=k(this,fe).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(At)),n},Gp=function(){ue(this,me,Xp).call(this);const t=si(this.options.staleTime,k(this,fe));if(ol.isServer()||k(this,xt).isStale||!zp(t))return;const r=RS(k(this,xt).dataUpdatedAt,t)+1;H(this,Ui,Ni.setTimeout(()=>{k(this,xt).isStale||this.updateResult()},r))},Kp=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(k(this,fe)):this.options.refetchInterval)??!1},Qp=function(t){ue(this,me,Jp).call(this),H(this,Br,t),!(ol.isServer()||Wt(this.options.enabled,k(this,fe))===!1||!zp(k(this,Br))||k(this,Br)===0)&&H(this,Vi,Ni.setInterval(()=>{(this.options.refetchIntervalInBackground||Ag.isFocused())&&ue(this,me,ha).call(this)},k(this,Br)))},Yp=function(){ue(this,me,Gp).call(this),ue(this,me,Qp).call(this,ue(this,me,Kp).call(this))},Xp=function(){k(this,Ui)!==void 0&&(Ni.clearTimeout(k(this,Ui)),H(this,Ui,void 0))},Jp=function(){k(this,Vi)!==void 0&&(Ni.clearInterval(k(this,Vi)),H(this,Vi,void 0))},Zp=function(){const t=k(this,Ot).getQueryCache().build(k(this,Ot),this.options);if(t===k(this,fe))return;const n=k(this,fe);H(this,fe,t),H(this,fl,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},jS=function(t){at.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(k(this,xt))}),k(this,Ot).getQueryCache().notify({query:k(this,fe),type:"observerResultsUpdated"})})},nw);function HA(e,t){return Wt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Wt(t.retryOnMount,e)===!1)}function o0(e,t){return HA(e,t)||e.state.data!==void 0&&ev(e,t,t.refetchOnMount)}function ev(e,t,n){if(Wt(t.enabled,e)!==!1&&si(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Fg(e,t)}return!1}function a0(e,t,n,r){return(e!==t||Wt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Fg(e,n)}function Fg(e,t){return Wt(t.enabled,e)!==!1&&e.isStaleByTime(si(t.staleTime,e))}function GA(e,t){return!Up(e.getCurrentResult(),t)}var pl,Fn,pt,Bi,Ln,Ar,rw,KA=(rw=class extends NS{constructor(t){super();X(this,Ln);X(this,pl);X(this,Fn);X(this,pt);X(this,Bi);H(this,pl,t.client),this.mutationId=t.mutationId,H(this,pt,t.mutationCache),H(this,Fn,[]),this.state=t.state||QA(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){k(this,Fn).includes(t)||(k(this,Fn).push(t),this.clearGcTimeout(),k(this,pt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){H(this,Fn,k(this,Fn).filter(n=>n!==t)),this.scheduleGc(),k(this,pt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){k(this,Fn).length||(this.state.status==="pending"?this.scheduleGc():k(this,pt).remove(this))}continue(){var t;return((t=k(this,Bi))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,a,l,u,c,d,f,m,_,p,y,h,v,x,b,E,S,P;const n=()=>{ue(this,Ln,Ar).call(this,{type:"continue"})},r={client:k(this,pl),meta:this.options.meta,mutationKey:this.options.mutationKey};H(this,Bi,AS({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(C,T)=>{ue(this,Ln,Ar).call(this,{type:"failed",failureCount:C,error:T})},onPause:()=>{ue(this,Ln,Ar).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>k(this,pt).canRun(this)}));const i=this.state.status==="pending",s=!k(this,Bi).canStart();try{if(i)n();else{ue(this,Ln,Ar).call(this,{type:"pending",variables:t,isPaused:s}),k(this,pt).config.onMutate&&await k(this,pt).config.onMutate(t,this,r);const T=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,t,r));T!==this.state.context&&ue(this,Ln,Ar).call(this,{type:"pending",context:T,variables:t,isPaused:s})}const C=await k(this,Bi).start();return await((u=(l=k(this,pt).config).onSuccess)==null?void 0:u.call(l,C,t,this.state.context,this,r)),await((d=(c=this.options).onSuccess)==null?void 0:d.call(c,C,t,this.state.context,r)),await((m=(f=k(this,pt).config).onSettled)==null?void 0:m.call(f,C,null,this.state.variables,this.state.context,this,r)),await((p=(_=this.options).onSettled)==null?void 0:p.call(_,C,null,t,this.state.context,r)),ue(this,Ln,Ar).call(this,{type:"success",data:C}),C}catch(C){try{await((h=(y=k(this,pt).config).onError)==null?void 0:h.call(y,C,t,this.state.context,this,r))}catch(T){Promise.reject(T)}try{await((x=(v=this.options).onError)==null?void 0:x.call(v,C,t,this.state.context,r))}catch(T){Promise.reject(T)}try{await((E=(b=k(this,pt).config).onSettled)==null?void 0:E.call(b,void 0,C,this.state.variables,this.state.context,this,r))}catch(T){Promise.reject(T)}try{await((P=(S=this.options).onSettled)==null?void 0:P.call(S,void 0,C,t,this.state.context,r))}catch(T){Promise.reject(T)}throw ue(this,Ln,Ar).call(this,{type:"error",error:C}),C}finally{k(this,pt).runNext(this)}}},pl=new WeakMap,Fn=new WeakMap,pt=new WeakMap,Bi=new WeakMap,Ln=new WeakSet,Ar=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),at.batch(()=>{k(this,Fn).forEach(r=>{r.onMutationUpdate(t)}),k(this,pt).notify({mutation:this,type:"updated",action:t})})},rw);function QA(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var or,_n,vl,iw,YA=(iw=class extends El{constructor(t={}){super();X(this,or);X(this,_n);X(this,vl);this.config=t,H(this,or,new Set),H(this,_n,new Map),H(this,vl,0)}build(t,n,r){const i=new KA({client:t,mutationCache:this,mutationId:++Tl(this,vl)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){k(this,or).add(t);const n=su(t);if(typeof n=="string"){const r=k(this,_n).get(n);r?r.push(t):k(this,_n).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(k(this,or).delete(t)){const n=su(t);if(typeof n=="string"){const r=k(this,_n).get(n);if(r)if(r.length>1){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}else r[0]===t&&k(this,_n).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=su(t);if(typeof n=="string"){const r=k(this,_n).get(n),i=r==null?void 0:r.find(s=>s.state.status==="pending");return!i||i===t}else return!0}runNext(t){var r;const n=su(t);if(typeof n=="string"){const i=(r=k(this,_n).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused);return(i==null?void 0:i.continue())??Promise.resolve()}else return Promise.resolve()}clear(){at.batch(()=>{k(this,or).forEach(t=>{this.notify({type:"removed",mutation:t})}),k(this,or).clear(),k(this,_n).clear()})}getAll(){return Array.from(k(this,or))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>t0(n,r))}findAll(t={}){return this.getAll().filter(n=>t0(t,n))}notify(t){at.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return at.batch(()=>Promise.all(t.map(n=>n.continue().catch(At))))}},or=new WeakMap,_n=new WeakMap,vl=new WeakMap,iw);function su(e){var t;return(t=e.options.scope)==null?void 0:t.id}var jn,sw,XA=(sw=class extends El{constructor(t={}){super();X(this,jn);this.config=t,H(this,jn,new Map)}build(t,n,r){const i=n.queryKey,s=n.queryHash??Ng(i,n);let o=this.get(s);return o||(o=new qA({client:t,queryKey:i,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(o)),o}add(t){k(this,jn).has(t.queryHash)||(k(this,jn).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=k(this,jn).get(t.queryHash);n&&(t.destroy(),n===t&&k(this,jn).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){at.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return k(this,jn).get(t)}getAll(){return[...k(this,jn).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>e0(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>e0(t,r)):n}notify(t){at.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){at.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){at.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},jn=new WeakMap,sw),qe,qr,Wr,lo,uo,Hr,co,fo,ow,JA=(ow=class{constructor(e={}){X(this,qe);X(this,qr);X(this,Wr);X(this,lo);X(this,uo);X(this,Hr);X(this,co);X(this,fo);H(this,qe,e.queryCache||new XA),H(this,qr,e.mutationCache||new YA),H(this,Wr,e.defaultOptions||{}),H(this,lo,new Map),H(this,uo,new Map),H(this,Hr,0)}mount(){Tl(this,Hr)._++,k(this,Hr)===1&&(H(this,co,Ag.subscribe(async e=>{e&&(await this.resumePausedMutations(),k(this,qe).onFocus())})),H(this,fo,jc.subscribe(async e=>{e&&(await this.resumePausedMutations(),k(this,qe).onOnline())})))}unmount(){var e,t;Tl(this,Hr)._--,k(this,Hr)===0&&((e=k(this,co))==null||e.call(this),H(this,co,void 0),(t=k(this,fo))==null||t.call(this),H(this,fo,void 0))}isFetching(e){return k(this,qe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return k(this,qr).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=k(this,qe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=k(this,qe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(si(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return k(this,qe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=k(this,qe).get(r.queryHash),s=i==null?void 0:i.state.data,o=AA(t,s);if(o!==void 0)return k(this,qe).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return at.batch(()=>k(this,qe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=k(this,qe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=k(this,qe);at.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=k(this,qe);return at.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=at.batch(()=>k(this,qe).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(At).catch(At)}invalidateQueries(e,t={}){return at.batch(()=>(k(this,qe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=at.batch(()=>k(this,qe).findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(At)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(At)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=k(this,qe).build(this,t);return n.isStaleByTime(si(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(At).catch(At)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(At).catch(At)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return jc.isOnline()?k(this,qr).resumePausedMutations():Promise.resolve()}getQueryCache(){return k(this,qe)}getMutationCache(){return k(this,qr)}getDefaultOptions(){return k(this,Wr)}setDefaultOptions(e){H(this,Wr,e)}setQueryDefaults(e,t){k(this,lo).set(il(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...k(this,lo).values()],n={};return t.forEach(r=>{sl(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){k(this,uo).set(il(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...k(this,uo).values()],n={};return t.forEach(r=>{sl(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...k(this,Wr).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ng(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===$g&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...k(this,Wr).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){k(this,qe).clear(),k(this,qr).clear()}},qe=new WeakMap,qr=new WeakMap,Wr=new WeakMap,lo=new WeakMap,uo=new WeakMap,Hr=new WeakMap,co=new WeakMap,fo=new WeakMap,ow),DS=g.createContext(void 0),zS=e=>{const t=g.useContext(DS);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ZA=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),w.jsx(DS.Provider,{value:e,children:t})),US=g.createContext(!1),eN=()=>g.useContext(US);US.Provider;function tN(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var nN=g.createContext(tN()),rN=()=>g.useContext(nN),iN=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?OS(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},sN=e=>{g.useEffect(()=>{e.clearReset()},[e])},oN=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||OS(n,[e.error,r])),aN=e=>{if(e.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},lN=(e,t)=>e.isLoading&&e.isFetching&&!t,uN=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,l0=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function cN(e,t,n){var f,m,_,p;const r=eN(),i=rN(),s=zS(),o=s.defaultQueryOptions(e);(m=(f=s.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||m.call(f,o);const a=s.getQueryCache().get(o.queryHash);o._optimisticResults=r?"isRestoring":"optimistic",aN(o),iN(o,i,a),sN(i);const l=!s.getQueryCache().get(o.queryHash),[u]=g.useState(()=>new t(s,o)),c=u.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(g.useSyncExternalStore(g.useCallback(y=>{const h=d?u.subscribe(at.batchCalls(y)):At;return u.updateResult(),h},[u,d]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),g.useEffect(()=>{u.setOptions(o)},[o,u]),uN(o,c))throw l0(o,u,i);if(oN({result:c,errorResetBoundary:i,throwOnError:o.throwOnError,query:a,suspense:o.suspense}))throw c.error;if((p=(_=s.getDefaultOptions().queries)==null?void 0:_._experimental_afterQuery)==null||p.call(_,o,c),o.experimental_prefetchInRender&&!ol.isServer()&&lN(c,r)){const y=l?l0(o,u,i):a==null?void 0:a.promise;y==null||y.catch(At).finally(()=>{u.updateResult()})}return o.notifyOnChangeProps?c:u.trackResult(c)}function dN(e,t){return cN(e,WA)}function ee(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function u0(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function vi(...e){return t=>{let n=!1;const r=e.map(i=>{const s=u0(i,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i{const{children:o,...a}=s,l=g.useMemo(()=>a,Object.values(a));return w.jsx(n.Provider,{value:l,children:o})};r.displayName=e+"Provider";function i(s){const o=g.useContext(n);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,i]}function ss(e,t=[]){let n=[];function r(s,o){const a=g.createContext(o),l=n.length;n=[...n,o];const u=d=>{var h;const{scope:f,children:m,..._}=d,p=((h=f==null?void 0:f[e])==null?void 0:h[l])||a,y=g.useMemo(()=>_,Object.values(_));return w.jsx(p.Provider,{value:y,children:m})};u.displayName=s+"Provider";function c(d,f){var p;const m=((p=f==null?void 0:f[e])==null?void 0:p[l])||a,_=g.useContext(m);if(_)return _;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[u,c]}const i=()=>{const s=n.map(o=>g.createContext(o));return function(a){const l=(a==null?void 0:a[e])||s;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return i.scopeName=e,[r,hN(i,...t)]}function hN(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:u})=>{const d=l(s)[`__scope${u}`];return{...a,...d}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var fn=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},pN=Kc[" useId ".trim().toString()]||(()=>{}),vN=0;function Qs(e){const[t,n]=g.useState(pN());return fn(()=>{n(r=>r??String(vN++))},[e]),t?`radix-${t}`:""}var gN=Kc[" useInsertionEffect ".trim().toString()]||fn;function yd({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,s,o]=mN({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:i;{const c=g.useRef(e!==void 0);g.useEffect(()=>{const d=c.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=a},[a,r])}const u=g.useCallback(c=>{var d;if(a){const f=yN(c)?c(e):c;f!==e&&((d=o.current)==null||d.call(o,f))}else s(c)},[a,e,s,o]);return[l,u]}function mN({defaultProp:e,onChange:t}){const[n,r]=g.useState(e),i=g.useRef(n),s=g.useRef(t);return gN(()=>{s.current=t},[t]),g.useEffect(()=>{var o;i.current!==n&&((o=s.current)==null||o.call(s,n),i.current=n)},[n,i]),[n,r,s]}function yN(e){return typeof e=="function"}function _N(e){const t=wN(e),n=g.forwardRef((r,i)=>{const{children:s,...o}=r,a=g.Children.toArray(s),l=a.find(bN);if(l){const u=l.props.children,c=a.map(d=>d===l?g.Children.count(u)>1?g.Children.only(null):g.isValidElement(u)?u.props.children:null:d);return w.jsx(t,{...o,ref:i,children:g.isValidElement(u)?g.cloneElement(u,void 0,c):null})}return w.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function wN(e){const t=g.forwardRef((n,r)=>{const{children:i,...s}=n;if(g.isValidElement(i)){const o=SN(i),a=EN(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vi(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var xN=Symbol("radix.slottable");function bN(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xN}function EN(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function SN(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var CN=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ke=CN.reduce((e,t)=>{const n=_N(`Primitive.${t}`),r=g.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),w.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Lg(e,t){e&&xl.flushSync(()=>e.dispatchEvent(t))}function Ut(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function kN(e,t=globalThis==null?void 0:globalThis.document){const n=Ut(e);g.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var PN="DismissableLayer",tv="dismissableLayer.update",RN="dismissableLayer.pointerDownOutside",TN="dismissableLayer.focusOutside",c0,VS=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_d=g.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...l}=e,u=g.useContext(VS),[c,d]=g.useState(null),f=(c==null?void 0:c.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=g.useState({}),_=et(t,P=>d(P)),p=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),h=p.indexOf(y),v=c?p.indexOf(c):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,b=v>=h,E=ON(P=>{const C=P.target,T=[...u.branches].some(R=>R.contains(C));!b||T||(i==null||i(P),o==null||o(P),P.defaultPrevented||a==null||a())},f),S=MN(P=>{const C=P.target;[...u.branches].some(R=>R.contains(C))||(s==null||s(P),o==null||o(P),P.defaultPrevented||a==null||a())},f);return kN(P=>{v===u.layers.size-1&&(r==null||r(P),!P.defaultPrevented&&a&&(P.preventDefault(),a()))},f),g.useEffect(()=>{if(c)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(c0=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),d0(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=c0)}},[c,f,n,u]),g.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),d0())},[c,u]),g.useEffect(()=>{const P=()=>m({});return document.addEventListener(tv,P),()=>document.removeEventListener(tv,P)},[]),w.jsx(ke.div,{...l,ref:_,style:{pointerEvents:x?b?"auto":"none":void 0,...e.style},onFocusCapture:ee(e.onFocusCapture,S.onFocusCapture),onBlurCapture:ee(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:ee(e.onPointerDownCapture,E.onPointerDownCapture)})});_d.displayName=PN;var IN="DismissableLayerBranch",BS=g.forwardRef((e,t)=>{const n=g.useContext(VS),r=g.useRef(null),i=et(t,r);return g.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),w.jsx(ke.div,{...e,ref:i})});BS.displayName=IN;function ON(e,t=globalThis==null?void 0:globalThis.document){const n=Ut(e),r=g.useRef(!1),i=g.useRef(()=>{});return g.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){qS(RN,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=l,t.addEventListener("click",i.current,{once:!0})):l()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",s),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function MN(e,t=globalThis==null?void 0:globalThis.document){const n=Ut(e),r=g.useRef(!1);return g.useEffect(()=>{const i=s=>{s.target&&!r.current&&qS(TN,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function d0(){const e=new CustomEvent(tv);document.dispatchEvent(e)}function qS(e,t,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Lg(i,s):i.dispatchEvent(s)}var AN=_d,NN=BS,Vf="focusScope.autoFocusOnMount",Bf="focusScope.autoFocusOnUnmount",f0={bubbles:!1,cancelable:!0},$N="FocusScope",jg=g.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=e,[a,l]=g.useState(null),u=Ut(i),c=Ut(s),d=g.useRef(null),f=et(t,p=>l(p)),m=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let p=function(x){if(m.paused||!a)return;const b=x.target;a.contains(b)?d.current=b:Nr(d.current,{select:!0})},y=function(x){if(m.paused||!a)return;const b=x.relatedTarget;b!==null&&(a.contains(b)||Nr(d.current,{select:!0}))},h=function(x){if(document.activeElement===document.body)for(const E of x)E.removedNodes.length>0&&Nr(a)};document.addEventListener("focusin",p),document.addEventListener("focusout",y);const v=new MutationObserver(h);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",y),v.disconnect()}}},[r,a,m.paused]),g.useEffect(()=>{if(a){p0.add(m);const p=document.activeElement;if(!a.contains(p)){const h=new CustomEvent(Vf,f0);a.addEventListener(Vf,u),a.dispatchEvent(h),h.defaultPrevented||(FN(UN(WS(a)),{select:!0}),document.activeElement===p&&Nr(a))}return()=>{a.removeEventListener(Vf,u),setTimeout(()=>{const h=new CustomEvent(Bf,f0);a.addEventListener(Bf,c),a.dispatchEvent(h),h.defaultPrevented||Nr(p??document.body,{select:!0}),a.removeEventListener(Bf,c),p0.remove(m)},0)}}},[a,u,c,m]);const _=g.useCallback(p=>{if(!n&&!r||m.paused)return;const y=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,h=document.activeElement;if(y&&h){const v=p.currentTarget,[x,b]=LN(v);x&&b?!p.shiftKey&&h===b?(p.preventDefault(),n&&Nr(x,{select:!0})):p.shiftKey&&h===x&&(p.preventDefault(),n&&Nr(b,{select:!0})):h===v&&p.preventDefault()}},[n,r,m.paused]);return w.jsx(ke.div,{tabIndex:-1,...o,ref:f,onKeyDown:_})});jg.displayName=$N;function FN(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Nr(r,{select:t}),document.activeElement!==n)return}function LN(e){const t=WS(e),n=h0(t,e),r=h0(t.reverse(),e);return[n,r]}function WS(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function h0(e,t){for(const n of e)if(!jN(n,{upTo:t}))return n}function jN(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function DN(e){return e instanceof HTMLInputElement&&"select"in e}function Nr(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&DN(e)&&t&&e.select()}}var p0=zN();function zN(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=v0(e,t),e.unshift(t)},remove(t){var n;e=v0(e,t),(n=e[0])==null||n.resume()}}}function v0(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function UN(e){return e.filter(t=>t.tagName!=="A")}var VN="Portal",wd=g.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[i,s]=g.useState(!1);fn(()=>s(!0),[]);const o=n||i&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?gT.createPortal(w.jsx(ke.div,{...r,ref:t}),o):null});wd.displayName=VN;function BN(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var br=e=>{const{present:t,children:n}=e,r=qN(t),i=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),s=et(r.ref,WN(i));return typeof n=="function"||r.isPresent?g.cloneElement(i,{ref:s}):null};br.displayName="Presence";function qN(e){const[t,n]=g.useState(),r=g.useRef(null),i=g.useRef(e),s=g.useRef("none"),o=e?"mounted":"unmounted",[a,l]=BN(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const u=ou(r.current);s.current=a==="mounted"?u:"none"},[a]),fn(()=>{const u=r.current,c=i.current;if(c!==e){const f=s.current,m=ou(u);e?l("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(c&&f!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),fn(()=>{if(t){let u;const c=t.ownerDocument.defaultView??window,d=m=>{const p=ou(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&p&&(l("ANIMATION_END"),!i.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},f=m=>{m.target===t&&(s.current=ou(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(u),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:g.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function ou(e){return(e==null?void 0:e.animationName)||"none"}function WN(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var qf=0;function HS(){g.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??g0()),document.body.insertAdjacentElement("beforeend",e[1]??g0()),qf++,()=>{qf===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),qf--}},[])}function g0(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Un=function(){return Un=Object.assign||function(t){for(var n,r=1,i=arguments.length;r"u")return l$;var t=u$(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},d$=YS(),Ys="data-scroll-locked",f$=function(e,t,n,r){var i=e.left,s=e.top,o=e.right,a=e.gap;return n===void 0&&(n="margin"),` - .`.concat(GN,` { + */function Fc(){return Fc=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[i]=e[i]);return n}function fA(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function hA(e,t){return e.button===0&&(!t||t==="_self")&&!fA(e)}function jp(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function pA(e,t){let n=jp(e);return t&&t.forEach((r,i)=>{n.has(i)||t.getAll(i).forEach(s=>{n.append(i,s)})}),n}const vA=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],gA=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],mA="6";try{window.__reactRouterVersion=mA}catch{}const yA=g.createContext({isTransitioning:!1}),_A="startTransition",Lc=Kc[_A];function wA(e){let{basename:t,children:n,future:r,window:i}=e,s=g.useRef();s.current==null&&(s.current=xM({window:i,v5Compat:!0}));let o=s.current,[a,l]=g.useState({action:o.action,location:o.location}),{v7_startTransition:u}=r||{},c=g.useCallback(d=>{u&&Lc?Lc(()=>l(d)):l(d)},[l,u]);return g.useLayoutEffect(()=>o.listen(c),[o,c]),g.useEffect(()=>CS(r),[r]),g.createElement(kS,{basename:t,children:n,location:a.location,navigationType:a.action,navigator:o,future:r})}function xA(e){let{basename:t,children:n,future:r,window:i}=e,s=g.useRef();s.current==null&&(s.current=bM({window:i,v5Compat:!0}));let o=s.current,[a,l]=g.useState({action:o.action,location:o.location}),{v7_startTransition:u}=r||{},c=g.useCallback(d=>{u&&Lc?Lc(()=>l(d)):l(d)},[l,u]);return g.useLayoutEffect(()=>o.listen(c),[o,c]),g.useEffect(()=>CS(r),[r]),g.createElement(kS,{basename:t,children:n,location:a.location,navigationType:a.action,navigator:o,future:r})}const bA=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",EA=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,bn=g.forwardRef(function(t,n){let{onClick:r,relative:i,reloadDocument:s,replace:o,state:a,target:l,to:u,preventScrollReset:c,viewTransition:d}=t,f=PS(t,vA),{basename:m}=g.useContext(xr),_,p=!1;if(typeof u=="string"&&EA.test(u)&&(_=u,bA))try{let x=new URL(window.location.href),b=u.startsWith("//")?new URL(x.protocol+u):new URL(u),E=Po(b.pathname,m);b.origin===x.origin&&E!=null?u=E+b.search+b.hash:p=!0}catch{}let y=GM(u,{relative:i}),h=CA(u,{replace:o,state:a,target:l,preventScrollReset:c,relative:i,viewTransition:d});function v(x){r&&r(x),x.defaultPrevented||h(x)}return g.createElement("a",Fc({},f,{href:_||y,onClick:p||s?r:v,ref:n,target:l}))}),ms=g.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:i=!1,className:s="",end:o=!1,style:a,to:l,viewTransition:u,children:c}=t,d=PS(t,gA),f=md(l,{relative:d.relative}),m=hn(),_=g.useContext(yS),{navigator:p,basename:y}=g.useContext(xr),h=_!=null&&kA(f)&&u===!0,v=p.encodeLocation?p.encodeLocation(f).pathname:f.pathname,x=m.pathname,b=_&&_.navigation&&_.navigation.location?_.navigation.location.pathname:null;i||(x=x.toLowerCase(),b=b?b.toLowerCase():null,v=v.toLowerCase()),b&&y&&(b=Po(b,y)||b);const E=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let S=x===v||!o&&x.startsWith(v)&&x.charAt(E)==="/",P=b!=null&&(b===v||!o&&b.startsWith(v)&&b.charAt(v.length)==="/"),C={isActive:S,isPending:P,isTransitioning:h},T=S?r:void 0,R;typeof s=="function"?R=s(C):R=[s,S?"active":null,P?"pending":null,h?"transitioning":null].filter(Boolean).join(" ");let N=typeof a=="function"?a(C):a;return g.createElement(bn,Fc({},d,{"aria-current":T,className:R,ref:n,style:N,to:l,viewTransition:u}),typeof c=="function"?c(C):c)});var Dp;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Dp||(Dp={}));var Z_;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Z_||(Z_={}));function SA(e){let t=g.useContext(vd);return t||Ue(!1),t}function CA(e,t){let{target:n,replace:r,state:i,preventScrollReset:s,relative:o,viewTransition:a}=t===void 0?{}:t,l=Mg(),u=hn(),c=md(e,{relative:o});return g.useCallback(d=>{if(hA(d,n)){d.preventDefault();let f=r!==void 0?r:nl(u)===nl(c);l(e,{replace:f,state:i,preventScrollReset:s,relative:o,viewTransition:a})}},[u,l,c,r,i,n,e,s,o,a])}function iz(e){let t=g.useRef(jp(e)),n=g.useRef(!1),r=hn(),i=g.useMemo(()=>pA(r.search,n.current?null:t.current),[r.search]),s=Mg(),o=g.useCallback((a,l)=>{const u=jp(typeof a=="function"?a(i):a);n.current=!0,s("?"+u,l)},[s,i]);return[i,o]}function kA(e,t){t===void 0&&(t={});let n=g.useContext(yA);n==null&&Ue(!1);let{basename:r}=SA(Dp.useViewTransitionState),i=md(e,{relative:t.relative});if(!n.isTransitioning)return!1;let s=Po(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Po(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Fp(i.pathname,o)!=null||Fp(i.pathname,s)!=null}var El=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},$i,Dr,Zs,X0,PA=(X0=class extends El{constructor(){super();X(this,$i);X(this,Dr);X(this,Zs);H(this,Zs,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){k(this,Dr)||this.setEventListener(k(this,Zs))}onUnsubscribe(){var t;this.hasListeners()||((t=k(this,Dr))==null||t.call(this),H(this,Dr,void 0))}setEventListener(t){var n;H(this,Zs,t),(n=k(this,Dr))==null||n.call(this),H(this,Dr,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){k(this,$i)!==t&&(H(this,$i,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof k(this,$i)=="boolean"?k(this,$i):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},$i=new WeakMap,Dr=new WeakMap,Zs=new WeakMap,X0),Ag=new PA,RA={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},zr,vv,J0,TA=(J0=class{constructor(){X(this,zr,RA);X(this,vv,!1)}setTimeoutProvider(e){H(this,zr,e)}setTimeout(e,t){return k(this,zr).setTimeout(e,t)}clearTimeout(e){k(this,zr).clearTimeout(e)}setInterval(e,t){return k(this,zr).setInterval(e,t)}clearInterval(e){k(this,zr).clearInterval(e)}},zr=new WeakMap,vv=new WeakMap,J0),Ni=new TA;function IA(e){setTimeout(e,0)}var OA=typeof window>"u"||"Deno"in globalThis;function At(){}function MA(e,t){return typeof e=="function"?e(t):e}function zp(e){return typeof e=="number"&&e>=0&&e!==1/0}function RS(e,t){return Math.max(e+(t||0)-Date.now(),0)}function si(e,t){return typeof e=="function"?e(t):e}function Wt(e,t){return typeof e=="function"?e(t):e}function e0(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:a}=e;if(o){if(r){if(t.queryHash!==Ng(o,t.options))return!1}else if(!sl(t.queryKey,o))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||i&&i!==t.state.fetchStatus||s&&!s(t))}function t0(e,t){const{exact:n,status:r,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(il(t.options.mutationKey)!==il(s))return!1}else if(!sl(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Ng(e,t){return((t==null?void 0:t.queryKeyHashFn)||il)(e)}function il(e){return JSON.stringify(e,(t,n)=>Vp(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function sl(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>sl(e[n],t[n])):!1}var AA=Object.prototype.hasOwnProperty;function TS(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=n0(e)&&n0(t);if(!r&&!(Vp(e)&&Vp(t)))return t;const s=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),a=o.length,l=r?new Array(a):{};let u=0;for(let c=0;c{Ni.setTimeout(t,e)})}function Bp(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?TS(e,t):t}function $A(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function FA(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var $g=Symbol();function IS(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===$g?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function OS(e,t){return typeof e=="function"?e(...t):!!e}function LA(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??(i=t()),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),e}var ol=(()=>{let e=()=>OA;return{isServer(){return e()},setIsServer(t){e=t}}})();function qp(){let e,t;const n=new Promise((i,s)=>{e=i,t=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},n.reject=i=>{r({status:"rejected",reason:i}),t(i)},n}var jA=IA;function DA(){let e=[],t=0,n=a=>{a()},r=a=>{a()},i=jA;const s=a=>{t?e.push(a):i(()=>{n(a)})},o=()=>{const a=e;e=[],a.length&&i(()=>{r(()=>{a.forEach(l=>{n(l)})})})};return{batch:a=>{let l;t++;try{l=a()}finally{t--,t||o()}return l},batchCalls:a=>(...l)=>{s(()=>{a(...l)})},schedule:s,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{i=a}}}var at=DA(),eo,Ur,to,Z0,zA=(Z0=class extends El{constructor(){super();X(this,eo,!0);X(this,Ur);X(this,to);H(this,to,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){k(this,Ur)||this.setEventListener(k(this,to))}onUnsubscribe(){var t;this.hasListeners()||((t=k(this,Ur))==null||t.call(this),H(this,Ur,void 0))}setEventListener(t){var n;H(this,to,t),(n=k(this,Ur))==null||n.call(this),H(this,Ur,t(this.setOnline.bind(this)))}setOnline(t){k(this,eo)!==t&&(H(this,eo,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return k(this,eo)}},eo=new WeakMap,Ur=new WeakMap,to=new WeakMap,Z0),jc=new zA;function UA(e){return Math.min(1e3*2**e,3e4)}function MS(e){return(e??"online")==="online"?jc.isOnline():!0}var Wp=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function AS(e){let t=!1,n=0,r;const i=qp(),s=()=>i.status!=="pending",o=p=>{var y;if(!s()){const h=new Wp(p);f(h),(y=e.onCancel)==null||y.call(e,h)}},a=()=>{t=!0},l=()=>{t=!1},u=()=>Ag.isFocused()&&(e.networkMode==="always"||jc.isOnline())&&e.canRun(),c=()=>MS(e.networkMode)&&e.canRun(),d=p=>{s()||(r==null||r(),i.resolve(p))},f=p=>{s()||(r==null||r(),i.reject(p))},m=()=>new Promise(p=>{var y;r=h=>{(s()||u())&&p(h)},(y=e.onPause)==null||y.call(e)}).then(()=>{var p;r=void 0,s()||(p=e.onContinue)==null||p.call(e)}),_=()=>{if(s())return;let p;const y=n===0?e.initialPromise:void 0;try{p=y??e.fn()}catch(h){p=Promise.reject(h)}Promise.resolve(p).then(d).catch(h=>{var S;if(s())return;const v=e.retry??(ol.isServer()?0:3),x=e.retryDelay??UA,b=typeof x=="function"?x(n,h):x,E=v===!0||typeof v=="number"&&nu()?void 0:m()).then(()=>{t?f(h):_()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r==null||r(),i),cancelRetry:a,continueRetry:l,canStart:c,start:()=>(c()?_():m().then(_),i)}}var Fi,ew,NS=(ew=class{constructor(){X(this,Fi)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),zp(this.gcTime)&&H(this,Fi,Ni.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ol.isServer()?1/0:5*60*1e3))}clearGcTimeout(){k(this,Fi)!==void 0&&(Ni.clearTimeout(k(this,Fi)),H(this,Fi,void 0))}},Fi=new WeakMap,ew);function VA(e){return{onFetch:(t,n)=>{var c,d,f,m,_;const r=t.options,i=(f=(d=(c=t.fetchOptions)==null?void 0:c.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,s=((m=t.state.data)==null?void 0:m.pages)||[],o=((_=t.state.data)==null?void 0:_.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const u=async()=>{let p=!1;const y=x=>{LA(x,()=>t.signal,()=>p=!0)},h=IS(t.options,t.fetchOptions),v=async(x,b,E)=>{if(p)return Promise.reject(t.signal.reason);if(b==null&&x.pages.length)return Promise.resolve(x);const P=(()=>{const N={client:t.client,queryKey:t.queryKey,pageParam:b,direction:E?"backward":"forward",meta:t.options.meta};return y(N),N})(),C=await h(P),{maxPages:T}=t.options,R=E?FA:$A;return{pages:R(x.pages,C,T),pageParams:R(x.pageParams,b,T)}};if(i&&s.length){const x=i==="backward",b=x?$S:Hp,E={pages:s,pageParams:o},S=b(r,E);a=await v(E,S,x)}else{const x=e??s.length;do{const b=l===0?o[0]??r.initialPageParam:Hp(r,a);if(l>0&&b==null)break;a=await v(a,b),l++}while(l{var p,y;return(y=(p=t.options).persister)==null?void 0:y.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Hp(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function $S(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}function sz(e,t){return t?Hp(e,t)!=null:!1}function oz(e,t){return!t||!e.getPreviousPageParam?!1:$S(e,t)!=null}var no,Li,ro,nn,ji,tt,dl,Di,Bt,FS,Zn,tw,BA=(tw=class extends NS{constructor(t){super();X(this,Bt);X(this,no);X(this,Li);X(this,ro);X(this,nn);X(this,ji);X(this,tt);X(this,dl);X(this,Di);H(this,Di,!1),H(this,dl,t.defaultOptions),this.setOptions(t.options),this.observers=[],H(this,ji,t.client),H(this,nn,k(this,ji).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,H(this,Li,s0(this.options)),this.state=t.state??k(this,Li),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return k(this,no)}get promise(){var t;return(t=k(this,tt))==null?void 0:t.promise}setOptions(t){if(this.options={...k(this,dl),...t},t!=null&&t._type&&H(this,no,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=s0(this.options);n.data!==void 0&&(this.setState(i0(n.data,n.dataUpdatedAt)),H(this,Li,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&k(this,nn).remove(this)}setData(t,n){const r=Bp(this.state.data,t,this.options);return ue(this,Bt,Zn).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){ue(this,Bt,Zn).call(this,{type:"setState",state:t})}cancel(t){var r,i;const n=(r=k(this,tt))==null?void 0:r.promise;return(i=k(this,tt))==null||i.cancel(t),n?n.then(At).catch(At):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return k(this,Li)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Wt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===$g||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>si(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!RS(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=k(this,tt))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=k(this,tt))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),k(this,nn).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(k(this,tt)&&(k(this,Di)||ue(this,Bt,FS).call(this)?k(this,tt).cancel({revert:!0}):k(this,tt).cancelRetry()),this.scheduleGc()),k(this,nn).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ue(this,Bt,Zn).call(this,{type:"invalidate"})}async fetch(t,n){var u,c,d,f,m,_,p,y,h,v,x;if(this.state.fetchStatus!=="idle"&&((u=k(this,tt))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(k(this,tt))return k(this,tt).continueRetry(),k(this,tt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const b=this.observers.find(E=>E.options.queryFn);b&&this.setOptions(b.options)}const r=new AbortController,i=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(H(this,Di,!0),r.signal)})},s=()=>{const b=IS(this.options,n),S=(()=>{const P={client:k(this,ji),queryKey:this.queryKey,meta:this.meta};return i(P),P})();return H(this,Di,!1),this.options.persister?this.options.persister(b,S,this):b(S)},a=(()=>{const b={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:k(this,ji),state:this.state,fetchFn:s};return i(b),b})(),l=k(this,no)==="infinite"?VA(this.options.pages):this.options.behavior;l==null||l.onFetch(a,this),H(this,ro,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((c=a.fetchOptions)==null?void 0:c.meta))&&ue(this,Bt,Zn).call(this,{type:"fetch",meta:(d=a.fetchOptions)==null?void 0:d.meta}),H(this,tt,AS({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:b=>{b instanceof Wp&&b.revert&&this.setState({...k(this,ro),fetchStatus:"idle"}),r.abort()},onFail:(b,E)=>{ue(this,Bt,Zn).call(this,{type:"failed",failureCount:b,error:E})},onPause:()=>{ue(this,Bt,Zn).call(this,{type:"pause"})},onContinue:()=>{ue(this,Bt,Zn).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const b=await k(this,tt).start();if(b===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(b),(m=(f=k(this,nn).config).onSuccess)==null||m.call(f,b,this),(p=(_=k(this,nn).config).onSettled)==null||p.call(_,b,this.state.error,this),b}catch(b){if(b instanceof Wp){if(b.silent)return k(this,tt).promise;if(b.revert){if(this.state.data===void 0)throw b;return this.state.data}}throw ue(this,Bt,Zn).call(this,{type:"error",error:b}),(h=(y=k(this,nn).config).onError)==null||h.call(y,b,this),(x=(v=k(this,nn).config).onSettled)==null||x.call(v,this.state.data,b,this),b}finally{this.scheduleGc()}}},no=new WeakMap,Li=new WeakMap,ro=new WeakMap,nn=new WeakMap,ji=new WeakMap,tt=new WeakMap,dl=new WeakMap,Di=new WeakMap,Bt=new WeakSet,FS=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Zn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...LS(r.data,this.options),fetchMeta:t.meta??null};case"success":const i={...r,...i0(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return H(this,ro,t.manual?i:void 0),i;case"error":const s=t.error;return{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),at.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),k(this,nn).notify({query:this,type:"updated",action:t})})},tw);function LS(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:MS(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function i0(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function s0(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Ot,fe,fl,xt,zi,io,sr,Vr,hl,so,oo,Ui,Vi,Br,ao,me,ha,Gp,Kp,Qp,Yp,Xp,Jp,Zp,jS,nw,qA=(nw=class extends El{constructor(t,n){super();X(this,me);X(this,Ot);X(this,fe);X(this,fl);X(this,xt);X(this,zi);X(this,io);X(this,sr);X(this,Vr);X(this,hl);X(this,so);X(this,oo);X(this,Ui);X(this,Vi);X(this,Br);X(this,ao,new Set);this.options=n,H(this,Ot,t),H(this,Vr,null),H(this,sr,qp()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(k(this,fe).addObserver(this),o0(k(this,fe),this.options)?ue(this,me,ha).call(this):this.updateResult(),ue(this,me,Yp).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ev(k(this,fe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ev(k(this,fe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ue(this,me,Xp).call(this),ue(this,me,Jp).call(this),k(this,fe).removeObserver(this)}setOptions(t){const n=this.options,r=k(this,fe);if(this.options=k(this,Ot).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Wt(this.options.enabled,k(this,fe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ue(this,me,Zp).call(this),k(this,fe).setOptions(this.options),n._defaulted&&!Up(this.options,n)&&k(this,Ot).getQueryCache().notify({type:"observerOptionsUpdated",query:k(this,fe),observer:this});const i=this.hasListeners();i&&a0(k(this,fe),r,this.options,n)&&ue(this,me,ha).call(this),this.updateResult(),i&&(k(this,fe)!==r||Wt(this.options.enabled,k(this,fe))!==Wt(n.enabled,k(this,fe))||si(this.options.staleTime,k(this,fe))!==si(n.staleTime,k(this,fe)))&&ue(this,me,Gp).call(this);const s=ue(this,me,Kp).call(this);i&&(k(this,fe)!==r||Wt(this.options.enabled,k(this,fe))!==Wt(n.enabled,k(this,fe))||s!==k(this,Br))&&ue(this,me,Qp).call(this,s)}getOptimisticResult(t){const n=k(this,Ot).getQueryCache().build(k(this,Ot),t),r=this.createResult(n,t);return HA(this,r)&&(H(this,xt,r),H(this,io,this.options),H(this,zi,k(this,fe).state)),r}getCurrentResult(){return k(this,xt)}trackResult(t,n){return new Proxy(t,{get:(r,i)=>(this.trackProp(i),n==null||n(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&k(this,sr).status==="pending"&&k(this,sr).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,i))})}trackProp(t){k(this,ao).add(t)}getCurrentQuery(){return k(this,fe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=k(this,Ot).defaultQueryOptions(t),r=k(this,Ot).getQueryCache().build(k(this,Ot),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return ue(this,me,ha).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),k(this,xt)))}createResult(t,n){var T;const r=k(this,fe),i=this.options,s=k(this,xt),o=k(this,zi),a=k(this,io),u=t!==r?t.state:k(this,fl),{state:c}=t;let d={...c},f=!1,m;if(n._optimisticResults){const R=this.hasListeners(),N=!R&&o0(t,n),M=R&&a0(t,r,n,i);(N||M)&&(d={...d,...LS(c.data,t.options)}),n._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:_,errorUpdatedAt:p,status:y}=d;m=d.data;let h=!1;if(n.placeholderData!==void 0&&m===void 0&&y==="pending"){let R;s!=null&&s.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(R=s.data,h=!0):R=typeof n.placeholderData=="function"?n.placeholderData((T=k(this,oo))==null?void 0:T.state.data,k(this,oo)):n.placeholderData,R!==void 0&&(y="success",m=Bp(s==null?void 0:s.data,R,n),f=!0)}if(n.select&&m!==void 0&&!h)if(s&&m===(o==null?void 0:o.data)&&n.select===k(this,hl))m=k(this,so);else try{H(this,hl,n.select),m=n.select(m),m=Bp(s==null?void 0:s.data,m,n),H(this,so,m),H(this,Vr,null)}catch(R){H(this,Vr,R)}k(this,Vr)&&(_=k(this,Vr),m=k(this,so),p=Date.now(),y="error");const v=d.fetchStatus==="fetching",x=y==="pending",b=y==="error",E=x&&v,S=m!==void 0,C={status:y,fetchStatus:d.fetchStatus,isPending:x,isSuccess:y==="success",isError:b,isInitialLoading:E,isLoading:E,data:m,dataUpdatedAt:d.dataUpdatedAt,error:_,errorUpdatedAt:p,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:v,isRefetching:v&&!x,isLoadingError:b&&!S,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:b&&S,isStale:Fg(t,n),refetch:this.refetch,promise:k(this,sr),isEnabled:Wt(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=C.data!==void 0,N=C.status==="error"&&!R,M=W=>{N?W.reject(C.error):R&&W.resolve(C.data)},z=()=>{const W=H(this,sr,C.promise=qp());M(W)},F=k(this,sr);switch(F.status){case"pending":t.queryHash===r.queryHash&&M(F);break;case"fulfilled":(N||C.data!==F.value)&&z();break;case"rejected":(!N||C.error!==F.reason)&&z();break}}return C}updateResult(){const t=k(this,xt),n=this.createResult(k(this,fe),this.options);if(H(this,zi,k(this,fe).state),H(this,io,this.options),k(this,zi).data!==void 0&&H(this,oo,k(this,fe)),Up(n,t))return;H(this,xt,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,s=typeof i=="function"?i():i;if(s==="all"||!s&&!k(this,ao).size)return!0;const o=new Set(s??k(this,ao));return this.options.throwOnError&&o.add("error"),Object.keys(k(this,xt)).some(a=>{const l=a;return k(this,xt)[l]!==t[l]&&o.has(l)})};ue(this,me,jS).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ue(this,me,Yp).call(this)}},Ot=new WeakMap,fe=new WeakMap,fl=new WeakMap,xt=new WeakMap,zi=new WeakMap,io=new WeakMap,sr=new WeakMap,Vr=new WeakMap,hl=new WeakMap,so=new WeakMap,oo=new WeakMap,Ui=new WeakMap,Vi=new WeakMap,Br=new WeakMap,ao=new WeakMap,me=new WeakSet,ha=function(t){ue(this,me,Zp).call(this);let n=k(this,fe).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(At)),n},Gp=function(){ue(this,me,Xp).call(this);const t=si(this.options.staleTime,k(this,fe));if(ol.isServer()||k(this,xt).isStale||!zp(t))return;const r=RS(k(this,xt).dataUpdatedAt,t)+1;H(this,Ui,Ni.setTimeout(()=>{k(this,xt).isStale||this.updateResult()},r))},Kp=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(k(this,fe)):this.options.refetchInterval)??!1},Qp=function(t){ue(this,me,Jp).call(this),H(this,Br,t),!(ol.isServer()||Wt(this.options.enabled,k(this,fe))===!1||!zp(k(this,Br))||k(this,Br)===0)&&H(this,Vi,Ni.setInterval(()=>{(this.options.refetchIntervalInBackground||Ag.isFocused())&&ue(this,me,ha).call(this)},k(this,Br)))},Yp=function(){ue(this,me,Gp).call(this),ue(this,me,Qp).call(this,ue(this,me,Kp).call(this))},Xp=function(){k(this,Ui)!==void 0&&(Ni.clearTimeout(k(this,Ui)),H(this,Ui,void 0))},Jp=function(){k(this,Vi)!==void 0&&(Ni.clearInterval(k(this,Vi)),H(this,Vi,void 0))},Zp=function(){const t=k(this,Ot).getQueryCache().build(k(this,Ot),this.options);if(t===k(this,fe))return;const n=k(this,fe);H(this,fe,t),H(this,fl,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},jS=function(t){at.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(k(this,xt))}),k(this,Ot).getQueryCache().notify({query:k(this,fe),type:"observerResultsUpdated"})})},nw);function WA(e,t){return Wt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Wt(t.retryOnMount,e)===!1)}function o0(e,t){return WA(e,t)||e.state.data!==void 0&&ev(e,t,t.refetchOnMount)}function ev(e,t,n){if(Wt(t.enabled,e)!==!1&&si(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Fg(e,t)}return!1}function a0(e,t,n,r){return(e!==t||Wt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Fg(e,n)}function Fg(e,t){return Wt(t.enabled,e)!==!1&&e.isStaleByTime(si(t.staleTime,e))}function HA(e,t){return!Up(e.getCurrentResult(),t)}var pl,Fn,pt,Bi,Ln,Ar,rw,GA=(rw=class extends NS{constructor(t){super();X(this,Ln);X(this,pl);X(this,Fn);X(this,pt);X(this,Bi);H(this,pl,t.client),this.mutationId=t.mutationId,H(this,pt,t.mutationCache),H(this,Fn,[]),this.state=t.state||KA(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){k(this,Fn).includes(t)||(k(this,Fn).push(t),this.clearGcTimeout(),k(this,pt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){H(this,Fn,k(this,Fn).filter(n=>n!==t)),this.scheduleGc(),k(this,pt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){k(this,Fn).length||(this.state.status==="pending"?this.scheduleGc():k(this,pt).remove(this))}continue(){var t;return((t=k(this,Bi))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,a,l,u,c,d,f,m,_,p,y,h,v,x,b,E,S,P;const n=()=>{ue(this,Ln,Ar).call(this,{type:"continue"})},r={client:k(this,pl),meta:this.options.meta,mutationKey:this.options.mutationKey};H(this,Bi,AS({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(C,T)=>{ue(this,Ln,Ar).call(this,{type:"failed",failureCount:C,error:T})},onPause:()=>{ue(this,Ln,Ar).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>k(this,pt).canRun(this)}));const i=this.state.status==="pending",s=!k(this,Bi).canStart();try{if(i)n();else{ue(this,Ln,Ar).call(this,{type:"pending",variables:t,isPaused:s}),k(this,pt).config.onMutate&&await k(this,pt).config.onMutate(t,this,r);const T=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,t,r));T!==this.state.context&&ue(this,Ln,Ar).call(this,{type:"pending",context:T,variables:t,isPaused:s})}const C=await k(this,Bi).start();return await((u=(l=k(this,pt).config).onSuccess)==null?void 0:u.call(l,C,t,this.state.context,this,r)),await((d=(c=this.options).onSuccess)==null?void 0:d.call(c,C,t,this.state.context,r)),await((m=(f=k(this,pt).config).onSettled)==null?void 0:m.call(f,C,null,this.state.variables,this.state.context,this,r)),await((p=(_=this.options).onSettled)==null?void 0:p.call(_,C,null,t,this.state.context,r)),ue(this,Ln,Ar).call(this,{type:"success",data:C}),C}catch(C){try{await((h=(y=k(this,pt).config).onError)==null?void 0:h.call(y,C,t,this.state.context,this,r))}catch(T){Promise.reject(T)}try{await((x=(v=this.options).onError)==null?void 0:x.call(v,C,t,this.state.context,r))}catch(T){Promise.reject(T)}try{await((E=(b=k(this,pt).config).onSettled)==null?void 0:E.call(b,void 0,C,this.state.variables,this.state.context,this,r))}catch(T){Promise.reject(T)}try{await((P=(S=this.options).onSettled)==null?void 0:P.call(S,void 0,C,t,this.state.context,r))}catch(T){Promise.reject(T)}throw ue(this,Ln,Ar).call(this,{type:"error",error:C}),C}finally{k(this,pt).runNext(this)}}},pl=new WeakMap,Fn=new WeakMap,pt=new WeakMap,Bi=new WeakMap,Ln=new WeakSet,Ar=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),at.batch(()=>{k(this,Fn).forEach(r=>{r.onMutationUpdate(t)}),k(this,pt).notify({mutation:this,type:"updated",action:t})})},rw);function KA(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var or,_n,vl,iw,QA=(iw=class extends El{constructor(t={}){super();X(this,or);X(this,_n);X(this,vl);this.config=t,H(this,or,new Set),H(this,_n,new Map),H(this,vl,0)}build(t,n,r){const i=new GA({client:t,mutationCache:this,mutationId:++Tl(this,vl)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){k(this,or).add(t);const n=su(t);if(typeof n=="string"){const r=k(this,_n).get(n);r?r.push(t):k(this,_n).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(k(this,or).delete(t)){const n=su(t);if(typeof n=="string"){const r=k(this,_n).get(n);if(r)if(r.length>1){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}else r[0]===t&&k(this,_n).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=su(t);if(typeof n=="string"){const r=k(this,_n).get(n),i=r==null?void 0:r.find(s=>s.state.status==="pending");return!i||i===t}else return!0}runNext(t){var r;const n=su(t);if(typeof n=="string"){const i=(r=k(this,_n).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused);return(i==null?void 0:i.continue())??Promise.resolve()}else return Promise.resolve()}clear(){at.batch(()=>{k(this,or).forEach(t=>{this.notify({type:"removed",mutation:t})}),k(this,or).clear(),k(this,_n).clear()})}getAll(){return Array.from(k(this,or))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>t0(n,r))}findAll(t={}){return this.getAll().filter(n=>t0(t,n))}notify(t){at.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return at.batch(()=>Promise.all(t.map(n=>n.continue().catch(At))))}},or=new WeakMap,_n=new WeakMap,vl=new WeakMap,iw);function su(e){var t;return(t=e.options.scope)==null?void 0:t.id}var jn,sw,YA=(sw=class extends El{constructor(t={}){super();X(this,jn);this.config=t,H(this,jn,new Map)}build(t,n,r){const i=n.queryKey,s=n.queryHash??Ng(i,n);let o=this.get(s);return o||(o=new BA({client:t,queryKey:i,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(o)),o}add(t){k(this,jn).has(t.queryHash)||(k(this,jn).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=k(this,jn).get(t.queryHash);n&&(t.destroy(),n===t&&k(this,jn).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){at.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return k(this,jn).get(t)}getAll(){return[...k(this,jn).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>e0(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>e0(t,r)):n}notify(t){at.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){at.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){at.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},jn=new WeakMap,sw),qe,qr,Wr,lo,uo,Hr,co,fo,ow,XA=(ow=class{constructor(e={}){X(this,qe);X(this,qr);X(this,Wr);X(this,lo);X(this,uo);X(this,Hr);X(this,co);X(this,fo);H(this,qe,e.queryCache||new YA),H(this,qr,e.mutationCache||new QA),H(this,Wr,e.defaultOptions||{}),H(this,lo,new Map),H(this,uo,new Map),H(this,Hr,0)}mount(){Tl(this,Hr)._++,k(this,Hr)===1&&(H(this,co,Ag.subscribe(async e=>{e&&(await this.resumePausedMutations(),k(this,qe).onFocus())})),H(this,fo,jc.subscribe(async e=>{e&&(await this.resumePausedMutations(),k(this,qe).onOnline())})))}unmount(){var e,t;Tl(this,Hr)._--,k(this,Hr)===0&&((e=k(this,co))==null||e.call(this),H(this,co,void 0),(t=k(this,fo))==null||t.call(this),H(this,fo,void 0))}isFetching(e){return k(this,qe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return k(this,qr).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=k(this,qe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=k(this,qe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(si(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return k(this,qe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=k(this,qe).get(r.queryHash),s=i==null?void 0:i.state.data,o=MA(t,s);if(o!==void 0)return k(this,qe).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return at.batch(()=>k(this,qe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=k(this,qe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=k(this,qe);at.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=k(this,qe);return at.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=at.batch(()=>k(this,qe).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(At).catch(At)}invalidateQueries(e,t={}){return at.batch(()=>(k(this,qe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=at.batch(()=>k(this,qe).findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(At)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(At)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=k(this,qe).build(this,t);return n.isStaleByTime(si(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(At).catch(At)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(At).catch(At)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return jc.isOnline()?k(this,qr).resumePausedMutations():Promise.resolve()}getQueryCache(){return k(this,qe)}getMutationCache(){return k(this,qr)}getDefaultOptions(){return k(this,Wr)}setDefaultOptions(e){H(this,Wr,e)}setQueryDefaults(e,t){k(this,lo).set(il(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...k(this,lo).values()],n={};return t.forEach(r=>{sl(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){k(this,uo).set(il(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...k(this,uo).values()],n={};return t.forEach(r=>{sl(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...k(this,Wr).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ng(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===$g&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...k(this,Wr).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){k(this,qe).clear(),k(this,qr).clear()}},qe=new WeakMap,qr=new WeakMap,Wr=new WeakMap,lo=new WeakMap,uo=new WeakMap,Hr=new WeakMap,co=new WeakMap,fo=new WeakMap,ow),DS=g.createContext(void 0),zS=e=>{const t=g.useContext(DS);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},JA=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),w.jsx(DS.Provider,{value:e,children:t})),US=g.createContext(!1),ZA=()=>g.useContext(US);US.Provider;function eN(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var tN=g.createContext(eN()),nN=()=>g.useContext(tN),rN=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?OS(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},iN=e=>{g.useEffect(()=>{e.clearReset()},[e])},sN=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||OS(n,[e.error,r])),oN=e=>{if(e.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},aN=(e,t)=>e.isLoading&&e.isFetching&&!t,lN=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,l0=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function uN(e,t,n){var f,m,_,p;const r=ZA(),i=nN(),s=zS(),o=s.defaultQueryOptions(e);(m=(f=s.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||m.call(f,o);const a=s.getQueryCache().get(o.queryHash);o._optimisticResults=r?"isRestoring":"optimistic",oN(o),rN(o,i,a),iN(i);const l=!s.getQueryCache().get(o.queryHash),[u]=g.useState(()=>new t(s,o)),c=u.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(g.useSyncExternalStore(g.useCallback(y=>{const h=d?u.subscribe(at.batchCalls(y)):At;return u.updateResult(),h},[u,d]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),g.useEffect(()=>{u.setOptions(o)},[o,u]),lN(o,c))throw l0(o,u,i);if(sN({result:c,errorResetBoundary:i,throwOnError:o.throwOnError,query:a,suspense:o.suspense}))throw c.error;if((p=(_=s.getDefaultOptions().queries)==null?void 0:_._experimental_afterQuery)==null||p.call(_,o,c),o.experimental_prefetchInRender&&!ol.isServer()&&aN(c,r)){const y=l?l0(o,u,i):a==null?void 0:a.promise;y==null||y.catch(At).finally(()=>{u.updateResult()})}return o.notifyOnChangeProps?c:u.trackResult(c)}function cN(e,t){return uN(e,qA)}function ee(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function u0(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function vi(...e){return t=>{let n=!1;const r=e.map(i=>{const s=u0(i,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i{const{children:o,...a}=s,l=g.useMemo(()=>a,Object.values(a));return w.jsx(n.Provider,{value:l,children:o})};r.displayName=e+"Provider";function i(s){const o=g.useContext(n);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,i]}function ss(e,t=[]){let n=[];function r(s,o){const a=g.createContext(o),l=n.length;n=[...n,o];const u=d=>{var h;const{scope:f,children:m,..._}=d,p=((h=f==null?void 0:f[e])==null?void 0:h[l])||a,y=g.useMemo(()=>_,Object.values(_));return w.jsx(p.Provider,{value:y,children:m})};u.displayName=s+"Provider";function c(d,f){var p;const m=((p=f==null?void 0:f[e])==null?void 0:p[l])||a,_=g.useContext(m);if(_)return _;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[u,c]}const i=()=>{const s=n.map(o=>g.createContext(o));return function(a){const l=(a==null?void 0:a[e])||s;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return i.scopeName=e,[r,fN(i,...t)]}function fN(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:u})=>{const d=l(s)[`__scope${u}`];return{...a,...d}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var fn=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},hN=Kc[" useId ".trim().toString()]||(()=>{}),pN=0;function Qs(e){const[t,n]=g.useState(hN());return fn(()=>{n(r=>r??String(pN++))},[e]),t?`radix-${t}`:""}var vN=Kc[" useInsertionEffect ".trim().toString()]||fn;function yd({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,s,o]=gN({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:i;{const c=g.useRef(e!==void 0);g.useEffect(()=>{const d=c.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=a},[a,r])}const u=g.useCallback(c=>{var d;if(a){const f=mN(c)?c(e):c;f!==e&&((d=o.current)==null||d.call(o,f))}else s(c)},[a,e,s,o]);return[l,u]}function gN({defaultProp:e,onChange:t}){const[n,r]=g.useState(e),i=g.useRef(n),s=g.useRef(t);return vN(()=>{s.current=t},[t]),g.useEffect(()=>{var o;i.current!==n&&((o=s.current)==null||o.call(s,n),i.current=n)},[n,i]),[n,r,s]}function mN(e){return typeof e=="function"}function yN(e){const t=_N(e),n=g.forwardRef((r,i)=>{const{children:s,...o}=r,a=g.Children.toArray(s),l=a.find(xN);if(l){const u=l.props.children,c=a.map(d=>d===l?g.Children.count(u)>1?g.Children.only(null):g.isValidElement(u)?u.props.children:null:d);return w.jsx(t,{...o,ref:i,children:g.isValidElement(u)?g.cloneElement(u,void 0,c):null})}return w.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function _N(e){const t=g.forwardRef((n,r)=>{const{children:i,...s}=n;if(g.isValidElement(i)){const o=EN(i),a=bN(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vi(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var wN=Symbol("radix.slottable");function xN(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===wN}function bN(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function EN(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var SN=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ke=SN.reduce((e,t)=>{const n=yN(`Primitive.${t}`),r=g.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),w.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Lg(e,t){e&&xl.flushSync(()=>e.dispatchEvent(t))}function Ut(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function CN(e,t=globalThis==null?void 0:globalThis.document){const n=Ut(e);g.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var kN="DismissableLayer",tv="dismissableLayer.update",PN="dismissableLayer.pointerDownOutside",RN="dismissableLayer.focusOutside",c0,VS=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_d=g.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...l}=e,u=g.useContext(VS),[c,d]=g.useState(null),f=(c==null?void 0:c.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=g.useState({}),_=et(t,P=>d(P)),p=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),h=p.indexOf(y),v=c?p.indexOf(c):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,b=v>=h,E=IN(P=>{const C=P.target,T=[...u.branches].some(R=>R.contains(C));!b||T||(i==null||i(P),o==null||o(P),P.defaultPrevented||a==null||a())},f),S=ON(P=>{const C=P.target;[...u.branches].some(R=>R.contains(C))||(s==null||s(P),o==null||o(P),P.defaultPrevented||a==null||a())},f);return CN(P=>{v===u.layers.size-1&&(r==null||r(P),!P.defaultPrevented&&a&&(P.preventDefault(),a()))},f),g.useEffect(()=>{if(c)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(c0=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),d0(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=c0)}},[c,f,n,u]),g.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),d0())},[c,u]),g.useEffect(()=>{const P=()=>m({});return document.addEventListener(tv,P),()=>document.removeEventListener(tv,P)},[]),w.jsx(ke.div,{...l,ref:_,style:{pointerEvents:x?b?"auto":"none":void 0,...e.style},onFocusCapture:ee(e.onFocusCapture,S.onFocusCapture),onBlurCapture:ee(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:ee(e.onPointerDownCapture,E.onPointerDownCapture)})});_d.displayName=kN;var TN="DismissableLayerBranch",BS=g.forwardRef((e,t)=>{const n=g.useContext(VS),r=g.useRef(null),i=et(t,r);return g.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),w.jsx(ke.div,{...e,ref:i})});BS.displayName=TN;function IN(e,t=globalThis==null?void 0:globalThis.document){const n=Ut(e),r=g.useRef(!1),i=g.useRef(()=>{});return g.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){qS(PN,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=l,t.addEventListener("click",i.current,{once:!0})):l()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",s),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function ON(e,t=globalThis==null?void 0:globalThis.document){const n=Ut(e),r=g.useRef(!1);return g.useEffect(()=>{const i=s=>{s.target&&!r.current&&qS(RN,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function d0(){const e=new CustomEvent(tv);document.dispatchEvent(e)}function qS(e,t,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Lg(i,s):i.dispatchEvent(s)}var MN=_d,AN=BS,Vf="focusScope.autoFocusOnMount",Bf="focusScope.autoFocusOnUnmount",f0={bubbles:!1,cancelable:!0},NN="FocusScope",jg=g.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=e,[a,l]=g.useState(null),u=Ut(i),c=Ut(s),d=g.useRef(null),f=et(t,p=>l(p)),m=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let p=function(x){if(m.paused||!a)return;const b=x.target;a.contains(b)?d.current=b:Nr(d.current,{select:!0})},y=function(x){if(m.paused||!a)return;const b=x.relatedTarget;b!==null&&(a.contains(b)||Nr(d.current,{select:!0}))},h=function(x){if(document.activeElement===document.body)for(const E of x)E.removedNodes.length>0&&Nr(a)};document.addEventListener("focusin",p),document.addEventListener("focusout",y);const v=new MutationObserver(h);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",y),v.disconnect()}}},[r,a,m.paused]),g.useEffect(()=>{if(a){p0.add(m);const p=document.activeElement;if(!a.contains(p)){const h=new CustomEvent(Vf,f0);a.addEventListener(Vf,u),a.dispatchEvent(h),h.defaultPrevented||($N(zN(WS(a)),{select:!0}),document.activeElement===p&&Nr(a))}return()=>{a.removeEventListener(Vf,u),setTimeout(()=>{const h=new CustomEvent(Bf,f0);a.addEventListener(Bf,c),a.dispatchEvent(h),h.defaultPrevented||Nr(p??document.body,{select:!0}),a.removeEventListener(Bf,c),p0.remove(m)},0)}}},[a,u,c,m]);const _=g.useCallback(p=>{if(!n&&!r||m.paused)return;const y=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,h=document.activeElement;if(y&&h){const v=p.currentTarget,[x,b]=FN(v);x&&b?!p.shiftKey&&h===b?(p.preventDefault(),n&&Nr(x,{select:!0})):p.shiftKey&&h===x&&(p.preventDefault(),n&&Nr(b,{select:!0})):h===v&&p.preventDefault()}},[n,r,m.paused]);return w.jsx(ke.div,{tabIndex:-1,...o,ref:f,onKeyDown:_})});jg.displayName=NN;function $N(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Nr(r,{select:t}),document.activeElement!==n)return}function FN(e){const t=WS(e),n=h0(t,e),r=h0(t.reverse(),e);return[n,r]}function WS(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function h0(e,t){for(const n of e)if(!LN(n,{upTo:t}))return n}function LN(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function jN(e){return e instanceof HTMLInputElement&&"select"in e}function Nr(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&jN(e)&&t&&e.select()}}var p0=DN();function DN(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=v0(e,t),e.unshift(t)},remove(t){var n;e=v0(e,t),(n=e[0])==null||n.resume()}}}function v0(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function zN(e){return e.filter(t=>t.tagName!=="A")}var UN="Portal",wd=g.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[i,s]=g.useState(!1);fn(()=>s(!0),[]);const o=n||i&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?vT.createPortal(w.jsx(ke.div,{...r,ref:t}),o):null});wd.displayName=UN;function VN(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var br=e=>{const{present:t,children:n}=e,r=BN(t),i=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),s=et(r.ref,qN(i));return typeof n=="function"||r.isPresent?g.cloneElement(i,{ref:s}):null};br.displayName="Presence";function BN(e){const[t,n]=g.useState(),r=g.useRef(null),i=g.useRef(e),s=g.useRef("none"),o=e?"mounted":"unmounted",[a,l]=VN(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const u=ou(r.current);s.current=a==="mounted"?u:"none"},[a]),fn(()=>{const u=r.current,c=i.current;if(c!==e){const f=s.current,m=ou(u);e?l("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(c&&f!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),fn(()=>{if(t){let u;const c=t.ownerDocument.defaultView??window,d=m=>{const p=ou(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&p&&(l("ANIMATION_END"),!i.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},f=m=>{m.target===t&&(s.current=ou(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(u),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:g.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function ou(e){return(e==null?void 0:e.animationName)||"none"}function qN(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var qf=0;function HS(){g.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??g0()),document.body.insertAdjacentElement("beforeend",e[1]??g0()),qf++,()=>{qf===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),qf--}},[])}function g0(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Un=function(){return Un=Object.assign||function(t){for(var n,r=1,i=arguments.length;r"u")return a$;var t=l$(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},c$=YS(),Ys="data-scroll-locked",d$=function(e,t,n,r){var i=e.left,s=e.top,o=e.right,a=e.gap;return n===void 0&&(n="margin"),` + .`.concat(HN,` { overflow: hidden `).concat(r,`; padding-right: `).concat(a,"px ").concat(r,`; } @@ -102,16 +102,16 @@ Error generating stack: `+s.message+` } body[`).concat(Ys,`] { - `).concat(KN,": ").concat(a,`px; + `).concat(GN,": ").concat(a,`px; } -`)},y0=function(){var e=parseInt(document.body.getAttribute(Ys)||"0",10);return isFinite(e)?e:0},h$=function(){g.useEffect(function(){return document.body.setAttribute(Ys,(y0()+1).toString()),function(){var e=y0()-1;e<=0?document.body.removeAttribute(Ys):document.body.setAttribute(Ys,e.toString())}},[])},p$=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;h$();var s=g.useMemo(function(){return c$(i)},[i]);return g.createElement(d$,{styles:f$(s,!t,i,n?"":"!important")})},nv=!1;if(typeof window<"u")try{var au=Object.defineProperty({},"passive",{get:function(){return nv=!0,!0}});window.addEventListener("test",au,au),window.removeEventListener("test",au,au)}catch{nv=!1}var ys=nv?{passive:!1}:!1,v$=function(e){return e.tagName==="TEXTAREA"},XS=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!v$(e)&&n[t]==="visible")},g$=function(e){return XS(e,"overflowY")},m$=function(e){return XS(e,"overflowX")},_0=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=JS(e,r);if(i){var s=ZS(e,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},y$=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},_$=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},JS=function(e,t){return e==="v"?g$(t):m$(t)},ZS=function(e,t){return e==="v"?y$(t):_$(t)},w$=function(e,t){return e==="h"&&t==="rtl"?-1:1},x$=function(e,t,n,r,i){var s=w$(e,window.getComputedStyle(t).direction),o=s*r,a=n.target,l=t.contains(a),u=!1,c=o>0,d=0,f=0;do{if(!a)break;var m=ZS(e,a),_=m[0],p=m[1],y=m[2],h=p-y-s*_;(_||h)&&JS(e,a)&&(d+=h,f+=_);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(c&&Math.abs(d)<1||!c&&Math.abs(f)<1)&&(u=!0),u},lu=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},w0=function(e){return[e.deltaX,e.deltaY]},x0=function(e){return e&&"current"in e?e.current:e},b$=function(e,t){return e[0]===t[0]&&e[1]===t[1]},E$=function(e){return` +`)},y0=function(){var e=parseInt(document.body.getAttribute(Ys)||"0",10);return isFinite(e)?e:0},f$=function(){g.useEffect(function(){return document.body.setAttribute(Ys,(y0()+1).toString()),function(){var e=y0()-1;e<=0?document.body.removeAttribute(Ys):document.body.setAttribute(Ys,e.toString())}},[])},h$=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;f$();var s=g.useMemo(function(){return u$(i)},[i]);return g.createElement(c$,{styles:d$(s,!t,i,n?"":"!important")})},nv=!1;if(typeof window<"u")try{var au=Object.defineProperty({},"passive",{get:function(){return nv=!0,!0}});window.addEventListener("test",au,au),window.removeEventListener("test",au,au)}catch{nv=!1}var ys=nv?{passive:!1}:!1,p$=function(e){return e.tagName==="TEXTAREA"},XS=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!p$(e)&&n[t]==="visible")},v$=function(e){return XS(e,"overflowY")},g$=function(e){return XS(e,"overflowX")},_0=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=JS(e,r);if(i){var s=ZS(e,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},m$=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},y$=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},JS=function(e,t){return e==="v"?v$(t):g$(t)},ZS=function(e,t){return e==="v"?m$(t):y$(t)},_$=function(e,t){return e==="h"&&t==="rtl"?-1:1},w$=function(e,t,n,r,i){var s=_$(e,window.getComputedStyle(t).direction),o=s*r,a=n.target,l=t.contains(a),u=!1,c=o>0,d=0,f=0;do{if(!a)break;var m=ZS(e,a),_=m[0],p=m[1],y=m[2],h=p-y-s*_;(_||h)&&JS(e,a)&&(d+=h,f+=_);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(c&&Math.abs(d)<1||!c&&Math.abs(f)<1)&&(u=!0),u},lu=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},w0=function(e){return[e.deltaX,e.deltaY]},x0=function(e){return e&&"current"in e?e.current:e},x$=function(e,t){return e[0]===t[0]&&e[1]===t[1]},b$=function(e){return` .block-interactivity-`.concat(e,` {pointer-events: none;} .allow-interactivity-`).concat(e,` {pointer-events: all;} -`)},S$=0,_s=[];function C$(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(S$++)[0],s=g.useState(YS)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var p=HN([e.lockRef.current],(e.shards||[]).map(x0),!0).filter(Boolean);return p.forEach(function(y){return y.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),p.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(p,y){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!o.current.allowPinchZoom;var h=lu(p),v=n.current,x="deltaX"in p?p.deltaX:v[0]-h[0],b="deltaY"in p?p.deltaY:v[1]-h[1],E,S=p.target,P=Math.abs(x)>Math.abs(b)?"h":"v";if("touches"in p&&P==="h"&&S.type==="range")return!1;var C=window.getSelection(),T=C&&C.anchorNode,R=T?T===S||T.contains(S):!1;if(R)return!1;var N=_0(P,S);if(!N)return!0;if(N?E=P:(E=P==="v"?"h":"v",N=_0(P,S)),!N)return!1;if(!r.current&&"changedTouches"in p&&(x||b)&&(r.current=E),!E)return!0;var M=r.current||E;return x$(M,y,p,M==="h"?x:b)},[]),l=g.useCallback(function(p){var y=p;if(!(!_s.length||_s[_s.length-1]!==s)){var h="deltaY"in y?w0(y):lu(y),v=t.current.filter(function(E){return E.name===y.type&&(E.target===y.target||y.target===E.shadowParent)&&b$(E.delta,h)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var x=(o.current.shards||[]).map(x0).filter(Boolean).filter(function(E){return E.contains(y.target)}),b=x.length>0?a(y,x[0]):!o.current.noIsolation;b&&y.cancelable&&y.preventDefault()}}},[]),u=g.useCallback(function(p,y,h,v){var x={name:p,delta:y,target:h,should:v,shadowParent:k$(h)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(b){return b!==x})},1)},[]),c=g.useCallback(function(p){n.current=lu(p),r.current=void 0},[]),d=g.useCallback(function(p){u(p.type,w0(p),p.target,a(p,e.lockRef.current))},[]),f=g.useCallback(function(p){u(p.type,lu(p),p.target,a(p,e.lockRef.current))},[]);g.useEffect(function(){return _s.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,ys),document.addEventListener("touchmove",l,ys),document.addEventListener("touchstart",c,ys),function(){_s=_s.filter(function(p){return p!==s}),document.removeEventListener("wheel",l,ys),document.removeEventListener("touchmove",l,ys),document.removeEventListener("touchstart",c,ys)}},[]);var m=e.removeScrollBar,_=e.inert;return g.createElement(g.Fragment,null,_?g.createElement(s,{styles:E$(i)}):null,m?g.createElement(p$,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function k$(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const P$=t$(QS,C$);var Dg=g.forwardRef(function(e,t){return g.createElement(xd,Un({},e,{ref:t,sideCar:P$}))});Dg.classNames=xd.classNames;var R$=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ws=new WeakMap,uu=new WeakMap,cu={},Kf=0,e1=function(e){return e&&(e.host||e1(e.parentNode))},T$=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=e1(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},I$=function(e,t,n,r){var i=T$(t,Array.isArray(e)?e:[e]);cu[n]||(cu[n]=new WeakMap);var s=cu[n],o=[],a=new Set,l=new Set(i),u=function(d){!d||a.has(d)||(a.add(d),u(d.parentNode))};i.forEach(u);var c=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))c(f);else try{var m=f.getAttribute(r),_=m!==null&&m!=="false",p=(ws.get(f)||0)+1,y=(s.get(f)||0)+1;ws.set(f,p),s.set(f,y),o.push(f),p===1&&_&&uu.set(f,!0),y===1&&f.setAttribute(n,"true"),_||f.setAttribute(r,"true")}catch(h){console.error("aria-hidden: cannot operate on ",f,h)}})};return c(t),a.clear(),Kf++,function(){o.forEach(function(d){var f=ws.get(d)-1,m=s.get(d)-1;ws.set(d,f),s.set(d,m),f||(uu.has(d)||d.removeAttribute(r),uu.delete(d)),m||d.removeAttribute(n)}),Kf--,Kf||(ws=new WeakMap,ws=new WeakMap,uu=new WeakMap,cu={})}},t1=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=R$(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),I$(r,i,n,"aria-hidden")):function(){return null}};function O$(e){const t=M$(e),n=g.forwardRef((r,i)=>{const{children:s,...o}=r,a=g.Children.toArray(s),l=a.find(N$);if(l){const u=l.props.children,c=a.map(d=>d===l?g.Children.count(u)>1?g.Children.only(null):g.isValidElement(u)?u.props.children:null:d);return w.jsx(t,{...o,ref:i,children:g.isValidElement(u)?g.cloneElement(u,void 0,c):null})}return w.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function M$(e){const t=g.forwardRef((n,r)=>{const{children:i,...s}=n;if(g.isValidElement(i)){const o=F$(i),a=$$(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vi(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var A$=Symbol("radix.slottable");function N$(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===A$}function $$(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function F$(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var bd="Dialog",[n1]=ss(bd),[L$,Tn]=n1(bd),r1=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=g.useRef(null),l=g.useRef(null),[u,c]=yd({prop:r,defaultProp:i??!1,onChange:s,caller:bd});return w.jsx(L$,{scope:t,triggerRef:a,contentRef:l,contentId:Qs(),titleId:Qs(),descriptionId:Qs(),open:u,onOpenChange:c,onOpenToggle:g.useCallback(()=>c(d=>!d),[c]),modal:o,children:n})};r1.displayName=bd;var i1="DialogTrigger",s1=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Tn(i1,n),s=et(t,i.triggerRef);return w.jsx(ke.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Vg(i.open),...r,ref:s,onClick:ee(e.onClick,i.onOpenToggle)})});s1.displayName=i1;var zg="DialogPortal",[j$,o1]=n1(zg,{forceMount:void 0}),a1=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=Tn(zg,t);return w.jsx(j$,{scope:t,forceMount:n,children:g.Children.map(r,o=>w.jsx(br,{present:n||s.open,children:w.jsx(wd,{asChild:!0,container:i,children:o})}))})};a1.displayName=zg;var Dc="DialogOverlay",l1=g.forwardRef((e,t)=>{const n=o1(Dc,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Tn(Dc,e.__scopeDialog);return s.modal?w.jsx(br,{present:r||s.open,children:w.jsx(z$,{...i,ref:t})}):null});l1.displayName=Dc;var D$=O$("DialogOverlay.RemoveScroll"),z$=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Tn(Dc,n);return w.jsx(Dg,{as:D$,allowPinchZoom:!0,shards:[i.contentRef],children:w.jsx(ke.div,{"data-state":Vg(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),es="DialogContent",u1=g.forwardRef((e,t)=>{const n=o1(es,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Tn(es,e.__scopeDialog);return w.jsx(br,{present:r||s.open,children:s.modal?w.jsx(U$,{...i,ref:t}):w.jsx(V$,{...i,ref:t})})});u1.displayName=es;var U$=g.forwardRef((e,t)=>{const n=Tn(es,e.__scopeDialog),r=g.useRef(null),i=et(t,n.contentRef,r);return g.useEffect(()=>{const s=r.current;if(s)return t1(s)},[]),w.jsx(c1,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ee(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:ee(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:ee(e.onFocusOutside,s=>s.preventDefault())})}),V$=g.forwardRef((e,t)=>{const n=Tn(es,e.__scopeDialog),r=g.useRef(!1),i=g.useRef(!1);return w.jsx(c1,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),c1=g.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=Tn(es,n),l=g.useRef(null),u=et(t,l);return HS(),w.jsxs(w.Fragment,{children:[w.jsx(jg,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:w.jsx(_d,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Vg(a.open),...o,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),w.jsxs(w.Fragment,{children:[w.jsx(B$,{titleId:a.titleId}),w.jsx(W$,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ug="DialogTitle",d1=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Tn(Ug,n);return w.jsx(ke.h2,{id:i.titleId,...r,ref:t})});d1.displayName=Ug;var f1="DialogDescription",h1=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Tn(f1,n);return w.jsx(ke.p,{id:i.descriptionId,...r,ref:t})});h1.displayName=f1;var p1="DialogClose",v1=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Tn(p1,n);return w.jsx(ke.button,{type:"button",...r,ref:t,onClick:ee(e.onClick,()=>i.onOpenChange(!1))})});v1.displayName=p1;function Vg(e){return e?"open":"closed"}var g1="DialogTitleWarning",[az,m1]=fN(g1,{contentName:es,titleName:Ug,docsSlug:"dialog"}),B$=({titleId:e})=>{const t=m1(g1),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users. +`)},E$=0,_s=[];function S$(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(E$++)[0],s=g.useState(YS)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var p=WN([e.lockRef.current],(e.shards||[]).map(x0),!0).filter(Boolean);return p.forEach(function(y){return y.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),p.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(p,y){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!o.current.allowPinchZoom;var h=lu(p),v=n.current,x="deltaX"in p?p.deltaX:v[0]-h[0],b="deltaY"in p?p.deltaY:v[1]-h[1],E,S=p.target,P=Math.abs(x)>Math.abs(b)?"h":"v";if("touches"in p&&P==="h"&&S.type==="range")return!1;var C=window.getSelection(),T=C&&C.anchorNode,R=T?T===S||T.contains(S):!1;if(R)return!1;var N=_0(P,S);if(!N)return!0;if(N?E=P:(E=P==="v"?"h":"v",N=_0(P,S)),!N)return!1;if(!r.current&&"changedTouches"in p&&(x||b)&&(r.current=E),!E)return!0;var M=r.current||E;return w$(M,y,p,M==="h"?x:b)},[]),l=g.useCallback(function(p){var y=p;if(!(!_s.length||_s[_s.length-1]!==s)){var h="deltaY"in y?w0(y):lu(y),v=t.current.filter(function(E){return E.name===y.type&&(E.target===y.target||y.target===E.shadowParent)&&x$(E.delta,h)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var x=(o.current.shards||[]).map(x0).filter(Boolean).filter(function(E){return E.contains(y.target)}),b=x.length>0?a(y,x[0]):!o.current.noIsolation;b&&y.cancelable&&y.preventDefault()}}},[]),u=g.useCallback(function(p,y,h,v){var x={name:p,delta:y,target:h,should:v,shadowParent:C$(h)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(b){return b!==x})},1)},[]),c=g.useCallback(function(p){n.current=lu(p),r.current=void 0},[]),d=g.useCallback(function(p){u(p.type,w0(p),p.target,a(p,e.lockRef.current))},[]),f=g.useCallback(function(p){u(p.type,lu(p),p.target,a(p,e.lockRef.current))},[]);g.useEffect(function(){return _s.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,ys),document.addEventListener("touchmove",l,ys),document.addEventListener("touchstart",c,ys),function(){_s=_s.filter(function(p){return p!==s}),document.removeEventListener("wheel",l,ys),document.removeEventListener("touchmove",l,ys),document.removeEventListener("touchstart",c,ys)}},[]);var m=e.removeScrollBar,_=e.inert;return g.createElement(g.Fragment,null,_?g.createElement(s,{styles:b$(i)}):null,m?g.createElement(h$,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function C$(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const k$=e$(QS,S$);var Dg=g.forwardRef(function(e,t){return g.createElement(xd,Un({},e,{ref:t,sideCar:k$}))});Dg.classNames=xd.classNames;var P$=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ws=new WeakMap,uu=new WeakMap,cu={},Kf=0,e1=function(e){return e&&(e.host||e1(e.parentNode))},R$=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=e1(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},T$=function(e,t,n,r){var i=R$(t,Array.isArray(e)?e:[e]);cu[n]||(cu[n]=new WeakMap);var s=cu[n],o=[],a=new Set,l=new Set(i),u=function(d){!d||a.has(d)||(a.add(d),u(d.parentNode))};i.forEach(u);var c=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))c(f);else try{var m=f.getAttribute(r),_=m!==null&&m!=="false",p=(ws.get(f)||0)+1,y=(s.get(f)||0)+1;ws.set(f,p),s.set(f,y),o.push(f),p===1&&_&&uu.set(f,!0),y===1&&f.setAttribute(n,"true"),_||f.setAttribute(r,"true")}catch(h){console.error("aria-hidden: cannot operate on ",f,h)}})};return c(t),a.clear(),Kf++,function(){o.forEach(function(d){var f=ws.get(d)-1,m=s.get(d)-1;ws.set(d,f),s.set(d,m),f||(uu.has(d)||d.removeAttribute(r),uu.delete(d)),m||d.removeAttribute(n)}),Kf--,Kf||(ws=new WeakMap,ws=new WeakMap,uu=new WeakMap,cu={})}},t1=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=P$(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),T$(r,i,n,"aria-hidden")):function(){return null}};function I$(e){const t=O$(e),n=g.forwardRef((r,i)=>{const{children:s,...o}=r,a=g.Children.toArray(s),l=a.find(A$);if(l){const u=l.props.children,c=a.map(d=>d===l?g.Children.count(u)>1?g.Children.only(null):g.isValidElement(u)?u.props.children:null:d);return w.jsx(t,{...o,ref:i,children:g.isValidElement(u)?g.cloneElement(u,void 0,c):null})}return w.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function O$(e){const t=g.forwardRef((n,r)=>{const{children:i,...s}=n;if(g.isValidElement(i)){const o=$$(i),a=N$(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vi(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var M$=Symbol("radix.slottable");function A$(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===M$}function N$(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function $$(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var bd="Dialog",[n1]=ss(bd),[F$,Tn]=n1(bd),r1=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=g.useRef(null),l=g.useRef(null),[u,c]=yd({prop:r,defaultProp:i??!1,onChange:s,caller:bd});return w.jsx(F$,{scope:t,triggerRef:a,contentRef:l,contentId:Qs(),titleId:Qs(),descriptionId:Qs(),open:u,onOpenChange:c,onOpenToggle:g.useCallback(()=>c(d=>!d),[c]),modal:o,children:n})};r1.displayName=bd;var i1="DialogTrigger",s1=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Tn(i1,n),s=et(t,i.triggerRef);return w.jsx(ke.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Vg(i.open),...r,ref:s,onClick:ee(e.onClick,i.onOpenToggle)})});s1.displayName=i1;var zg="DialogPortal",[L$,o1]=n1(zg,{forceMount:void 0}),a1=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=Tn(zg,t);return w.jsx(L$,{scope:t,forceMount:n,children:g.Children.map(r,o=>w.jsx(br,{present:n||s.open,children:w.jsx(wd,{asChild:!0,container:i,children:o})}))})};a1.displayName=zg;var Dc="DialogOverlay",l1=g.forwardRef((e,t)=>{const n=o1(Dc,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Tn(Dc,e.__scopeDialog);return s.modal?w.jsx(br,{present:r||s.open,children:w.jsx(D$,{...i,ref:t})}):null});l1.displayName=Dc;var j$=I$("DialogOverlay.RemoveScroll"),D$=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Tn(Dc,n);return w.jsx(Dg,{as:j$,allowPinchZoom:!0,shards:[i.contentRef],children:w.jsx(ke.div,{"data-state":Vg(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),es="DialogContent",u1=g.forwardRef((e,t)=>{const n=o1(es,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Tn(es,e.__scopeDialog);return w.jsx(br,{present:r||s.open,children:s.modal?w.jsx(z$,{...i,ref:t}):w.jsx(U$,{...i,ref:t})})});u1.displayName=es;var z$=g.forwardRef((e,t)=>{const n=Tn(es,e.__scopeDialog),r=g.useRef(null),i=et(t,n.contentRef,r);return g.useEffect(()=>{const s=r.current;if(s)return t1(s)},[]),w.jsx(c1,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ee(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:ee(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:ee(e.onFocusOutside,s=>s.preventDefault())})}),U$=g.forwardRef((e,t)=>{const n=Tn(es,e.__scopeDialog),r=g.useRef(!1),i=g.useRef(!1);return w.jsx(c1,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),c1=g.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=Tn(es,n),l=g.useRef(null),u=et(t,l);return HS(),w.jsxs(w.Fragment,{children:[w.jsx(jg,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:w.jsx(_d,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Vg(a.open),...o,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),w.jsxs(w.Fragment,{children:[w.jsx(V$,{titleId:a.titleId}),w.jsx(q$,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ug="DialogTitle",d1=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Tn(Ug,n);return w.jsx(ke.h2,{id:i.titleId,...r,ref:t})});d1.displayName=Ug;var f1="DialogDescription",h1=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Tn(f1,n);return w.jsx(ke.p,{id:i.descriptionId,...r,ref:t})});h1.displayName=f1;var p1="DialogClose",v1=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Tn(p1,n);return w.jsx(ke.button,{type:"button",...r,ref:t,onClick:ee(e.onClick,()=>i.onOpenChange(!1))})});v1.displayName=p1;function Vg(e){return e?"open":"closed"}var g1="DialogTitleWarning",[az,m1]=dN(g1,{contentName:es,titleName:Ug,docsSlug:"dialog"}),V$=({titleId:e})=>{const t=m1(g1),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component. -For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},q$="DialogDescriptionWarning",W$=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${m1(q$).contentName}}.`;return g.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},H$=r1,G$=s1,K$=a1,Q$=l1,Y$=u1,X$=d1,lz=h1,J$=v1;const b0=e=>e.endsWith("/")?e.slice(0,-1):e;function os(e){return["1","true","yes"].includes(String(e??"").trim().toLowerCase())}function Bg(){const e="https://paperswithcode.co".trim();if(!e)return"";try{const t=e.startsWith("http")?new URL(e):new URL(e,typeof window<"u"?window.location.origin:"http://localhost");return b0(t.origin)}catch{return b0(e)}}function Z$(e){const t=e.startsWith("/")?e:`/${e}`,n=Bg();return n?`${n}${t}`:t}function qg(e){const t=e.startsWith("/")?e:`/${e}`;return Z$(t)}function y1(e,t={}){const n=qg("/api/v1/auth/hf/login"),i=new URL(n,window.location.origin).origin===window.location.origin?e:new URL(e,window.location.origin).toString(),s=new URLSearchParams({return_to:i});return t.authorizeInference&&s.set("authorize_inference","true"),t.collectEmail&&s.set("collect_email","true"),t.authorizeBucket&&s.set("authorize_bucket","true"),t.bucketCreate&&s.set("bucket_create","true"),`${n}?${s.toString()}`}function eF(){return qg("/admin-dashboard")}function uz(e){if(!e)return null;if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("blob:")||e.startsWith("//"))return e;if(e.startsWith("/")){const t=Bg();return t?`${t}${e}`:e}return e}function $o(){return os("1")}function al(){return os("0")}const tF="https://paperswithcode.co/chat";function nF(){return $o()&&!al()}function rF(){return os(void 0)}function cz(){return al()&&os(void 0)}function dz(){return os("0")}function fz(){return os("0")}function hz(){return typeof window<"u"&&window.location.hostname==="staging.paperswithcode.co"}function iF(){return os("1")}const sF="/hf-logo.svg?v=20260513b",E0=({size:e=14})=>w.jsx("img",{src:sF,alt:"",width:Math.round(e*95/88),height:e,"aria-hidden":"true",draggable:!1,style:{display:"block"}});function pz(e,t=!1){return y1(e,{authorizeInference:t})}const _1=({returnTo:e,compact:t=!1,label:n="Sign in",authorizeInference:r=!1,collectEmail:i=!1})=>{if($o())return null;const s=()=>{window.location.href=y1(e,{authorizeInference:r,collectEmail:i})};return t?w.jsx("button",{type:"button",className:"icon-btn","aria-label":"Sign in with Hugging Face",title:"Sign in with Hugging Face",onClick:s,children:w.jsx(E0,{size:16})}):w.jsxs("button",{type:"button",className:"hf-signin-btn",onClick:s,"aria-label":"Sign in with Hugging Face",children:[w.jsx(E0,{size:18}),w.jsx("span",{children:n})]})};function oF(e,t=[]){let n=[];function r(s,o){const a=g.createContext(o);a.displayName=s+"Context";const l=n.length;n=[...n,o];const u=d=>{var h;const{scope:f,children:m,..._}=d,p=((h=f==null?void 0:f[e])==null?void 0:h[l])||a,y=g.useMemo(()=>_,Object.values(_));return w.jsx(p.Provider,{value:y,children:m})};u.displayName=s+"Provider";function c(d,f){var p;const m=((p=f==null?void 0:f[e])==null?void 0:p[l])||a,_=g.useContext(m);if(_)return _;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[u,c]}const i=()=>{const s=n.map(o=>g.createContext(o));return function(a){const l=(a==null?void 0:a[e])||s;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return i.scopeName=e,[r,aF(i,...t)]}function aF(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:u})=>{const d=l(s)[`__scope${u}`];return{...a,...d}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var lF=Symbol.for("react.lazy"),zc=Kc[" use ".trim().toString()];function uF(e){return typeof e=="object"&&e!==null&&"then"in e}function w1(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===lF&&"_payload"in e&&uF(e._payload)}function x1(e){const t=cF(e),n=g.forwardRef((r,i)=>{let{children:s,...o}=r;w1(s)&&typeof zc=="function"&&(s=zc(s._payload));const a=g.Children.toArray(s),l=a.find(fF);if(l){const u=l.props.children,c=a.map(d=>d===l?g.Children.count(u)>1?g.Children.only(null):g.isValidElement(u)?u.props.children:null:d);return w.jsx(t,{...o,ref:i,children:g.isValidElement(u)?g.cloneElement(u,void 0,c):null})}return w.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}var vz=x1("Slot");function cF(e){const t=g.forwardRef((n,r)=>{let{children:i,...s}=n;if(w1(i)&&typeof zc=="function"&&(i=zc(i._payload)),g.isValidElement(i)){const o=pF(i),a=hF(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vi(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var dF=Symbol("radix.slottable");function fF(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===dF}function hF(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function pF(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var vF=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Wg=vF.reduce((e,t)=>{const n=x1(`Primitive.${t}`),r=g.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),w.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),b1={exports:{}},E1={};/** +For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},B$="DialogDescriptionWarning",q$=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${m1(B$).contentName}}.`;return g.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},W$=r1,H$=s1,G$=a1,K$=l1,Q$=u1,Y$=d1,lz=h1,X$=v1;const b0=e=>e.endsWith("/")?e.slice(0,-1):e;function os(e){return["1","true","yes"].includes(String(e??"").trim().toLowerCase())}function Bg(){const e="https://paperswithcode.co".trim();if(!e)return"";try{const t=e.startsWith("http")?new URL(e):new URL(e,typeof window<"u"?window.location.origin:"http://localhost");return b0(t.origin)}catch{return b0(e)}}function J$(e){const t=e.startsWith("/")?e:`/${e}`,n=Bg();return n?`${n}${t}`:t}function qg(e){const t=e.startsWith("/")?e:`/${e}`;return J$(t)}function Z$(e,t={}){const n=qg("/api/v1/auth/hf/login"),i=new URL(n,window.location.origin).origin===window.location.origin?e:new URL(e,window.location.origin).toString(),s=new URLSearchParams({return_to:i});return t.authorizeInference&&s.set("authorize_inference","true"),t.collectEmail&&s.set("collect_email","true"),t.authorizeBucket&&s.set("authorize_bucket","true"),t.bucketCreate&&s.set("bucket_create","true"),`${n}?${s.toString()}`}function eF(){return qg("/admin-dashboard")}function uz(e){if(!e)return null;if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("blob:")||e.startsWith("//"))return e;if(e.startsWith("/")){const t=Bg();return t?`${t}${e}`:e}return e}function $o(){return os("1")}function al(){return os("0")}const tF="https://paperswithcode.co/chat";function nF(){return $o()&&!al()}function rF(){return os(void 0)}function cz(){return al()&&os(void 0)}function dz(){return os("0")}function fz(){return os("0")}function hz(){return typeof window<"u"&&window.location.hostname==="staging.paperswithcode.co"}function iF(){return os("1")}const sF="/hf-logo.svg?v=20260513b",E0=({size:e=14})=>w.jsx("img",{src:sF,alt:"",width:Math.round(e*95/88),height:e,"aria-hidden":"true",draggable:!1,style:{display:"block"}}),y1=({returnTo:e,compact:t=!1,label:n="Sign in",authorizeInference:r=!1,collectEmail:i=!1})=>{if($o())return null;const s=()=>{window.location.href=Z$(e,{authorizeInference:r,collectEmail:i})};return t?w.jsx("button",{type:"button",className:"icon-btn","aria-label":"Sign in with Hugging Face",title:"Sign in with Hugging Face",onClick:s,children:w.jsx(E0,{size:16})}):w.jsxs("button",{type:"button",className:"hf-signin-btn",onClick:s,"aria-label":"Sign in with Hugging Face",children:[w.jsx(E0,{size:18}),w.jsx("span",{children:n})]})};function oF(e,t=[]){let n=[];function r(s,o){const a=g.createContext(o);a.displayName=s+"Context";const l=n.length;n=[...n,o];const u=d=>{var h;const{scope:f,children:m,..._}=d,p=((h=f==null?void 0:f[e])==null?void 0:h[l])||a,y=g.useMemo(()=>_,Object.values(_));return w.jsx(p.Provider,{value:y,children:m})};u.displayName=s+"Provider";function c(d,f){var p;const m=((p=f==null?void 0:f[e])==null?void 0:p[l])||a,_=g.useContext(m);if(_)return _;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[u,c]}const i=()=>{const s=n.map(o=>g.createContext(o));return function(a){const l=(a==null?void 0:a[e])||s;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return i.scopeName=e,[r,aF(i,...t)]}function aF(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:u})=>{const d=l(s)[`__scope${u}`];return{...a,...d}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var lF=Symbol.for("react.lazy"),zc=Kc[" use ".trim().toString()];function uF(e){return typeof e=="object"&&e!==null&&"then"in e}function _1(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===lF&&"_payload"in e&&uF(e._payload)}function w1(e){const t=cF(e),n=g.forwardRef((r,i)=>{let{children:s,...o}=r;_1(s)&&typeof zc=="function"&&(s=zc(s._payload));const a=g.Children.toArray(s),l=a.find(fF);if(l){const u=l.props.children,c=a.map(d=>d===l?g.Children.count(u)>1?g.Children.only(null):g.isValidElement(u)?u.props.children:null:d);return w.jsx(t,{...o,ref:i,children:g.isValidElement(u)?g.cloneElement(u,void 0,c):null})}return w.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}var pz=w1("Slot");function cF(e){const t=g.forwardRef((n,r)=>{let{children:i,...s}=n;if(_1(i)&&typeof zc=="function"&&(i=zc(i._payload)),g.isValidElement(i)){const o=pF(i),a=hF(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vi(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var dF=Symbol("radix.slottable");function fF(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===dF}function hF(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function pF(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var vF=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Wg=vF.reduce((e,t)=>{const n=w1(`Primitive.${t}`),r=g.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),w.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),x1={exports:{}},b1={};/** * @license React * use-sync-external-store-shim.production.js * @@ -119,12 +119,12 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var To=g;function gF(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var mF=typeof Object.is=="function"?Object.is:gF,yF=To.useState,_F=To.useEffect,wF=To.useLayoutEffect,xF=To.useDebugValue;function bF(e,t){var n=t(),r=yF({inst:{value:n,getSnapshot:t}}),i=r[0].inst,s=r[1];return wF(function(){i.value=n,i.getSnapshot=t,Qf(i)&&s({inst:i})},[e,n,t]),_F(function(){return Qf(i)&&s({inst:i}),e(function(){Qf(i)&&s({inst:i})})},[e]),xF(n),n}function Qf(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!mF(e,n)}catch{return!0}}function EF(e,t){return t()}var SF=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?EF:bF;E1.useSyncExternalStore=To.useSyncExternalStore!==void 0?To.useSyncExternalStore:SF;b1.exports=E1;var CF=b1.exports;function kF(){return CF.useSyncExternalStore(PF,()=>!0,()=>!1)}function PF(){return()=>{}}var Hg="Avatar",[RF]=oF(Hg),[TF,S1]=RF(Hg),C1=g.forwardRef((e,t)=>{const{__scopeAvatar:n,...r}=e,[i,s]=g.useState("idle");return w.jsx(TF,{scope:n,imageLoadingStatus:i,onImageLoadingStatusChange:s,children:w.jsx(Wg.span,{...r,ref:t})})});C1.displayName=Hg;var k1="AvatarImage",P1=g.forwardRef((e,t)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:i=()=>{},...s}=e,o=S1(k1,n),a=IF(r,s),l=Ut(u=>{i(u),o.onImageLoadingStatusChange(u)});return fn(()=>{a!=="idle"&&l(a)},[a,l]),a==="loaded"?w.jsx(Wg.img,{...s,ref:t,src:r}):null});P1.displayName=k1;var R1="AvatarFallback",T1=g.forwardRef((e,t)=>{const{__scopeAvatar:n,delayMs:r,...i}=e,s=S1(R1,n),[o,a]=g.useState(r===void 0);return g.useEffect(()=>{if(r!==void 0){const l=window.setTimeout(()=>a(!0),r);return()=>window.clearTimeout(l)}},[r]),o&&s.imageLoadingStatus!=="loaded"?w.jsx(Wg.span,{...i,ref:t}):null});T1.displayName=R1;function S0(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function IF(e,{referrerPolicy:t,crossOrigin:n}){const r=kF(),i=g.useRef(null),s=r?(i.current||(i.current=new window.Image),i.current):null,[o,a]=g.useState(()=>S0(s,e));return fn(()=>{a(S0(s,e))},[s,e]),fn(()=>{const l=d=>()=>{a(d)};if(!s)return;const u=l("loaded"),c=l("error");return s.addEventListener("load",u),s.addEventListener("error",c),t&&(s.referrerPolicy=t),typeof n=="string"&&(s.crossOrigin=n),()=>{s.removeEventListener("load",u),s.removeEventListener("error",c)}},[s,n,t]),o}var I1=C1,O1=P1,M1=T1;function A1(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t{const t=AF(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const a=o.split(Gg);return a[0]===""&&a.length!==1&&a.shift(),$1(a,t)||MF(o)},getConflictingClassGroupIds:(o,a)=>{const l=n[o]||[];return a&&r[o]?[...l,...r[o]]:l}}},$1=(e,t)=>{var o;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?$1(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;const s=e.join(Gg);return(o=t.validators.find(({validator:a})=>a(s)))==null?void 0:o.classGroupId},C0=/^\[(.+)\]$/,MF=e=>{if(C0.test(e)){const t=C0.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},AF=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return $F(Object.entries(e.classGroups),n).forEach(([s,o])=>{rv(o,r,s,t)}),r},rv=(e,t,n,r)=>{e.forEach(i=>{if(typeof i=="string"){const s=i===""?t:k0(t,i);s.classGroupId=n;return}if(typeof i=="function"){if(NF(i)){rv(i(r),t,n,r);return}t.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{rv(o,k0(t,s),n,r)})})},k0=(e,t)=>{let n=e;return t.split(Gg).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},NF=e=>e.isThemeGetter,$F=(e,t)=>t?e.map(([n,r])=>{const i=r.map(s=>typeof s=="string"?t+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,a])=>[t+o,a])):s);return[n,i]}):e,FF=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},F1="!",LF=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,i=t[0],s=t.length,o=a=>{const l=[];let u=0,c=0,d;for(let y=0;yc?d-c:void 0;return{modifiers:l,hasImportantModifier:m,baseClassName:_,maybePostfixModifierPosition:p}};return n?a=>n({className:a,parseClassName:o}):o},jF=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},DF=e=>({cache:FF(e.cacheSize),parseClassName:LF(e),...OF(e)}),zF=/\s+/,UF=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,s=[],o=e.trim().split(zF);let a="";for(let l=o.length-1;l>=0;l-=1){const u=o[l],{modifiers:c,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:m}=n(u);let _=!!m,p=r(_?f.substring(0,m):f);if(!p){if(!_){a=u+(a.length>0?" "+a:a);continue}if(p=r(f),!p){a=u+(a.length>0?" "+a:a);continue}_=!1}const y=jF(c).join(":"),h=d?y+F1:y,v=h+p;if(s.includes(v))continue;s.push(v);const x=i(p,_);for(let b=0;b0?" "+a:a)}return a};function VF(){let e=0,t,n,r="";for(;e{if(typeof e=="string")return e;let t,n="";for(let r=0;rd(c),e());return n=DF(u),r=n.cache.get,i=n.cache.set,s=a,a(l)}function a(l){const u=r(l);if(u)return u;const c=UF(l,n);return i(l,c),c}return function(){return s(VF.apply(null,arguments))}}const Oe=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},j1=/^\[(?:([a-z-]+):)?(.+)\]$/i,qF=/^\d+\/\d+$/,WF=new Set(["px","full","screen"]),HF=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,GF=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,KF=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,QF=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,YF=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Xn=e=>Xs(e)||WF.has(e)||qF.test(e),Ir=e=>Fo(e,"length",iL),Xs=e=>!!e&&!Number.isNaN(Number(e)),Yf=e=>Fo(e,"number",Xs),ra=e=>!!e&&Number.isInteger(Number(e)),XF=e=>e.endsWith("%")&&Xs(e.slice(0,-1)),ie=e=>j1.test(e),Or=e=>HF.test(e),JF=new Set(["length","size","percentage"]),ZF=e=>Fo(e,JF,D1),eL=e=>Fo(e,"position",D1),tL=new Set(["image","url"]),nL=e=>Fo(e,tL,oL),rL=e=>Fo(e,"",sL),ia=()=>!0,Fo=(e,t,n)=>{const r=j1.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},iL=e=>GF.test(e)&&!KF.test(e),D1=()=>!1,sL=e=>QF.test(e),oL=e=>YF.test(e),aL=()=>{const e=Oe("colors"),t=Oe("spacing"),n=Oe("blur"),r=Oe("brightness"),i=Oe("borderColor"),s=Oe("borderRadius"),o=Oe("borderSpacing"),a=Oe("borderWidth"),l=Oe("contrast"),u=Oe("grayscale"),c=Oe("hueRotate"),d=Oe("invert"),f=Oe("gap"),m=Oe("gradientColorStops"),_=Oe("gradientColorStopPositions"),p=Oe("inset"),y=Oe("margin"),h=Oe("opacity"),v=Oe("padding"),x=Oe("saturate"),b=Oe("scale"),E=Oe("sepia"),S=Oe("skew"),P=Oe("space"),C=Oe("translate"),T=()=>["auto","contain","none"],R=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto",ie,t],M=()=>[ie,t],z=()=>["",Xn,Ir],F=()=>["auto",Xs,ie],W=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],B=()=>["solid","dashed","dotted","double","none"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],O=()=>["start","end","center","between","around","evenly","stretch"],A=()=>["","0",ie],V=()=>["auto","avoid","all","avoid-page","page","left","right","column"],K=()=>[Xs,ie];return{cacheSize:500,separator:":",theme:{colors:[ia],spacing:[Xn,Ir],blur:["none","",Or,ie],brightness:K(),borderColor:[e],borderRadius:["none","","full",Or,ie],borderSpacing:M(),borderWidth:z(),contrast:K(),grayscale:A(),hueRotate:K(),invert:A(),gap:M(),gradientColorStops:[e],gradientColorStopPositions:[XF,Ir],inset:N(),margin:N(),opacity:K(),padding:M(),saturate:K(),scale:K(),sepia:A(),skew:K(),space:M(),translate:M()},classGroups:{aspect:[{aspect:["auto","square","video",ie]}],container:["container"],columns:[{columns:[Or]}],"break-after":[{"break-after":V()}],"break-before":[{"break-before":V()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...W(),ie]}],overflow:[{overflow:R()}],"overflow-x":[{"overflow-x":R()}],"overflow-y":[{"overflow-y":R()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[p]}],"inset-x":[{"inset-x":[p]}],"inset-y":[{"inset-y":[p]}],start:[{start:[p]}],end:[{end:[p]}],top:[{top:[p]}],right:[{right:[p]}],bottom:[{bottom:[p]}],left:[{left:[p]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ra,ie]}],basis:[{basis:N()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ie]}],grow:[{grow:A()}],shrink:[{shrink:A()}],order:[{order:["first","last","none",ra,ie]}],"grid-cols":[{"grid-cols":[ia]}],"col-start-end":[{col:["auto",{span:["full",ra,ie]},ie]}],"col-start":[{"col-start":F()}],"col-end":[{"col-end":F()}],"grid-rows":[{"grid-rows":[ia]}],"row-start-end":[{row:["auto",{span:[ra,ie]},ie]}],"row-start":[{"row-start":F()}],"row-end":[{"row-end":F()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ie]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ie]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...O()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...O(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...O(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[y]}],mx:[{mx:[y]}],my:[{my:[y]}],ms:[{ms:[y]}],me:[{me:[y]}],mt:[{mt:[y]}],mr:[{mr:[y]}],mb:[{mb:[y]}],ml:[{ml:[y]}],"space-x":[{"space-x":[P]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[P]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ie,t]}],"min-w":[{"min-w":[ie,t,"min","max","fit"]}],"max-w":[{"max-w":[ie,t,"none","full","min","max","fit","prose",{screen:[Or]},Or]}],h:[{h:[ie,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ie,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ie,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ie,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Or,Ir]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Yf]}],"font-family":[{font:[ia]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ie]}],"line-clamp":[{"line-clamp":["none",Xs,Yf]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Xn,ie]}],"list-image":[{"list-image":["none",ie]}],"list-style-type":[{list:["none","disc","decimal",ie]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[h]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[h]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...B(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Xn,Ir]}],"underline-offset":[{"underline-offset":["auto",Xn,ie]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:M()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ie]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ie]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[h]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...W(),eL]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",ZF]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},nL]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[_]}],"gradient-via-pos":[{via:[_]}],"gradient-to-pos":[{to:[_]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[h]}],"border-style":[{border:[...B(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[h]}],"divide-style":[{divide:B()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...B()]}],"outline-offset":[{"outline-offset":[Xn,ie]}],"outline-w":[{outline:[Xn,Ir]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[h]}],"ring-offset-w":[{"ring-offset":[Xn,Ir]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Or,rL]}],"shadow-color":[{shadow:[ia]}],opacity:[{opacity:[h]}],"mix-blend":[{"mix-blend":[...Q(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Q()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Or,ie]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[d]}],saturate:[{saturate:[x]}],sepia:[{sepia:[E]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[h]}],"backdrop-saturate":[{"backdrop-saturate":[x]}],"backdrop-sepia":[{"backdrop-sepia":[E]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ie]}],duration:[{duration:K()}],ease:[{ease:["linear","in","out","in-out",ie]}],delay:[{delay:K()}],animate:[{animate:["none","spin","ping","pulse","bounce",ie]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[b]}],"scale-x":[{"scale-x":[b]}],"scale-y":[{"scale-y":[b]}],rotate:[{rotate:[ra,ie]}],"translate-x":[{"translate-x":[C]}],"translate-y":[{"translate-y":[C]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ie]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ie]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":M()}],"scroll-mx":[{"scroll-mx":M()}],"scroll-my":[{"scroll-my":M()}],"scroll-ms":[{"scroll-ms":M()}],"scroll-me":[{"scroll-me":M()}],"scroll-mt":[{"scroll-mt":M()}],"scroll-mr":[{"scroll-mr":M()}],"scroll-mb":[{"scroll-mb":M()}],"scroll-ml":[{"scroll-ml":M()}],"scroll-p":[{"scroll-p":M()}],"scroll-px":[{"scroll-px":M()}],"scroll-py":[{"scroll-py":M()}],"scroll-ps":[{"scroll-ps":M()}],"scroll-pe":[{"scroll-pe":M()}],"scroll-pt":[{"scroll-pt":M()}],"scroll-pr":[{"scroll-pr":M()}],"scroll-pb":[{"scroll-pb":M()}],"scroll-pl":[{"scroll-pl":M()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ie]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Xn,Ir,Yf]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},lL=BF(aL);function ct(...e){return lL(N1(e))}function gz(e){return e.replace(/v\d+$/i,"")}function mz(e){const t=e.trim(),n=t.match(/^(\d{4})-(\d{4,5})(v\d+)?$/);if(n)return`${n[1]}.${n[2]}`;const r=t.match(/^(\d{4}\.\d{4,5})(v\d+)$/);return r?r[1]:t}function yz(e){if(e==null||e==="")return"—";const t=typeof e=="string"?parseFloat(e):e;return Number.isFinite(t)?Math.abs(t)>=100?du(t,0):Math.abs(t)>=10?du(t,1):Math.abs(t)<1?du(t,3):du(t,2):String(e)}function du(e,t){const n=String(Math.abs(e));if(n.includes("e"))return e.toFixed(t);const r=+`${Math.round(+`${n}e${t}`)}e-${t}`;return(e<0?-r:r).toFixed(t)}const z1=g.forwardRef(({className:e,...t},n)=>w.jsx(I1,{ref:n,className:ct("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));z1.displayName=I1.displayName;const U1=g.forwardRef(({className:e,...t},n)=>w.jsx(O1,{ref:n,className:ct("aspect-square h-full w-full",e),...t}));U1.displayName=O1.displayName;const V1=g.forwardRef(({className:e,...t},n)=>w.jsx(M1,{ref:n,className:ct("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));V1.displayName=M1.displayName;function P0(e){const t=uL(e),n=g.forwardRef((r,i)=>{const{children:s,...o}=r,a=g.Children.toArray(s),l=a.find(dL);if(l){const u=l.props.children,c=a.map(d=>d===l?g.Children.count(u)>1?g.Children.only(null):g.isValidElement(u)?u.props.children:null:d);return w.jsx(t,{...o,ref:i,children:g.isValidElement(u)?g.cloneElement(u,void 0,c):null})}return w.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function uL(e){const t=g.forwardRef((n,r)=>{const{children:i,...s}=n;if(g.isValidElement(i)){const o=hL(i),a=fL(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vi(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var cL=Symbol("radix.slottable");function dL(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===cL}function fL(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function hL(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Kg(e){const t=e+"CollectionProvider",[n,r]=ss(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=p=>{const{scope:y,children:h}=p,v=q.useRef(null),x=q.useRef(new Map).current;return w.jsx(i,{scope:y,itemMap:x,collectionRef:v,children:h})};o.displayName=t;const a=e+"CollectionSlot",l=P0(a),u=q.forwardRef((p,y)=>{const{scope:h,children:v}=p,x=s(a,h),b=et(y,x.collectionRef);return w.jsx(l,{ref:b,children:v})});u.displayName=a;const c=e+"CollectionItemSlot",d="data-radix-collection-item",f=P0(c),m=q.forwardRef((p,y)=>{const{scope:h,children:v,...x}=p,b=q.useRef(null),E=et(y,b),S=s(c,h);return q.useEffect(()=>(S.itemMap.set(b,{ref:b,...x}),()=>void S.itemMap.delete(b))),w.jsx(f,{[d]:"",ref:E,children:v})});m.displayName=c;function _(p){const y=s(e+"CollectionConsumer",p);return q.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const x=Array.from(v.querySelectorAll(`[${d}]`));return Array.from(y.itemMap.values()).sort((S,P)=>x.indexOf(S.ref.current)-x.indexOf(P.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:o,Slot:u,ItemSlot:m},_,r]}var pL=g.createContext(void 0);function B1(e){const t=g.useContext(pL);return e||t||"ltr"}const vL=["top","right","bottom","left"],ci=Math.min,Ht=Math.max,Uc=Math.round,fu=Math.floor,Hn=e=>({x:e,y:e}),gL={left:"right",right:"left",bottom:"top",top:"bottom"};function iv(e,t,n){return Ht(e,ci(t,n))}function yr(e,t){return typeof e=="function"?e(t):e}function _r(e){return e.split("-")[0]}function Lo(e){return e.split("-")[1]}function Qg(e){return e==="x"?"y":"x"}function Yg(e){return e==="y"?"height":"width"}function Bn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Xg(e){return Qg(Bn(e))}function mL(e,t,n){n===void 0&&(n=!1);const r=Lo(e),i=Xg(e),s=Yg(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=Vc(o)),[o,Vc(o)]}function yL(e){const t=Vc(e);return[sv(e),t,sv(t)]}function sv(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const R0=["left","right"],T0=["right","left"],_L=["top","bottom"],wL=["bottom","top"];function xL(e,t,n){switch(e){case"top":case"bottom":return n?t?T0:R0:t?R0:T0;case"left":case"right":return t?_L:wL;default:return[]}}function bL(e,t,n,r){const i=Lo(e);let s=xL(_r(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(sv)))),s}function Vc(e){const t=_r(e);return gL[t]+e.slice(t.length)}function EL(e){return{top:0,right:0,bottom:0,left:0,...e}}function q1(e){return typeof e!="number"?EL(e):{top:e,right:e,bottom:e,left:e}}function Bc(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function I0(e,t,n){let{reference:r,floating:i}=e;const s=Bn(t),o=Xg(t),a=Yg(o),l=_r(t),u=s==="y",c=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[a]/2-i[a]/2;let m;switch(l){case"top":m={x:c,y:r.y-i.height};break;case"bottom":m={x:c,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:d};break;case"left":m={x:r.x-i.width,y:d};break;default:m={x:r.x,y:r.y}}switch(Lo(t)){case"start":m[o]-=f*(n&&u?-1:1);break;case"end":m[o]+=f*(n&&u?-1:1);break}return m}async function SL(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:m=0}=yr(t,e),_=q1(m),y=a[f?d==="floating"?"reference":"floating":d],h=Bc(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:c,strategy:l})),v=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),b=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},E=Bc(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:l}):v);return{top:(h.top-E.top+_.top)/b.y,bottom:(E.bottom-h.bottom+_.bottom)/b.y,left:(h.left-E.left+_.left)/b.x,right:(E.right-h.right+_.right)/b.x}}const CL=50,kL=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:SL},l=await(o.isRTL==null?void 0:o.isRTL(t));let u=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:c,y:d}=I0(u,r,l),f=r,m=0;const _={};for(let p=0;p({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=t,{element:u,padding:c=0}=yr(e,t)||{};if(u==null)return{};const d=q1(c),f={x:n,y:r},m=Xg(i),_=Yg(m),p=await o.getDimensions(u),y=m==="y",h=y?"top":"left",v=y?"bottom":"right",x=y?"clientHeight":"clientWidth",b=s.reference[_]+s.reference[m]-f[m]-s.floating[_],E=f[m]-s.reference[m],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let P=S?S[x]:0;(!P||!await(o.isElement==null?void 0:o.isElement(S)))&&(P=a.floating[x]||s.floating[_]);const C=b/2-E/2,T=P/2-p[_]/2-1,R=ci(d[h],T),N=ci(d[v],T),M=R,z=P-p[_]-N,F=P/2-p[_]/2+C,W=iv(M,F,z),B=!l.arrow&&Lo(i)!=null&&F!==W&&s.reference[_]/2-(FF<=0)){var N,M;const F=(((N=s.flip)==null?void 0:N.index)||0)+1,W=P[F];if(W&&(!(d==="alignment"?v!==Bn(W):!1)||R.every(O=>Bn(O.placement)===v?O.overflows[0]>0:!0)))return{data:{index:F,overflows:R},reset:{placement:W}};let B=(M=R.filter(Q=>Q.overflows[0]<=0).sort((Q,O)=>Q.overflows[1]-O.overflows[1])[0])==null?void 0:M.placement;if(!B)switch(m){case"bestFit":{var z;const Q=(z=R.filter(O=>{if(S){const A=Bn(O.placement);return A===v||A==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(A=>A>0).reduce((A,V)=>A+V,0)]).sort((O,A)=>O[1]-A[1])[0])==null?void 0:z[0];Q&&(B=Q);break}case"initialPlacement":B=a;break}if(i!==B)return{reset:{placement:B}}}return{}}}};function O0(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function M0(e){return vL.some(t=>e[t]>=0)}const TL=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=yr(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),a=O0(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:M0(a)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),a=O0(o,n.floating);return{data:{escapedOffsets:a,escaped:M0(a)}}}default:return{}}}}},W1=new Set(["left","top"]);async function IL(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=_r(n),a=Lo(n),l=Bn(n)==="y",u=W1.has(o)?-1:1,c=s&&l?-1:1,d=yr(t,e);let{mainAxis:f,crossAxis:m,alignmentAxis:_}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof _=="number"&&(m=a==="end"?_*-1:_),l?{x:m*c,y:f*u}:{x:f*u,y:m*c}}const OL=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=t,l=await IL(t,e);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},ML=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:h=>{let{x:v,y:x}=h;return{x:v,y:x}}},...u}=yr(e,t),c={x:n,y:r},d=await s.detectOverflow(t,u),f=Bn(_r(i)),m=Qg(f);let _=c[m],p=c[f];if(o){const h=m==="y"?"top":"left",v=m==="y"?"bottom":"right",x=_+d[h],b=_-d[v];_=iv(x,_,b)}if(a){const h=f==="y"?"top":"left",v=f==="y"?"bottom":"right",x=p+d[h],b=p-d[v];p=iv(x,p,b)}const y=l.fn({...t,[m]:_,[f]:p});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[m]:o,[f]:a}}}}}},AL=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=yr(e,t),c={x:n,y:r},d=Bn(i),f=Qg(d);let m=c[f],_=c[d];const p=yr(a,t),y=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(l){const x=f==="y"?"height":"width",b=s.reference[f]-s.floating[x]+y.mainAxis,E=s.reference[f]+s.reference[x]-y.mainAxis;mE&&(m=E)}if(u){var h,v;const x=f==="y"?"width":"height",b=W1.has(_r(i)),E=s.reference[d]-s.floating[x]+(b&&((h=o.offset)==null?void 0:h[d])||0)+(b?0:y.crossAxis),S=s.reference[d]+s.reference[x]+(b?0:((v=o.offset)==null?void 0:v[d])||0)-(b?y.crossAxis:0);_S&&(_=S)}return{[f]:m,[d]:_}}}},NL=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:o,elements:a}=t,{apply:l=()=>{},...u}=yr(e,t),c=await o.detectOverflow(t,u),d=_r(i),f=Lo(i),m=Bn(i)==="y",{width:_,height:p}=s.floating;let y,h;d==="top"||d==="bottom"?(y=d,h=f===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(h=d,y=f==="end"?"top":"bottom");const v=p-c.top-c.bottom,x=_-c.left-c.right,b=ci(p-c[y],v),E=ci(_-c[h],x),S=!t.middlewareData.shift;let P=b,C=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(C=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(P=v),S&&!f){const R=Ht(c.left,0),N=Ht(c.right,0),M=Ht(c.top,0),z=Ht(c.bottom,0);m?C=_-2*(R!==0||N!==0?R+N:Ht(c.left,c.right)):P=p-2*(M!==0||z!==0?M+z:Ht(c.top,c.bottom))}await l({...t,availableWidth:C,availableHeight:P});const T=await o.getDimensions(a.floating);return _!==T.width||p!==T.height?{reset:{rects:!0}}:{}}}};function Ed(){return typeof window<"u"}function jo(e){return H1(e)?(e.nodeName||"").toLowerCase():"#document"}function Xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Kn(e){var t;return(t=(H1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function H1(e){return Ed()?e instanceof Node||e instanceof Xt(e).Node:!1}function Pn(e){return Ed()?e instanceof Element||e instanceof Xt(e).Element:!1}function Er(e){return Ed()?e instanceof HTMLElement||e instanceof Xt(e).HTMLElement:!1}function A0(e){return!Ed()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Xt(e).ShadowRoot}function Sl(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Rn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function $L(e){return/^(table|td|th)$/.test(jo(e))}function Sd(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const FL=/transform|translate|scale|rotate|perspective|filter/,LL=/paint|layout|strict|content/,xi=e=>!!e&&e!=="none";let Xf;function Jg(e){const t=Pn(e)?Rn(e):e;return xi(t.transform)||xi(t.translate)||xi(t.scale)||xi(t.rotate)||xi(t.perspective)||!Zg()&&(xi(t.backdropFilter)||xi(t.filter))||FL.test(t.willChange||"")||LL.test(t.contain||"")}function jL(e){let t=di(e);for(;Er(t)&&!Io(t);){if(Jg(t))return t;if(Sd(t))return null;t=di(t)}return null}function Zg(){return Xf==null&&(Xf=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Xf}function Io(e){return/^(html|body|#document)$/.test(jo(e))}function Rn(e){return Xt(e).getComputedStyle(e)}function Cd(e){return Pn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function di(e){if(jo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||A0(e)&&e.host||Kn(e);return A0(t)?t.host:t}function G1(e){const t=di(e);return Io(t)?e.ownerDocument?e.ownerDocument.body:e.body:Er(t)&&Sl(t)?t:G1(t)}function ll(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=G1(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=Xt(i);if(s){const a=ov(o);return t.concat(o,o.visualViewport||[],Sl(i)?i:[],a&&n?ll(a):[])}else return t.concat(i,ll(i,[],n))}function ov(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function K1(e){const t=Rn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Er(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=Uc(n)!==s||Uc(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function em(e){return Pn(e)?e:e.contextElement}function Js(e){const t=em(e);if(!Er(t))return Hn(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=K1(t);let o=(s?Uc(n.width):n.width)/r,a=(s?Uc(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const DL=Hn(0);function Q1(e){const t=Xt(e);return!Zg()||!t.visualViewport?DL:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function zL(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Xt(e)?!1:t}function ts(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=em(e);let o=Hn(1);t&&(r?Pn(r)&&(o=Js(r)):o=Js(e));const a=zL(s,n,r)?Q1(s):Hn(0);let l=(i.left+a.x)/o.x,u=(i.top+a.y)/o.y,c=i.width/o.x,d=i.height/o.y;if(s){const f=Xt(s),m=r&&Pn(r)?Xt(r):r;let _=f,p=ov(_);for(;p&&r&&m!==_;){const y=Js(p),h=p.getBoundingClientRect(),v=Rn(p),x=h.left+(p.clientLeft+parseFloat(v.paddingLeft))*y.x,b=h.top+(p.clientTop+parseFloat(v.paddingTop))*y.y;l*=y.x,u*=y.y,c*=y.x,d*=y.y,l+=x,u+=b,_=Xt(p),p=ov(_)}}return Bc({width:c,height:d,x:l,y:u})}function kd(e,t){const n=Cd(e).scrollLeft;return t?t.left+n:ts(Kn(e)).left+n}function Y1(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-kd(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function UL(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=Kn(r),a=t?Sd(t.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=Hn(1);const c=Hn(0),d=Er(r);if((d||!d&&!s)&&((jo(r)!=="body"||Sl(o))&&(l=Cd(r)),d)){const m=ts(r);u=Js(r),c.x=m.x+r.clientLeft,c.y=m.y+r.clientTop}const f=o&&!d&&!s?Y1(o,l):Hn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+c.x+f.x,y:n.y*u.y-l.scrollTop*u.y+c.y+f.y}}function VL(e){return Array.from(e.getClientRects())}function BL(e){const t=Kn(e),n=Cd(e),r=e.ownerDocument.body,i=Ht(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ht(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+kd(e);const a=-n.scrollTop;return Rn(r).direction==="rtl"&&(o+=Ht(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}const N0=25;function qL(e,t){const n=Xt(e),r=Kn(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const c=Zg();(!c||c&&t==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}const u=kd(r);if(u<=0){const c=r.ownerDocument,d=c.body,f=getComputedStyle(d),m=c.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,_=Math.abs(r.clientWidth-d.clientWidth-m);_<=N0&&(s-=_)}else u<=N0&&(s+=u);return{width:s,height:o,x:a,y:l}}function WL(e,t){const n=ts(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Er(e)?Js(e):Hn(1),o=e.clientWidth*s.x,a=e.clientHeight*s.y,l=i*s.x,u=r*s.y;return{width:o,height:a,x:l,y:u}}function $0(e,t,n){let r;if(t==="viewport")r=qL(e,n);else if(t==="document")r=BL(Kn(e));else if(Pn(t))r=WL(t,n);else{const i=Q1(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Bc(r)}function X1(e,t){const n=di(e);return n===t||!Pn(n)||Io(n)?!1:Rn(n).position==="fixed"||X1(n,t)}function HL(e,t){const n=t.get(e);if(n)return n;let r=ll(e,[],!1).filter(a=>Pn(a)&&jo(a)!=="body"),i=null;const s=Rn(e).position==="fixed";let o=s?di(e):e;for(;Pn(o)&&!Io(o);){const a=Rn(o),l=Jg(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Sl(o)&&!l&&X1(e,o))?r=r.filter(c=>c!==o):i=a,o=di(o)}return t.set(e,r),r}function GL(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?Sd(t)?[]:HL(t,this._c):[].concat(n),r],a=$0(t,o[0],i);let l=a.top,u=a.right,c=a.bottom,d=a.left;for(let f=1;f{o(!1,1e-7)},1e3)}P===1&&!Z1(u,e.getBoundingClientRect())&&o(),b=!1}try{n=new IntersectionObserver(E,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(E,x)}n.observe(e)}return o(!0),s}function ej(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=em(e),c=i||s?[...u?ll(u):[],...t?ll(t):[]]:[];c.forEach(h=>{i&&h.addEventListener("scroll",n,{passive:!0}),s&&h.addEventListener("resize",n)});const d=u&&a?ZL(u,n):null;let f=-1,m=null;o&&(m=new ResizeObserver(h=>{let[v]=h;v&&v.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=m)==null||x.observe(t)})),n()}),u&&!l&&m.observe(u),t&&m.observe(t));let _,p=l?ts(e):null;l&&y();function y(){const h=ts(e);p&&!Z1(p,h)&&n(),p=h,_=requestAnimationFrame(y)}return n(),()=>{var h;c.forEach(v=>{i&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),d==null||d(),(h=m)==null||h.disconnect(),m=null,l&&cancelAnimationFrame(_)}}const tj=OL,nj=ML,rj=RL,ij=NL,sj=TL,L0=PL,oj=AL,aj=(e,t,n)=>{const r=new Map,i={platform:JL,...n},s={...i.platform,_c:r};return kL(e,t,{...i,platform:s})};var lj=typeof document<"u",uj=function(){},Fu=lj?g.useLayoutEffect:uj;function qc(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!qc(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!qc(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function eC(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function j0(e,t){const n=eC(e);return Math.round(t*n)/n}function Zf(e){const t=g.useRef(e);return Fu(()=>{t.current=e}),t}function cj(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[c,d]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,m]=g.useState(r);qc(f,r)||m(r);const[_,p]=g.useState(null),[y,h]=g.useState(null),v=g.useCallback(O=>{O!==S.current&&(S.current=O,p(O))},[]),x=g.useCallback(O=>{O!==P.current&&(P.current=O,h(O))},[]),b=s||_,E=o||y,S=g.useRef(null),P=g.useRef(null),C=g.useRef(c),T=l!=null,R=Zf(l),N=Zf(i),M=Zf(u),z=g.useCallback(()=>{if(!S.current||!P.current)return;const O={placement:t,strategy:n,middleware:f};N.current&&(O.platform=N.current),aj(S.current,P.current,O).then(A=>{const V={...A,isPositioned:M.current!==!1};F.current&&!qc(C.current,V)&&(C.current=V,xl.flushSync(()=>{d(V)}))})},[f,t,n,N,M]);Fu(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,d(O=>({...O,isPositioned:!1})))},[u]);const F=g.useRef(!1);Fu(()=>(F.current=!0,()=>{F.current=!1}),[]),Fu(()=>{if(b&&(S.current=b),E&&(P.current=E),b&&E){if(R.current)return R.current(b,E,z);z()}},[b,E,z,R,T]);const W=g.useMemo(()=>({reference:S,floating:P,setReference:v,setFloating:x}),[v,x]),B=g.useMemo(()=>({reference:b,floating:E}),[b,E]),Q=g.useMemo(()=>{const O={position:n,left:0,top:0};if(!B.floating)return O;const A=j0(B.floating,c.x),V=j0(B.floating,c.y);return a?{...O,transform:"translate("+A+"px, "+V+"px)",...eC(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:V}},[n,a,B.floating,c.x,c.y]);return g.useMemo(()=>({...c,update:z,refs:W,elements:B,floatingStyles:Q}),[c,z,W,B,Q])}const dj=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?L0({element:r.current,padding:i}).fn(n):{}:r?L0({element:r,padding:i}).fn(n):{}}}},fj=(e,t)=>{const n=tj(e);return{name:n.name,fn:n.fn,options:[e,t]}},hj=(e,t)=>{const n=nj(e);return{name:n.name,fn:n.fn,options:[e,t]}},pj=(e,t)=>({fn:oj(e).fn,options:[e,t]}),vj=(e,t)=>{const n=rj(e);return{name:n.name,fn:n.fn,options:[e,t]}},gj=(e,t)=>{const n=ij(e);return{name:n.name,fn:n.fn,options:[e,t]}},mj=(e,t)=>{const n=sj(e);return{name:n.name,fn:n.fn,options:[e,t]}},yj=(e,t)=>{const n=dj(e);return{name:n.name,fn:n.fn,options:[e,t]}};var _j="Arrow",tC=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return w.jsx(ke.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:w.jsx("polygon",{points:"0,0 30,0 15,10"})})});tC.displayName=_j;var wj=tC;function xj(e){const[t,n]=g.useState(void 0);return fn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;o=u.inlineSize,a=u.blockSize}else o=e.offsetWidth,a=e.offsetHeight;n({width:o,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var tm="Popper",[nC,rC]=ss(tm),[bj,iC]=nC(tm),sC=e=>{const{__scopePopper:t,children:n}=e,[r,i]=g.useState(null);return w.jsx(bj,{scope:t,anchor:r,onAnchorChange:i,children:n})};sC.displayName=tm;var oC="PopperAnchor",aC=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=iC(oC,n),o=g.useRef(null),a=et(t,o),l=g.useRef(null);return g.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||o.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:w.jsx(ke.div,{...i,ref:a})});aC.displayName=oC;var nm="PopperContent",[Ej,Sj]=nC(nm),lC=g.forwardRef((e,t)=>{var Be,ye,Fe,Tt,Sr,_t;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:m="optimized",onPlaced:_,...p}=e,y=iC(nm,n),[h,v]=g.useState(null),x=et(t,Ye=>v(Ye)),[b,E]=g.useState(null),S=xj(b),P=(S==null?void 0:S.width)??0,C=(S==null?void 0:S.height)??0,T=r+(s!=="center"?"-"+s:""),R=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},N=Array.isArray(u)?u:[u],M=N.length>0,z={padding:R,boundary:N.filter(kj),altBoundary:M},{refs:F,floatingStyles:W,placement:B,isPositioned:Q,middlewareData:O}=cj({strategy:"fixed",placement:T,whileElementsMounted:(...Ye)=>ej(...Ye,{animationFrame:m==="always"}),elements:{reference:y.anchor},middleware:[fj({mainAxis:i+C,alignmentAxis:o}),l&&hj({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?pj():void 0,...z}),l&&vj({...z}),gj({...z,apply:({elements:Ye,rects:gi,availableWidth:us,availableHeight:It})=>{const{width:cs,height:Cr}=gi.reference,pn=Ye.floating.style;pn.setProperty("--radix-popper-available-width",`${us}px`),pn.setProperty("--radix-popper-available-height",`${It}px`),pn.setProperty("--radix-popper-anchor-width",`${cs}px`),pn.setProperty("--radix-popper-anchor-height",`${Cr}px`)}}),b&&yj({element:b,padding:a}),Pj({arrowWidth:P,arrowHeight:C}),f&&mj({strategy:"referenceHidden",...z})]}),[A,V]=dC(B),K=Ut(_);fn(()=>{Q&&(K==null||K())},[Q,K]);const te=(Be=O.arrow)==null?void 0:Be.x,oe=(ye=O.arrow)==null?void 0:ye.y,de=((Fe=O.arrow)==null?void 0:Fe.centerOffset)!==0,[be,Pe]=g.useState();return fn(()=>{h&&Pe(window.getComputedStyle(h).zIndex)},[h]),w.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:Q?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(Tt=O.transformOrigin)==null?void 0:Tt.x,(Sr=O.transformOrigin)==null?void 0:Sr.y].join(" "),...((_t=O.hide)==null?void 0:_t.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:w.jsx(Ej,{scope:n,placedSide:A,onArrowChange:E,arrowX:te,arrowY:oe,shouldHideArrow:de,children:w.jsx(ke.div,{"data-side":A,"data-align":V,...p,ref:x,style:{...p.style,animation:Q?void 0:"none"}})})})});lC.displayName=nm;var uC="PopperArrow",Cj={top:"bottom",right:"left",bottom:"top",left:"right"},cC=g.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=Sj(uC,r),o=Cj[s.placedSide];return w.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:w.jsx(wj,{...i,ref:n,style:{...i.style,display:"block"}})})});cC.displayName=uC;function kj(e){return e!==null}var Pj=e=>({name:"transformOrigin",options:e,fn(t){var y,h,v;const{placement:n,rects:r,middlewareData:i}=t,o=((y=i.arrow)==null?void 0:y.centerOffset)!==0,a=o?0:e.arrowWidth,l=o?0:e.arrowHeight,[u,c]=dC(n),d={start:"0%",center:"50%",end:"100%"}[c],f=(((h=i.arrow)==null?void 0:h.x)??0)+a/2,m=(((v=i.arrow)==null?void 0:v.y)??0)+l/2;let _="",p="";return u==="bottom"?(_=o?d:`${f}px`,p=`${-l}px`):u==="top"?(_=o?d:`${f}px`,p=`${r.floating.height+l}px`):u==="right"?(_=`${-l}px`,p=o?d:`${m}px`):u==="left"&&(_=`${r.floating.width+l}px`,p=o?d:`${m}px`),{data:{x:_,y:p}}}});function dC(e){const[t,n="center"]=e.split("-");return[t,n]}var Rj=sC,Tj=aC,Ij=lC,Oj=cC,eh="rovingFocusGroup.onEntryFocus",Mj={bubbles:!1,cancelable:!0},Cl="RovingFocusGroup",[av,fC,Aj]=Kg(Cl),[Nj,hC]=ss(Cl,[Aj]),[$j,Fj]=Nj(Cl),pC=g.forwardRef((e,t)=>w.jsx(av.Provider,{scope:e.__scopeRovingFocusGroup,children:w.jsx(av.Slot,{scope:e.__scopeRovingFocusGroup,children:w.jsx(Lj,{...e,ref:t})})}));pC.displayName=Cl;var Lj=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:c=!1,...d}=e,f=g.useRef(null),m=et(t,f),_=B1(s),[p,y]=yd({prop:o,defaultProp:a??null,onChange:l,caller:Cl}),[h,v]=g.useState(!1),x=Ut(u),b=fC(n),E=g.useRef(!1),[S,P]=g.useState(0);return g.useEffect(()=>{const C=f.current;if(C)return C.addEventListener(eh,x),()=>C.removeEventListener(eh,x)},[x]),w.jsx($j,{scope:n,orientation:r,dir:_,loop:i,currentTabStopId:p,onItemFocus:g.useCallback(C=>y(C),[y]),onItemShiftTab:g.useCallback(()=>v(!0),[]),onFocusableItemAdd:g.useCallback(()=>P(C=>C+1),[]),onFocusableItemRemove:g.useCallback(()=>P(C=>C-1),[]),children:w.jsx(ke.div,{tabIndex:h||S===0?-1:0,"data-orientation":r,...d,ref:m,style:{outline:"none",...e.style},onMouseDown:ee(e.onMouseDown,()=>{E.current=!0}),onFocus:ee(e.onFocus,C=>{const T=!E.current;if(C.target===C.currentTarget&&T&&!h){const R=new CustomEvent(eh,Mj);if(C.currentTarget.dispatchEvent(R),!R.defaultPrevented){const N=b().filter(B=>B.focusable),M=N.find(B=>B.active),z=N.find(B=>B.id===p),W=[M,z,...N].filter(Boolean).map(B=>B.ref.current);mC(W,c)}}E.current=!1}),onBlur:ee(e.onBlur,()=>v(!1))})})}),vC="RovingFocusGroupItem",gC=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=e,l=Qs(),u=s||l,c=Fj(vC,n),d=c.currentTabStopId===u,f=fC(n),{onFocusableItemAdd:m,onFocusableItemRemove:_,currentTabStopId:p}=c;return g.useEffect(()=>{if(r)return m(),()=>_()},[r,m,_]),w.jsx(av.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:w.jsx(ke.span,{tabIndex:d?0:-1,"data-orientation":c.orientation,...a,ref:t,onMouseDown:ee(e.onMouseDown,y=>{r?c.onItemFocus(u):y.preventDefault()}),onFocus:ee(e.onFocus,()=>c.onItemFocus(u)),onKeyDown:ee(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){c.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const h=zj(y,c.orientation,c.dir);if(h!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let x=f().filter(b=>b.focusable).map(b=>b.ref.current);if(h==="last")x.reverse();else if(h==="prev"||h==="next"){h==="prev"&&x.reverse();const b=x.indexOf(y.currentTarget);x=c.loop?Uj(x,b+1):x.slice(b+1)}setTimeout(()=>mC(x))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:p!=null}):o})})});gC.displayName=vC;var jj={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Dj(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function zj(e,t,n){const r=Dj(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return jj[r]}function mC(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Uj(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Vj=pC,Bj=gC;function qj(e){const t=Wj(e),n=g.forwardRef((r,i)=>{const{children:s,...o}=r,a=g.Children.toArray(s),l=a.find(Gj);if(l){const u=l.props.children,c=a.map(d=>d===l?g.Children.count(u)>1?g.Children.only(null):g.isValidElement(u)?u.props.children:null:d);return w.jsx(t,{...o,ref:i,children:g.isValidElement(u)?g.cloneElement(u,void 0,c):null})}return w.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function Wj(e){const t=g.forwardRef((n,r)=>{const{children:i,...s}=n;if(g.isValidElement(i)){const o=Qj(i),a=Kj(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vi(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Hj=Symbol("radix.slottable");function Gj(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Hj}function Kj(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function Qj(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var lv=["Enter"," "],Yj=["ArrowDown","PageUp","Home"],yC=["ArrowUp","PageDown","End"],Xj=[...Yj,...yC],Jj={ltr:[...lv,"ArrowRight"],rtl:[...lv,"ArrowLeft"]},Zj={ltr:["ArrowLeft"],rtl:["ArrowRight"]},kl="Menu",[ul,eD,tD]=Kg(kl),[as,_C]=ss(kl,[tD,rC,hC]),Pd=rC(),wC=hC(),[nD,ls]=as(kl),[rD,Pl]=as(kl),xC=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Pd(t),[l,u]=g.useState(null),c=g.useRef(!1),d=Ut(s),f=B1(i);return g.useEffect(()=>{const m=()=>{c.current=!0,document.addEventListener("pointerdown",_,{capture:!0,once:!0}),document.addEventListener("pointermove",_,{capture:!0,once:!0})},_=()=>c.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",_,{capture:!0}),document.removeEventListener("pointermove",_,{capture:!0})}},[]),w.jsx(Rj,{...a,children:w.jsx(nD,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:u,children:w.jsx(rD,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:c,dir:f,modal:o,children:r})})})};xC.displayName=kl;var iD="MenuAnchor",rm=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Pd(n);return w.jsx(Tj,{...i,...r,ref:t})});rm.displayName=iD;var im="MenuPortal",[sD,bC]=as(im,{forceMount:void 0}),EC=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=ls(im,t);return w.jsx(sD,{scope:t,forceMount:n,children:w.jsx(br,{present:n||s.open,children:w.jsx(wd,{asChild:!0,container:i,children:r})})})};EC.displayName=im;var un="MenuContent",[oD,sm]=as(un),SC=g.forwardRef((e,t)=>{const n=bC(un,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=ls(un,e.__scopeMenu),o=Pl(un,e.__scopeMenu);return w.jsx(ul.Provider,{scope:e.__scopeMenu,children:w.jsx(br,{present:r||s.open,children:w.jsx(ul.Slot,{scope:e.__scopeMenu,children:o.modal?w.jsx(aD,{...i,ref:t}):w.jsx(lD,{...i,ref:t})})})})}),aD=g.forwardRef((e,t)=>{const n=ls(un,e.__scopeMenu),r=g.useRef(null),i=et(t,r);return g.useEffect(()=>{const s=r.current;if(s)return t1(s)},[]),w.jsx(om,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ee(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),lD=g.forwardRef((e,t)=>{const n=ls(un,e.__scopeMenu);return w.jsx(om,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),uD=qj("MenuContent.ScrollLock"),om=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:f,onDismiss:m,disableOutsideScroll:_,...p}=e,y=ls(un,n),h=Pl(un,n),v=Pd(n),x=wC(n),b=eD(n),[E,S]=g.useState(null),P=g.useRef(null),C=et(t,P,y.onContentChange),T=g.useRef(0),R=g.useRef(""),N=g.useRef(0),M=g.useRef(null),z=g.useRef("right"),F=g.useRef(0),W=_?Dg:g.Fragment,B=_?{as:uD,allowPinchZoom:!0}:void 0,Q=A=>{var Be,ye;const V=R.current+A,K=b().filter(Fe=>!Fe.disabled),te=document.activeElement,oe=(Be=K.find(Fe=>Fe.ref.current===te))==null?void 0:Be.textValue,de=K.map(Fe=>Fe.textValue),be=xD(de,V,oe),Pe=(ye=K.find(Fe=>Fe.textValue===be))==null?void 0:ye.ref.current;(function Fe(Tt){R.current=Tt,window.clearTimeout(T.current),Tt!==""&&(T.current=window.setTimeout(()=>Fe(""),1e3))})(V),Pe&&setTimeout(()=>Pe.focus())};g.useEffect(()=>()=>window.clearTimeout(T.current),[]),HS();const O=g.useCallback(A=>{var K,te;return z.current===((K=M.current)==null?void 0:K.side)&&ED(A,(te=M.current)==null?void 0:te.area)},[]);return w.jsx(oD,{scope:n,searchRef:R,onItemEnter:g.useCallback(A=>{O(A)&&A.preventDefault()},[O]),onItemLeave:g.useCallback(A=>{var V;O(A)||((V=P.current)==null||V.focus(),S(null))},[O]),onTriggerLeave:g.useCallback(A=>{O(A)&&A.preventDefault()},[O]),pointerGraceTimerRef:N,onPointerGraceIntentChange:g.useCallback(A=>{M.current=A},[]),children:w.jsx(W,{...B,children:w.jsx(jg,{asChild:!0,trapped:i,onMountAutoFocus:ee(s,A=>{var V;A.preventDefault(),(V=P.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:w.jsx(_d,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:f,onDismiss:m,children:w.jsx(Vj,{asChild:!0,...x,dir:h.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:S,onEntryFocus:ee(l,A=>{h.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:w.jsx(Ij,{role:"menu","aria-orientation":"vertical","data-state":zC(y.open),"data-radix-menu-content":"",dir:h.dir,...v,...p,ref:C,style:{outline:"none",...p.style},onKeyDown:ee(p.onKeyDown,A=>{const K=A.target.closest("[data-radix-menu-content]")===A.currentTarget,te=A.ctrlKey||A.altKey||A.metaKey,oe=A.key.length===1;K&&(A.key==="Tab"&&A.preventDefault(),!te&&oe&&Q(A.key));const de=P.current;if(A.target!==de||!Xj.includes(A.key))return;A.preventDefault();const Pe=b().filter(Be=>!Be.disabled).map(Be=>Be.ref.current);yC.includes(A.key)&&Pe.reverse(),_D(Pe)}),onBlur:ee(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(T.current),R.current="")}),onPointerMove:ee(e.onPointerMove,cl(A=>{const V=A.target,K=F.current!==A.clientX;if(A.currentTarget.contains(V)&&K){const te=A.clientX>F.current?"right":"left";z.current=te,F.current=A.clientX}}))})})})})})})});SC.displayName=un;var cD="MenuGroup",am=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return w.jsx(ke.div,{role:"group",...r,ref:t})});am.displayName=cD;var dD="MenuLabel",CC=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return w.jsx(ke.div,{...r,ref:t})});CC.displayName=dD;var Wc="MenuItem",D0="menu.itemSelect",Rd=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Pl(Wc,e.__scopeMenu),a=sm(Wc,e.__scopeMenu),l=et(t,s),u=g.useRef(!1),c=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(D0,{bubbles:!0,cancelable:!0});d.addEventListener(D0,m=>r==null?void 0:r(m),{once:!0}),Lg(d,f),f.defaultPrevented?u.current=!1:o.onClose()}};return w.jsx(kC,{...i,ref:l,disabled:n,onClick:ee(e.onClick,c),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),u.current=!0},onPointerUp:ee(e.onPointerUp,d=>{var f;u.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:ee(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||lv.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Rd.displayName=Wc;var kC=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=sm(Wc,n),a=wC(n),l=g.useRef(null),u=et(t,l),[c,d]=g.useState(!1),[f,m]=g.useState("");return g.useEffect(()=>{const _=l.current;_&&m((_.textContent??"").trim())},[s.children]),w.jsx(ul.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:w.jsx(Bj,{asChild:!0,...a,focusable:!r,children:w.jsx(ke.div,{role:"menuitem","data-highlighted":c?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:ee(e.onPointerMove,cl(_=>{r?o.onItemLeave(_):(o.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ee(e.onPointerLeave,cl(_=>o.onItemLeave(_))),onFocus:ee(e.onFocus,()=>d(!0)),onBlur:ee(e.onBlur,()=>d(!1))})})})}),fD="MenuCheckboxItem",PC=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return w.jsx(MC,{scope:e.__scopeMenu,checked:n,children:w.jsx(Rd,{role:"menuitemcheckbox","aria-checked":Hc(n)?"mixed":n,...i,ref:t,"data-state":um(n),onSelect:ee(i.onSelect,()=>r==null?void 0:r(Hc(n)?!0:!n),{checkForDefaultPrevented:!1})})})});PC.displayName=fD;var RC="MenuRadioGroup",[hD,pD]=as(RC,{value:void 0,onValueChange:()=>{}}),TC=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=Ut(r);return w.jsx(hD,{scope:e.__scopeMenu,value:n,onValueChange:s,children:w.jsx(am,{...i,ref:t})})});TC.displayName=RC;var IC="MenuRadioItem",OC=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=pD(IC,e.__scopeMenu),s=n===i.value;return w.jsx(MC,{scope:e.__scopeMenu,checked:s,children:w.jsx(Rd,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":um(s),onSelect:ee(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});OC.displayName=IC;var lm="MenuItemIndicator",[MC,vD]=as(lm,{checked:!1}),AC=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=vD(lm,n);return w.jsx(br,{present:r||Hc(s.checked)||s.checked===!0,children:w.jsx(ke.span,{...i,ref:t,"data-state":um(s.checked)})})});AC.displayName=lm;var gD="MenuSeparator",NC=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return w.jsx(ke.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});NC.displayName=gD;var mD="MenuArrow",$C=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Pd(n);return w.jsx(Oj,{...i,...r,ref:t})});$C.displayName=mD;var yD="MenuSub",[_z,FC]=as(yD),pa="MenuSubTrigger",LC=g.forwardRef((e,t)=>{const n=ls(pa,e.__scopeMenu),r=Pl(pa,e.__scopeMenu),i=FC(pa,e.__scopeMenu),s=sm(pa,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},c=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>c,[c]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),w.jsx(rm,{asChild:!0,...u,children:w.jsx(kC,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":zC(n.open),...e,ref:vi(t,i.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ee(e.onPointerMove,cl(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),c()},100))})),onPointerLeave:ee(e.onPointerLeave,cl(d=>{var m,_;c();const f=(m=n.content)==null?void 0:m.getBoundingClientRect();if(f){const p=(_=n.content)==null?void 0:_.dataset.side,y=p==="right",h=y?-5:5,v=f[y?"left":"right"],x=f[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+h,y:d.clientY},{x:v,y:f.top},{x,y:f.top},{x,y:f.bottom},{x:v,y:f.bottom}],side:p}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ee(e.onKeyDown,d=>{var m;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||Jj[r.dir].includes(d.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),d.preventDefault())})})})});LC.displayName=pa;var jC="MenuSubContent",DC=g.forwardRef((e,t)=>{const n=bC(un,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=ls(un,e.__scopeMenu),o=Pl(un,e.__scopeMenu),a=FC(jC,e.__scopeMenu),l=g.useRef(null),u=et(t,l);return w.jsx(ul.Provider,{scope:e.__scopeMenu,children:w.jsx(br,{present:r||s.open,children:w.jsx(ul.Slot,{scope:e.__scopeMenu,children:w.jsx(om,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:u,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:c=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),c.preventDefault()},onCloseAutoFocus:c=>c.preventDefault(),onFocusOutside:ee(e.onFocusOutside,c=>{c.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ee(e.onEscapeKeyDown,c=>{o.onClose(),c.preventDefault()}),onKeyDown:ee(e.onKeyDown,c=>{var m;const d=c.currentTarget.contains(c.target),f=Zj[o.dir].includes(c.key);d&&f&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),c.preventDefault())})})})})})});DC.displayName=jC;function zC(e){return e?"open":"closed"}function Hc(e){return e==="indeterminate"}function um(e){return Hc(e)?"indeterminate":e?"checked":"unchecked"}function _D(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function wD(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function xD(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=wD(e,Math.max(s,0));i.length===1&&(o=o.filter(u=>u!==n));const l=o.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function bD(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;sr!=f>r&&n<(d-u)*(r-c)/(f-c)+u&&(i=!i)}return i}function ED(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return bD(n,t)}function cl(e){return t=>t.pointerType==="mouse"?e(t):void 0}var SD=xC,CD=rm,kD=EC,PD=SC,RD=am,TD=CC,ID=Rd,OD=PC,MD=TC,AD=OC,ND=AC,$D=NC,FD=$C,LD=LC,jD=DC,Td="DropdownMenu",[DD]=ss(Td,[_C]),Rt=_C(),[zD,UC]=DD(Td),VC=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Rt(t),u=g.useRef(null),[c,d]=yd({prop:i,defaultProp:s??!1,onChange:o,caller:Td});return w.jsx(zD,{scope:t,triggerId:Qs(),triggerRef:u,contentId:Qs(),open:c,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:w.jsx(SD,{...l,open:c,onOpenChange:d,dir:r,modal:a,children:n})})};VC.displayName=Td;var BC="DropdownMenuTrigger",qC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=UC(BC,n),o=Rt(n);return w.jsx(CD,{asChild:!0,...o,children:w.jsx(ke.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:vi(t,s.triggerRef),onPointerDown:ee(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ee(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});qC.displayName=BC;var UD="DropdownMenuPortal",WC=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Rt(t);return w.jsx(kD,{...r,...n})};WC.displayName=UD;var HC="DropdownMenuContent",GC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=UC(HC,n),s=Rt(n),o=g.useRef(!1);return w.jsx(PD,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:ee(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:ee(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,c=l.button===2||u;(!i.modal||c)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});GC.displayName=HC;var VD="DropdownMenuGroup",BD=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(RD,{...i,...r,ref:t})});BD.displayName=VD;var qD="DropdownMenuLabel",KC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(TD,{...i,...r,ref:t})});KC.displayName=qD;var WD="DropdownMenuItem",QC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(ID,{...i,...r,ref:t})});QC.displayName=WD;var HD="DropdownMenuCheckboxItem",YC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(OD,{...i,...r,ref:t})});YC.displayName=HD;var GD="DropdownMenuRadioGroup",KD=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(MD,{...i,...r,ref:t})});KD.displayName=GD;var QD="DropdownMenuRadioItem",XC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(AD,{...i,...r,ref:t})});XC.displayName=QD;var YD="DropdownMenuItemIndicator",JC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(ND,{...i,...r,ref:t})});JC.displayName=YD;var XD="DropdownMenuSeparator",ZC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx($D,{...i,...r,ref:t})});ZC.displayName=XD;var JD="DropdownMenuArrow",ZD=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(FD,{...i,...r,ref:t})});ZD.displayName=JD;var e2="DropdownMenuSubTrigger",ek=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(LD,{...i,...r,ref:t})});ek.displayName=e2;var t2="DropdownMenuSubContent",tk=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(jD,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});tk.displayName=t2;var n2=VC,r2=qC,i2=WC,nk=GC,rk=KC,ik=QC,sk=YC,ok=XC,ak=JC,lk=ZC,uk=ek,ck=tk;/** + */var To=g;function gF(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var mF=typeof Object.is=="function"?Object.is:gF,yF=To.useState,_F=To.useEffect,wF=To.useLayoutEffect,xF=To.useDebugValue;function bF(e,t){var n=t(),r=yF({inst:{value:n,getSnapshot:t}}),i=r[0].inst,s=r[1];return wF(function(){i.value=n,i.getSnapshot=t,Qf(i)&&s({inst:i})},[e,n,t]),_F(function(){return Qf(i)&&s({inst:i}),e(function(){Qf(i)&&s({inst:i})})},[e]),xF(n),n}function Qf(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!mF(e,n)}catch{return!0}}function EF(e,t){return t()}var SF=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?EF:bF;b1.useSyncExternalStore=To.useSyncExternalStore!==void 0?To.useSyncExternalStore:SF;x1.exports=b1;var CF=x1.exports;function kF(){return CF.useSyncExternalStore(PF,()=>!0,()=>!1)}function PF(){return()=>{}}var Hg="Avatar",[RF]=oF(Hg),[TF,E1]=RF(Hg),S1=g.forwardRef((e,t)=>{const{__scopeAvatar:n,...r}=e,[i,s]=g.useState("idle");return w.jsx(TF,{scope:n,imageLoadingStatus:i,onImageLoadingStatusChange:s,children:w.jsx(Wg.span,{...r,ref:t})})});S1.displayName=Hg;var C1="AvatarImage",k1=g.forwardRef((e,t)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:i=()=>{},...s}=e,o=E1(C1,n),a=IF(r,s),l=Ut(u=>{i(u),o.onImageLoadingStatusChange(u)});return fn(()=>{a!=="idle"&&l(a)},[a,l]),a==="loaded"?w.jsx(Wg.img,{...s,ref:t,src:r}):null});k1.displayName=C1;var P1="AvatarFallback",R1=g.forwardRef((e,t)=>{const{__scopeAvatar:n,delayMs:r,...i}=e,s=E1(P1,n),[o,a]=g.useState(r===void 0);return g.useEffect(()=>{if(r!==void 0){const l=window.setTimeout(()=>a(!0),r);return()=>window.clearTimeout(l)}},[r]),o&&s.imageLoadingStatus!=="loaded"?w.jsx(Wg.span,{...i,ref:t}):null});R1.displayName=P1;function S0(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function IF(e,{referrerPolicy:t,crossOrigin:n}){const r=kF(),i=g.useRef(null),s=r?(i.current||(i.current=new window.Image),i.current):null,[o,a]=g.useState(()=>S0(s,e));return fn(()=>{a(S0(s,e))},[s,e]),fn(()=>{const l=d=>()=>{a(d)};if(!s)return;const u=l("loaded"),c=l("error");return s.addEventListener("load",u),s.addEventListener("error",c),t&&(s.referrerPolicy=t),typeof n=="string"&&(s.crossOrigin=n),()=>{s.removeEventListener("load",u),s.removeEventListener("error",c)}},[s,n,t]),o}var T1=S1,I1=k1,O1=R1;function M1(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t{const t=AF(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const a=o.split(Gg);return a[0]===""&&a.length!==1&&a.shift(),N1(a,t)||MF(o)},getConflictingClassGroupIds:(o,a)=>{const l=n[o]||[];return a&&r[o]?[...l,...r[o]]:l}}},N1=(e,t)=>{var o;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?N1(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;const s=e.join(Gg);return(o=t.validators.find(({validator:a})=>a(s)))==null?void 0:o.classGroupId},C0=/^\[(.+)\]$/,MF=e=>{if(C0.test(e)){const t=C0.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},AF=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return $F(Object.entries(e.classGroups),n).forEach(([s,o])=>{rv(o,r,s,t)}),r},rv=(e,t,n,r)=>{e.forEach(i=>{if(typeof i=="string"){const s=i===""?t:k0(t,i);s.classGroupId=n;return}if(typeof i=="function"){if(NF(i)){rv(i(r),t,n,r);return}t.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{rv(o,k0(t,s),n,r)})})},k0=(e,t)=>{let n=e;return t.split(Gg).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},NF=e=>e.isThemeGetter,$F=(e,t)=>t?e.map(([n,r])=>{const i=r.map(s=>typeof s=="string"?t+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,a])=>[t+o,a])):s);return[n,i]}):e,FF=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},$1="!",LF=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,i=t[0],s=t.length,o=a=>{const l=[];let u=0,c=0,d;for(let y=0;yc?d-c:void 0;return{modifiers:l,hasImportantModifier:m,baseClassName:_,maybePostfixModifierPosition:p}};return n?a=>n({className:a,parseClassName:o}):o},jF=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},DF=e=>({cache:FF(e.cacheSize),parseClassName:LF(e),...OF(e)}),zF=/\s+/,UF=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,s=[],o=e.trim().split(zF);let a="";for(let l=o.length-1;l>=0;l-=1){const u=o[l],{modifiers:c,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:m}=n(u);let _=!!m,p=r(_?f.substring(0,m):f);if(!p){if(!_){a=u+(a.length>0?" "+a:a);continue}if(p=r(f),!p){a=u+(a.length>0?" "+a:a);continue}_=!1}const y=jF(c).join(":"),h=d?y+$1:y,v=h+p;if(s.includes(v))continue;s.push(v);const x=i(p,_);for(let b=0;b0?" "+a:a)}return a};function VF(){let e=0,t,n,r="";for(;e{if(typeof e=="string")return e;let t,n="";for(let r=0;rd(c),e());return n=DF(u),r=n.cache.get,i=n.cache.set,s=a,a(l)}function a(l){const u=r(l);if(u)return u;const c=UF(l,n);return i(l,c),c}return function(){return s(VF.apply(null,arguments))}}const Oe=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},L1=/^\[(?:([a-z-]+):)?(.+)\]$/i,qF=/^\d+\/\d+$/,WF=new Set(["px","full","screen"]),HF=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,GF=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,KF=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,QF=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,YF=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Xn=e=>Xs(e)||WF.has(e)||qF.test(e),Ir=e=>Fo(e,"length",iL),Xs=e=>!!e&&!Number.isNaN(Number(e)),Yf=e=>Fo(e,"number",Xs),ra=e=>!!e&&Number.isInteger(Number(e)),XF=e=>e.endsWith("%")&&Xs(e.slice(0,-1)),ie=e=>L1.test(e),Or=e=>HF.test(e),JF=new Set(["length","size","percentage"]),ZF=e=>Fo(e,JF,j1),eL=e=>Fo(e,"position",j1),tL=new Set(["image","url"]),nL=e=>Fo(e,tL,oL),rL=e=>Fo(e,"",sL),ia=()=>!0,Fo=(e,t,n)=>{const r=L1.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},iL=e=>GF.test(e)&&!KF.test(e),j1=()=>!1,sL=e=>QF.test(e),oL=e=>YF.test(e),aL=()=>{const e=Oe("colors"),t=Oe("spacing"),n=Oe("blur"),r=Oe("brightness"),i=Oe("borderColor"),s=Oe("borderRadius"),o=Oe("borderSpacing"),a=Oe("borderWidth"),l=Oe("contrast"),u=Oe("grayscale"),c=Oe("hueRotate"),d=Oe("invert"),f=Oe("gap"),m=Oe("gradientColorStops"),_=Oe("gradientColorStopPositions"),p=Oe("inset"),y=Oe("margin"),h=Oe("opacity"),v=Oe("padding"),x=Oe("saturate"),b=Oe("scale"),E=Oe("sepia"),S=Oe("skew"),P=Oe("space"),C=Oe("translate"),T=()=>["auto","contain","none"],R=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto",ie,t],M=()=>[ie,t],z=()=>["",Xn,Ir],F=()=>["auto",Xs,ie],W=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],B=()=>["solid","dashed","dotted","double","none"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],O=()=>["start","end","center","between","around","evenly","stretch"],A=()=>["","0",ie],V=()=>["auto","avoid","all","avoid-page","page","left","right","column"],K=()=>[Xs,ie];return{cacheSize:500,separator:":",theme:{colors:[ia],spacing:[Xn,Ir],blur:["none","",Or,ie],brightness:K(),borderColor:[e],borderRadius:["none","","full",Or,ie],borderSpacing:M(),borderWidth:z(),contrast:K(),grayscale:A(),hueRotate:K(),invert:A(),gap:M(),gradientColorStops:[e],gradientColorStopPositions:[XF,Ir],inset:N(),margin:N(),opacity:K(),padding:M(),saturate:K(),scale:K(),sepia:A(),skew:K(),space:M(),translate:M()},classGroups:{aspect:[{aspect:["auto","square","video",ie]}],container:["container"],columns:[{columns:[Or]}],"break-after":[{"break-after":V()}],"break-before":[{"break-before":V()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...W(),ie]}],overflow:[{overflow:R()}],"overflow-x":[{"overflow-x":R()}],"overflow-y":[{"overflow-y":R()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[p]}],"inset-x":[{"inset-x":[p]}],"inset-y":[{"inset-y":[p]}],start:[{start:[p]}],end:[{end:[p]}],top:[{top:[p]}],right:[{right:[p]}],bottom:[{bottom:[p]}],left:[{left:[p]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ra,ie]}],basis:[{basis:N()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ie]}],grow:[{grow:A()}],shrink:[{shrink:A()}],order:[{order:["first","last","none",ra,ie]}],"grid-cols":[{"grid-cols":[ia]}],"col-start-end":[{col:["auto",{span:["full",ra,ie]},ie]}],"col-start":[{"col-start":F()}],"col-end":[{"col-end":F()}],"grid-rows":[{"grid-rows":[ia]}],"row-start-end":[{row:["auto",{span:[ra,ie]},ie]}],"row-start":[{"row-start":F()}],"row-end":[{"row-end":F()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ie]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ie]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...O()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...O(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...O(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[y]}],mx:[{mx:[y]}],my:[{my:[y]}],ms:[{ms:[y]}],me:[{me:[y]}],mt:[{mt:[y]}],mr:[{mr:[y]}],mb:[{mb:[y]}],ml:[{ml:[y]}],"space-x":[{"space-x":[P]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[P]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ie,t]}],"min-w":[{"min-w":[ie,t,"min","max","fit"]}],"max-w":[{"max-w":[ie,t,"none","full","min","max","fit","prose",{screen:[Or]},Or]}],h:[{h:[ie,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ie,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ie,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ie,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Or,Ir]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Yf]}],"font-family":[{font:[ia]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ie]}],"line-clamp":[{"line-clamp":["none",Xs,Yf]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Xn,ie]}],"list-image":[{"list-image":["none",ie]}],"list-style-type":[{list:["none","disc","decimal",ie]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[h]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[h]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...B(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Xn,Ir]}],"underline-offset":[{"underline-offset":["auto",Xn,ie]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:M()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ie]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ie]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[h]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...W(),eL]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",ZF]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},nL]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[_]}],"gradient-via-pos":[{via:[_]}],"gradient-to-pos":[{to:[_]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[h]}],"border-style":[{border:[...B(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[h]}],"divide-style":[{divide:B()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...B()]}],"outline-offset":[{"outline-offset":[Xn,ie]}],"outline-w":[{outline:[Xn,Ir]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[h]}],"ring-offset-w":[{"ring-offset":[Xn,Ir]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Or,rL]}],"shadow-color":[{shadow:[ia]}],opacity:[{opacity:[h]}],"mix-blend":[{"mix-blend":[...Q(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Q()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Or,ie]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[d]}],saturate:[{saturate:[x]}],sepia:[{sepia:[E]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[h]}],"backdrop-saturate":[{"backdrop-saturate":[x]}],"backdrop-sepia":[{"backdrop-sepia":[E]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ie]}],duration:[{duration:K()}],ease:[{ease:["linear","in","out","in-out",ie]}],delay:[{delay:K()}],animate:[{animate:["none","spin","ping","pulse","bounce",ie]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[b]}],"scale-x":[{"scale-x":[b]}],"scale-y":[{"scale-y":[b]}],rotate:[{rotate:[ra,ie]}],"translate-x":[{"translate-x":[C]}],"translate-y":[{"translate-y":[C]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ie]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ie]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":M()}],"scroll-mx":[{"scroll-mx":M()}],"scroll-my":[{"scroll-my":M()}],"scroll-ms":[{"scroll-ms":M()}],"scroll-me":[{"scroll-me":M()}],"scroll-mt":[{"scroll-mt":M()}],"scroll-mr":[{"scroll-mr":M()}],"scroll-mb":[{"scroll-mb":M()}],"scroll-ml":[{"scroll-ml":M()}],"scroll-p":[{"scroll-p":M()}],"scroll-px":[{"scroll-px":M()}],"scroll-py":[{"scroll-py":M()}],"scroll-ps":[{"scroll-ps":M()}],"scroll-pe":[{"scroll-pe":M()}],"scroll-pt":[{"scroll-pt":M()}],"scroll-pr":[{"scroll-pr":M()}],"scroll-pb":[{"scroll-pb":M()}],"scroll-pl":[{"scroll-pl":M()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ie]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Xn,Ir,Yf]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},lL=BF(aL);function ct(...e){return lL(A1(e))}function vz(e){return e.replace(/v\d+$/i,"")}function gz(e){const t=e.trim(),n=t.match(/^(\d{4})-(\d{4,5})(v\d+)?$/);if(n)return`${n[1]}.${n[2]}`;const r=t.match(/^(\d{4}\.\d{4,5})(v\d+)$/);return r?r[1]:t}function mz(e){if(e==null||e==="")return"—";const t=typeof e=="string"?parseFloat(e):e;return Number.isFinite(t)?Math.abs(t)>=100?du(t,0):Math.abs(t)>=10?du(t,1):Math.abs(t)<1?du(t,3):du(t,2):String(e)}function du(e,t){const n=String(Math.abs(e));if(n.includes("e"))return e.toFixed(t);const r=+`${Math.round(+`${n}e${t}`)}e-${t}`;return(e<0?-r:r).toFixed(t)}const D1=g.forwardRef(({className:e,...t},n)=>w.jsx(T1,{ref:n,className:ct("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));D1.displayName=T1.displayName;const z1=g.forwardRef(({className:e,...t},n)=>w.jsx(I1,{ref:n,className:ct("aspect-square h-full w-full",e),...t}));z1.displayName=I1.displayName;const U1=g.forwardRef(({className:e,...t},n)=>w.jsx(O1,{ref:n,className:ct("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));U1.displayName=O1.displayName;function P0(e){const t=uL(e),n=g.forwardRef((r,i)=>{const{children:s,...o}=r,a=g.Children.toArray(s),l=a.find(dL);if(l){const u=l.props.children,c=a.map(d=>d===l?g.Children.count(u)>1?g.Children.only(null):g.isValidElement(u)?u.props.children:null:d);return w.jsx(t,{...o,ref:i,children:g.isValidElement(u)?g.cloneElement(u,void 0,c):null})}return w.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function uL(e){const t=g.forwardRef((n,r)=>{const{children:i,...s}=n;if(g.isValidElement(i)){const o=hL(i),a=fL(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vi(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var cL=Symbol("radix.slottable");function dL(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===cL}function fL(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function hL(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Kg(e){const t=e+"CollectionProvider",[n,r]=ss(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=p=>{const{scope:y,children:h}=p,v=q.useRef(null),x=q.useRef(new Map).current;return w.jsx(i,{scope:y,itemMap:x,collectionRef:v,children:h})};o.displayName=t;const a=e+"CollectionSlot",l=P0(a),u=q.forwardRef((p,y)=>{const{scope:h,children:v}=p,x=s(a,h),b=et(y,x.collectionRef);return w.jsx(l,{ref:b,children:v})});u.displayName=a;const c=e+"CollectionItemSlot",d="data-radix-collection-item",f=P0(c),m=q.forwardRef((p,y)=>{const{scope:h,children:v,...x}=p,b=q.useRef(null),E=et(y,b),S=s(c,h);return q.useEffect(()=>(S.itemMap.set(b,{ref:b,...x}),()=>void S.itemMap.delete(b))),w.jsx(f,{[d]:"",ref:E,children:v})});m.displayName=c;function _(p){const y=s(e+"CollectionConsumer",p);return q.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const x=Array.from(v.querySelectorAll(`[${d}]`));return Array.from(y.itemMap.values()).sort((S,P)=>x.indexOf(S.ref.current)-x.indexOf(P.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:o,Slot:u,ItemSlot:m},_,r]}var pL=g.createContext(void 0);function V1(e){const t=g.useContext(pL);return e||t||"ltr"}const vL=["top","right","bottom","left"],ci=Math.min,Ht=Math.max,Uc=Math.round,fu=Math.floor,Hn=e=>({x:e,y:e}),gL={left:"right",right:"left",bottom:"top",top:"bottom"};function iv(e,t,n){return Ht(e,ci(t,n))}function yr(e,t){return typeof e=="function"?e(t):e}function _r(e){return e.split("-")[0]}function Lo(e){return e.split("-")[1]}function Qg(e){return e==="x"?"y":"x"}function Yg(e){return e==="y"?"height":"width"}function Bn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Xg(e){return Qg(Bn(e))}function mL(e,t,n){n===void 0&&(n=!1);const r=Lo(e),i=Xg(e),s=Yg(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=Vc(o)),[o,Vc(o)]}function yL(e){const t=Vc(e);return[sv(e),t,sv(t)]}function sv(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const R0=["left","right"],T0=["right","left"],_L=["top","bottom"],wL=["bottom","top"];function xL(e,t,n){switch(e){case"top":case"bottom":return n?t?T0:R0:t?R0:T0;case"left":case"right":return t?_L:wL;default:return[]}}function bL(e,t,n,r){const i=Lo(e);let s=xL(_r(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(sv)))),s}function Vc(e){const t=_r(e);return gL[t]+e.slice(t.length)}function EL(e){return{top:0,right:0,bottom:0,left:0,...e}}function B1(e){return typeof e!="number"?EL(e):{top:e,right:e,bottom:e,left:e}}function Bc(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function I0(e,t,n){let{reference:r,floating:i}=e;const s=Bn(t),o=Xg(t),a=Yg(o),l=_r(t),u=s==="y",c=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[a]/2-i[a]/2;let m;switch(l){case"top":m={x:c,y:r.y-i.height};break;case"bottom":m={x:c,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:d};break;case"left":m={x:r.x-i.width,y:d};break;default:m={x:r.x,y:r.y}}switch(Lo(t)){case"start":m[o]-=f*(n&&u?-1:1);break;case"end":m[o]+=f*(n&&u?-1:1);break}return m}async function SL(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:m=0}=yr(t,e),_=B1(m),y=a[f?d==="floating"?"reference":"floating":d],h=Bc(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:c,strategy:l})),v=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),b=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},E=Bc(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:l}):v);return{top:(h.top-E.top+_.top)/b.y,bottom:(E.bottom-h.bottom+_.bottom)/b.y,left:(h.left-E.left+_.left)/b.x,right:(E.right-h.right+_.right)/b.x}}const CL=50,kL=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:SL},l=await(o.isRTL==null?void 0:o.isRTL(t));let u=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:c,y:d}=I0(u,r,l),f=r,m=0;const _={};for(let p=0;p({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=t,{element:u,padding:c=0}=yr(e,t)||{};if(u==null)return{};const d=B1(c),f={x:n,y:r},m=Xg(i),_=Yg(m),p=await o.getDimensions(u),y=m==="y",h=y?"top":"left",v=y?"bottom":"right",x=y?"clientHeight":"clientWidth",b=s.reference[_]+s.reference[m]-f[m]-s.floating[_],E=f[m]-s.reference[m],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let P=S?S[x]:0;(!P||!await(o.isElement==null?void 0:o.isElement(S)))&&(P=a.floating[x]||s.floating[_]);const C=b/2-E/2,T=P/2-p[_]/2-1,R=ci(d[h],T),N=ci(d[v],T),M=R,z=P-p[_]-N,F=P/2-p[_]/2+C,W=iv(M,F,z),B=!l.arrow&&Lo(i)!=null&&F!==W&&s.reference[_]/2-(FF<=0)){var N,M;const F=(((N=s.flip)==null?void 0:N.index)||0)+1,W=P[F];if(W&&(!(d==="alignment"?v!==Bn(W):!1)||R.every(O=>Bn(O.placement)===v?O.overflows[0]>0:!0)))return{data:{index:F,overflows:R},reset:{placement:W}};let B=(M=R.filter(Q=>Q.overflows[0]<=0).sort((Q,O)=>Q.overflows[1]-O.overflows[1])[0])==null?void 0:M.placement;if(!B)switch(m){case"bestFit":{var z;const Q=(z=R.filter(O=>{if(S){const A=Bn(O.placement);return A===v||A==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(A=>A>0).reduce((A,V)=>A+V,0)]).sort((O,A)=>O[1]-A[1])[0])==null?void 0:z[0];Q&&(B=Q);break}case"initialPlacement":B=a;break}if(i!==B)return{reset:{placement:B}}}return{}}}};function O0(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function M0(e){return vL.some(t=>e[t]>=0)}const TL=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=yr(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),a=O0(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:M0(a)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),a=O0(o,n.floating);return{data:{escapedOffsets:a,escaped:M0(a)}}}default:return{}}}}},q1=new Set(["left","top"]);async function IL(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=_r(n),a=Lo(n),l=Bn(n)==="y",u=q1.has(o)?-1:1,c=s&&l?-1:1,d=yr(t,e);let{mainAxis:f,crossAxis:m,alignmentAxis:_}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof _=="number"&&(m=a==="end"?_*-1:_),l?{x:m*c,y:f*u}:{x:f*u,y:m*c}}const OL=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=t,l=await IL(t,e);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},ML=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:h=>{let{x:v,y:x}=h;return{x:v,y:x}}},...u}=yr(e,t),c={x:n,y:r},d=await s.detectOverflow(t,u),f=Bn(_r(i)),m=Qg(f);let _=c[m],p=c[f];if(o){const h=m==="y"?"top":"left",v=m==="y"?"bottom":"right",x=_+d[h],b=_-d[v];_=iv(x,_,b)}if(a){const h=f==="y"?"top":"left",v=f==="y"?"bottom":"right",x=p+d[h],b=p-d[v];p=iv(x,p,b)}const y=l.fn({...t,[m]:_,[f]:p});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[m]:o,[f]:a}}}}}},AL=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=yr(e,t),c={x:n,y:r},d=Bn(i),f=Qg(d);let m=c[f],_=c[d];const p=yr(a,t),y=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(l){const x=f==="y"?"height":"width",b=s.reference[f]-s.floating[x]+y.mainAxis,E=s.reference[f]+s.reference[x]-y.mainAxis;mE&&(m=E)}if(u){var h,v;const x=f==="y"?"width":"height",b=q1.has(_r(i)),E=s.reference[d]-s.floating[x]+(b&&((h=o.offset)==null?void 0:h[d])||0)+(b?0:y.crossAxis),S=s.reference[d]+s.reference[x]+(b?0:((v=o.offset)==null?void 0:v[d])||0)-(b?y.crossAxis:0);_S&&(_=S)}return{[f]:m,[d]:_}}}},NL=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:o,elements:a}=t,{apply:l=()=>{},...u}=yr(e,t),c=await o.detectOverflow(t,u),d=_r(i),f=Lo(i),m=Bn(i)==="y",{width:_,height:p}=s.floating;let y,h;d==="top"||d==="bottom"?(y=d,h=f===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(h=d,y=f==="end"?"top":"bottom");const v=p-c.top-c.bottom,x=_-c.left-c.right,b=ci(p-c[y],v),E=ci(_-c[h],x),S=!t.middlewareData.shift;let P=b,C=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(C=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(P=v),S&&!f){const R=Ht(c.left,0),N=Ht(c.right,0),M=Ht(c.top,0),z=Ht(c.bottom,0);m?C=_-2*(R!==0||N!==0?R+N:Ht(c.left,c.right)):P=p-2*(M!==0||z!==0?M+z:Ht(c.top,c.bottom))}await l({...t,availableWidth:C,availableHeight:P});const T=await o.getDimensions(a.floating);return _!==T.width||p!==T.height?{reset:{rects:!0}}:{}}}};function Ed(){return typeof window<"u"}function jo(e){return W1(e)?(e.nodeName||"").toLowerCase():"#document"}function Xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Kn(e){var t;return(t=(W1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function W1(e){return Ed()?e instanceof Node||e instanceof Xt(e).Node:!1}function Pn(e){return Ed()?e instanceof Element||e instanceof Xt(e).Element:!1}function Er(e){return Ed()?e instanceof HTMLElement||e instanceof Xt(e).HTMLElement:!1}function A0(e){return!Ed()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Xt(e).ShadowRoot}function Sl(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Rn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function $L(e){return/^(table|td|th)$/.test(jo(e))}function Sd(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const FL=/transform|translate|scale|rotate|perspective|filter/,LL=/paint|layout|strict|content/,xi=e=>!!e&&e!=="none";let Xf;function Jg(e){const t=Pn(e)?Rn(e):e;return xi(t.transform)||xi(t.translate)||xi(t.scale)||xi(t.rotate)||xi(t.perspective)||!Zg()&&(xi(t.backdropFilter)||xi(t.filter))||FL.test(t.willChange||"")||LL.test(t.contain||"")}function jL(e){let t=di(e);for(;Er(t)&&!Io(t);){if(Jg(t))return t;if(Sd(t))return null;t=di(t)}return null}function Zg(){return Xf==null&&(Xf=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Xf}function Io(e){return/^(html|body|#document)$/.test(jo(e))}function Rn(e){return Xt(e).getComputedStyle(e)}function Cd(e){return Pn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function di(e){if(jo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||A0(e)&&e.host||Kn(e);return A0(t)?t.host:t}function H1(e){const t=di(e);return Io(t)?e.ownerDocument?e.ownerDocument.body:e.body:Er(t)&&Sl(t)?t:H1(t)}function ll(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=H1(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=Xt(i);if(s){const a=ov(o);return t.concat(o,o.visualViewport||[],Sl(i)?i:[],a&&n?ll(a):[])}else return t.concat(i,ll(i,[],n))}function ov(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function G1(e){const t=Rn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Er(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=Uc(n)!==s||Uc(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function em(e){return Pn(e)?e:e.contextElement}function Js(e){const t=em(e);if(!Er(t))return Hn(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=G1(t);let o=(s?Uc(n.width):n.width)/r,a=(s?Uc(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const DL=Hn(0);function K1(e){const t=Xt(e);return!Zg()||!t.visualViewport?DL:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function zL(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Xt(e)?!1:t}function ts(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=em(e);let o=Hn(1);t&&(r?Pn(r)&&(o=Js(r)):o=Js(e));const a=zL(s,n,r)?K1(s):Hn(0);let l=(i.left+a.x)/o.x,u=(i.top+a.y)/o.y,c=i.width/o.x,d=i.height/o.y;if(s){const f=Xt(s),m=r&&Pn(r)?Xt(r):r;let _=f,p=ov(_);for(;p&&r&&m!==_;){const y=Js(p),h=p.getBoundingClientRect(),v=Rn(p),x=h.left+(p.clientLeft+parseFloat(v.paddingLeft))*y.x,b=h.top+(p.clientTop+parseFloat(v.paddingTop))*y.y;l*=y.x,u*=y.y,c*=y.x,d*=y.y,l+=x,u+=b,_=Xt(p),p=ov(_)}}return Bc({width:c,height:d,x:l,y:u})}function kd(e,t){const n=Cd(e).scrollLeft;return t?t.left+n:ts(Kn(e)).left+n}function Q1(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-kd(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function UL(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=Kn(r),a=t?Sd(t.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=Hn(1);const c=Hn(0),d=Er(r);if((d||!d&&!s)&&((jo(r)!=="body"||Sl(o))&&(l=Cd(r)),d)){const m=ts(r);u=Js(r),c.x=m.x+r.clientLeft,c.y=m.y+r.clientTop}const f=o&&!d&&!s?Q1(o,l):Hn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+c.x+f.x,y:n.y*u.y-l.scrollTop*u.y+c.y+f.y}}function VL(e){return Array.from(e.getClientRects())}function BL(e){const t=Kn(e),n=Cd(e),r=e.ownerDocument.body,i=Ht(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ht(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+kd(e);const a=-n.scrollTop;return Rn(r).direction==="rtl"&&(o+=Ht(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}const N0=25;function qL(e,t){const n=Xt(e),r=Kn(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const c=Zg();(!c||c&&t==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}const u=kd(r);if(u<=0){const c=r.ownerDocument,d=c.body,f=getComputedStyle(d),m=c.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,_=Math.abs(r.clientWidth-d.clientWidth-m);_<=N0&&(s-=_)}else u<=N0&&(s+=u);return{width:s,height:o,x:a,y:l}}function WL(e,t){const n=ts(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Er(e)?Js(e):Hn(1),o=e.clientWidth*s.x,a=e.clientHeight*s.y,l=i*s.x,u=r*s.y;return{width:o,height:a,x:l,y:u}}function $0(e,t,n){let r;if(t==="viewport")r=qL(e,n);else if(t==="document")r=BL(Kn(e));else if(Pn(t))r=WL(t,n);else{const i=K1(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Bc(r)}function Y1(e,t){const n=di(e);return n===t||!Pn(n)||Io(n)?!1:Rn(n).position==="fixed"||Y1(n,t)}function HL(e,t){const n=t.get(e);if(n)return n;let r=ll(e,[],!1).filter(a=>Pn(a)&&jo(a)!=="body"),i=null;const s=Rn(e).position==="fixed";let o=s?di(e):e;for(;Pn(o)&&!Io(o);){const a=Rn(o),l=Jg(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Sl(o)&&!l&&Y1(e,o))?r=r.filter(c=>c!==o):i=a,o=di(o)}return t.set(e,r),r}function GL(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?Sd(t)?[]:HL(t,this._c):[].concat(n),r],a=$0(t,o[0],i);let l=a.top,u=a.right,c=a.bottom,d=a.left;for(let f=1;f{o(!1,1e-7)},1e3)}P===1&&!J1(u,e.getBoundingClientRect())&&o(),b=!1}try{n=new IntersectionObserver(E,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(E,x)}n.observe(e)}return o(!0),s}function ej(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=em(e),c=i||s?[...u?ll(u):[],...t?ll(t):[]]:[];c.forEach(h=>{i&&h.addEventListener("scroll",n,{passive:!0}),s&&h.addEventListener("resize",n)});const d=u&&a?ZL(u,n):null;let f=-1,m=null;o&&(m=new ResizeObserver(h=>{let[v]=h;v&&v.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=m)==null||x.observe(t)})),n()}),u&&!l&&m.observe(u),t&&m.observe(t));let _,p=l?ts(e):null;l&&y();function y(){const h=ts(e);p&&!J1(p,h)&&n(),p=h,_=requestAnimationFrame(y)}return n(),()=>{var h;c.forEach(v=>{i&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),d==null||d(),(h=m)==null||h.disconnect(),m=null,l&&cancelAnimationFrame(_)}}const tj=OL,nj=ML,rj=RL,ij=NL,sj=TL,L0=PL,oj=AL,aj=(e,t,n)=>{const r=new Map,i={platform:JL,...n},s={...i.platform,_c:r};return kL(e,t,{...i,platform:s})};var lj=typeof document<"u",uj=function(){},Fu=lj?g.useLayoutEffect:uj;function qc(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!qc(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!qc(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Z1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function j0(e,t){const n=Z1(e);return Math.round(t*n)/n}function Zf(e){const t=g.useRef(e);return Fu(()=>{t.current=e}),t}function cj(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[c,d]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,m]=g.useState(r);qc(f,r)||m(r);const[_,p]=g.useState(null),[y,h]=g.useState(null),v=g.useCallback(O=>{O!==S.current&&(S.current=O,p(O))},[]),x=g.useCallback(O=>{O!==P.current&&(P.current=O,h(O))},[]),b=s||_,E=o||y,S=g.useRef(null),P=g.useRef(null),C=g.useRef(c),T=l!=null,R=Zf(l),N=Zf(i),M=Zf(u),z=g.useCallback(()=>{if(!S.current||!P.current)return;const O={placement:t,strategy:n,middleware:f};N.current&&(O.platform=N.current),aj(S.current,P.current,O).then(A=>{const V={...A,isPositioned:M.current!==!1};F.current&&!qc(C.current,V)&&(C.current=V,xl.flushSync(()=>{d(V)}))})},[f,t,n,N,M]);Fu(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,d(O=>({...O,isPositioned:!1})))},[u]);const F=g.useRef(!1);Fu(()=>(F.current=!0,()=>{F.current=!1}),[]),Fu(()=>{if(b&&(S.current=b),E&&(P.current=E),b&&E){if(R.current)return R.current(b,E,z);z()}},[b,E,z,R,T]);const W=g.useMemo(()=>({reference:S,floating:P,setReference:v,setFloating:x}),[v,x]),B=g.useMemo(()=>({reference:b,floating:E}),[b,E]),Q=g.useMemo(()=>{const O={position:n,left:0,top:0};if(!B.floating)return O;const A=j0(B.floating,c.x),V=j0(B.floating,c.y);return a?{...O,transform:"translate("+A+"px, "+V+"px)",...Z1(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:V}},[n,a,B.floating,c.x,c.y]);return g.useMemo(()=>({...c,update:z,refs:W,elements:B,floatingStyles:Q}),[c,z,W,B,Q])}const dj=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?L0({element:r.current,padding:i}).fn(n):{}:r?L0({element:r,padding:i}).fn(n):{}}}},fj=(e,t)=>{const n=tj(e);return{name:n.name,fn:n.fn,options:[e,t]}},hj=(e,t)=>{const n=nj(e);return{name:n.name,fn:n.fn,options:[e,t]}},pj=(e,t)=>({fn:oj(e).fn,options:[e,t]}),vj=(e,t)=>{const n=rj(e);return{name:n.name,fn:n.fn,options:[e,t]}},gj=(e,t)=>{const n=ij(e);return{name:n.name,fn:n.fn,options:[e,t]}},mj=(e,t)=>{const n=sj(e);return{name:n.name,fn:n.fn,options:[e,t]}},yj=(e,t)=>{const n=dj(e);return{name:n.name,fn:n.fn,options:[e,t]}};var _j="Arrow",eC=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return w.jsx(ke.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:w.jsx("polygon",{points:"0,0 30,0 15,10"})})});eC.displayName=_j;var wj=eC;function xj(e){const[t,n]=g.useState(void 0);return fn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;o=u.inlineSize,a=u.blockSize}else o=e.offsetWidth,a=e.offsetHeight;n({width:o,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var tm="Popper",[tC,nC]=ss(tm),[bj,rC]=tC(tm),iC=e=>{const{__scopePopper:t,children:n}=e,[r,i]=g.useState(null);return w.jsx(bj,{scope:t,anchor:r,onAnchorChange:i,children:n})};iC.displayName=tm;var sC="PopperAnchor",oC=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=rC(sC,n),o=g.useRef(null),a=et(t,o),l=g.useRef(null);return g.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||o.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:w.jsx(ke.div,{...i,ref:a})});oC.displayName=sC;var nm="PopperContent",[Ej,Sj]=tC(nm),aC=g.forwardRef((e,t)=>{var Be,ye,Fe,Tt,Sr,_t;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:m="optimized",onPlaced:_,...p}=e,y=rC(nm,n),[h,v]=g.useState(null),x=et(t,Ye=>v(Ye)),[b,E]=g.useState(null),S=xj(b),P=(S==null?void 0:S.width)??0,C=(S==null?void 0:S.height)??0,T=r+(s!=="center"?"-"+s:""),R=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},N=Array.isArray(u)?u:[u],M=N.length>0,z={padding:R,boundary:N.filter(kj),altBoundary:M},{refs:F,floatingStyles:W,placement:B,isPositioned:Q,middlewareData:O}=cj({strategy:"fixed",placement:T,whileElementsMounted:(...Ye)=>ej(...Ye,{animationFrame:m==="always"}),elements:{reference:y.anchor},middleware:[fj({mainAxis:i+C,alignmentAxis:o}),l&&hj({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?pj():void 0,...z}),l&&vj({...z}),gj({...z,apply:({elements:Ye,rects:gi,availableWidth:us,availableHeight:It})=>{const{width:cs,height:Cr}=gi.reference,pn=Ye.floating.style;pn.setProperty("--radix-popper-available-width",`${us}px`),pn.setProperty("--radix-popper-available-height",`${It}px`),pn.setProperty("--radix-popper-anchor-width",`${cs}px`),pn.setProperty("--radix-popper-anchor-height",`${Cr}px`)}}),b&&yj({element:b,padding:a}),Pj({arrowWidth:P,arrowHeight:C}),f&&mj({strategy:"referenceHidden",...z})]}),[A,V]=cC(B),K=Ut(_);fn(()=>{Q&&(K==null||K())},[Q,K]);const te=(Be=O.arrow)==null?void 0:Be.x,oe=(ye=O.arrow)==null?void 0:ye.y,de=((Fe=O.arrow)==null?void 0:Fe.centerOffset)!==0,[be,Pe]=g.useState();return fn(()=>{h&&Pe(window.getComputedStyle(h).zIndex)},[h]),w.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:Q?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(Tt=O.transformOrigin)==null?void 0:Tt.x,(Sr=O.transformOrigin)==null?void 0:Sr.y].join(" "),...((_t=O.hide)==null?void 0:_t.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:w.jsx(Ej,{scope:n,placedSide:A,onArrowChange:E,arrowX:te,arrowY:oe,shouldHideArrow:de,children:w.jsx(ke.div,{"data-side":A,"data-align":V,...p,ref:x,style:{...p.style,animation:Q?void 0:"none"}})})})});aC.displayName=nm;var lC="PopperArrow",Cj={top:"bottom",right:"left",bottom:"top",left:"right"},uC=g.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=Sj(lC,r),o=Cj[s.placedSide];return w.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:w.jsx(wj,{...i,ref:n,style:{...i.style,display:"block"}})})});uC.displayName=lC;function kj(e){return e!==null}var Pj=e=>({name:"transformOrigin",options:e,fn(t){var y,h,v;const{placement:n,rects:r,middlewareData:i}=t,o=((y=i.arrow)==null?void 0:y.centerOffset)!==0,a=o?0:e.arrowWidth,l=o?0:e.arrowHeight,[u,c]=cC(n),d={start:"0%",center:"50%",end:"100%"}[c],f=(((h=i.arrow)==null?void 0:h.x)??0)+a/2,m=(((v=i.arrow)==null?void 0:v.y)??0)+l/2;let _="",p="";return u==="bottom"?(_=o?d:`${f}px`,p=`${-l}px`):u==="top"?(_=o?d:`${f}px`,p=`${r.floating.height+l}px`):u==="right"?(_=`${-l}px`,p=o?d:`${m}px`):u==="left"&&(_=`${r.floating.width+l}px`,p=o?d:`${m}px`),{data:{x:_,y:p}}}});function cC(e){const[t,n="center"]=e.split("-");return[t,n]}var Rj=iC,Tj=oC,Ij=aC,Oj=uC,eh="rovingFocusGroup.onEntryFocus",Mj={bubbles:!1,cancelable:!0},Cl="RovingFocusGroup",[av,dC,Aj]=Kg(Cl),[Nj,fC]=ss(Cl,[Aj]),[$j,Fj]=Nj(Cl),hC=g.forwardRef((e,t)=>w.jsx(av.Provider,{scope:e.__scopeRovingFocusGroup,children:w.jsx(av.Slot,{scope:e.__scopeRovingFocusGroup,children:w.jsx(Lj,{...e,ref:t})})}));hC.displayName=Cl;var Lj=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:c=!1,...d}=e,f=g.useRef(null),m=et(t,f),_=V1(s),[p,y]=yd({prop:o,defaultProp:a??null,onChange:l,caller:Cl}),[h,v]=g.useState(!1),x=Ut(u),b=dC(n),E=g.useRef(!1),[S,P]=g.useState(0);return g.useEffect(()=>{const C=f.current;if(C)return C.addEventListener(eh,x),()=>C.removeEventListener(eh,x)},[x]),w.jsx($j,{scope:n,orientation:r,dir:_,loop:i,currentTabStopId:p,onItemFocus:g.useCallback(C=>y(C),[y]),onItemShiftTab:g.useCallback(()=>v(!0),[]),onFocusableItemAdd:g.useCallback(()=>P(C=>C+1),[]),onFocusableItemRemove:g.useCallback(()=>P(C=>C-1),[]),children:w.jsx(ke.div,{tabIndex:h||S===0?-1:0,"data-orientation":r,...d,ref:m,style:{outline:"none",...e.style},onMouseDown:ee(e.onMouseDown,()=>{E.current=!0}),onFocus:ee(e.onFocus,C=>{const T=!E.current;if(C.target===C.currentTarget&&T&&!h){const R=new CustomEvent(eh,Mj);if(C.currentTarget.dispatchEvent(R),!R.defaultPrevented){const N=b().filter(B=>B.focusable),M=N.find(B=>B.active),z=N.find(B=>B.id===p),W=[M,z,...N].filter(Boolean).map(B=>B.ref.current);gC(W,c)}}E.current=!1}),onBlur:ee(e.onBlur,()=>v(!1))})})}),pC="RovingFocusGroupItem",vC=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=e,l=Qs(),u=s||l,c=Fj(pC,n),d=c.currentTabStopId===u,f=dC(n),{onFocusableItemAdd:m,onFocusableItemRemove:_,currentTabStopId:p}=c;return g.useEffect(()=>{if(r)return m(),()=>_()},[r,m,_]),w.jsx(av.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:w.jsx(ke.span,{tabIndex:d?0:-1,"data-orientation":c.orientation,...a,ref:t,onMouseDown:ee(e.onMouseDown,y=>{r?c.onItemFocus(u):y.preventDefault()}),onFocus:ee(e.onFocus,()=>c.onItemFocus(u)),onKeyDown:ee(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){c.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const h=zj(y,c.orientation,c.dir);if(h!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let x=f().filter(b=>b.focusable).map(b=>b.ref.current);if(h==="last")x.reverse();else if(h==="prev"||h==="next"){h==="prev"&&x.reverse();const b=x.indexOf(y.currentTarget);x=c.loop?Uj(x,b+1):x.slice(b+1)}setTimeout(()=>gC(x))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:p!=null}):o})})});vC.displayName=pC;var jj={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Dj(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function zj(e,t,n){const r=Dj(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return jj[r]}function gC(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Uj(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Vj=hC,Bj=vC;function qj(e){const t=Wj(e),n=g.forwardRef((r,i)=>{const{children:s,...o}=r,a=g.Children.toArray(s),l=a.find(Gj);if(l){const u=l.props.children,c=a.map(d=>d===l?g.Children.count(u)>1?g.Children.only(null):g.isValidElement(u)?u.props.children:null:d);return w.jsx(t,{...o,ref:i,children:g.isValidElement(u)?g.cloneElement(u,void 0,c):null})}return w.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function Wj(e){const t=g.forwardRef((n,r)=>{const{children:i,...s}=n;if(g.isValidElement(i)){const o=Qj(i),a=Kj(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vi(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Hj=Symbol("radix.slottable");function Gj(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Hj}function Kj(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function Qj(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var lv=["Enter"," "],Yj=["ArrowDown","PageUp","Home"],mC=["ArrowUp","PageDown","End"],Xj=[...Yj,...mC],Jj={ltr:[...lv,"ArrowRight"],rtl:[...lv,"ArrowLeft"]},Zj={ltr:["ArrowLeft"],rtl:["ArrowRight"]},kl="Menu",[ul,eD,tD]=Kg(kl),[as,yC]=ss(kl,[tD,nC,fC]),Pd=nC(),_C=fC(),[nD,ls]=as(kl),[rD,Pl]=as(kl),wC=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Pd(t),[l,u]=g.useState(null),c=g.useRef(!1),d=Ut(s),f=V1(i);return g.useEffect(()=>{const m=()=>{c.current=!0,document.addEventListener("pointerdown",_,{capture:!0,once:!0}),document.addEventListener("pointermove",_,{capture:!0,once:!0})},_=()=>c.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",_,{capture:!0}),document.removeEventListener("pointermove",_,{capture:!0})}},[]),w.jsx(Rj,{...a,children:w.jsx(nD,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:u,children:w.jsx(rD,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:c,dir:f,modal:o,children:r})})})};wC.displayName=kl;var iD="MenuAnchor",rm=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Pd(n);return w.jsx(Tj,{...i,...r,ref:t})});rm.displayName=iD;var im="MenuPortal",[sD,xC]=as(im,{forceMount:void 0}),bC=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=ls(im,t);return w.jsx(sD,{scope:t,forceMount:n,children:w.jsx(br,{present:n||s.open,children:w.jsx(wd,{asChild:!0,container:i,children:r})})})};bC.displayName=im;var un="MenuContent",[oD,sm]=as(un),EC=g.forwardRef((e,t)=>{const n=xC(un,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=ls(un,e.__scopeMenu),o=Pl(un,e.__scopeMenu);return w.jsx(ul.Provider,{scope:e.__scopeMenu,children:w.jsx(br,{present:r||s.open,children:w.jsx(ul.Slot,{scope:e.__scopeMenu,children:o.modal?w.jsx(aD,{...i,ref:t}):w.jsx(lD,{...i,ref:t})})})})}),aD=g.forwardRef((e,t)=>{const n=ls(un,e.__scopeMenu),r=g.useRef(null),i=et(t,r);return g.useEffect(()=>{const s=r.current;if(s)return t1(s)},[]),w.jsx(om,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ee(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),lD=g.forwardRef((e,t)=>{const n=ls(un,e.__scopeMenu);return w.jsx(om,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),uD=qj("MenuContent.ScrollLock"),om=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:f,onDismiss:m,disableOutsideScroll:_,...p}=e,y=ls(un,n),h=Pl(un,n),v=Pd(n),x=_C(n),b=eD(n),[E,S]=g.useState(null),P=g.useRef(null),C=et(t,P,y.onContentChange),T=g.useRef(0),R=g.useRef(""),N=g.useRef(0),M=g.useRef(null),z=g.useRef("right"),F=g.useRef(0),W=_?Dg:g.Fragment,B=_?{as:uD,allowPinchZoom:!0}:void 0,Q=A=>{var Be,ye;const V=R.current+A,K=b().filter(Fe=>!Fe.disabled),te=document.activeElement,oe=(Be=K.find(Fe=>Fe.ref.current===te))==null?void 0:Be.textValue,de=K.map(Fe=>Fe.textValue),be=xD(de,V,oe),Pe=(ye=K.find(Fe=>Fe.textValue===be))==null?void 0:ye.ref.current;(function Fe(Tt){R.current=Tt,window.clearTimeout(T.current),Tt!==""&&(T.current=window.setTimeout(()=>Fe(""),1e3))})(V),Pe&&setTimeout(()=>Pe.focus())};g.useEffect(()=>()=>window.clearTimeout(T.current),[]),HS();const O=g.useCallback(A=>{var K,te;return z.current===((K=M.current)==null?void 0:K.side)&&ED(A,(te=M.current)==null?void 0:te.area)},[]);return w.jsx(oD,{scope:n,searchRef:R,onItemEnter:g.useCallback(A=>{O(A)&&A.preventDefault()},[O]),onItemLeave:g.useCallback(A=>{var V;O(A)||((V=P.current)==null||V.focus(),S(null))},[O]),onTriggerLeave:g.useCallback(A=>{O(A)&&A.preventDefault()},[O]),pointerGraceTimerRef:N,onPointerGraceIntentChange:g.useCallback(A=>{M.current=A},[]),children:w.jsx(W,{...B,children:w.jsx(jg,{asChild:!0,trapped:i,onMountAutoFocus:ee(s,A=>{var V;A.preventDefault(),(V=P.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:w.jsx(_d,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:f,onDismiss:m,children:w.jsx(Vj,{asChild:!0,...x,dir:h.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:S,onEntryFocus:ee(l,A=>{h.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:w.jsx(Ij,{role:"menu","aria-orientation":"vertical","data-state":DC(y.open),"data-radix-menu-content":"",dir:h.dir,...v,...p,ref:C,style:{outline:"none",...p.style},onKeyDown:ee(p.onKeyDown,A=>{const K=A.target.closest("[data-radix-menu-content]")===A.currentTarget,te=A.ctrlKey||A.altKey||A.metaKey,oe=A.key.length===1;K&&(A.key==="Tab"&&A.preventDefault(),!te&&oe&&Q(A.key));const de=P.current;if(A.target!==de||!Xj.includes(A.key))return;A.preventDefault();const Pe=b().filter(Be=>!Be.disabled).map(Be=>Be.ref.current);mC.includes(A.key)&&Pe.reverse(),_D(Pe)}),onBlur:ee(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(T.current),R.current="")}),onPointerMove:ee(e.onPointerMove,cl(A=>{const V=A.target,K=F.current!==A.clientX;if(A.currentTarget.contains(V)&&K){const te=A.clientX>F.current?"right":"left";z.current=te,F.current=A.clientX}}))})})})})})})});EC.displayName=un;var cD="MenuGroup",am=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return w.jsx(ke.div,{role:"group",...r,ref:t})});am.displayName=cD;var dD="MenuLabel",SC=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return w.jsx(ke.div,{...r,ref:t})});SC.displayName=dD;var Wc="MenuItem",D0="menu.itemSelect",Rd=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Pl(Wc,e.__scopeMenu),a=sm(Wc,e.__scopeMenu),l=et(t,s),u=g.useRef(!1),c=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(D0,{bubbles:!0,cancelable:!0});d.addEventListener(D0,m=>r==null?void 0:r(m),{once:!0}),Lg(d,f),f.defaultPrevented?u.current=!1:o.onClose()}};return w.jsx(CC,{...i,ref:l,disabled:n,onClick:ee(e.onClick,c),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),u.current=!0},onPointerUp:ee(e.onPointerUp,d=>{var f;u.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:ee(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||lv.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Rd.displayName=Wc;var CC=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=sm(Wc,n),a=_C(n),l=g.useRef(null),u=et(t,l),[c,d]=g.useState(!1),[f,m]=g.useState("");return g.useEffect(()=>{const _=l.current;_&&m((_.textContent??"").trim())},[s.children]),w.jsx(ul.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:w.jsx(Bj,{asChild:!0,...a,focusable:!r,children:w.jsx(ke.div,{role:"menuitem","data-highlighted":c?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:ee(e.onPointerMove,cl(_=>{r?o.onItemLeave(_):(o.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ee(e.onPointerLeave,cl(_=>o.onItemLeave(_))),onFocus:ee(e.onFocus,()=>d(!0)),onBlur:ee(e.onBlur,()=>d(!1))})})})}),fD="MenuCheckboxItem",kC=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return w.jsx(OC,{scope:e.__scopeMenu,checked:n,children:w.jsx(Rd,{role:"menuitemcheckbox","aria-checked":Hc(n)?"mixed":n,...i,ref:t,"data-state":um(n),onSelect:ee(i.onSelect,()=>r==null?void 0:r(Hc(n)?!0:!n),{checkForDefaultPrevented:!1})})})});kC.displayName=fD;var PC="MenuRadioGroup",[hD,pD]=as(PC,{value:void 0,onValueChange:()=>{}}),RC=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=Ut(r);return w.jsx(hD,{scope:e.__scopeMenu,value:n,onValueChange:s,children:w.jsx(am,{...i,ref:t})})});RC.displayName=PC;var TC="MenuRadioItem",IC=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=pD(TC,e.__scopeMenu),s=n===i.value;return w.jsx(OC,{scope:e.__scopeMenu,checked:s,children:w.jsx(Rd,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":um(s),onSelect:ee(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});IC.displayName=TC;var lm="MenuItemIndicator",[OC,vD]=as(lm,{checked:!1}),MC=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=vD(lm,n);return w.jsx(br,{present:r||Hc(s.checked)||s.checked===!0,children:w.jsx(ke.span,{...i,ref:t,"data-state":um(s.checked)})})});MC.displayName=lm;var gD="MenuSeparator",AC=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return w.jsx(ke.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});AC.displayName=gD;var mD="MenuArrow",NC=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Pd(n);return w.jsx(Oj,{...i,...r,ref:t})});NC.displayName=mD;var yD="MenuSub",[yz,$C]=as(yD),pa="MenuSubTrigger",FC=g.forwardRef((e,t)=>{const n=ls(pa,e.__scopeMenu),r=Pl(pa,e.__scopeMenu),i=$C(pa,e.__scopeMenu),s=sm(pa,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},c=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>c,[c]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),w.jsx(rm,{asChild:!0,...u,children:w.jsx(CC,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":DC(n.open),...e,ref:vi(t,i.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ee(e.onPointerMove,cl(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),c()},100))})),onPointerLeave:ee(e.onPointerLeave,cl(d=>{var m,_;c();const f=(m=n.content)==null?void 0:m.getBoundingClientRect();if(f){const p=(_=n.content)==null?void 0:_.dataset.side,y=p==="right",h=y?-5:5,v=f[y?"left":"right"],x=f[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+h,y:d.clientY},{x:v,y:f.top},{x,y:f.top},{x,y:f.bottom},{x:v,y:f.bottom}],side:p}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ee(e.onKeyDown,d=>{var m;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||Jj[r.dir].includes(d.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),d.preventDefault())})})})});FC.displayName=pa;var LC="MenuSubContent",jC=g.forwardRef((e,t)=>{const n=xC(un,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=ls(un,e.__scopeMenu),o=Pl(un,e.__scopeMenu),a=$C(LC,e.__scopeMenu),l=g.useRef(null),u=et(t,l);return w.jsx(ul.Provider,{scope:e.__scopeMenu,children:w.jsx(br,{present:r||s.open,children:w.jsx(ul.Slot,{scope:e.__scopeMenu,children:w.jsx(om,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:u,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:c=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),c.preventDefault()},onCloseAutoFocus:c=>c.preventDefault(),onFocusOutside:ee(e.onFocusOutside,c=>{c.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ee(e.onEscapeKeyDown,c=>{o.onClose(),c.preventDefault()}),onKeyDown:ee(e.onKeyDown,c=>{var m;const d=c.currentTarget.contains(c.target),f=Zj[o.dir].includes(c.key);d&&f&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),c.preventDefault())})})})})})});jC.displayName=LC;function DC(e){return e?"open":"closed"}function Hc(e){return e==="indeterminate"}function um(e){return Hc(e)?"indeterminate":e?"checked":"unchecked"}function _D(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function wD(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function xD(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=wD(e,Math.max(s,0));i.length===1&&(o=o.filter(u=>u!==n));const l=o.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function bD(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;sr!=f>r&&n<(d-u)*(r-c)/(f-c)+u&&(i=!i)}return i}function ED(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return bD(n,t)}function cl(e){return t=>t.pointerType==="mouse"?e(t):void 0}var SD=wC,CD=rm,kD=bC,PD=EC,RD=am,TD=SC,ID=Rd,OD=kC,MD=RC,AD=IC,ND=MC,$D=AC,FD=NC,LD=FC,jD=jC,Td="DropdownMenu",[DD]=ss(Td,[yC]),Rt=yC(),[zD,zC]=DD(Td),UC=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Rt(t),u=g.useRef(null),[c,d]=yd({prop:i,defaultProp:s??!1,onChange:o,caller:Td});return w.jsx(zD,{scope:t,triggerId:Qs(),triggerRef:u,contentId:Qs(),open:c,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:w.jsx(SD,{...l,open:c,onOpenChange:d,dir:r,modal:a,children:n})})};UC.displayName=Td;var VC="DropdownMenuTrigger",BC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=zC(VC,n),o=Rt(n);return w.jsx(CD,{asChild:!0,...o,children:w.jsx(ke.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:vi(t,s.triggerRef),onPointerDown:ee(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ee(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});BC.displayName=VC;var UD="DropdownMenuPortal",qC=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Rt(t);return w.jsx(kD,{...r,...n})};qC.displayName=UD;var WC="DropdownMenuContent",HC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=zC(WC,n),s=Rt(n),o=g.useRef(!1);return w.jsx(PD,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:ee(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:ee(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,c=l.button===2||u;(!i.modal||c)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});HC.displayName=WC;var VD="DropdownMenuGroup",BD=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(RD,{...i,...r,ref:t})});BD.displayName=VD;var qD="DropdownMenuLabel",GC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(TD,{...i,...r,ref:t})});GC.displayName=qD;var WD="DropdownMenuItem",KC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(ID,{...i,...r,ref:t})});KC.displayName=WD;var HD="DropdownMenuCheckboxItem",QC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(OD,{...i,...r,ref:t})});QC.displayName=HD;var GD="DropdownMenuRadioGroup",KD=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(MD,{...i,...r,ref:t})});KD.displayName=GD;var QD="DropdownMenuRadioItem",YC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(AD,{...i,...r,ref:t})});YC.displayName=QD;var YD="DropdownMenuItemIndicator",XC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(ND,{...i,...r,ref:t})});XC.displayName=YD;var XD="DropdownMenuSeparator",JC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx($D,{...i,...r,ref:t})});JC.displayName=XD;var JD="DropdownMenuArrow",ZD=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(FD,{...i,...r,ref:t})});ZD.displayName=JD;var e2="DropdownMenuSubTrigger",ZC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(LD,{...i,...r,ref:t})});ZC.displayName=e2;var t2="DropdownMenuSubContent",ek=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rt(n);return w.jsx(jD,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ek.displayName=t2;var n2=UC,r2=BC,i2=qC,tk=HC,nk=GC,rk=KC,ik=QC,sk=YC,ok=XC,ak=JC,lk=ZC,uk=ek;/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const s2=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),dk=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/** + */const s2=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ck=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. @@ -134,12 +134,12 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const a2=g.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...a},l)=>g.createElement("svg",{ref:l,...o2,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:dk("lucide",i),...a},[...o.map(([u,c])=>g.createElement(u,c)),...Array.isArray(s)?s:[s]]));/** + */const a2=g.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...a},l)=>g.createElement("svg",{ref:l,...o2,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:ck("lucide",i),...a},[...o.map(([u,c])=>g.createElement(u,c)),...Array.isArray(s)?s:[s]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Id=(e,t)=>{const n=g.forwardRef(({className:r,...i},s)=>g.createElement(a2,{ref:s,iconNode:t,className:dk(`lucide-${s2(e)}`,r),...i}));return n.displayName=`${e}`,n};/** + */const Id=(e,t)=>{const n=g.forwardRef(({className:r,...i},s)=>g.createElement(a2,{ref:s,iconNode:t,className:ck(`lucide-${s2(e)}`,r),...i}));return n.displayName=`${e}`,n};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. @@ -159,4 +159,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const d2=Id("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),f2=n2,h2=r2,p2=g.forwardRef(({className:e,inset:t,children:n,...r},i)=>w.jsxs(uk,{ref:i,className:ct("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",t&&"pl-8",e),...r,children:[n,w.jsx(u2,{className:"ml-auto h-4 w-4"})]}));p2.displayName=uk.displayName;const v2=g.forwardRef(({className:e,...t},n)=>w.jsx(ck,{ref:n,className:ct("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));v2.displayName=ck.displayName;const fk=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>w.jsx(i2,{children:w.jsx(nk,{ref:r,sideOffset:t,className:ct("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));fk.displayName=nk.displayName;const er=g.forwardRef(({className:e,inset:t,...n},r)=>w.jsx(ik,{ref:r,className:ct("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...n}));er.displayName=ik.displayName;const g2=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>w.jsxs(sk,{ref:i,className:ct("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:n,...r,children:[w.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:w.jsx(ak,{children:w.jsx(l2,{className:"h-4 w-4"})})}),t]}));g2.displayName=sk.displayName;const m2=g.forwardRef(({className:e,children:t,...n},r)=>w.jsxs(ok,{ref:r,className:ct("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[w.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:w.jsx(ak,{children:w.jsx(c2,{className:"h-2 w-2 fill-current"})})}),t]}));m2.displayName=ok.displayName;const hk=g.forwardRef(({className:e,inset:t,...n},r)=>w.jsx(rk,{ref:r,className:ct("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));hk.displayName=rk.displayName;const uv=g.forwardRef(({className:e,...t},n)=>w.jsx(lk,{ref:n,className:ct("-mx-1 my-1 h-px bg-muted",e),...t}));uv.displayName=lk.displayName;function y2(e){const n=(e.name||e.username||"?").trim().split(/\s+/).filter(Boolean);return n.length===0?"?":n.length===1?n[0][0].toUpperCase():(n[0][0]+n[n.length-1][0]).toUpperCase()}const _2=({user:e,onLogout:t})=>w.jsxs(f2,{children:[w.jsx(h2,{asChild:!0,children:w.jsx("button",{type:"button",className:"user-avatar-btn","aria-label":`Account menu for ${e.username}`,children:w.jsxs(z1,{className:"h-8 w-8",children:[e.avatar_url&&w.jsx(U1,{src:e.avatar_url,alt:e.username}),w.jsx(V1,{className:"text-xs",children:y2(e)})]})})}),w.jsxs(fk,{align:"end",className:"w-56",children:[w.jsxs(hk,{className:"flex flex-col gap-0.5 py-2",children:[w.jsx("span",{className:"text-sm font-medium leading-tight",children:e.name||e.username}),w.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["@",e.username]}),e.is_admin&&w.jsx("span",{className:"mt-1 inline-flex w-fit items-center rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-amber-900",children:"Admin"}),e.role==="contributor"&&w.jsx("span",{className:"mt-1 inline-flex w-fit items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-blue-900",children:"Contributor"})]}),w.jsx(uv,{}),w.jsx(er,{asChild:!0,children:w.jsx("a",{href:`https://huggingface.co/${encodeURIComponent(e.username)}`,target:"_blank",rel:"noopener noreferrer",children:"Hugging Face profile"})}),w.jsx(er,{asChild:!0,children:w.jsx(bn,{to:"/frameworks",children:"Frameworks"})}),w.jsx(er,{asChild:!0,children:w.jsx(bn,{to:"/trends",children:"Trends"})}),e.is_admin&&w.jsxs(w.Fragment,{children:[w.jsx(er,{asChild:!0,children:w.jsx(bn,{to:"/admin-dashboard",children:"Admin dashboard"})}),w.jsx(er,{asChild:!0,children:w.jsx(bn,{to:"/submissions",children:"Review submissions"})})]}),w.jsx(er,{asChild:!0,children:w.jsx(bn,{to:`/${encodeURIComponent(e.username)}`,children:"My contributions"})}),w.jsx(er,{asChild:!0,children:w.jsx(bn,{to:"/settings",children:"Settings"})}),w.jsx(uv,{}),w.jsx(er,{onSelect:n=>{n.preventDefault(),t()},children:"Log out"})]})]}),w2=!1;class Od extends Error{constructor(n,r){var i;super(`API request failed: ${n.status} ${n.statusText}`);kr(this,"status");kr(this,"statusText");kr(this,"response");kr(this,"detail");kr(this,"code");kr(this,"displayMessage");this.name="ApiError",this.status=n.status,this.statusText=n.statusText,this.response=r;try{if(this.detail=(i=JSON.parse(r))==null?void 0:i.detail,typeof this.detail=="string"&&(this.message=this.detail),Array.isArray(this.detail)){const s=this.detail[0];typeof s=="object"&&s!==null&&"msg"in s&&typeof s.msg=="string"&&(this.message=s.msg)}if(typeof this.detail=="object"&&this.detail!==null&&"code"in this.detail&&typeof this.detail.code=="string"&&(this.code=this.detail.code),typeof this.detail=="object"&&this.detail!==null&&"message"in this.detail&&typeof this.detail.message=="string"){const s="help"in this.detail&&typeof this.detail.help=="string"?` See ${this.detail.help} for help.`:"";this.message=`${this.detail.message}${s}`}}catch{this.detail=void 0,this.displayMessage=r||this.message;return}this.displayMessage=this.message}}function wz(e,t){return e instanceof Od?e.displayMessage||t:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message||t}class x2{constructor(t){this.baseUrl=t}async fetch(t,n){const r=`${this.baseUrl}${t}`;try{const{headers:i,...s}=n??{},a=(s.method??"GET").toUpperCase()==="GET"?"default":"no-store",l=new Headers(i);return typeof s.body=="string"&&!l.has("Content-Type")&&l.set("Content-Type","application/json"),await fetch(r,{...s,cache:s.cache??a,credentials:s.credentials??"include",headers:l})}catch(i){throw console.error(`[API] Request to ${r} failed:`,i),i}}async fetchOk(t,n){const r=await this.fetch(t,n);if(!r.ok){const i=new Od(r,await r.text());throw console.error("[API] Error response:",i.response),i}return r}async request(t,n){const r=await this.fetchOk(t,n);return r.status===204?void 0:await r.json()}}function b2(e){e instanceof Od&&e.status===401&&e.code!=="fresh_auth_required"&&e.code!=="saved_papers_bucket_authorization_required"&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("pwc:auth-stale"))}async function pk(e){try{return await e()}catch(t){throw b2(t),t}}const cm=new x2(`${Bg()}/api/v1`),E2=(e,t)=>cm.fetch(e,t),xz=(e,t)=>pk(()=>cm.fetchOk(e,t)),cv=(e,t)=>pk(()=>cm.request(e,t));async function bz(e,t){try{return await cv(e,t)}catch(n){if(n instanceof Od&&n.status===404)return null;throw n}}const z0={async getCurrentUser(){if($o())return null;const e=await E2("/auth/me",{cache:"no-store"});return e.status===401||!e.ok?null:e.json()},async logout(){await cv("/auth/logout",{method:"POST"})},async requestStagingAccess(){await cv("/staging-access-request",{method:"POST"})}},S2={detail:e=>["paper",e],arxiv:e=>["paper-arxiv",e],preview:e=>["paper-preview",e],summary:e=>["paper-summary",e],feeds:{list:["papers"],infinite:["papers-infinite"],xTrending:["x-trending-papers-infinite"],following:["research-feed"],search:["paper-search-feed"],task:["task-papers-infinite"],conference:["conference-papers-infinite"],organization:["organization-papers-infinite"],method:["method-papers-infinite"],saved:["my-bookmarks"],related:["related-papers"],versions:["paper-versions"],searchOverlay:["search-papers"],mentions:["chat-paper-mention-search"],trending:["trending-papers"]}},Ez=10*60*1e3,hu={me:["auth","me"]},Sz={preferences:["account","preferences"],bookmarkIds:["my-bookmark-ids"]},Cz={areas:["areas-all"],area:e=>["area",e],topTasksSidebar:["top-tasks-sidebar"],task:e=>["task",e],method:e=>["method",e],organization:e=>["organization",e],dataset:e=>["dataset",e],datasets:["dataset"],datasetTasks:["dataset-tasks"],taskPage:["task-page"],taskBenchmarkTrends:["task-benchmark-trends"],organizations:["organizations"]},kz={all:["evaluations"],byPaper:e=>["evaluations","paper",e],byPaperAll:["evaluations","paper"],byDatasetAll:["dataset-evals"],byDataset:e=>["dataset-evals",e]},Pz={pendingEdits:["pendingPaperEdits"]},Rz={all:["admin"],cronStatus:["admin","cronStatus"],chatSandboxSpend:e=>["admin","chatSandboxSpend",e],chatWebSearchBudget:["admin","chatWebSearchBudget"],autonomousOperations:["admin","autonomousOperations"],paperMarkdownJobs:["admin","paperMarkdownJobs"],codexPaperJobs:["admin","codexPaperJobs"],codexPaperJob:(e,t)=>["admin","codexPaperJob",e,t],catalogAudit:["catalog-audit"]},Tz={follows:e=>["research-follows",e],topic:e=>["research-topic",e],email:e=>["research-email",e],feed:e=>[...S2.feeds.following,e]},dm=q.createContext(null),U0="pwc:auth-stale",C2=({children:e})=>{const t=zS(),n=dN({queryKey:hu.me,queryFn:()=>z0.getCurrentUser(),staleTime:1/0}),r=n.data??null,i=q.useRef(null),{refetch:s}=n,o=q.useCallback(async()=>{await s()},[s]),a=q.useCallback(async()=>{const u=qg("/api/v1/auth/logout");if(new URL(u,window.location.origin).origin!==window.location.origin){const c=document.createElement("form");c.method="POST",c.action=`${u}?return_to=${encodeURIComponent(window.location.href)}`,document.body.appendChild(c),c.submit();return}await z0.logout(),t.setQueryData(hu.me,null)},[t]);q.useEffect(()=>{},[r]),q.useEffect(()=>{i.current&&!r&&t.resetQueries({predicate:u=>u.queryKey[0]!==hu.me[0]}),i.current=r},[t,r]),q.useEffect(()=>{const u=()=>t.setQueryData(hu.me,null);return window.addEventListener(U0,u),()=>window.removeEventListener(U0,u)},[t]);const l=q.useMemo(()=>({user:r,isLoading:n.isPending,refresh:o,logout:a}),[r,n.isPending,o,a]);return w.jsx(dm.Provider,{value:l,children:e})};function vk(){const e=q.useContext(dm);if(!e)throw new Error("useAuth must be used inside an ");return e}function Iz(){return q.useContext(dm)}const Mr=({name:e,size:t=14})=>{const n={search:w.jsx("path",{d:"M11 11l3 3M7 12.5a5.5 5.5 0 110-11 5.5 5.5 0 010 11z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round"}),bookmark:w.jsx("path",{d:"M4 2h8v12l-4-3-4 3V2z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinejoin:"round"}),menu:w.jsx("path",{d:"M2 4h12M2 8h12M2 12h12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),close:w.jsx("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),github:w.jsx("path",{fill:"currentColor",d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"})};return w.jsx("svg",{className:t===11?"icon-sm":"icon",viewBox:"0 0 16 16",width:t,height:t,children:n[e]})},V0="https://github.com/huggingface/paperswithcode-feedback/issues",B0="https://github.com/huggingface/paperswithcode",k2="https://paperswithcode.co/following",q0="pwc:announcement:following-feed:v1:dismissed",th=[{to:"/",label:"Trending",end:!0},{to:"/tasks",label:"Browse state-of-the-art",end:!1},{to:"/methods",label:"Methods",end:!1},{to:"/conferences",label:"Conferences",end:!1},{to:"/organizations",label:"Organizations",end:!1},{to:"/submit",label:"Submit",end:!1}],P2=()=>{if(typeof navigator>"u")return!1;const e=navigator.userAgentData,t=(e==null?void 0:e.platform)||navigator.platform||navigator.userAgent||"";return/Mac|iPhone|iPad|iPod/i.test(t)},R2=()=>{const[e,t]=q.useState(!1);return q.useEffect(()=>{t(P2())},[]),w.jsx("kbd",{children:e?"⌘K":"Ctrl K"})},T2=({onOpenSearch:e})=>{const[t,n]=q.useState(!1),[r,i]=q.useState(()=>localStorage.getItem(q0)!=="1"),s=q.useRef(null),o=q.useRef(null),a=()=>n(!1),{user:l,logout:u}=vk(),c=hn(),d=c.pathname.startsWith("/pdf/"),f=`${c.pathname}${c.search}`||"/",m=$o(),_=al()?{to:"/chat",label:"Chat",end:!1,badge:"New"}:nF()?{to:"/chat",label:"Chat",end:!1,badge:"New",href:tF}:null,p=_?[th[0],_,...th.slice(1)]:th;return q.useLayoutEffect(()=>{var S;const y=s.current,h=o.current;if(!y||!h)return;let v=!1;const x=()=>{if(v)return;const P=y.querySelector(".nav-item.active"),C=(P==null?void 0:P.offsetWidth)??0;h.style.width=`${C}px`,h.style.transform=`translateX(${(P==null?void 0:P.offsetLeft)??0}px)`,h.style.opacity=C>0?"1":"0"};x();const b=window.requestAnimationFrame(()=>{h.classList.add("nav-indicator-ready")}),E=typeof ResizeObserver>"u"?null:new ResizeObserver(x);return E==null||E.observe(y),window.addEventListener("resize",x),(S=document.fonts)==null||S.ready.then(x),()=>{v=!0,window.cancelAnimationFrame(b),E==null||E.disconnect(),window.removeEventListener("resize",x)}},[c.pathname,p.length]),w.jsxs(H$,{open:t,onOpenChange:n,children:[w.jsxs("header",{className:"app-header",children:[w.jsxs("div",{className:"app-header-inner",children:[w.jsxs(ms,{to:"/",className:"brand",onClick:a,children:[w.jsx("span",{className:"brand-mark"}),w.jsxs("span",{className:"brand-name",children:["Papers ",w.jsx("em",{children:"With Code"})]})]}),w.jsxs("nav",{className:"nav",ref:s,children:[p.map(({to:y,label:h,end:v,badge:x,href:b})=>{const E=w.jsxs(w.Fragment,{children:[w.jsx("span",{children:h}),x&&w.jsx("span",{className:"nav-new-badge","aria-hidden":"true",children:x})]});return b?w.jsx("a",{href:b,target:"_blank",rel:"noreferrer",className:`nav-item${x?" nav-item-with-badge":""}`,children:E},y):w.jsx(ms,{to:y,end:v,className:({isActive:S})=>`nav-item${x?" nav-item-with-badge":""}${S?" active":""}`,children:E},y)}),w.jsx("span",{ref:o,className:"nav-indicator","aria-hidden":"true"})]}),w.jsx("div",{className:"header-spacer"}),w.jsx("a",{className:"feedback-link header-feedback-link",href:V0,target:"_blank",rel:"noreferrer",children:"Submit feedback"}),w.jsx("a",{className:"icon-btn header-github-btn",href:B0,target:"_blank",rel:"noreferrer","aria-label":"GitHub repository",title:"GitHub repository",children:w.jsx(Mr,{name:"github",size:14})}),w.jsxs("button",{className:"search-trigger","aria-label":"Search papers, authors, domains",onClick:e,children:[w.jsx(Mr,{name:"search",size:13}),w.jsx("span",{children:"Search papers, authors, domains…"}),w.jsx(R2,{})]}),w.jsx("button",{className:"icon-btn mobile-search-btn","aria-label":"Search",onClick:e,children:w.jsx(Mr,{name:"search",size:14})}),!m&&w.jsx(ms,{to:"/saved",className:"icon-btn header-bookmark-btn","aria-label":"Saved papers",title:"Saved papers",children:w.jsx(Mr,{name:"bookmark",size:13})}),m?null:l?w.jsx(_2,{user:l,onLogout:u}):w.jsx(_1,{returnTo:f}),w.jsx(G$,{asChild:!0,children:w.jsx("button",{className:"icon-btn mobile-menu-btn","aria-label":"Open menu",children:w.jsx(Mr,{name:"menu",size:14})})})]}),!d&&r&&w.jsxs("div",{className:"site-announcement",role:"status",children:[w.jsx("span",{children:"New: "}),m?w.jsx("a",{href:k2,target:"_blank",rel:"noreferrer",children:"following feed"}):w.jsx(bn,{to:"/following",children:"following feed"}),w.jsx("span",{children:", follow your favorite tasks, benchmarks, authors or organizations"}),w.jsx("button",{type:"button",className:"site-announcement-close","aria-label":"Dismiss announcement",onClick:()=>{localStorage.setItem(q0,"1"),i(!1)},children:w.jsx(Mr,{name:"close",size:11})})]})]}),w.jsx(K$,{children:w.jsx(Q$,{className:"mobile-nav-drawer",children:w.jsxs(Y$,{className:"mobile-nav-panel","aria-describedby":void 0,children:[w.jsx(X$,{className:"sr-only",children:"Navigation menu"}),w.jsx(J$,{className:"icon-btn mobile-nav-close","aria-label":"Close menu",children:w.jsx(Mr,{name:"close",size:14})}),w.jsxs("button",{type:"button",className:"mobile-nav-link mobile-nav-search",onClick:()=>{a(),e()},children:[w.jsx(Mr,{name:"search",size:14}),w.jsx("span",{children:"Search papers, authors, domains…"})]}),p.map(({to:y,label:h,end:v,badge:x,href:b})=>{const E=`mobile-nav-link${x?" mobile-nav-link-with-badge":""}`,S=w.jsxs(w.Fragment,{children:[w.jsx("span",{children:h}),x&&w.jsx("span",{className:"nav-new-badge","aria-hidden":"true",children:x})]});return b?w.jsx("a",{href:b,target:"_blank",rel:"noreferrer",className:E,onClick:a,children:S},y):w.jsx(ms,{to:y,end:v,className:E,onClick:a,children:S},y)}),w.jsx("a",{className:"mobile-nav-link",href:V0,target:"_blank",rel:"noreferrer",onClick:a,children:"Submit feedback"}),w.jsx("a",{className:"mobile-nav-link",href:B0,target:"_blank",rel:"noreferrer",onClick:a,children:"GitHub"}),!m&&w.jsx(ms,{to:"/saved",className:"mobile-nav-link",onClick:a,children:"Saved papers"}),!m&&(l==null?void 0:l.is_admin)&&w.jsx(ms,{to:"/admin-dashboard",className:"mobile-nav-link",onClick:a,children:"Admin dashboard"})]})})})]})},I2=()=>{const{pathname:e}=hn();return e==="/chat"||e.startsWith("/chat/")||e.startsWith("/pdf/")?null:w.jsx("footer",{className:"site-footer",children:w.jsxs("div",{className:"site-footer-inner",children:[w.jsxs("span",{children:["© ",new Date().getFullYear()," Hugging Face"]}),w.jsx(bn,{to:"/docs/api",children:"API"}),w.jsx(bn,{to:"/mcp",children:"MCP"}),w.jsx(bn,{to:"/privacy",children:"Privacy"}),w.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback/issues",target:"_blank",rel:"noreferrer",children:"Feedback"})]})})},O2=1,M2=1e6;let nh=0;function A2(){return nh=(nh+1)%Number.MAX_SAFE_INTEGER,nh.toString()}const rh=new Map,W0=e=>{if(rh.has(e))return;const t=setTimeout(()=>{rh.delete(e),Ia({type:"REMOVE_TOAST",toastId:e})},M2);rh.set(e,t)},N2=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,O2)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?W0(n):e.toasts.forEach(r=>{W0(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Lu=[];let ju={toasts:[]};function Ia(e){ju=N2(ju,e),Lu.forEach(t=>{t(ju)})}function $2({...e}){const t=A2(),n=i=>Ia({type:"UPDATE_TOAST",toast:{...i,id:t}}),r=()=>Ia({type:"DISMISS_TOAST",toastId:t});return Ia({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:i=>{i||r()}}}),{id:t,dismiss:r,update:n}}function F2(){const[e,t]=g.useState(ju);return g.useEffect(()=>(Lu.push(t),()=>{const n=Lu.indexOf(t);n>-1&&Lu.splice(n,1)}),[e]),{...e,toast:$2,dismiss:n=>Ia({type:"DISMISS_TOAST",toastId:n})}}var L2=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),j2="VisuallyHidden",fm=g.forwardRef((e,t)=>w.jsx(ke.span,{...e,ref:t,style:{...L2,...e.style}}));fm.displayName=j2;var hm="ToastProvider",[pm,D2,z2]=Kg("Toast"),[gk]=ss("Toast",[z2]),[U2,Md]=gk(hm),mk=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:s=50,children:o}=e,[a,l]=g.useState(null),[u,c]=g.useState(0),d=g.useRef(!1),f=g.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${hm}\`. Expected non-empty \`string\`.`),w.jsx(pm.Provider,{scope:t,children:w.jsx(U2,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:s,toastCount:u,viewport:a,onViewportChange:l,onToastAdd:g.useCallback(()=>c(m=>m+1),[]),onToastRemove:g.useCallback(()=>c(m=>m-1),[]),isFocusedToastEscapeKeyDownRef:d,isClosePausedRef:f,children:o})})};mk.displayName=hm;var yk="ToastViewport",V2=["F8"],dv="toast.viewportPause",fv="toast.viewportResume",_k=g.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=V2,label:i="Notifications ({hotkey})",...s}=e,o=Md(yk,n),a=D2(n),l=g.useRef(null),u=g.useRef(null),c=g.useRef(null),d=g.useRef(null),f=et(t,d,o.onViewportChange),m=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),_=o.toastCount>0;g.useEffect(()=>{const y=h=>{var x;r.length!==0&&r.every(b=>h[b]||h.code===b)&&((x=d.current)==null||x.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[r]),g.useEffect(()=>{const y=l.current,h=d.current;if(_&&y&&h){const v=()=>{if(!o.isClosePausedRef.current){const S=new CustomEvent(dv);h.dispatchEvent(S),o.isClosePausedRef.current=!0}},x=()=>{if(o.isClosePausedRef.current){const S=new CustomEvent(fv);h.dispatchEvent(S),o.isClosePausedRef.current=!1}},b=S=>{!y.contains(S.relatedTarget)&&x()},E=()=>{y.contains(document.activeElement)||x()};return y.addEventListener("focusin",v),y.addEventListener("focusout",b),y.addEventListener("pointermove",v),y.addEventListener("pointerleave",E),window.addEventListener("blur",v),window.addEventListener("focus",x),()=>{y.removeEventListener("focusin",v),y.removeEventListener("focusout",b),y.removeEventListener("pointermove",v),y.removeEventListener("pointerleave",E),window.removeEventListener("blur",v),window.removeEventListener("focus",x)}}},[_,o.isClosePausedRef]);const p=g.useCallback(({tabbingDirection:y})=>{const v=a().map(x=>{const b=x.ref.current,E=[b,...t3(b)];return y==="forwards"?E:E.reverse()});return(y==="forwards"?v.reverse():v).flat()},[a]);return g.useEffect(()=>{const y=d.current;if(y){const h=v=>{var E,S,P;const x=v.altKey||v.ctrlKey||v.metaKey;if(v.key==="Tab"&&!x){const C=document.activeElement,T=v.shiftKey;if(v.target===y&&T){(E=u.current)==null||E.focus();return}const M=p({tabbingDirection:T?"backwards":"forwards"}),z=M.findIndex(F=>F===C);ih(M.slice(z+1))?v.preventDefault():T?(S=u.current)==null||S.focus():(P=c.current)==null||P.focus()}};return y.addEventListener("keydown",h),()=>y.removeEventListener("keydown",h)}},[a,p]),w.jsxs(NN,{ref:l,role:"region","aria-label":i.replace("{hotkey}",m),tabIndex:-1,style:{pointerEvents:_?void 0:"none"},children:[_&&w.jsx(hv,{ref:u,onFocusFromOutsideViewport:()=>{const y=p({tabbingDirection:"forwards"});ih(y)}}),w.jsx(pm.Slot,{scope:n,children:w.jsx(ke.ol,{tabIndex:-1,...s,ref:f})}),_&&w.jsx(hv,{ref:c,onFocusFromOutsideViewport:()=>{const y=p({tabbingDirection:"backwards"});ih(y)}})]})});_k.displayName=yk;var wk="ToastFocusProxy",hv=g.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=e,s=Md(wk,n);return w.jsx(fm,{tabIndex:0,...i,ref:t,style:{position:"fixed"},onFocus:o=>{var u;const a=o.relatedTarget;!((u=s.viewport)!=null&&u.contains(a))&&r()}})});hv.displayName=wk;var Rl="Toast",B2="toast.swipeStart",q2="toast.swipeMove",W2="toast.swipeCancel",H2="toast.swipeEnd",xk=g.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:i,onOpenChange:s,...o}=e,[a,l]=yd({prop:r,defaultProp:i??!0,onChange:s,caller:Rl});return w.jsx(br,{present:n||a,children:w.jsx(Q2,{open:a,...o,ref:t,onClose:()=>l(!1),onPause:Ut(e.onPause),onResume:Ut(e.onResume),onSwipeStart:ee(e.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ee(e.onSwipeMove,u=>{const{x:c,y:d}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${c}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${d}px`)}),onSwipeCancel:ee(e.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ee(e.onSwipeEnd,u=>{const{x:c,y:d}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${c}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${d}px`),l(!1)})})})});xk.displayName=Rl;var[G2,K2]=gk(Rl,{onClose(){}}),Q2=g.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:i,open:s,onClose:o,onEscapeKeyDown:a,onPause:l,onResume:u,onSwipeStart:c,onSwipeMove:d,onSwipeCancel:f,onSwipeEnd:m,..._}=e,p=Md(Rl,n),[y,h]=g.useState(null),v=et(t,F=>h(F)),x=g.useRef(null),b=g.useRef(null),E=i||p.duration,S=g.useRef(0),P=g.useRef(E),C=g.useRef(0),{onToastAdd:T,onToastRemove:R}=p,N=Ut(()=>{var W;(y==null?void 0:y.contains(document.activeElement))&&((W=p.viewport)==null||W.focus()),o()}),M=g.useCallback(F=>{!F||F===1/0||(window.clearTimeout(C.current),S.current=new Date().getTime(),C.current=window.setTimeout(N,F))},[N]);g.useEffect(()=>{const F=p.viewport;if(F){const W=()=>{M(P.current),u==null||u()},B=()=>{const Q=new Date().getTime()-S.current;P.current=P.current-Q,window.clearTimeout(C.current),l==null||l()};return F.addEventListener(dv,B),F.addEventListener(fv,W),()=>{F.removeEventListener(dv,B),F.removeEventListener(fv,W)}}},[p.viewport,E,l,u,M]),g.useEffect(()=>{s&&!p.isClosePausedRef.current&&M(E)},[s,E,p.isClosePausedRef,M]),g.useEffect(()=>(T(),()=>R()),[T,R]);const z=g.useMemo(()=>y?Rk(y):null,[y]);return p.viewport?w.jsxs(w.Fragment,{children:[z&&w.jsx(Y2,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:z}),w.jsx(G2,{scope:n,onClose:N,children:xl.createPortal(w.jsx(pm.ItemSlot,{scope:n,children:w.jsx(AN,{asChild:!0,onEscapeKeyDown:ee(a,()=>{p.isFocusedToastEscapeKeyDownRef.current||N(),p.isFocusedToastEscapeKeyDownRef.current=!1}),children:w.jsx(ke.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":p.swipeDirection,..._,ref:v,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ee(e.onKeyDown,F=>{F.key==="Escape"&&(a==null||a(F.nativeEvent),F.nativeEvent.defaultPrevented||(p.isFocusedToastEscapeKeyDownRef.current=!0,N()))}),onPointerDown:ee(e.onPointerDown,F=>{F.button===0&&(x.current={x:F.clientX,y:F.clientY})}),onPointerMove:ee(e.onPointerMove,F=>{if(!x.current)return;const W=F.clientX-x.current.x,B=F.clientY-x.current.y,Q=!!b.current,O=["left","right"].includes(p.swipeDirection),A=["left","up"].includes(p.swipeDirection)?Math.min:Math.max,V=O?A(0,W):0,K=O?0:A(0,B),te=F.pointerType==="touch"?10:2,oe={x:V,y:K},de={originalEvent:F,delta:oe};Q?(b.current=oe,pu(q2,d,de,{discrete:!1})):H0(oe,p.swipeDirection,te)?(b.current=oe,pu(B2,c,de,{discrete:!1}),F.target.setPointerCapture(F.pointerId)):(Math.abs(W)>te||Math.abs(B)>te)&&(x.current=null)}),onPointerUp:ee(e.onPointerUp,F=>{const W=b.current,B=F.target;if(B.hasPointerCapture(F.pointerId)&&B.releasePointerCapture(F.pointerId),b.current=null,x.current=null,W){const Q=F.currentTarget,O={originalEvent:F,delta:W};H0(W,p.swipeDirection,p.swipeThreshold)?pu(H2,m,O,{discrete:!0}):pu(W2,f,O,{discrete:!0}),Q.addEventListener("click",A=>A.preventDefault(),{once:!0})}})})})}),p.viewport)})]}):null}),Y2=e=>{const{__scopeToast:t,children:n,...r}=e,i=Md(Rl,t),[s,o]=g.useState(!1),[a,l]=g.useState(!1);return Z2(()=>o(!0)),g.useEffect(()=>{const u=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(u)},[]),a?null:w.jsx(wd,{asChild:!0,children:w.jsx(fm,{...r,children:s&&w.jsxs(w.Fragment,{children:[i.label," ",n]})})})},X2="ToastTitle",bk=g.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return w.jsx(ke.div,{...r,ref:t})});bk.displayName=X2;var J2="ToastDescription",Ek=g.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return w.jsx(ke.div,{...r,ref:t})});Ek.displayName=J2;var Sk="ToastAction",Ck=g.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?w.jsx(Pk,{altText:n,asChild:!0,children:w.jsx(vm,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Sk}\`. Expected non-empty \`string\`.`),null)});Ck.displayName=Sk;var kk="ToastClose",vm=g.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,i=K2(kk,n);return w.jsx(Pk,{asChild:!0,children:w.jsx(ke.button,{type:"button",...r,ref:t,onClick:ee(e.onClick,i.onClose)})})});vm.displayName=kk;var Pk=g.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...i}=e;return w.jsx(ke.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...i,ref:t})});function Rk(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),e3(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!i)if(s){const o=r.dataset.radixToastAnnounceAlt;o&&t.push(o)}else t.push(...Rk(r))}}),t}function pu(e,t,n,{discrete:r}){const i=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Lg(i,s):i.dispatchEvent(s)}var H0=(e,t,n=0)=>{const r=Math.abs(e.x),i=Math.abs(e.y),s=r>i;return t==="left"||t==="right"?s&&r>n:!s&&i>n};function Z2(e=()=>{}){const t=Ut(e);fn(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function e3(e){return e.nodeType===e.ELEMENT_NODE}function t3(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ih(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var n3=mk,Tk=_k,Ik=xk,Ok=bk,Mk=Ek,Ak=Ck,Nk=vm;const G0=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,K0=N1,r3=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return K0(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(u=>{const c=n==null?void 0:n[u],d=s==null?void 0:s[u];if(c===null)return null;const f=G0(c)||G0(d);return i[u][f]}),a=n&&Object.entries(n).reduce((u,c)=>{let[d,f]=c;return f===void 0||(u[d]=f),u},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,c)=>{let{class:d,className:f,...m}=c;return Object.entries(m).every(_=>{let[p,y]=_;return Array.isArray(y)?y.includes({...s,...a}[p]):{...s,...a}[p]===y})?[...u,d,f]:u},[]);return K0(e,o,l,n==null?void 0:n.class,n==null?void 0:n.className)},i3=n3,$k=g.forwardRef(({className:e,...t},n)=>w.jsx(Tk,{ref:n,className:ct("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));$k.displayName=Tk.displayName;const s3=r3("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-16 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Fk=g.forwardRef(({className:e,variant:t,...n},r)=>w.jsx(Ik,{ref:r,className:ct(s3({variant:t}),e),...n}));Fk.displayName=Ik.displayName;const o3=g.forwardRef(({className:e,...t},n)=>w.jsx(Ak,{ref:n,className:ct("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",e),...t}));o3.displayName=Ak.displayName;const Lk=g.forwardRef(({className:e,...t},n)=>w.jsx(Nk,{ref:n,className:ct("absolute right-2 top-2 inline-flex h-11 w-11 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring group-[.destructive]:text-destructive-foreground group-[.destructive]:hover:bg-destructive-foreground/10 group-[.destructive]:focus:ring-destructive-foreground",e),"aria-label":"Dismiss notification","toast-close":"",...t,children:w.jsx(d2,{className:"h-4 w-4"})}));Lk.displayName=Nk.displayName;const jk=g.forwardRef(({className:e,...t},n)=>w.jsx(Ok,{ref:n,className:ct("text-sm font-semibold",e),...t}));jk.displayName=Ok.displayName;const Dk=g.forwardRef(({className:e,...t},n)=>w.jsx(Mk,{ref:n,className:ct("text-sm opacity-90",e),...t}));Dk.displayName=Mk.displayName;function a3(){const{toasts:e}=F2();return w.jsxs(i3,{children:[e.map(function({id:t,title:n,description:r,action:i,...s}){return w.jsxs(Fk,{...s,children:[w.jsxs("div",{className:"grid gap-1",children:[n&&w.jsx(jk,{children:n}),r&&w.jsx(Dk,{children:r})]}),i,w.jsx(Lk,{})]},t)}),w.jsx($k,{})]})}function l3(){const{pathname:e,hash:t}=hn();g.useLayoutEffect(()=>{t||window.scrollTo({top:0,left:0,behavior:"instant"})},[e,t])}const zk=iF(),u3=zk?bA:xA;if(!zk&&typeof window<"u"){const e=window.location.hash;e.startsWith("#/")&&!e.startsWith("#//")&&window.history.replaceState(null,"",e.slice(1))}const c3=q.lazy(()=>ae(()=>import("./AuthorizePaperEditView-DNfre5z5.js"),__vite__mapDeps([0,1,2,3]))),d3=q.lazy(()=>ae(()=>import("./FollowingView-Ctbw54vk.js"),__vite__mapDeps([4,5,6,7,8,9,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33]))),Q0=q.lazy(()=>ae(()=>import("./FeedView-tA68x8iy.js"),__vite__mapDeps([5,6,7,8,9,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33]))),f3=q.lazy(()=>ae(()=>import("./ChatView-D06zYumh.js"),__vite__mapDeps([34,35,29,30,21,22,36,37,8,38,39,40,41,42,43,1,44,45,46,47,11,48,49,15,16,50,51,27,28,52,53,54]))),h3=q.lazy(()=>ae(()=>import("./SharedChatView-Cd2cL7B4.js"),__vite__mapDeps([55,35,29,30,21,22,36,37,8,38,39,40,41,42,43,1,44,45,46,47,11,48,49,15,16,50,51]))),p3=q.lazy(()=>ae(()=>import("./PapersListView-BwwaBBb8.js"),__vite__mapDeps([56,17,18,10,19,13,14,15,16,20,21,22,23,24,25,26,8,31,32,57,33,58,59]))),v3=q.lazy(()=>ae(()=>import("./PaperDetailView-BlSDULsI.js"),__vite__mapDeps([60,1,19,17,18,10,20,61,22,36,23,62,21,63,31,32,64,65,66,25,33,2,7,28,44,67,68,69,70,24,48,71,37,8,72,73,74,75,11,76,77,38,78,79,41,42,26,80,81,15,16,82]))),g3=q.lazy(()=>ae(()=>import("./PaperReaderView-C7GrMxPx.js"),__vite__mapDeps([83,35,29,30,21,22,36,37,8,38,39,40,41,42,43,1,44,45,46,47,11,48,49,15,16,50,51,84,63,23,31,32,34,27,28,52,53,54]))),m3=q.lazy(()=>ae(()=>import("./TagsIndexView-BwVoxBoD.js"),__vite__mapDeps([85,8,18,10,86,48,87,52,88,89,45,75,90,39,91,77,6,33,92,25,93,72,2,69,73,70,24,7,71,1,74,11,94,95]))),y3=q.lazy(()=>ae(()=>import("./TagBrowseView-DKVo9Mlp.js"),__vite__mapDeps([96,97,9,1,11,17,18,10,13,14,15,16,19,20,21,22,23,24,25,26,12,98,84,40,41,42,43,36,51,8,58,59,65,66,86,31,32,33,99,90,38]))),_3=q.lazy(()=>ae(()=>import("./MethodsIndexView-D_aKGLyJ.js"),__vite__mapDeps([100,8,95,86,33,92,25,93,72,2,69,73,70,24,7,48,71,1,74,11,94,88]))),w3=q.lazy(()=>ae(()=>import("./FrameworksIndexView-CZmHXkeL.js"),__vite__mapDeps([101,19,8,18,59]))),x3=q.lazy(()=>ae(()=>import("./TrendsView-DCijqOnv.js"),__vite__mapDeps([102,33,25]))),b3=q.lazy(()=>ae(()=>import("./ConferencesIndexView-DJVYKUiz.js"),__vite__mapDeps([103,8,104,33,92,25,93,72,2,69,73,70,24,7,48,71,1,74,11]))),E3=q.lazy(()=>ae(()=>import("./AiDeadlinesView--bEB1R4q.js"),__vite__mapDeps([105,8,106,78,25,33,23,7,104]))),S3=q.lazy(()=>ae(()=>import("./ConferenceDetailView-DgDeLFoO.js"),__vite__mapDeps([107,92,25,84,40,41,42,43,36,21,22,1,51,8,58,95,18,108,104,10,33,23,99]))),C3=q.lazy(()=>ae(()=>import("./ConferenceTaskView-BvWfAecx.js"),__vite__mapDeps([109,13,14,15,16,17,18,10,19,20,21,22,23,24,25,26,84,40,41,42,43,36,1,51,8,58,108,31,32,33,99]))),k3=q.lazy(()=>ae(()=>import("./OrganizationsIndexView-DpJistoL.js"),__vite__mapDeps([110,33,8,111]))),P3=q.lazy(()=>ae(()=>import("./OrganizationDetailView-DYOQ1Mwd.js"),__vite__mapDeps([112,97,9,1,11,84,40,41,42,43,36,21,22,51,113,25,8,13,14,15,16,17,18,10,19,20,23,24,26,33,70,2,7,48,71,31,32,58,81,99]))),R3=q.lazy(()=>ae(()=>import("./OrganizationDetailView-DYOQ1Mwd.js"),__vite__mapDeps([112,97,9,1,11,84,40,41,42,43,36,21,22,51,113,25,8,13,14,15,16,17,18,10,19,20,23,24,26,33,70,2,7,48,71,31,32,58,81,99]))),T3=q.lazy(()=>ae(()=>import("./AuthorDetailView-BykOxZh0.js"),__vite__mapDeps([114,15,16,13,14,17,18,10,19,20,21,22,23,24,25,26,97,9,1,11,33,31,32,58,99]))),I3=q.lazy(()=>ae(()=>import("./MethodDetailView-5wFkSBs8.js"),__vite__mapDeps([115,97,9,1,11,17,18,10,13,14,15,16,19,20,21,22,23,24,25,26,84,40,41,42,43,36,51,8,58,86,31,32,33,99]))),O3=q.lazy(()=>ae(()=>import("./BenchmarkDetailView-BObHaEFx.js"),__vite__mapDeps([116,97,9,1,11,8,61,22,36,23,62,65,66,20,106,78,19,25,33,98,86,58,99,117]))),M3=q.lazy(()=>ae(()=>import("./SavedPapersView-B2fQDeYi.js"),__vite__mapDeps([118,14,15,16,17,18,10,19,20,21,22,23,25,33,66,80]))),A3=q.lazy(()=>ae(()=>import("./SettingsView-BuCdwlbq.js"),__vite__mapDeps([119,1,9,106,78,6,12,90,30,64,53,65,66,47,89]))),N3=q.lazy(()=>ae(()=>import("./PrivacyView-BQ3x7IFA.js"),__vite__mapDeps([120,64]))),$3=q.lazy(()=>ae(()=>import("./ApiDocsView-DhYUFS5g.js"),__vite__mapDeps([121,64,41,122]))),F3=q.lazy(()=>ae(()=>import("./McpView-DYa6GKrp.js"),__vite__mapDeps([123,64,54,38,47,44,124]))),L3=q.lazy(()=>ae(()=>import("./SubmitView-CDuD6xEz.js"),__vite__mapDeps([125,1,33,2,69,73,21,22,68]))),j3=q.lazy(()=>ae(()=>import("./CronDashboard-kqcQ1rzf.js"),__vite__mapDeps([126,1,127,128,76,2,49,75,88,91,39,87,47,129,71,130,79,32,3,8,30]))),D3=q.lazy(()=>ae(()=>import("./AutonomousOperations-B4vSAvB8.js"),__vite__mapDeps([131,1,127,128,76,2,69,91,46]))),z3=q.lazy(()=>ae(()=>import("./SubmissionsDashboard-CZ6QfHso.js"),__vite__mapDeps([132,67,68,1,32,8,23,74,21,22,129,71,130,133]))),U3=q.lazy(()=>ae(()=>import("./UserProfileView-BnW4I15t.js"),__vite__mapDeps([134,113,25,8]))),V3=q.lazy(()=>ae(()=>import("./RateLimitsView-phVSVOy1.js"),__vite__mapDeps([135,66]))),B3=q.lazy(()=>ae(()=>import("./AstraForRoboticsView-BZJ-P8S9.js"),__vite__mapDeps([136,13,14,15,16,17,18,10,19,20,21,22,23,24,25,26,33,31,32,64,137]))),sh=q.lazy(()=>ae(()=>import("./NotFound-DV_nwcxG.js"),[])),q3=q.lazy(()=>ae(()=>import("./SearchOverlay-5zBt7fdP.js"),__vite__mapDeps([138,20,8,21,22,57,18,10]))),W3=q.lazy(()=>ae(()=>import("./StagingAccessRequestView-CZz80h2x.js"),__vite__mapDeps([139,130]))),Uk=()=>w.jsxs("div",{className:"page","aria-busy":"true","aria-live":"polite",children:[w.jsx("div",{className:"animate-pulse rounded-md bg-muted",style:{height:24,width:"30%",marginBottom:24}}),w.jsx("div",{className:"animate-pulse rounded-md bg-muted",style:{height:64,width:"60%",marginBottom:32}}),w.jsxs("div",{className:"paper-list",style:{display:"grid",gap:16},children:[w.jsx("div",{className:"animate-pulse rounded-md bg-muted",style:{height:96}}),w.jsx("div",{className:"animate-pulse rounded-md bg-muted",style:{height:96}}),w.jsx("div",{className:"animate-pulse rounded-md bg-muted",style:{height:96}})]})]}),H3=new JA({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}}),G3=()=>{const{arxivId:e}=xS();return w.jsx(Ro,{to:e?`/paper/${e}`:"/papers",replace:!0})},K3=()=>{const{taskSlug:e}=xS();return w.jsx(Ro,{to:e?`/tasks/${e}`:"/tasks",replace:!0})},Q3=({element:e})=>$o()?w.jsx(Ro,{to:"/",replace:!0}):w.jsx(w.Fragment,{children:e}),pv=({element:e})=>{const{user:t,isLoading:n}=vk(),r=hn();return $o()?w.jsx(Ro,{to:"/",replace:!0}):n?w.jsx("div",{className:"page",children:w.jsx("div",{className:"submission-loading",children:w.jsx("span",{children:"Checking admin session..."})})}):t?t.is_admin?w.jsx(w.Fragment,{children:e}):w.jsx("div",{className:"page",children:w.jsxs("div",{className:"submission-empty submission-empty-warn",children:[w.jsx("h1",{children:"Admin access required"}),w.jsxs("p",{children:["Signed in as @",t.username,". This dashboard is limited to allowlisted admin accounts."]})]})}):w.jsx("div",{className:"page",children:w.jsxs("div",{className:"submission-empty submission-empty-warn",children:[w.jsx("h1",{children:"Sign in required"}),w.jsx("p",{children:"Sign in with an allowlisted Hugging Face admin account to view admin operations."}),w.jsx(_1,{returnTo:`${r.pathname}${r.search}`})]})})},Y3=()=>{const e=eF(),t=typeof window<"u"&&new URL(e,window.location.origin).origin!==window.location.origin;return q.useEffect(()=>{t&&window.location.replace(e)},[e,t]),t?w.jsx("div",{className:"page",children:w.jsxs("div",{className:"submission-loading",children:[w.jsx("span",{children:"Opening the production admin dashboard..."}),w.jsx("a",{href:e,children:"Continue"})]})}):w.jsx(pv,{element:w.jsx(j3,{})})},Y0=({reader:e=!1})=>{const[t,n]=q.useState(!1),{pathname:r}=hn();q.useEffect(()=>{const a=l=>{(l.metaKey||l.ctrlKey)&&l.key==="k"&&(l.preventDefault(),n(!0))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]);const i=w.jsx(T2,{onOpenSearch:()=>n(!0)}),s=w.jsx(fS,{resetKey:r,children:w.jsx(q.Suspense,{fallback:w.jsx(Uk,{}),children:w.jsx(dA,{})})}),o=t&&w.jsx(q.Suspense,{fallback:null,children:w.jsx(q3,{open:t,onClose:()=>n(!1)})});return e?w.jsxs("div",{className:"reader-route-shell",children:[i,w.jsx("div",{className:"reader-route-content",children:s}),o]}):w.jsxs(w.Fragment,{children:[i,w.jsx("main",{children:s}),w.jsx(I2,{}),o]})},X3=()=>(l3(),q.useLayoutEffect(()=>{var e;(e=document.getElementById("initial-discovery-footer"))==null||e.remove()},[]),w.jsxs(fA,{children:[w.jsx(re,{path:"/request-access",element:w.jsx(q.Suspense,{fallback:w.jsx(Uk,{}),children:w.jsx(W3,{})})}),w.jsx(re,{element:w.jsx(Y0,{reader:!0}),children:w.jsx(re,{path:"/pdf/:paperId",element:rF()?w.jsx(g3,{}):w.jsx(sh,{})})}),w.jsxs(re,{element:w.jsx(Y0,{}),children:[w.jsx(re,{path:"/",element:w.jsx(Q0,{})}),w.jsx(re,{path:"/following",element:w.jsx(d3,{})}),w.jsx(re,{path:"/x-trending",element:w.jsx(Q0,{xTrending:!0})}),w.jsx(re,{path:"/chat/:sessionId?",element:al()?w.jsx(f3,{}):w.jsx(Ro,{to:"/",replace:!0})}),w.jsx(re,{path:"/share/:shareId",element:al()?w.jsx(h3,{}):w.jsx(sh,{})}),w.jsx(re,{path:"/papers",element:w.jsx(p3,{})}),w.jsx(re,{path:"/papers/:arxivId",element:w.jsx(G3,{})}),w.jsx(re,{path:"/paper/:arxivId",element:w.jsx(v3,{})}),w.jsx(re,{path:"/tasks",element:w.jsx(m3,{})}),w.jsx(re,{path:"/tasks/:taskSlug",element:w.jsx(y3,{})}),w.jsx(re,{path:"/task/:taskSlug",element:w.jsx(K3,{})}),w.jsx(re,{path:"/methods",element:w.jsx(_3,{})}),w.jsx(re,{path:"/methods/:methodSlug",element:w.jsx(I3,{})}),w.jsx(re,{path:"/frameworks",element:w.jsx(w3,{})}),w.jsx(re,{path:"/trends",element:w.jsx(x3,{})}),w.jsx(re,{path:"/conferences",element:w.jsx(b3,{})}),w.jsx(re,{path:"/ai-deadlines",element:w.jsx(E3,{})}),w.jsx(re,{path:"/conferences/:confSlug",element:w.jsx(S3,{})}),w.jsx(re,{path:"/conferences/:confSlug/:taskSlug",element:w.jsx(C3,{})}),w.jsx(re,{path:"/organizations",element:w.jsx(k3,{})}),w.jsx(re,{path:"/orgs/:orgSlug",element:w.jsx(P3,{})}),w.jsx(re,{path:"/orgs/:orgSlug/:taskSlug",element:w.jsx(R3,{})}),w.jsx(re,{path:"/authors/:authorId",element:w.jsx(T3,{})}),w.jsx(re,{path:"/benchmark/:datasetSlug",element:w.jsx(O3,{})}),w.jsx(re,{path:"/authorize-paper-edit/:authorizationId",element:w.jsx(c3,{})}),w.jsx(re,{path:"/submit",element:w.jsx(L3,{})}),w.jsx(re,{path:"/saved",element:w.jsx(Q3,{element:w.jsx(M3,{})})}),w.jsx(re,{path:"/settings",element:w.jsx(A3,{})}),w.jsx(re,{path:"/privacy",element:w.jsx(N3,{})}),w.jsx(re,{path:"/docs/api",element:w.jsx($3,{})}),w.jsx(re,{path:"/mcp",element:w.jsx(F3,{})}),w.jsx(re,{path:"/admin-dashboard",element:w.jsx(Y3,{})}),w.jsx(re,{path:"/autonomous-operations",element:w.jsx(pv,{element:w.jsx(D3,{})})}),w.jsx(re,{path:"/cron-dashboard",element:w.jsx(Ro,{to:"/admin-dashboard",replace:!0})}),w.jsx(re,{path:"/submissions",element:w.jsx(pv,{element:w.jsx(z3,{})})}),w.jsx(re,{path:"/rate-limits",element:w.jsx(V3,{})}),w.jsx(re,{path:"/astra-for-robotics",element:w.jsx(B3,{})}),w.jsx(re,{path:"/:username",element:w.jsx(U3,{})}),w.jsx(re,{path:"*",element:w.jsx(sh,{})})]})]})),J3=()=>w.jsx(ZA,{client:H3,children:w.jsxs(C2,{children:[w.jsx(u3,{children:w.jsx(X3,{})}),w.jsx(a3,{}),!1]})});_M();const Z3=w.jsx(_T,{attribute:"class",defaultTheme:"system",enableSystem:!0,disableTransitionOnChange:!0,storageKey:"pwc-theme",children:w.jsx(fS,{children:w.jsx(J3,{})})}),ez=wb(document.getElementById("root"));ez.render(w.jsx(q.StrictMode,{children:Z3}));export{h2 as $,yd as A,et as B,l2 as C,ee as D,xj as E,ss as F,ct as G,_1 as H,Rz as I,dz as J,yz as K,bn as L,B1 as M,Bj as N,hC as O,br as P,c2 as Q,Vj as R,o3 as S,Ez as T,Od as U,q as V,Sz as W,d2 as X,rF as Y,cz as Z,f2 as _,vk as a,oz as a$,fk as a0,er as a1,fz as a2,uz as a3,pz as a4,aw as a5,Z$ as a6,ae as a7,N1 as a8,u2 as a9,Pz as aA,z1 as aB,U1 as aC,V1 as aD,El as aE,at as aF,Up as aG,TS as aH,WA as aI,eN as aJ,rN as aK,aN as aL,iN as aM,sN as aN,At as aO,uN as aP,l0 as aQ,oN as aR,il as aS,QA as aT,OS as aU,xz as aV,bz as aW,t1 as aX,Dg as aY,HS as aZ,jg as a_,xl as aa,b2 as ab,cv as ac,x1 as ad,r3 as ae,Qs as af,H$ as ag,K$ as ah,Q$ as ai,Y$ as aj,vi as ak,J$ as al,X$ as am,lz as an,Ro as ao,Rj as ap,Tj as aq,rC as ar,wd as as,_d as at,Ij as au,Oj as av,rz as aw,nz as ax,E2 as ay,vz as az,dN as b,sz as b0,cN as b1,qg as b2,z0 as b3,hn as c,g as d,Mg as e,Iz as f,iz as g,y1 as h,zS as i,w as j,$o as k,al as l,nF as m,tF as n,Cz as o,S2 as p,hz as q,Tz as r,Id as s,kz as t,xS as u,gz as v,mz as w,F2 as x,wz as y,ke as z}; + */const d2=Id("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),f2=n2,h2=r2,p2=g.forwardRef(({className:e,inset:t,children:n,...r},i)=>w.jsxs(lk,{ref:i,className:ct("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",t&&"pl-8",e),...r,children:[n,w.jsx(u2,{className:"ml-auto h-4 w-4"})]}));p2.displayName=lk.displayName;const v2=g.forwardRef(({className:e,...t},n)=>w.jsx(uk,{ref:n,className:ct("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));v2.displayName=uk.displayName;const dk=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>w.jsx(i2,{children:w.jsx(tk,{ref:r,sideOffset:t,className:ct("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));dk.displayName=tk.displayName;const er=g.forwardRef(({className:e,inset:t,...n},r)=>w.jsx(rk,{ref:r,className:ct("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...n}));er.displayName=rk.displayName;const g2=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>w.jsxs(ik,{ref:i,className:ct("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:n,...r,children:[w.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:w.jsx(ok,{children:w.jsx(l2,{className:"h-4 w-4"})})}),t]}));g2.displayName=ik.displayName;const m2=g.forwardRef(({className:e,children:t,...n},r)=>w.jsxs(sk,{ref:r,className:ct("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[w.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:w.jsx(ok,{children:w.jsx(c2,{className:"h-2 w-2 fill-current"})})}),t]}));m2.displayName=sk.displayName;const fk=g.forwardRef(({className:e,inset:t,...n},r)=>w.jsx(nk,{ref:r,className:ct("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));fk.displayName=nk.displayName;const uv=g.forwardRef(({className:e,...t},n)=>w.jsx(ak,{ref:n,className:ct("-mx-1 my-1 h-px bg-muted",e),...t}));uv.displayName=ak.displayName;function y2(e){const n=(e.name||e.username||"?").trim().split(/\s+/).filter(Boolean);return n.length===0?"?":n.length===1?n[0][0].toUpperCase():(n[0][0]+n[n.length-1][0]).toUpperCase()}const _2=({user:e,onLogout:t})=>w.jsxs(f2,{children:[w.jsx(h2,{asChild:!0,children:w.jsx("button",{type:"button",className:"user-avatar-btn","aria-label":`Account menu for ${e.username}`,children:w.jsxs(D1,{className:"h-8 w-8",children:[e.avatar_url&&w.jsx(z1,{src:e.avatar_url,alt:e.username}),w.jsx(U1,{className:"text-xs",children:y2(e)})]})})}),w.jsxs(dk,{align:"end",className:"w-56",children:[w.jsxs(fk,{className:"flex flex-col gap-0.5 py-2",children:[w.jsx("span",{className:"text-sm font-medium leading-tight",children:e.name||e.username}),w.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["@",e.username]}),e.is_admin&&w.jsx("span",{className:"mt-1 inline-flex w-fit items-center rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-amber-900",children:"Admin"}),e.role==="contributor"&&w.jsx("span",{className:"mt-1 inline-flex w-fit items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-blue-900",children:"Contributor"})]}),w.jsx(uv,{}),w.jsx(er,{asChild:!0,children:w.jsx("a",{href:`https://huggingface.co/${encodeURIComponent(e.username)}`,target:"_blank",rel:"noopener noreferrer",children:"Hugging Face profile"})}),w.jsx(er,{asChild:!0,children:w.jsx(bn,{to:"/frameworks",children:"Frameworks"})}),w.jsx(er,{asChild:!0,children:w.jsx(bn,{to:"/trends",children:"Trends"})}),e.is_admin&&w.jsxs(w.Fragment,{children:[w.jsx(er,{asChild:!0,children:w.jsx(bn,{to:"/admin-dashboard",children:"Admin dashboard"})}),w.jsx(er,{asChild:!0,children:w.jsx(bn,{to:"/submissions",children:"Review submissions"})})]}),w.jsx(er,{asChild:!0,children:w.jsx(bn,{to:`/${encodeURIComponent(e.username)}`,children:"My contributions"})}),w.jsx(er,{asChild:!0,children:w.jsx(bn,{to:"/settings",children:"Settings"})}),w.jsx(uv,{}),w.jsx(er,{onSelect:n=>{n.preventDefault(),t()},children:"Log out"})]})]}),w2=!1;class Od extends Error{constructor(n,r){var i;super(`API request failed: ${n.status} ${n.statusText}`);kr(this,"status");kr(this,"statusText");kr(this,"response");kr(this,"detail");kr(this,"code");kr(this,"displayMessage");this.name="ApiError",this.status=n.status,this.statusText=n.statusText,this.response=r;try{if(this.detail=(i=JSON.parse(r))==null?void 0:i.detail,typeof this.detail=="string"&&(this.message=this.detail),Array.isArray(this.detail)){const s=this.detail[0];typeof s=="object"&&s!==null&&"msg"in s&&typeof s.msg=="string"&&(this.message=s.msg)}if(typeof this.detail=="object"&&this.detail!==null&&"code"in this.detail&&typeof this.detail.code=="string"&&(this.code=this.detail.code),typeof this.detail=="object"&&this.detail!==null&&"message"in this.detail&&typeof this.detail.message=="string"){const s="help"in this.detail&&typeof this.detail.help=="string"?` See ${this.detail.help} for help.`:"";this.message=`${this.detail.message}${s}`}}catch{this.detail=void 0,this.displayMessage=r||this.message;return}this.displayMessage=this.message}}function _z(e,t){return e instanceof Od?e.displayMessage||t:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message||t}class x2{constructor(t){this.baseUrl=t}async fetch(t,n){const r=`${this.baseUrl}${t}`;try{const{headers:i,...s}=n??{},a=(s.method??"GET").toUpperCase()==="GET"?"default":"no-store",l=new Headers(i);return typeof s.body=="string"&&!l.has("Content-Type")&&l.set("Content-Type","application/json"),await fetch(r,{...s,cache:s.cache??a,credentials:s.credentials??"include",headers:l})}catch(i){throw console.error(`[API] Request to ${r} failed:`,i),i}}async fetchOk(t,n){const r=await this.fetch(t,n);if(!r.ok){const i=new Od(r,await r.text());throw console.error("[API] Error response:",i.response),i}return r}async request(t,n){const r=await this.fetchOk(t,n);return r.status===204?void 0:await r.json()}}function b2(e){e instanceof Od&&e.status===401&&e.code!=="fresh_auth_required"&&e.code!=="saved_papers_bucket_authorization_required"&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("pwc:auth-stale"))}async function hk(e){try{return await e()}catch(t){throw b2(t),t}}const cm=new x2(`${Bg()}/api/v1`),E2=(e,t)=>cm.fetch(e,t),wz=(e,t)=>hk(()=>cm.fetchOk(e,t)),cv=(e,t)=>hk(()=>cm.request(e,t));async function xz(e,t){try{return await cv(e,t)}catch(n){if(n instanceof Od&&n.status===404)return null;throw n}}const z0={async getCurrentUser(){if($o())return null;const e=await E2("/auth/me",{cache:"no-store"});return e.status===401||!e.ok?null:e.json()},async logout(){await cv("/auth/logout",{method:"POST"})},async requestStagingAccess(){await cv("/staging-access-request",{method:"POST"})}},S2={detail:e=>["paper",e],arxiv:e=>["paper-arxiv",e],preview:e=>["paper-preview",e],summary:e=>["paper-summary",e],feeds:{list:["papers"],infinite:["papers-infinite"],xTrending:["x-trending-papers-infinite"],following:["research-feed"],search:["paper-search-feed"],task:["task-papers-infinite"],conference:["conference-papers-infinite"],organization:["organization-papers-infinite"],method:["method-papers-infinite"],saved:["my-bookmarks"],related:["related-papers"],versions:["paper-versions"],searchOverlay:["search-papers"],mentions:["chat-paper-mention-search"],trending:["trending-papers"]}},bz=10*60*1e3,hu={me:["auth","me"]},Ez={preferences:["account","preferences"],bookmarkIds:["my-bookmark-ids"]},Sz={areas:["areas-all"],area:e=>["area",e],topTasksSidebar:["top-tasks-sidebar"],task:e=>["task",e],method:e=>["method",e],organization:e=>["organization",e],dataset:e=>["dataset",e],datasets:["dataset"],datasetTasks:["dataset-tasks"],taskPage:["task-page"],taskBenchmarkTrends:["task-benchmark-trends"],organizations:["organizations"]},Cz={all:["evaluations"],byPaper:e=>["evaluations","paper",e],byPaperAll:["evaluations","paper"],byDatasetAll:["dataset-evals"],byDataset:e=>["dataset-evals",e]},kz={pendingEdits:["pendingPaperEdits"]},Pz={all:["admin"],cronStatus:["admin","cronStatus"],chatSandboxSpend:e=>["admin","chatSandboxSpend",e],chatWebSearchBudget:["admin","chatWebSearchBudget"],autonomousOperations:["admin","autonomousOperations"],paperMarkdownJobs:["admin","paperMarkdownJobs"],codexPaperJobs:["admin","codexPaperJobs"],codexPaperJob:(e,t)=>["admin","codexPaperJob",e,t],catalogAudit:["catalog-audit"]},Rz={follows:e=>["research-follows",e],topic:e=>["research-topic",e],email:e=>["research-email",e],feed:e=>[...S2.feeds.following,e]},dm=q.createContext(null),U0="pwc:auth-stale",C2=({children:e})=>{const t=zS(),n=cN({queryKey:hu.me,queryFn:()=>z0.getCurrentUser(),staleTime:1/0}),r=n.data??null,i=q.useRef(null),{refetch:s}=n,o=q.useCallback(async()=>{await s()},[s]),a=q.useCallback(async()=>{const u=qg("/api/v1/auth/logout");if(new URL(u,window.location.origin).origin!==window.location.origin){const c=document.createElement("form");c.method="POST",c.action=`${u}?return_to=${encodeURIComponent(window.location.href)}`,document.body.appendChild(c),c.submit();return}await z0.logout(),t.setQueryData(hu.me,null)},[t]);q.useEffect(()=>{},[r]),q.useEffect(()=>{i.current&&!r&&t.resetQueries({predicate:u=>u.queryKey[0]!==hu.me[0]}),i.current=r},[t,r]),q.useEffect(()=>{const u=()=>t.setQueryData(hu.me,null);return window.addEventListener(U0,u),()=>window.removeEventListener(U0,u)},[t]);const l=q.useMemo(()=>({user:r,isLoading:n.isPending,refresh:o,logout:a}),[r,n.isPending,o,a]);return w.jsx(dm.Provider,{value:l,children:e})};function pk(){const e=q.useContext(dm);if(!e)throw new Error("useAuth must be used inside an ");return e}function Tz(){return q.useContext(dm)}const Mr=({name:e,size:t=14})=>{const n={search:w.jsx("path",{d:"M11 11l3 3M7 12.5a5.5 5.5 0 110-11 5.5 5.5 0 010 11z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round"}),bookmark:w.jsx("path",{d:"M4 2h8v12l-4-3-4 3V2z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinejoin:"round"}),menu:w.jsx("path",{d:"M2 4h12M2 8h12M2 12h12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),close:w.jsx("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),github:w.jsx("path",{fill:"currentColor",d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"})};return w.jsx("svg",{className:t===11?"icon-sm":"icon",viewBox:"0 0 16 16",width:t,height:t,children:n[e]})},V0="https://github.com/huggingface/paperswithcode-feedback/issues",B0="https://github.com/huggingface/paperswithcode",k2="https://paperswithcode.co/following",q0="pwc:announcement:following-feed:v1:dismissed",th=[{to:"/",label:"Trending",end:!0},{to:"/tasks",label:"Browse state-of-the-art",end:!1},{to:"/methods",label:"Methods",end:!1},{to:"/conferences",label:"Conferences",end:!1},{to:"/organizations",label:"Organizations",end:!1},{to:"/submit",label:"Submit",end:!1}],P2=()=>{if(typeof navigator>"u")return!1;const e=navigator.userAgentData,t=(e==null?void 0:e.platform)||navigator.platform||navigator.userAgent||"";return/Mac|iPhone|iPad|iPod/i.test(t)},R2=()=>{const[e,t]=q.useState(!1);return q.useEffect(()=>{t(P2())},[]),w.jsx("kbd",{children:e?"⌘K":"Ctrl K"})},T2=({onOpenSearch:e})=>{const[t,n]=q.useState(!1),[r,i]=q.useState(()=>localStorage.getItem(q0)!=="1"),s=q.useRef(null),o=q.useRef(null),a=()=>n(!1),{user:l,logout:u}=pk(),c=hn(),d=c.pathname.startsWith("/pdf/"),f=`${c.pathname}${c.search}`||"/",m=$o(),_=al()?{to:"/chat",label:"Chat",end:!1,badge:"New"}:nF()?{to:"/chat",label:"Chat",end:!1,badge:"New",href:tF}:null,p=_?[th[0],_,...th.slice(1)]:th;return q.useLayoutEffect(()=>{var S;const y=s.current,h=o.current;if(!y||!h)return;let v=!1;const x=()=>{if(v)return;const P=y.querySelector(".nav-item.active"),C=(P==null?void 0:P.offsetWidth)??0;h.style.width=`${C}px`,h.style.transform=`translateX(${(P==null?void 0:P.offsetLeft)??0}px)`,h.style.opacity=C>0?"1":"0"};x();const b=window.requestAnimationFrame(()=>{h.classList.add("nav-indicator-ready")}),E=typeof ResizeObserver>"u"?null:new ResizeObserver(x);return E==null||E.observe(y),window.addEventListener("resize",x),(S=document.fonts)==null||S.ready.then(x),()=>{v=!0,window.cancelAnimationFrame(b),E==null||E.disconnect(),window.removeEventListener("resize",x)}},[c.pathname,p.length]),w.jsxs(W$,{open:t,onOpenChange:n,children:[w.jsxs("header",{className:"app-header",children:[w.jsxs("div",{className:"app-header-inner",children:[w.jsxs(ms,{to:"/",className:"brand",onClick:a,children:[w.jsx("span",{className:"brand-mark"}),w.jsxs("span",{className:"brand-name",children:["Papers ",w.jsx("em",{children:"With Code"})]})]}),w.jsxs("nav",{className:"nav",ref:s,children:[p.map(({to:y,label:h,end:v,badge:x,href:b})=>{const E=w.jsxs(w.Fragment,{children:[w.jsx("span",{children:h}),x&&w.jsx("span",{className:"nav-new-badge","aria-hidden":"true",children:x})]});return b?w.jsx("a",{href:b,target:"_blank",rel:"noreferrer",className:`nav-item${x?" nav-item-with-badge":""}`,children:E},y):w.jsx(ms,{to:y,end:v,className:({isActive:S})=>`nav-item${x?" nav-item-with-badge":""}${S?" active":""}`,children:E},y)}),w.jsx("span",{ref:o,className:"nav-indicator","aria-hidden":"true"})]}),w.jsx("div",{className:"header-spacer"}),w.jsx("a",{className:"feedback-link header-feedback-link",href:V0,target:"_blank",rel:"noreferrer",children:"Submit feedback"}),w.jsx("a",{className:"icon-btn header-github-btn",href:B0,target:"_blank",rel:"noreferrer","aria-label":"GitHub repository",title:"GitHub repository",children:w.jsx(Mr,{name:"github",size:14})}),w.jsxs("button",{className:"search-trigger","aria-label":"Search papers, authors, domains",onClick:e,children:[w.jsx(Mr,{name:"search",size:13}),w.jsx("span",{children:"Search papers, authors, domains…"}),w.jsx(R2,{})]}),w.jsx("button",{className:"icon-btn mobile-search-btn","aria-label":"Search",onClick:e,children:w.jsx(Mr,{name:"search",size:14})}),!m&&w.jsx(ms,{to:"/saved",className:"icon-btn header-bookmark-btn","aria-label":"Saved papers",title:"Saved papers",children:w.jsx(Mr,{name:"bookmark",size:13})}),m?null:l?w.jsx(_2,{user:l,onLogout:u}):w.jsx(y1,{returnTo:f}),w.jsx(H$,{asChild:!0,children:w.jsx("button",{className:"icon-btn mobile-menu-btn","aria-label":"Open menu",children:w.jsx(Mr,{name:"menu",size:14})})})]}),!d&&r&&w.jsxs("div",{className:"site-announcement",role:"status",children:[w.jsx("span",{children:"New: "}),m?w.jsx("a",{href:k2,target:"_blank",rel:"noreferrer",children:"following feed"}):w.jsx(bn,{to:"/following",children:"following feed"}),w.jsx("span",{children:", follow your favorite tasks, benchmarks, authors or organizations"}),w.jsx("button",{type:"button",className:"site-announcement-close","aria-label":"Dismiss announcement",onClick:()=>{localStorage.setItem(q0,"1"),i(!1)},children:w.jsx(Mr,{name:"close",size:11})})]})]}),w.jsx(G$,{children:w.jsx(K$,{className:"mobile-nav-drawer",children:w.jsxs(Q$,{className:"mobile-nav-panel","aria-describedby":void 0,children:[w.jsx(Y$,{className:"sr-only",children:"Navigation menu"}),w.jsx(X$,{className:"icon-btn mobile-nav-close","aria-label":"Close menu",children:w.jsx(Mr,{name:"close",size:14})}),w.jsxs("button",{type:"button",className:"mobile-nav-link mobile-nav-search",onClick:()=>{a(),e()},children:[w.jsx(Mr,{name:"search",size:14}),w.jsx("span",{children:"Search papers, authors, domains…"})]}),p.map(({to:y,label:h,end:v,badge:x,href:b})=>{const E=`mobile-nav-link${x?" mobile-nav-link-with-badge":""}`,S=w.jsxs(w.Fragment,{children:[w.jsx("span",{children:h}),x&&w.jsx("span",{className:"nav-new-badge","aria-hidden":"true",children:x})]});return b?w.jsx("a",{href:b,target:"_blank",rel:"noreferrer",className:E,onClick:a,children:S},y):w.jsx(ms,{to:y,end:v,className:E,onClick:a,children:S},y)}),w.jsx("a",{className:"mobile-nav-link",href:V0,target:"_blank",rel:"noreferrer",onClick:a,children:"Submit feedback"}),w.jsx("a",{className:"mobile-nav-link",href:B0,target:"_blank",rel:"noreferrer",onClick:a,children:"GitHub"}),!m&&w.jsx(ms,{to:"/saved",className:"mobile-nav-link",onClick:a,children:"Saved papers"}),!m&&(l==null?void 0:l.is_admin)&&w.jsx(ms,{to:"/admin-dashboard",className:"mobile-nav-link",onClick:a,children:"Admin dashboard"})]})})})]})},I2=()=>{const{pathname:e}=hn();return e==="/chat"||e.startsWith("/chat/")||e.startsWith("/pdf/")?null:w.jsx("footer",{className:"site-footer",children:w.jsxs("div",{className:"site-footer-inner",children:[w.jsxs("span",{children:["© ",new Date().getFullYear()," Hugging Face"]}),w.jsx(bn,{to:"/docs/api",children:"API"}),w.jsx(bn,{to:"/mcp",children:"MCP"}),w.jsx(bn,{to:"/privacy",children:"Privacy"}),w.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback/issues",target:"_blank",rel:"noreferrer",children:"Feedback"})]})})},O2=1,M2=1e6;let nh=0;function A2(){return nh=(nh+1)%Number.MAX_SAFE_INTEGER,nh.toString()}const rh=new Map,W0=e=>{if(rh.has(e))return;const t=setTimeout(()=>{rh.delete(e),Ia({type:"REMOVE_TOAST",toastId:e})},M2);rh.set(e,t)},N2=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,O2)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?W0(n):e.toasts.forEach(r=>{W0(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Lu=[];let ju={toasts:[]};function Ia(e){ju=N2(ju,e),Lu.forEach(t=>{t(ju)})}function $2({...e}){const t=A2(),n=i=>Ia({type:"UPDATE_TOAST",toast:{...i,id:t}}),r=()=>Ia({type:"DISMISS_TOAST",toastId:t});return Ia({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:i=>{i||r()}}}),{id:t,dismiss:r,update:n}}function F2(){const[e,t]=g.useState(ju);return g.useEffect(()=>(Lu.push(t),()=>{const n=Lu.indexOf(t);n>-1&&Lu.splice(n,1)}),[e]),{...e,toast:$2,dismiss:n=>Ia({type:"DISMISS_TOAST",toastId:n})}}var L2=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),j2="VisuallyHidden",fm=g.forwardRef((e,t)=>w.jsx(ke.span,{...e,ref:t,style:{...L2,...e.style}}));fm.displayName=j2;var hm="ToastProvider",[pm,D2,z2]=Kg("Toast"),[vk]=ss("Toast",[z2]),[U2,Md]=vk(hm),gk=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:s=50,children:o}=e,[a,l]=g.useState(null),[u,c]=g.useState(0),d=g.useRef(!1),f=g.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${hm}\`. Expected non-empty \`string\`.`),w.jsx(pm.Provider,{scope:t,children:w.jsx(U2,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:s,toastCount:u,viewport:a,onViewportChange:l,onToastAdd:g.useCallback(()=>c(m=>m+1),[]),onToastRemove:g.useCallback(()=>c(m=>m-1),[]),isFocusedToastEscapeKeyDownRef:d,isClosePausedRef:f,children:o})})};gk.displayName=hm;var mk="ToastViewport",V2=["F8"],dv="toast.viewportPause",fv="toast.viewportResume",yk=g.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=V2,label:i="Notifications ({hotkey})",...s}=e,o=Md(mk,n),a=D2(n),l=g.useRef(null),u=g.useRef(null),c=g.useRef(null),d=g.useRef(null),f=et(t,d,o.onViewportChange),m=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),_=o.toastCount>0;g.useEffect(()=>{const y=h=>{var x;r.length!==0&&r.every(b=>h[b]||h.code===b)&&((x=d.current)==null||x.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[r]),g.useEffect(()=>{const y=l.current,h=d.current;if(_&&y&&h){const v=()=>{if(!o.isClosePausedRef.current){const S=new CustomEvent(dv);h.dispatchEvent(S),o.isClosePausedRef.current=!0}},x=()=>{if(o.isClosePausedRef.current){const S=new CustomEvent(fv);h.dispatchEvent(S),o.isClosePausedRef.current=!1}},b=S=>{!y.contains(S.relatedTarget)&&x()},E=()=>{y.contains(document.activeElement)||x()};return y.addEventListener("focusin",v),y.addEventListener("focusout",b),y.addEventListener("pointermove",v),y.addEventListener("pointerleave",E),window.addEventListener("blur",v),window.addEventListener("focus",x),()=>{y.removeEventListener("focusin",v),y.removeEventListener("focusout",b),y.removeEventListener("pointermove",v),y.removeEventListener("pointerleave",E),window.removeEventListener("blur",v),window.removeEventListener("focus",x)}}},[_,o.isClosePausedRef]);const p=g.useCallback(({tabbingDirection:y})=>{const v=a().map(x=>{const b=x.ref.current,E=[b,...t3(b)];return y==="forwards"?E:E.reverse()});return(y==="forwards"?v.reverse():v).flat()},[a]);return g.useEffect(()=>{const y=d.current;if(y){const h=v=>{var E,S,P;const x=v.altKey||v.ctrlKey||v.metaKey;if(v.key==="Tab"&&!x){const C=document.activeElement,T=v.shiftKey;if(v.target===y&&T){(E=u.current)==null||E.focus();return}const M=p({tabbingDirection:T?"backwards":"forwards"}),z=M.findIndex(F=>F===C);ih(M.slice(z+1))?v.preventDefault():T?(S=u.current)==null||S.focus():(P=c.current)==null||P.focus()}};return y.addEventListener("keydown",h),()=>y.removeEventListener("keydown",h)}},[a,p]),w.jsxs(AN,{ref:l,role:"region","aria-label":i.replace("{hotkey}",m),tabIndex:-1,style:{pointerEvents:_?void 0:"none"},children:[_&&w.jsx(hv,{ref:u,onFocusFromOutsideViewport:()=>{const y=p({tabbingDirection:"forwards"});ih(y)}}),w.jsx(pm.Slot,{scope:n,children:w.jsx(ke.ol,{tabIndex:-1,...s,ref:f})}),_&&w.jsx(hv,{ref:c,onFocusFromOutsideViewport:()=>{const y=p({tabbingDirection:"backwards"});ih(y)}})]})});yk.displayName=mk;var _k="ToastFocusProxy",hv=g.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=e,s=Md(_k,n);return w.jsx(fm,{tabIndex:0,...i,ref:t,style:{position:"fixed"},onFocus:o=>{var u;const a=o.relatedTarget;!((u=s.viewport)!=null&&u.contains(a))&&r()}})});hv.displayName=_k;var Rl="Toast",B2="toast.swipeStart",q2="toast.swipeMove",W2="toast.swipeCancel",H2="toast.swipeEnd",wk=g.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:i,onOpenChange:s,...o}=e,[a,l]=yd({prop:r,defaultProp:i??!0,onChange:s,caller:Rl});return w.jsx(br,{present:n||a,children:w.jsx(Q2,{open:a,...o,ref:t,onClose:()=>l(!1),onPause:Ut(e.onPause),onResume:Ut(e.onResume),onSwipeStart:ee(e.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ee(e.onSwipeMove,u=>{const{x:c,y:d}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${c}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${d}px`)}),onSwipeCancel:ee(e.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ee(e.onSwipeEnd,u=>{const{x:c,y:d}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${c}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${d}px`),l(!1)})})})});wk.displayName=Rl;var[G2,K2]=vk(Rl,{onClose(){}}),Q2=g.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:i,open:s,onClose:o,onEscapeKeyDown:a,onPause:l,onResume:u,onSwipeStart:c,onSwipeMove:d,onSwipeCancel:f,onSwipeEnd:m,..._}=e,p=Md(Rl,n),[y,h]=g.useState(null),v=et(t,F=>h(F)),x=g.useRef(null),b=g.useRef(null),E=i||p.duration,S=g.useRef(0),P=g.useRef(E),C=g.useRef(0),{onToastAdd:T,onToastRemove:R}=p,N=Ut(()=>{var W;(y==null?void 0:y.contains(document.activeElement))&&((W=p.viewport)==null||W.focus()),o()}),M=g.useCallback(F=>{!F||F===1/0||(window.clearTimeout(C.current),S.current=new Date().getTime(),C.current=window.setTimeout(N,F))},[N]);g.useEffect(()=>{const F=p.viewport;if(F){const W=()=>{M(P.current),u==null||u()},B=()=>{const Q=new Date().getTime()-S.current;P.current=P.current-Q,window.clearTimeout(C.current),l==null||l()};return F.addEventListener(dv,B),F.addEventListener(fv,W),()=>{F.removeEventListener(dv,B),F.removeEventListener(fv,W)}}},[p.viewport,E,l,u,M]),g.useEffect(()=>{s&&!p.isClosePausedRef.current&&M(E)},[s,E,p.isClosePausedRef,M]),g.useEffect(()=>(T(),()=>R()),[T,R]);const z=g.useMemo(()=>y?Pk(y):null,[y]);return p.viewport?w.jsxs(w.Fragment,{children:[z&&w.jsx(Y2,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:z}),w.jsx(G2,{scope:n,onClose:N,children:xl.createPortal(w.jsx(pm.ItemSlot,{scope:n,children:w.jsx(MN,{asChild:!0,onEscapeKeyDown:ee(a,()=>{p.isFocusedToastEscapeKeyDownRef.current||N(),p.isFocusedToastEscapeKeyDownRef.current=!1}),children:w.jsx(ke.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":p.swipeDirection,..._,ref:v,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ee(e.onKeyDown,F=>{F.key==="Escape"&&(a==null||a(F.nativeEvent),F.nativeEvent.defaultPrevented||(p.isFocusedToastEscapeKeyDownRef.current=!0,N()))}),onPointerDown:ee(e.onPointerDown,F=>{F.button===0&&(x.current={x:F.clientX,y:F.clientY})}),onPointerMove:ee(e.onPointerMove,F=>{if(!x.current)return;const W=F.clientX-x.current.x,B=F.clientY-x.current.y,Q=!!b.current,O=["left","right"].includes(p.swipeDirection),A=["left","up"].includes(p.swipeDirection)?Math.min:Math.max,V=O?A(0,W):0,K=O?0:A(0,B),te=F.pointerType==="touch"?10:2,oe={x:V,y:K},de={originalEvent:F,delta:oe};Q?(b.current=oe,pu(q2,d,de,{discrete:!1})):H0(oe,p.swipeDirection,te)?(b.current=oe,pu(B2,c,de,{discrete:!1}),F.target.setPointerCapture(F.pointerId)):(Math.abs(W)>te||Math.abs(B)>te)&&(x.current=null)}),onPointerUp:ee(e.onPointerUp,F=>{const W=b.current,B=F.target;if(B.hasPointerCapture(F.pointerId)&&B.releasePointerCapture(F.pointerId),b.current=null,x.current=null,W){const Q=F.currentTarget,O={originalEvent:F,delta:W};H0(W,p.swipeDirection,p.swipeThreshold)?pu(H2,m,O,{discrete:!0}):pu(W2,f,O,{discrete:!0}),Q.addEventListener("click",A=>A.preventDefault(),{once:!0})}})})})}),p.viewport)})]}):null}),Y2=e=>{const{__scopeToast:t,children:n,...r}=e,i=Md(Rl,t),[s,o]=g.useState(!1),[a,l]=g.useState(!1);return Z2(()=>o(!0)),g.useEffect(()=>{const u=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(u)},[]),a?null:w.jsx(wd,{asChild:!0,children:w.jsx(fm,{...r,children:s&&w.jsxs(w.Fragment,{children:[i.label," ",n]})})})},X2="ToastTitle",xk=g.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return w.jsx(ke.div,{...r,ref:t})});xk.displayName=X2;var J2="ToastDescription",bk=g.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return w.jsx(ke.div,{...r,ref:t})});bk.displayName=J2;var Ek="ToastAction",Sk=g.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?w.jsx(kk,{altText:n,asChild:!0,children:w.jsx(vm,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Ek}\`. Expected non-empty \`string\`.`),null)});Sk.displayName=Ek;var Ck="ToastClose",vm=g.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,i=K2(Ck,n);return w.jsx(kk,{asChild:!0,children:w.jsx(ke.button,{type:"button",...r,ref:t,onClick:ee(e.onClick,i.onClose)})})});vm.displayName=Ck;var kk=g.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...i}=e;return w.jsx(ke.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...i,ref:t})});function Pk(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),e3(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!i)if(s){const o=r.dataset.radixToastAnnounceAlt;o&&t.push(o)}else t.push(...Pk(r))}}),t}function pu(e,t,n,{discrete:r}){const i=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Lg(i,s):i.dispatchEvent(s)}var H0=(e,t,n=0)=>{const r=Math.abs(e.x),i=Math.abs(e.y),s=r>i;return t==="left"||t==="right"?s&&r>n:!s&&i>n};function Z2(e=()=>{}){const t=Ut(e);fn(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function e3(e){return e.nodeType===e.ELEMENT_NODE}function t3(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ih(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var n3=gk,Rk=yk,Tk=wk,Ik=xk,Ok=bk,Mk=Sk,Ak=vm;const G0=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,K0=A1,r3=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return K0(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(u=>{const c=n==null?void 0:n[u],d=s==null?void 0:s[u];if(c===null)return null;const f=G0(c)||G0(d);return i[u][f]}),a=n&&Object.entries(n).reduce((u,c)=>{let[d,f]=c;return f===void 0||(u[d]=f),u},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,c)=>{let{class:d,className:f,...m}=c;return Object.entries(m).every(_=>{let[p,y]=_;return Array.isArray(y)?y.includes({...s,...a}[p]):{...s,...a}[p]===y})?[...u,d,f]:u},[]);return K0(e,o,l,n==null?void 0:n.class,n==null?void 0:n.className)},i3=n3,Nk=g.forwardRef(({className:e,...t},n)=>w.jsx(Rk,{ref:n,className:ct("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));Nk.displayName=Rk.displayName;const s3=r3("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-16 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),$k=g.forwardRef(({className:e,variant:t,...n},r)=>w.jsx(Tk,{ref:r,className:ct(s3({variant:t}),e),...n}));$k.displayName=Tk.displayName;const o3=g.forwardRef(({className:e,...t},n)=>w.jsx(Mk,{ref:n,className:ct("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",e),...t}));o3.displayName=Mk.displayName;const Fk=g.forwardRef(({className:e,...t},n)=>w.jsx(Ak,{ref:n,className:ct("absolute right-2 top-2 inline-flex h-11 w-11 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring group-[.destructive]:text-destructive-foreground group-[.destructive]:hover:bg-destructive-foreground/10 group-[.destructive]:focus:ring-destructive-foreground",e),"aria-label":"Dismiss notification","toast-close":"",...t,children:w.jsx(d2,{className:"h-4 w-4"})}));Fk.displayName=Ak.displayName;const Lk=g.forwardRef(({className:e,...t},n)=>w.jsx(Ik,{ref:n,className:ct("text-sm font-semibold",e),...t}));Lk.displayName=Ik.displayName;const jk=g.forwardRef(({className:e,...t},n)=>w.jsx(Ok,{ref:n,className:ct("text-sm opacity-90",e),...t}));jk.displayName=Ok.displayName;function a3(){const{toasts:e}=F2();return w.jsxs(i3,{children:[e.map(function({id:t,title:n,description:r,action:i,...s}){return w.jsxs($k,{...s,children:[w.jsxs("div",{className:"grid gap-1",children:[n&&w.jsx(Lk,{children:n}),r&&w.jsx(jk,{children:r})]}),i,w.jsx(Fk,{})]},t)}),w.jsx(Nk,{})]})}function l3(){const{pathname:e,hash:t}=hn();g.useLayoutEffect(()=>{t||window.scrollTo({top:0,left:0,behavior:"instant"})},[e,t])}const Dk=iF(),u3=Dk?xA:wA;if(!Dk&&typeof window<"u"){const e=window.location.hash;e.startsWith("#/")&&!e.startsWith("#//")&&window.history.replaceState(null,"",e.slice(1))}const c3=q.lazy(()=>ae(()=>import("./AuthorizePaperEditView-C-sg5DHX.js"),__vite__mapDeps([0,1,2,3]))),d3=q.lazy(()=>ae(()=>import("./FollowingView-C0KL9Wds.js"),__vite__mapDeps([4,5,6,7,8,9,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33]))),Q0=q.lazy(()=>ae(()=>import("./FeedView-BZs7imUl.js"),__vite__mapDeps([5,6,7,8,9,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33]))),f3=q.lazy(()=>ae(()=>import("./ChatView-DeilSeCH.js"),__vite__mapDeps([34,35,29,30,21,22,36,37,8,38,39,40,41,42,43,1,44,45,46,47,48,11,49,50,15,16,51,52,27,28,53,54]))),h3=q.lazy(()=>ae(()=>import("./SharedChatView-BS81XNKW.js"),__vite__mapDeps([55,35,29,30,21,22,36,37,8,38,39,40,41,42,43,1,44,45,46,47,48,11,49,50,15,16,51,52]))),p3=q.lazy(()=>ae(()=>import("./PapersListView-DL7UDvBC.js"),__vite__mapDeps([56,17,18,10,19,13,14,15,16,20,21,22,23,24,25,26,8,31,32,57,33,58,59]))),v3=q.lazy(()=>ae(()=>import("./PaperDetailView-DSf05yVz.js"),__vite__mapDeps([60,1,19,17,18,10,20,61,22,36,23,62,21,63,31,32,64,65,66,25,33,2,7,28,45,67,68,69,70,24,49,71,37,8,72,73,74,75,11,76,77,38,78,79,41,42,26,80,81,15,16,82]))),g3=q.lazy(()=>ae(()=>import("./PaperReaderView-CqbyUlPD.js"),__vite__mapDeps([83,35,29,30,21,22,36,37,8,38,39,40,41,42,43,1,44,45,46,47,48,11,49,50,15,16,51,52,84,63,23,31,32,34,27,28,53,54]))),m3=q.lazy(()=>ae(()=>import("./TagsIndexView-Bqdox0Xx.js"),__vite__mapDeps([85,8,18,10,86,49,87,53,88,89,44,75,90,39,91,77,6,33,92,25,93,72,2,69,73,70,24,7,71,1,74,11,94,95]))),y3=q.lazy(()=>ae(()=>import("./TagBrowseView-jVCzOB7D.js"),__vite__mapDeps([96,97,9,1,11,17,18,10,13,14,15,16,19,20,21,22,23,24,25,26,12,98,84,40,41,42,43,36,52,8,58,59,65,66,86,31,32,33,99,90,38]))),_3=q.lazy(()=>ae(()=>import("./MethodsIndexView-BlMbRRsu.js"),__vite__mapDeps([100,8,95,86,33,92,25,93,72,2,69,73,70,24,7,49,71,1,74,11,94,88]))),w3=q.lazy(()=>ae(()=>import("./FrameworksIndexView-BBgK14SQ.js"),__vite__mapDeps([101,19,8,18,59]))),x3=q.lazy(()=>ae(()=>import("./TrendsView-DPKj3I8y.js"),__vite__mapDeps([102,33,25]))),b3=q.lazy(()=>ae(()=>import("./ConferencesIndexView-CS7nG4hL.js"),__vite__mapDeps([103,8,104,33,92,25,93,72,2,69,73,70,24,7,49,71,1,74,11]))),E3=q.lazy(()=>ae(()=>import("./AiDeadlinesView-Dh-TYdum.js"),__vite__mapDeps([105,8,106,78,25,33,23,7,104]))),S3=q.lazy(()=>ae(()=>import("./ConferenceDetailView-CujSkc9V.js"),__vite__mapDeps([107,92,25,84,40,41,42,43,36,21,22,1,52,8,58,95,18,108,104,10,33,23,99]))),C3=q.lazy(()=>ae(()=>import("./ConferenceTaskView-BrixcLRv.js"),__vite__mapDeps([109,13,14,15,16,17,18,10,19,20,21,22,23,24,25,26,84,40,41,42,43,36,1,52,8,58,108,31,32,33,99]))),k3=q.lazy(()=>ae(()=>import("./OrganizationsIndexView-ec7nj_SS.js"),__vite__mapDeps([110,33,8,111]))),P3=q.lazy(()=>ae(()=>import("./OrganizationDetailView-ysggtQzi.js"),__vite__mapDeps([112,97,9,1,11,84,40,41,42,43,36,21,22,52,113,25,8,13,14,15,16,17,18,10,19,20,23,24,26,33,70,2,7,49,71,31,32,58,81,99]))),R3=q.lazy(()=>ae(()=>import("./OrganizationDetailView-ysggtQzi.js"),__vite__mapDeps([112,97,9,1,11,84,40,41,42,43,36,21,22,52,113,25,8,13,14,15,16,17,18,10,19,20,23,24,26,33,70,2,7,49,71,31,32,58,81,99]))),T3=q.lazy(()=>ae(()=>import("./AuthorDetailView-BwEN_vpq.js"),__vite__mapDeps([114,15,16,13,14,17,18,10,19,20,21,22,23,24,25,26,97,9,1,11,33,31,32,58,99]))),I3=q.lazy(()=>ae(()=>import("./MethodDetailView-DVIskZnq.js"),__vite__mapDeps([115,97,9,1,11,17,18,10,13,14,15,16,19,20,21,22,23,24,25,26,84,40,41,42,43,36,52,8,58,86,31,32,33,99]))),O3=q.lazy(()=>ae(()=>import("./BenchmarkDetailView-B6qFGTVj.js"),__vite__mapDeps([116,97,9,1,11,8,61,22,36,23,62,65,66,20,106,78,19,25,33,98,86,58,99,117]))),M3=q.lazy(()=>ae(()=>import("./SavedPapersView-CCKo8hBZ.js"),__vite__mapDeps([118,14,15,16,17,18,10,19,20,21,22,23,25,33,66,80]))),A3=q.lazy(()=>ae(()=>import("./SettingsView-DAkLrhMP.js"),__vite__mapDeps([119,1,9,106,78,6,12,90,30,64,54,65,66,48,89]))),N3=q.lazy(()=>ae(()=>import("./PrivacyView-BHODG2cO.js"),__vite__mapDeps([120,64]))),$3=q.lazy(()=>ae(()=>import("./ApiDocsView-LwSN2FTa.js"),__vite__mapDeps([121,64,41,122]))),F3=q.lazy(()=>ae(()=>import("./McpView-A6zV6cTb.js"),__vite__mapDeps([123,64,46,38,48,45,124]))),L3=q.lazy(()=>ae(()=>import("./SubmitView-BCL1MLcF.js"),__vite__mapDeps([125,1,33,2,69,73,21,22,68]))),j3=q.lazy(()=>ae(()=>import("./CronDashboard-BgGmgfB6.js"),__vite__mapDeps([126,1,127,128,76,2,50,75,88,91,39,87,48,129,71,130,79,32,3,8,30]))),D3=q.lazy(()=>ae(()=>import("./AutonomousOperations-BMzZOLm6.js"),__vite__mapDeps([131,1,127,128,76,2,69,91,47]))),z3=q.lazy(()=>ae(()=>import("./SubmissionsDashboard-CkzOBcpM.js"),__vite__mapDeps([132,67,68,1,32,8,23,74,21,22,129,71,130,133]))),U3=q.lazy(()=>ae(()=>import("./UserProfileView-kB3mGrtz.js"),__vite__mapDeps([134,113,25,8]))),V3=q.lazy(()=>ae(()=>import("./RateLimitsView-CrvlGHnU.js"),__vite__mapDeps([135,66]))),B3=q.lazy(()=>ae(()=>import("./AstraForRoboticsView-BMiTVC2T.js"),__vite__mapDeps([136,13,14,15,16,17,18,10,19,20,21,22,23,24,25,26,33,31,32,64,137]))),sh=q.lazy(()=>ae(()=>import("./NotFound-BeWhm9El.js"),[])),q3=q.lazy(()=>ae(()=>import("./SearchOverlay-Dvr0LreX.js"),__vite__mapDeps([138,20,8,21,22,57,18,10]))),W3=q.lazy(()=>ae(()=>import("./StagingAccessRequestView-D1t7icpG.js"),__vite__mapDeps([139,130]))),zk=()=>w.jsxs("div",{className:"page","aria-busy":"true","aria-live":"polite",children:[w.jsx("div",{className:"animate-pulse rounded-md bg-muted",style:{height:24,width:"30%",marginBottom:24}}),w.jsx("div",{className:"animate-pulse rounded-md bg-muted",style:{height:64,width:"60%",marginBottom:32}}),w.jsxs("div",{className:"paper-list",style:{display:"grid",gap:16},children:[w.jsx("div",{className:"animate-pulse rounded-md bg-muted",style:{height:96}}),w.jsx("div",{className:"animate-pulse rounded-md bg-muted",style:{height:96}}),w.jsx("div",{className:"animate-pulse rounded-md bg-muted",style:{height:96}})]})]}),H3=new XA({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}}),G3=()=>{const{arxivId:e}=xS();return w.jsx(Ro,{to:e?`/paper/${e}`:"/papers",replace:!0})},K3=()=>{const{taskSlug:e}=xS();return w.jsx(Ro,{to:e?`/tasks/${e}`:"/tasks",replace:!0})},Q3=({element:e})=>$o()?w.jsx(Ro,{to:"/",replace:!0}):w.jsx(w.Fragment,{children:e}),pv=({element:e})=>{const{user:t,isLoading:n}=pk(),r=hn();return $o()?w.jsx(Ro,{to:"/",replace:!0}):n?w.jsx("div",{className:"page",children:w.jsx("div",{className:"submission-loading",children:w.jsx("span",{children:"Checking admin session..."})})}):t?t.is_admin?w.jsx(w.Fragment,{children:e}):w.jsx("div",{className:"page",children:w.jsxs("div",{className:"submission-empty submission-empty-warn",children:[w.jsx("h1",{children:"Admin access required"}),w.jsxs("p",{children:["Signed in as @",t.username,". This dashboard is limited to allowlisted admin accounts."]})]})}):w.jsx("div",{className:"page",children:w.jsxs("div",{className:"submission-empty submission-empty-warn",children:[w.jsx("h1",{children:"Sign in required"}),w.jsx("p",{children:"Sign in with an allowlisted Hugging Face admin account to view admin operations."}),w.jsx(y1,{returnTo:`${r.pathname}${r.search}`})]})})},Y3=()=>{const e=eF(),t=typeof window<"u"&&new URL(e,window.location.origin).origin!==window.location.origin;return q.useEffect(()=>{t&&window.location.replace(e)},[e,t]),t?w.jsx("div",{className:"page",children:w.jsxs("div",{className:"submission-loading",children:[w.jsx("span",{children:"Opening the production admin dashboard..."}),w.jsx("a",{href:e,children:"Continue"})]})}):w.jsx(pv,{element:w.jsx(j3,{})})},Y0=({reader:e=!1})=>{const[t,n]=q.useState(!1),{pathname:r}=hn();q.useEffect(()=>{const a=l=>{(l.metaKey||l.ctrlKey)&&l.key==="k"&&(l.preventDefault(),n(!0))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]);const i=w.jsx(T2,{onOpenSearch:()=>n(!0)}),s=w.jsx(fS,{resetKey:r,children:w.jsx(q.Suspense,{fallback:w.jsx(zk,{}),children:w.jsx(cA,{})})}),o=t&&w.jsx(q.Suspense,{fallback:null,children:w.jsx(q3,{open:t,onClose:()=>n(!1)})});return e?w.jsxs("div",{className:"reader-route-shell",children:[i,w.jsx("div",{className:"reader-route-content",children:s}),o]}):w.jsxs(w.Fragment,{children:[i,w.jsx("main",{children:s}),w.jsx(I2,{}),o]})},X3=()=>(l3(),q.useLayoutEffect(()=>{var e;(e=document.getElementById("initial-discovery-footer"))==null||e.remove()},[]),w.jsxs(dA,{children:[w.jsx(re,{path:"/request-access",element:w.jsx(q.Suspense,{fallback:w.jsx(zk,{}),children:w.jsx(W3,{})})}),w.jsx(re,{element:w.jsx(Y0,{reader:!0}),children:w.jsx(re,{path:"/pdf/:paperId",element:rF()?w.jsx(g3,{}):w.jsx(sh,{})})}),w.jsxs(re,{element:w.jsx(Y0,{}),children:[w.jsx(re,{path:"/",element:w.jsx(Q0,{})}),w.jsx(re,{path:"/following",element:w.jsx(d3,{})}),w.jsx(re,{path:"/x-trending",element:w.jsx(Q0,{xTrending:!0})}),w.jsx(re,{path:"/chat/:sessionId?",element:al()?w.jsx(f3,{}):w.jsx(Ro,{to:"/",replace:!0})}),w.jsx(re,{path:"/share/:shareId",element:al()?w.jsx(h3,{}):w.jsx(sh,{})}),w.jsx(re,{path:"/papers",element:w.jsx(p3,{})}),w.jsx(re,{path:"/papers/:arxivId",element:w.jsx(G3,{})}),w.jsx(re,{path:"/paper/:arxivId",element:w.jsx(v3,{})}),w.jsx(re,{path:"/tasks",element:w.jsx(m3,{})}),w.jsx(re,{path:"/tasks/:taskSlug",element:w.jsx(y3,{})}),w.jsx(re,{path:"/task/:taskSlug",element:w.jsx(K3,{})}),w.jsx(re,{path:"/methods",element:w.jsx(_3,{})}),w.jsx(re,{path:"/methods/:methodSlug",element:w.jsx(I3,{})}),w.jsx(re,{path:"/frameworks",element:w.jsx(w3,{})}),w.jsx(re,{path:"/trends",element:w.jsx(x3,{})}),w.jsx(re,{path:"/conferences",element:w.jsx(b3,{})}),w.jsx(re,{path:"/ai-deadlines",element:w.jsx(E3,{})}),w.jsx(re,{path:"/conferences/:confSlug",element:w.jsx(S3,{})}),w.jsx(re,{path:"/conferences/:confSlug/:taskSlug",element:w.jsx(C3,{})}),w.jsx(re,{path:"/organizations",element:w.jsx(k3,{})}),w.jsx(re,{path:"/orgs/:orgSlug",element:w.jsx(P3,{})}),w.jsx(re,{path:"/orgs/:orgSlug/:taskSlug",element:w.jsx(R3,{})}),w.jsx(re,{path:"/authors/:authorId",element:w.jsx(T3,{})}),w.jsx(re,{path:"/benchmark/:datasetSlug",element:w.jsx(O3,{})}),w.jsx(re,{path:"/authorize-paper-edit/:authorizationId",element:w.jsx(c3,{})}),w.jsx(re,{path:"/submit",element:w.jsx(L3,{})}),w.jsx(re,{path:"/saved",element:w.jsx(Q3,{element:w.jsx(M3,{})})}),w.jsx(re,{path:"/settings",element:w.jsx(A3,{})}),w.jsx(re,{path:"/privacy",element:w.jsx(N3,{})}),w.jsx(re,{path:"/docs/api",element:w.jsx($3,{})}),w.jsx(re,{path:"/mcp",element:w.jsx(F3,{})}),w.jsx(re,{path:"/admin-dashboard",element:w.jsx(Y3,{})}),w.jsx(re,{path:"/autonomous-operations",element:w.jsx(pv,{element:w.jsx(D3,{})})}),w.jsx(re,{path:"/cron-dashboard",element:w.jsx(Ro,{to:"/admin-dashboard",replace:!0})}),w.jsx(re,{path:"/submissions",element:w.jsx(pv,{element:w.jsx(z3,{})})}),w.jsx(re,{path:"/rate-limits",element:w.jsx(V3,{})}),w.jsx(re,{path:"/astra-for-robotics",element:w.jsx(B3,{})}),w.jsx(re,{path:"/:username",element:w.jsx(U3,{})}),w.jsx(re,{path:"*",element:w.jsx(sh,{})})]})]})),J3=()=>w.jsx(JA,{client:H3,children:w.jsxs(C2,{children:[w.jsx(u3,{children:w.jsx(X3,{})}),w.jsx(a3,{}),!1]})});yM();const Z3=w.jsx(yT,{attribute:"class",defaultTheme:"system",enableSystem:!0,disableTransitionOnChange:!0,storageKey:"pwc-theme",children:w.jsx(fS,{children:w.jsx(J3,{})})}),ez=wb(document.getElementById("root"));ez.render(w.jsx(q.StrictMode,{children:Z3}));export{h2 as $,Od as A,yd as B,l2 as C,et as D,ee as E,xj as F,ss as G,y1 as H,ct as I,Pz as J,dz as K,bn as L,mz as M,V1 as N,Bj as O,br as P,fC as Q,Vj as R,c2 as S,bz as T,o3 as U,q as V,Ez as W,d2 as X,rF as Y,cz as Z,f2 as _,pk as a,oz as a$,dk as a0,er as a1,fz as a2,uz as a3,aw as a4,J$ as a5,u2 as a6,ae as a7,A1 as a8,xl as a9,pz as aA,kz as aB,D1 as aC,z1 as aD,U1 as aE,El as aF,at as aG,Up as aH,TS as aI,qA as aJ,ZA as aK,nN as aL,oN as aM,rN as aN,iN as aO,At as aP,lN as aQ,l0 as aR,sN as aS,il as aT,KA as aU,OS as aV,xz as aW,t1 as aX,Dg as aY,HS as aZ,jg as a_,$g as aa,b2 as ab,cv as ac,w1 as ad,r3 as ae,Qs as af,W$ as ag,G$ as ah,K$ as ai,Q$ as aj,vi as ak,X$ as al,Y$ as am,lz as an,Ro as ao,Rj as ap,Tj as aq,nC as ar,wd as as,_d as at,Ij as au,Oj as av,rz as aw,nz as ax,E2 as ay,wz as az,cN as b,sz as b0,uN as b1,qg as b2,z0 as b3,hn as c,g as d,Mg as e,Tz as f,iz as g,Z$ as h,zS as i,w as j,$o as k,al as l,nF as m,tF as n,Sz as o,S2 as p,hz as q,Rz as r,Id as s,Cz as t,xS as u,vz as v,gz as w,F2 as x,_z as y,ke as z}; diff --git a/assets/index-2CvJmBVB.js b/assets/index-Dj6aE-6E.js similarity index 99% rename from assets/index-2CvJmBVB.js rename to assets/index-Dj6aE-6E.js index 239b3ecf77ef679785bcd37cc12f4580e184c6fa..e8370e3d02b1a29974fbaf127c4539603b274d75 100644 --- a/assets/index-2CvJmBVB.js +++ b/assets/index-Dj6aE-6E.js @@ -1,4 +1,4 @@ -import{c as ce,v as _e,o as E,u as I,e as Z,g as O,i as W,j as Oe,t as fe,E as je,k as J,l as M,q as A,r as Be,w as qe,f as S,x as H,y as We,m as P,z as T,A as $e}from"./index-mCi_y_l3.js";function re(e,n){const t=String(e);if(typeof n!="string")throw new TypeError("Expected character");let i=0,o=t.indexOf(n);for(;o!==-1;)i++,o=t.indexOf(n,o+n.length);return i}function He(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Ue(e,n,t){const o=ce((t||{}).ignore||[]),a=Ve(n);let r=-1;for(;++r0?{type:"text",value:y}:void 0),y===!1?p.lastIndex=v+1:(m!==v&&w.push({type:"text",value:s.value.slice(m,v)}),Array.isArray(y)?w.push(...y):y&&w.push(y),m=v+d[0].length,k=!0),!p.global)break;d=p.exec(s.value)}return k?(m?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let t=n[0],i=t.indexOf(")");const o=re(e,"(");let a=re(e,")");for(;i!==-1&&o>a;)e+=t.slice(0,i+1),t=t.slice(i+1),i=t.indexOf(")"),a++;return[e,t]}function he(e,n){const t=e.input.charCodeAt(e.index-1);return(e.index===0||I(t)||Z(t))&&(!n||t!==47)}me.peek=pt;function ot(){this.buffer()}function at(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function ut(){this.buffer()}function st(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function ct(e){const n=this.resume(),t=this.stack[this.stack.length-1];E(t.type==="footnoteReference"),t.identifier=O(this.sliceSerialize(e)).toLowerCase(),t.label=n}function ft(e){this.exit(e)}function ht(e){const n=this.resume(),t=this.stack[this.stack.length-1];E(t.type==="footnoteDefinition"),t.identifier=O(this.sliceSerialize(e)).toLowerCase(),t.label=n}function mt(e){this.exit(e)}function pt(){return"["}function me(e,n,t,i){const o=t.createTracker(i);let a=o.move("[^");const r=t.enter("footnoteReference"),u=t.enter("reference");return a+=o.move(t.safe(t.associationId(e),{after:"]",before:a})),u(),r(),a+=o.move("]"),a}function gt(){return{enter:{gfmFootnoteCallString:ot,gfmFootnoteCall:at,gfmFootnoteDefinitionLabelString:ut,gfmFootnoteDefinition:st},exit:{gfmFootnoteCallString:ct,gfmFootnoteCall:ft,gfmFootnoteDefinitionLabelString:ht,gfmFootnoteDefinition:mt}}}function kt(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:t,footnoteReference:me},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function t(i,o,a,r){const u=a.createTracker(r);let l=u.move("[^");const s=a.enter("footnoteDefinition"),h=a.enter("label");return l+=u.move(a.safe(a.associationId(i),{before:l,after:"]"})),h(),l+=u.move("]:"),i.children&&i.children.length>0&&(u.shift(4),l+=u.move((n?` +import{c as ce,v as _e,o as E,u as I,e as Z,g as O,i as W,j as Oe,t as fe,E as je,k as J,l as M,q as A,r as Be,w as qe,f as S,x as H,y as We,m as P,z as T,A as $e}from"./index-tLcwYp0U.js";function re(e,n){const t=String(e);if(typeof n!="string")throw new TypeError("Expected character");let i=0,o=t.indexOf(n);for(;o!==-1;)i++,o=t.indexOf(n,o+n.length);return i}function He(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Ue(e,n,t){const o=ce((t||{}).ignore||[]),a=Ve(n);let r=-1;for(;++r0?{type:"text",value:y}:void 0),y===!1?p.lastIndex=v+1:(m!==v&&w.push({type:"text",value:s.value.slice(m,v)}),Array.isArray(y)?w.push(...y):y&&w.push(y),m=v+d[0].length,k=!0),!p.global)break;d=p.exec(s.value)}return k?(m?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let t=n[0],i=t.indexOf(")");const o=re(e,"(");let a=re(e,")");for(;i!==-1&&o>a;)e+=t.slice(0,i+1),t=t.slice(i+1),i=t.indexOf(")"),a++;return[e,t]}function he(e,n){const t=e.input.charCodeAt(e.index-1);return(e.index===0||I(t)||Z(t))&&(!n||t!==47)}me.peek=pt;function ot(){this.buffer()}function at(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function ut(){this.buffer()}function st(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function ct(e){const n=this.resume(),t=this.stack[this.stack.length-1];E(t.type==="footnoteReference"),t.identifier=O(this.sliceSerialize(e)).toLowerCase(),t.label=n}function ft(e){this.exit(e)}function ht(e){const n=this.resume(),t=this.stack[this.stack.length-1];E(t.type==="footnoteDefinition"),t.identifier=O(this.sliceSerialize(e)).toLowerCase(),t.label=n}function mt(e){this.exit(e)}function pt(){return"["}function me(e,n,t,i){const o=t.createTracker(i);let a=o.move("[^");const r=t.enter("footnoteReference"),u=t.enter("reference");return a+=o.move(t.safe(t.associationId(e),{after:"]",before:a})),u(),r(),a+=o.move("]"),a}function gt(){return{enter:{gfmFootnoteCallString:ot,gfmFootnoteCall:at,gfmFootnoteDefinitionLabelString:ut,gfmFootnoteDefinition:st},exit:{gfmFootnoteCallString:ct,gfmFootnoteCall:ft,gfmFootnoteDefinitionLabelString:ht,gfmFootnoteDefinition:mt}}}function kt(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:t,footnoteReference:me},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function t(i,o,a,r){const u=a.createTracker(r);let l=u.move("[^");const s=a.enter("footnoteDefinition"),h=a.enter("label");return l+=u.move(a.safe(a.associationId(i),{before:l,after:"]"})),h(),l+=u.move("]:"),i.children&&i.children.length>0&&(u.shift(4),l+=u.move((n?` `:" ")+a.indentLines(a.containerFlow(i,u.current()),n?pe:bt))),s(),l}}function bt(e,n,t){return n===0?e:pe(e,n,t)}function pe(e,n,t){return(t?"":" ")+e}const xt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ge.peek=vt;function wt(){return{canContainEols:["delete"],enter:{strikethrough:yt},exit:{strikethrough:Ct}}}function dt(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:xt}],handlers:{delete:ge}}}function yt(e){this.enter({type:"delete",children:[]},e)}function Ct(e){this.exit(e)}function ge(e,n,t,i){const o=t.createTracker(i),a=t.enter("strikethrough");let r=o.move("~~");return r+=t.containerPhrasing(e,{...o.current(),before:r,after:"~"}),r+=o.move("~~"),a(),r}function vt(){return"~"}function At(e){return e.length}function Dt(e,n){const t=n||{},i=(t.align||[]).concat(),o=t.stringLength||At,a=[],r=[],u=[],l=[];let s=0,h=-1;for(;++hs&&(s=e[h].length);++kl[k])&&(l[k]=d)}b.push(w)}r[h]=b,u[h]=x}let c=-1;if(typeof i=="object"&&"length"in i)for(;++cl[c]&&(l[c]=w),g[c]=w),p[c]=d}r.splice(1,0,p),u.splice(1,0,g),h=-1;const m=[];for(;++h "),a.shift(2);const r=t.indentLines(t.containerFlow(e,a.current()),Lt);return o(),r}function Lt(e,n,t){return">"+(t?"":" ")+e}function Tt(e,n){return le(e,n.inConstruct,!0)&&!le(e,n.notInConstruct,!1)}function le(e,n,t){if(typeof n=="string"&&(n=[n]),!n||n.length===0)return t;let i=-1;for(;++i4&&t.slice(0,4)==="data"&&Fr.test(n)){if(n.charAt(4)==="-"){const l=n.slice(5).replace(Wn,Br);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=n.slice(4);if(!Wn.test(l)){let o=l.replace(Nr,Mr);o.charAt(0)!=="-"&&(o="-"+o),n="data"+o}}i=En}return new i(r,n)}function Mr(e){return"-"+e.toLowerCase()}function Br(e){return e.charAt(1).toUpperCase()}const jr=_t([Nt,Dr,Mt,Bt,jt],"html"),Cn=_t([Nt,Or,Mt,Bt,jt],"svg");function du(e){const n=String(e||"").trim();return n?n.split(/[ \t\n\r\f]+/g):[]}function Hr(e){return e.join(" ").trim()}var In={},Yn=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Ur=/\n/g,Vr=/^\s*/,qr=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,$r=/^:\s*/,Wr=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Yr=/^[;\s]*/,Xr=/^\s+|\s+$/g,Qr=` +import{ax as We,a4 as Ot,j as Ze}from"./index-CjdUkE4w.js";function hu(){}function mu(e){const n=[],t=String(e||"");let r=t.indexOf(","),i=0,l=!1;for(;!l;){r===-1&&(r=t.length,l=!0);const o=t.slice(i,r).trim();(o||!l)&&n.push(o),i=r+1,r=t.indexOf(",",i)}return n}function Ir(e,n){const t={};return(e[e.length-1]===""?[...e,""]:e).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}const Tr=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ar=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Pr={};function Vn(e,n){return(Pr.jsx?Ar:Tr).test(e)}const zr=/[ \t\n\f\r]/g;function Lr(e){return typeof e=="object"?e.type==="text"?qn(e.value):!1:qn(e)}function qn(e){return e.replace(zr,"")===""}class Me{constructor(n,t,r){this.normal=t,this.property=n,r&&(this.space=r)}}Me.prototype.normal={};Me.prototype.property={};Me.prototype.space=void 0;function _t(e,n){const t={},r={};for(const i of e)Object.assign(t,i.property),Object.assign(r,i.normal);return new Me(t,r,n)}function fn(e){return e.toLowerCase()}class J{constructor(n,t){this.attribute=t,this.property=n}}J.prototype.attribute="";J.prototype.booleanish=!1;J.prototype.boolean=!1;J.prototype.commaOrSpaceSeparated=!1;J.prototype.commaSeparated=!1;J.prototype.defined=!1;J.prototype.mustUseProperty=!1;J.prototype.number=!1;J.prototype.overloadedBoolean=!1;J.prototype.property="";J.prototype.spaceSeparated=!1;J.prototype.space=void 0;let vr=0;const z=be(),$=be(),hn=be(),k=be(),R=be(),Ie=be(),ee=be();function be(){return 2**++vr}const mn=Object.freeze(Object.defineProperty({__proto__:null,boolean:z,booleanish:$,commaOrSpaceSeparated:ee,commaSeparated:Ie,number:k,overloadedBoolean:hn,spaceSeparated:R},Symbol.toStringTag,{value:"Module"})),en=Object.keys(mn);class En extends J{constructor(n,t,r,i){let l=-1;if(super(n,t),$n(this,"space",i),typeof r=="number")for(;++l4&&t.slice(0,4)==="data"&&Fr.test(n)){if(n.charAt(4)==="-"){const l=n.slice(5).replace(Wn,Br);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=n.slice(4);if(!Wn.test(l)){let o=l.replace(Nr,Mr);o.charAt(0)!=="-"&&(o="-"+o),n="data"+o}}i=En}return new i(r,n)}function Mr(e){return"-"+e.toLowerCase()}function Br(e){return e.charAt(1).toUpperCase()}const jr=_t([Nt,Dr,Mt,Bt,jt],"html"),Cn=_t([Nt,Or,Mt,Bt,jt],"svg");function du(e){const n=String(e||"").trim();return n?n.split(/[ \t\n\r\f]+/g):[]}function Hr(e){return e.join(" ").trim()}var In={},Yn=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Ur=/\n/g,Vr=/^\s*/,qr=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,$r=/^:\s*/,Wr=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Yr=/^[;\s]*/,Xr=/^\s+|\s+$/g,Qr=` `,Xn="/",Qn="*",ke="",Gr="comment",Kr="declaration";function Jr(e,n){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];n=n||{};var t=1,r=1;function i(y){var b=y.match(Ur);b&&(t+=b.length);var T=y.lastIndexOf(Qr);r=~T?y.length-T:r+y.length}function l(){var y={line:t,column:r};return function(b){return b.position=new o(y),c(),b}}function o(y){this.start=y,this.end={line:t,column:r},this.source=n.source}o.prototype.content=e;function a(y){var b=new Error(n.source+":"+t+":"+r+": "+y);if(b.reason=y,b.filename=n.source,b.line=t,b.column=r,b.source=e,!n.silent)throw b}function u(y){var b=y.exec(e);if(b){var T=b[0];return i(T),e=e.slice(T.length),b}}function c(){u(Vr)}function s(y){var b;for(y=y||[];b=f();)b!==!1&&y.push(b);return y}function f(){var y=l();if(!(Xn!=e.charAt(0)||Qn!=e.charAt(1))){for(var b=2;ke!=e.charAt(b)&&(Qn!=e.charAt(b)||Xn!=e.charAt(b+1));)++b;if(b+=2,ke===e.charAt(b-1))return a("End of comment missing");var T=e.slice(2,b-2);return r+=2,i(T),e=e.slice(b),r+=2,y({type:Gr,comment:T})}}function d(){var y=l(),b=u(qr);if(b){if(f(),!u($r))return a("property missing ':'");var T=u(Wr),w=y({type:Kr,property:Gn(b[0].replace(Yn,ke)),value:T?Gn(T[0].replace(Yn,ke)):ke});return u(Yr),w}}function p(){var y=[];s(y);for(var b;b=d();)b!==!1&&(y.push(b),s(y));return y}return c(),p()}function Gn(e){return e?e.replace(Xr,ke):ke}var Zr=Jr,ei=We&&We.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(In,"__esModule",{value:!0});In.default=ti;const ni=ei(Zr);function ti(e,n){let t=null;if(!e||typeof e!="string")return t;const r=(0,ni.default)(e),i=typeof n=="function";return r.forEach(l=>{if(l.type!=="declaration")return;const{property:o,value:a}=l;i?n(o,a,l):a&&(t=t||{},t[o]=a)}),t}var Qe={};Object.defineProperty(Qe,"__esModule",{value:!0});Qe.camelCase=void 0;var ri=/^--[a-zA-Z0-9_-]+$/,ii=/-([a-z])/g,li=/^[^-]+$/,oi=/^-(webkit|moz|ms|o|khtml)-/,ai=/^-(ms)-/,ui=function(e){return!e||li.test(e)||ri.test(e)},si=function(e,n){return n.toUpperCase()},Kn=function(e,n){return"".concat(n,"-")},ci=function(e,n){return n===void 0&&(n={}),ui(e)?e:(e=e.toLowerCase(),n.reactCompat?e=e.replace(ai,Kn):e=e.replace(oi,Kn),e.replace(ii,si))};Qe.camelCase=ci;var pi=We&&We.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},fi=pi(In),hi=Qe;function dn(e,n){var t={};return!e||typeof e!="string"||(0,fi.default)(e,function(r,i){r&&i&&(t[(0,hi.camelCase)(r,n)]=i)}),t}dn.default=dn;var mi=dn;const di=Ot(mi),Ht=Ut("end"),Tn=Ut("start");function Ut(e){return n;function n(t){const r=t&&t.position&&t.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function gi(e){const n=Tn(e),t=Ht(e);if(n&&t)return{start:n,end:t}}function _e(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Jn(e.position):"start"in e||"end"in e?Jn(e):"line"in e||"column"in e?gn(e):""}function gn(e){return Zn(e&&e.line)+":"+Zn(e&&e.column)}function Jn(e){return gn(e&&e.start)+"-"+gn(e&&e.end)}function Zn(e){return e&&typeof e=="number"?e:1}class Q extends Error{constructor(n,t,r){super(),typeof t=="string"&&(r=t,t=void 0);let i="",l={},o=!1;if(t&&("line"in t&&"column"in t?l={place:t}:"start"in t&&"end"in t?l={place:t}:"type"in t?l={ancestors:[t],place:t.position}:l={...t}),typeof n=="string"?i=n:!l.cause&&n&&(o=!0,i=n.message,l.cause=n),!l.ruleId&&!l.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?l.ruleId=r:(l.source=r.slice(0,u),l.ruleId=r.slice(u+1))}if(!l.place&&l.ancestors&&l.ancestors){const u=l.ancestors[l.ancestors.length-1];u&&(l.place=u.position)}const a=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=_e(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=o&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Q.prototype.file="";Q.prototype.name="";Q.prototype.reason="";Q.prototype.message="";Q.prototype.stack="";Q.prototype.column=void 0;Q.prototype.line=void 0;Q.prototype.ancestors=void 0;Q.prototype.cause=void 0;Q.prototype.fatal=void 0;Q.prototype.place=void 0;Q.prototype.ruleId=void 0;Q.prototype.source=void 0;const An={}.hasOwnProperty,yi=new Map,xi=/[A-Z]/g,ki=new Set(["table","tbody","thead","tfoot","tr"]),bi=new Set(["td","th"]),Vt="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function wi(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const t=n.filePath||void 0;let r;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=zi(t,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Pi(t,n.jsx,n.jsxs)}const i={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:r,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:t,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?Cn:jr,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},l=qt(i,e,void 0);return l&&typeof l!="string"?l:i.create(e,i.Fragment,{children:l||void 0},void 0)}function qt(e,n,t){if(n.type==="element")return Si(e,n,t);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return Ei(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return Ii(e,n,t);if(n.type==="mdxjsEsm")return Ci(e,n);if(n.type==="root")return Ti(e,n,t);if(n.type==="text")return Ai(e,n)}function Si(e,n,t){const r=e.schema;let i=r;n.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Cn,e.schema=i),e.ancestors.push(n);const l=Wt(e,n.tagName,!1),o=Li(e,n);let a=zn(e,n);return ki.has(n.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!Lr(u):!0})),$t(e,o,l,n),Pn(o,a),e.ancestors.pop(),e.schema=r,e.create(n,l,o,t)}function Ei(e,n){if(n.data&&n.data.estree&&e.evaluater){const r=n.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Re(e,n.position)}function Ci(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Re(e,n.position)}function Ii(e,n,t){const r=e.schema;let i=r;n.name==="svg"&&r.space==="html"&&(i=Cn,e.schema=i),e.ancestors.push(n);const l=n.name===null?e.Fragment:Wt(e,n.name,!0),o=vi(e,n),a=zn(e,n);return $t(e,o,l,n),Pn(o,a),e.ancestors.pop(),e.schema=r,e.create(n,l,o,t)}function Ti(e,n,t){const r={};return Pn(r,zn(e,n)),e.create(n,e.Fragment,r,t)}function Ai(e,n){return n.value}function $t(e,n,t,r){typeof t!="string"&&t!==e.Fragment&&e.passNode&&(n.node=r)}function Pn(e,n){if(n.length>0){const t=n.length>1?n:n[0];t&&(e.children=t)}}function Pi(e,n,t){return r;function r(i,l,o,a){const c=Array.isArray(o.children)?t:n;return a?c(l,o,a):c(l,o)}}function zi(e,n){return t;function t(r,i,l,o){const a=Array.isArray(l.children),u=Tn(r);return n(i,l,o,a,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function Li(e,n){const t={};let r,i;for(i in n.properties)if(i!=="children"&&An.call(n.properties,i)){const l=Di(e,i,n.properties[i]);if(l){const[o,a]=l;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&bi.has(n.tagName)?r=a:t[o]=a}}if(r){const l=t.style||(t.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return t}function vi(e,n){const t={};for(const r of n.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const l=r.data.estree.body[0];l.type;const o=l.expression;o.type;const a=o.properties[0];a.type,Object.assign(t,e.evaluater.evaluateExpression(a.argument))}else Re(e,n.position);else{const i=r.name;let l;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,l=e.evaluater.evaluateExpression(a.expression)}else Re(e,n.position);else l=r.value===null?!0:r.value;t[i]=l}return t}function zn(e,n){const t=[];let r=-1;const i=e.passKeys?new Map:yi;for(;++ri?0:i+n:n=n>i?i:n,t=t>0?t:0,r.length<1e4)o=Array.from(r),o.unshift(n,t),e.splice(...o);else for(t&&e.splice(n,t);l0?(se(e,e.length,0,n),e):n}const tt={}.hasOwnProperty;function ji(e){const n={};let t=-1;for(;++t13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"�":String.fromCodePoint(t)}function Te(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ue=ge(/[A-Za-z]/),ne=ge(/[\dA-Za-z]/),Vi=ge(/[#-'*+\--9=?A-Z^-~]/);function yn(e){return e!==null&&(e<32||e===127)}const xn=ge(/\d/),qi=ge(/[\dA-Fa-f]/),$i=ge(/[!-/:-@[-`{-~]/);function A(e){return e!==null&&e<-2}function K(e){return e!==null&&(e<0||e===32)}function O(e){return e===-2||e===-1||e===32}const Wi=ge(new RegExp("\\p{P}|\\p{S}","u")),Yi=ge(/\s/);function ge(e){return n;function n(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Pe(e){const n=[];let t=-1,r=0,i=0;for(;++t55295&&l<57344){const a=e.charCodeAt(t+1);l<56320&&a>56319&&a<57344?(o=String.fromCharCode(l,a),i=1):o="�"}else o=String.fromCharCode(l);o&&(n.push(e.slice(r,t),encodeURIComponent(o)),r=t+i+1,o=""),i&&(t+=i,i=0)}return n.join("")+e.slice(r)}function M(e,n,t,r){const i=r?r-1:Number.POSITIVE_INFINITY;let l=0;return o;function o(u){return O(u)?(e.enter(t),a(u)):n(u)}function a(u){return O(u)&&l++o))return;const _=n.events.length;let V=_,N,B;for(;V--;)if(n.events[V][0]==="exit"&&n.events[V][1].type==="chunkFlow"){if(N){B=n.events[V][1].end;break}N=!0}for(w(r),x=_;xE;){const U=t[j];n.containerState=U[1],U[0].exit.call(n,e)}t.length=E}function L(){i.write([null]),l=void 0,i=void 0,n.containerState._closeFlow=void 0}}function Ji(e,n,t){return M(e,e.attempt(this.parser.constructs.document,n,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function it(e){if(e===null||K(e)||Yi(e))return 1;if(Wi(e))return 2}function vn(e,n,t){const r=[];let i=-1;for(;++i1&&e[t][1].end.offset-e[t][1].start.offset>1?2:1;const f={...e[r][1].end},d={...e[t][1].start};lt(f,-u),lt(d,u),o={type:u>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},a={type:u>1?"strongSequence":"emphasisSequence",start:{...e[t][1].start},end:d},l={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[t][1].start}},i={type:u>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[t][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=te(c,[["enter",e[r][1],n],["exit",e[r][1],n]])),c=te(c,[["enter",i,n],["enter",o,n],["exit",o,n],["enter",l,n]]),c=te(c,vn(n.parser.constructs.insideSpan.null,e.slice(r+1,t),n)),c=te(c,[["exit",l,n],["enter",a,n],["exit",a,n],["exit",i,n]]),e[t][1].end.offset-e[t][1].start.offset?(s=2,c=te(c,[["enter",e[t][1],n],["exit",e[t][1],n]])):s=0,se(e,r-1,t-r+3,c),t=r+c.length-s-2;break}}for(t=-1;++t0&&O(x)?M(e,L,"linePrefix",l+1)(x):L(x)}function L(x){return x===null||A(x)?e.check(ot,b,j)(x):(e.enter("codeFlowValue"),E(x))}function E(x){return x===null||A(x)?(e.exit("codeFlowValue"),L(x)):(e.consume(x),E)}function j(x){return e.exit("codeFenced"),n(x)}function U(x,_,V){let N=0;return B;function B(D){return x.enter("lineEnding"),x.consume(D),x.exit("lineEnding"),I}function I(D){return x.enter("codeFencedFence"),O(D)?M(x,C,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):C(D)}function C(D){return D===a?(x.enter("codeFencedFenceSequence"),H(D)):V(D)}function H(D){return D===a?(N++,x.consume(D),H):N>=o?(x.exit("codeFencedFenceSequence"),O(D)?M(x,q,"whitespace")(D):q(D)):V(D)}function q(D){return D===null||A(D)?(x.exit("codeFencedFence"),_(D)):V(D)}}}function cl(e,n,t){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),l)}function l(o){return r.parser.lazy[r.now().line]?t(o):n(o)}}const tn={name:"codeIndented",tokenize:fl},pl={partial:!0,tokenize:hl};function fl(e,n,t){const r=this;return i;function i(c){return e.enter("codeIndented"),M(e,l,"linePrefix",5)(c)}function l(c){const s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?o(c):t(c)}function o(c){return c===null?u(c):A(c)?e.attempt(pl,o,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||A(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),n(c)}}function hl(e,n,t){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?t(o):A(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):M(e,l,"linePrefix",5)(o)}function l(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?n(o):A(o)?i(o):t(o)}}const ml={name:"codeText",previous:gl,resolve:dl,tokenize:yl};function dl(e){let n=e.length-4,t=3,r,i;if((e[t][1].type==="lineEnding"||e[t][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(r=t;++r=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return nthis.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(n,t,r){const i=t||0;this.setCursor(Math.trunc(n));const l=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&De(this.left,r),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),De(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),De(this.right,n.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n=4?n(o):e.interrupt(r.parser.constructs.flow,t,n)(o)}}function Zt(e,n,t,r,i,l,o,a,u){const c=u||Number.POSITIVE_INFINITY;let s=0;return f;function f(w){return w===60?(e.enter(r),e.enter(i),e.enter(l),e.consume(w),e.exit(l),d):w===null||w===32||w===41||yn(w)?t(w):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),b(w))}function d(w){return w===62?(e.enter(l),e.consume(w),e.exit(l),e.exit(i),e.exit(r),n):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(w))}function p(w){return w===62?(e.exit("chunkString"),e.exit(a),d(w)):w===null||w===60||A(w)?t(w):(e.consume(w),w===92?y:p)}function y(w){return w===60||w===62||w===92?(e.consume(w),p):p(w)}function b(w){return!s&&(w===null||w===41||K(w))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),n(w)):s999||p===null||p===91||p===93&&!u||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?t(p):p===93?(e.exit(l),e.enter(i),e.consume(p),e.exit(i),e.exit(r),n):A(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),s):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===null||p===91||p===93||A(p)||a++>999?(e.exit("chunkString"),s(p)):(e.consume(p),u||(u=!O(p)),p===92?d:f)}function d(p){return p===91||p===92||p===93?(e.consume(p),a++,f):f(p)}}function nr(e,n,t,r,i,l){let o;return a;function a(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),o=d===40?41:d,u):t(d)}function u(d){return d===o?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),n):(e.enter(l),c(d))}function c(d){return d===o?(e.exit(l),u(o)):d===null?t(d):A(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),M(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),s(d))}function s(d){return d===o||d===null||A(d)?(e.exit("chunkString"),c(d)):(e.consume(d),d===92?f:s)}function f(d){return d===o||d===92?(e.consume(d),s):s(d)}}function Ne(e,n){let t;return r;function r(i){return A(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t=!0,r):O(i)?M(e,r,t?"linePrefix":"lineSuffix")(i):n(i)}}const Il={name:"definition",tokenize:Al},Tl={partial:!0,tokenize:Pl};function Al(e,n,t){const r=this;let i;return l;function l(p){return e.enter("definition"),o(p)}function o(p){return er.call(r,e,a,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Te(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),u):t(p)}function u(p){return K(p)?Ne(e,c)(p):c(p)}function c(p){return Zt(e,s,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function s(p){return e.attempt(Tl,f,f)(p)}function f(p){return O(p)?M(e,d,"whitespace")(p):d(p)}function d(p){return p===null||A(p)?(e.exit("definition"),r.parser.defined.push(i),n(p)):t(p)}}function Pl(e,n,t){return r;function r(a){return K(a)?Ne(e,i)(a):t(a)}function i(a){return nr(e,l,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function l(a){return O(a)?M(e,o,"whitespace")(a):o(a)}function o(a){return a===null||A(a)?n(a):t(a)}}const zl={name:"hardBreakEscape",tokenize:Ll};function Ll(e,n,t){return r;function r(l){return e.enter("hardBreakEscape"),e.consume(l),i}function i(l){return A(l)?(e.exit("hardBreakEscape"),n(l)):t(l)}}const vl={name:"headingAtx",resolve:Dl,tokenize:Ol};function Dl(e,n){let t=e.length-2,r=3,i,l;return e[r][1].type==="whitespace"&&(r+=2),t-2>r&&e[t][1].type==="whitespace"&&(t-=2),e[t][1].type==="atxHeadingSequence"&&(r===t-1||t-4>r&&e[t-2][1].type==="whitespace")&&(t-=r+1===t?2:4),t>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[t][1].end},l={type:"chunkText",start:e[r][1].start,end:e[t][1].end,contentType:"text"},se(e,r,t-r+1,[["enter",i,n],["enter",l,n],["exit",l,n],["exit",i,n]])),e}function Ol(e,n,t){let r=0;return i;function i(s){return e.enter("atxHeading"),l(s)}function l(s){return e.enter("atxHeadingSequence"),o(s)}function o(s){return s===35&&r++<6?(e.consume(s),o):s===null||K(s)?(e.exit("atxHeadingSequence"),a(s)):t(s)}function a(s){return s===35?(e.enter("atxHeadingSequence"),u(s)):s===null||A(s)?(e.exit("atxHeading"),n(s)):O(s)?M(e,a,"whitespace")(s):(e.enter("atxHeadingText"),c(s))}function u(s){return s===35?(e.consume(s),u):(e.exit("atxHeadingSequence"),a(s))}function c(s){return s===null||s===35||K(s)?(e.exit("atxHeadingText"),a(s)):(e.consume(s),c)}}const _l=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ut=["pre","script","style","textarea"],Nl={concrete:!0,name:"htmlFlow",resolveTo:Ml,tokenize:Bl},Fl={partial:!0,tokenize:Hl},Rl={partial:!0,tokenize:jl};function Ml(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function Bl(e,n,t){const r=this;let i,l,o,a,u;return c;function c(m){return s(m)}function s(m){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(m),f}function f(m){return m===33?(e.consume(m),d):m===47?(e.consume(m),l=!0,b):m===63?(e.consume(m),i=3,r.interrupt?n:h):ue(m)?(e.consume(m),o=String.fromCharCode(m),T):t(m)}function d(m){return m===45?(e.consume(m),i=2,p):m===91?(e.consume(m),i=5,a=0,y):ue(m)?(e.consume(m),i=4,r.interrupt?n:h):t(m)}function p(m){return m===45?(e.consume(m),r.interrupt?n:h):t(m)}function y(m){const le="CDATA[";return m===le.charCodeAt(a++)?(e.consume(m),a===le.length?r.interrupt?n:C:y):t(m)}function b(m){return ue(m)?(e.consume(m),o=String.fromCharCode(m),T):t(m)}function T(m){if(m===null||m===47||m===62||K(m)){const le=m===47,ye=o.toLowerCase();return!le&&!l&&ut.includes(ye)?(i=1,r.interrupt?n(m):C(m)):_l.includes(o.toLowerCase())?(i=6,le?(e.consume(m),w):r.interrupt?n(m):C(m)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(m):l?L(m):E(m))}return m===45||ne(m)?(e.consume(m),o+=String.fromCharCode(m),T):t(m)}function w(m){return m===62?(e.consume(m),r.interrupt?n:C):t(m)}function L(m){return O(m)?(e.consume(m),L):B(m)}function E(m){return m===47?(e.consume(m),B):m===58||m===95||ue(m)?(e.consume(m),j):O(m)?(e.consume(m),E):B(m)}function j(m){return m===45||m===46||m===58||m===95||ne(m)?(e.consume(m),j):U(m)}function U(m){return m===61?(e.consume(m),x):O(m)?(e.consume(m),U):E(m)}function x(m){return m===null||m===60||m===61||m===62||m===96?t(m):m===34||m===39?(e.consume(m),u=m,_):O(m)?(e.consume(m),x):V(m)}function _(m){return m===u?(e.consume(m),u=null,N):m===null||A(m)?t(m):(e.consume(m),_)}function V(m){return m===null||m===34||m===39||m===47||m===60||m===61||m===62||m===96||K(m)?U(m):(e.consume(m),V)}function N(m){return m===47||m===62||O(m)?E(m):t(m)}function B(m){return m===62?(e.consume(m),I):t(m)}function I(m){return m===null||A(m)?C(m):O(m)?(e.consume(m),I):t(m)}function C(m){return m===45&&i===2?(e.consume(m),X):m===60&&i===1?(e.consume(m),W):m===62&&i===4?(e.consume(m),ie):m===63&&i===3?(e.consume(m),h):m===93&&i===5?(e.consume(m),ce):A(m)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Fl,pe,H)(m)):m===null||A(m)?(e.exit("htmlFlowData"),H(m)):(e.consume(m),C)}function H(m){return e.check(Rl,q,pe)(m)}function q(m){return e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),D}function D(m){return m===null||A(m)?H(m):(e.enter("htmlFlowData"),C(m))}function X(m){return m===45?(e.consume(m),h):C(m)}function W(m){return m===47?(e.consume(m),o="",re):C(m)}function re(m){if(m===62){const le=o.toLowerCase();return ut.includes(le)?(e.consume(m),ie):C(m)}return ue(m)&&o.length<8?(e.consume(m),o+=String.fromCharCode(m),re):C(m)}function ce(m){return m===93?(e.consume(m),h):C(m)}function h(m){return m===62?(e.consume(m),ie):m===45&&i===2?(e.consume(m),h):C(m)}function ie(m){return m===null||A(m)?(e.exit("htmlFlowData"),pe(m)):(e.consume(m),ie)}function pe(m){return e.exit("htmlFlow"),n(m)}}function jl(e,n,t){const r=this;return i;function i(o){return A(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),l):t(o)}function l(o){return r.parser.lazy[r.now().line]?t(o):n(o)}}function Hl(e,n,t){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Ge,n,t)}}const Ul={name:"htmlText",tokenize:Vl};function Vl(e,n,t){const r=this;let i,l,o;return a;function a(h){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(h),u}function u(h){return h===33?(e.consume(h),c):h===47?(e.consume(h),U):h===63?(e.consume(h),E):ue(h)?(e.consume(h),V):t(h)}function c(h){return h===45?(e.consume(h),s):h===91?(e.consume(h),l=0,y):ue(h)?(e.consume(h),L):t(h)}function s(h){return h===45?(e.consume(h),p):t(h)}function f(h){return h===null?t(h):h===45?(e.consume(h),d):A(h)?(o=f,W(h)):(e.consume(h),f)}function d(h){return h===45?(e.consume(h),p):f(h)}function p(h){return h===62?X(h):h===45?d(h):f(h)}function y(h){const ie="CDATA[";return h===ie.charCodeAt(l++)?(e.consume(h),l===ie.length?b:y):t(h)}function b(h){return h===null?t(h):h===93?(e.consume(h),T):A(h)?(o=b,W(h)):(e.consume(h),b)}function T(h){return h===93?(e.consume(h),w):b(h)}function w(h){return h===62?X(h):h===93?(e.consume(h),w):b(h)}function L(h){return h===null||h===62?X(h):A(h)?(o=L,W(h)):(e.consume(h),L)}function E(h){return h===null?t(h):h===63?(e.consume(h),j):A(h)?(o=E,W(h)):(e.consume(h),E)}function j(h){return h===62?X(h):E(h)}function U(h){return ue(h)?(e.consume(h),x):t(h)}function x(h){return h===45||ne(h)?(e.consume(h),x):_(h)}function _(h){return A(h)?(o=_,W(h)):O(h)?(e.consume(h),_):X(h)}function V(h){return h===45||ne(h)?(e.consume(h),V):h===47||h===62||K(h)?N(h):t(h)}function N(h){return h===47?(e.consume(h),X):h===58||h===95||ue(h)?(e.consume(h),B):A(h)?(o=N,W(h)):O(h)?(e.consume(h),N):X(h)}function B(h){return h===45||h===46||h===58||h===95||ne(h)?(e.consume(h),B):I(h)}function I(h){return h===61?(e.consume(h),C):A(h)?(o=I,W(h)):O(h)?(e.consume(h),I):N(h)}function C(h){return h===null||h===60||h===61||h===62||h===96?t(h):h===34||h===39?(e.consume(h),i=h,H):A(h)?(o=C,W(h)):O(h)?(e.consume(h),C):(e.consume(h),q)}function H(h){return h===i?(e.consume(h),i=void 0,D):h===null?t(h):A(h)?(o=H,W(h)):(e.consume(h),H)}function q(h){return h===null||h===34||h===39||h===60||h===61||h===96?t(h):h===47||h===62||K(h)?N(h):(e.consume(h),q)}function D(h){return h===47||h===62||K(h)?N(h):t(h)}function X(h){return h===62?(e.consume(h),e.exit("htmlTextData"),e.exit("htmlText"),n):t(h)}function W(h){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),re}function re(h){return O(h)?M(e,ce,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h):ce(h)}function ce(h){return e.enter("htmlTextData"),o(h)}}const Dn={name:"labelEnd",resolveAll:Yl,resolveTo:Xl,tokenize:Ql},ql={tokenize:Gl},$l={tokenize:Kl},Wl={tokenize:Jl};function Yl(e){let n=-1;const t=[];for(;++n=3&&(c===null||A(c))?(e.exit("thematicBreak"),n(c)):t(c)}function u(c){return c===i?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),O(c)?M(e,a,"whitespace")(c):a(c))}}const G={continuation:{tokenize:uo},exit:co,name:"list",tokenize:ao},lo={partial:!0,tokenize:po},oo={partial:!0,tokenize:so};function ao(e,n,t){const r=this,i=r.events[r.events.length-1];let l=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const y=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:xn(p)){if(r.containerState.type||(r.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(qe,t,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(p)}return t(p)}function u(p){return xn(p)&&++o<10?(e.consume(p),u):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):t(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Ge,r.interrupt?t:s,e.attempt(lo,d,f))}function s(p){return r.containerState.initialBlankLine=!0,l++,d(p)}function f(p){return O(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),d):t(p)}function d(p){return r.containerState.size=l+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(p)}}function uo(e,n,t){const r=this;return r.containerState._closeFlow=void 0,e.check(Ge,i,l);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,M(e,n,"listItemIndent",r.containerState.size+1)(a)}function l(a){return r.containerState.furtherBlankLines||!O(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(oo,n,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,M(e,e.attempt(G,n,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function so(e,n,t){const r=this;return M(e,i,"listItemIndent",r.containerState.size+1);function i(l){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?n(l):t(l)}}function co(e){e.exit(this.containerState.type)}function po(e,n,t){const r=this;return M(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(l){const o=r.events[r.events.length-1];return!O(l)&&o&&o[1].type==="listItemPrefixWhitespace"?n(l):t(l)}}const st={name:"setextUnderline",resolveTo:fo,tokenize:ho};function fo(e,n){let t=e.length,r,i,l;for(;t--;)if(e[t][0]==="enter"){if(e[t][1].type==="content"){r=t;break}e[t][1].type==="paragraph"&&(i=t)}else e[t][1].type==="content"&&e.splice(t,1),!l&&e[t][1].type==="definition"&&(l=t);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",l?(e.splice(i,0,["enter",o,n]),e.splice(l+1,0,["exit",e[r][1],n]),e[r][1].end={...e[l][1].end}):e[r][1]=o,e.push(["exit",o,n]),e}function ho(e,n,t){const r=this;let i;return l;function l(c){let s=r.events.length,f;for(;s--;)if(r.events[s][1].type!=="lineEnding"&&r.events[s][1].type!=="linePrefix"&&r.events[s][1].type!=="content"){f=r.events[s][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=c,o(c)):t(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),O(c)?M(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||A(c)?(e.exit("setextHeadingLine"),n(c)):t(c)}}const mo={tokenize:go};function go(e){const n=this,t=e.attempt(Ge,r,e.attempt(this.parser.constructs.flowInitial,i,M(e,e.attempt(this.parser.constructs.flow,i,e.attempt(bl,i)),"linePrefix")));return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),n.currentConstruct=void 0,t}function i(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),n.currentConstruct=void 0,t}}const yo={resolveAll:rr()},xo=tr("string"),ko=tr("text");function tr(e){return{resolveAll:rr(e==="text"?bo:void 0),tokenize:n};function n(t){const r=this,i=this.parser.constructs[e],l=t.attempt(i,o,a);return o;function o(s){return c(s)?l(s):a(s)}function a(s){if(s===null){t.consume(s);return}return t.enter("data"),t.consume(s),u}function u(s){return c(s)?(t.exit("data"),l(s)):(t.consume(s),u)}function c(s){if(s===null)return!0;const f=i[s];let d=-1;if(f)for(;++d-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}l>0&&o.push(e[i].slice(0,l))}return o}function Oo(e,n){let t=-1;const r=[];let i;for(;++t0){const oe=P.tokenStack[P.tokenStack.length-1];(oe[1]||pt).call(P,void 0,oe[0])}for(S.position={start:de(g.length>0?g[0][1].start:{line:1,column:1,offset:0}),end:de(g.length>0?g[g.length-2][1].end:{line:1,column:1,offset:0})},F=-1;++Fi.jsx("input",{type:r,className:n("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:t,...o}));d.displayName="Input";export{d as I}; +import{d as s,j as i,I as n}from"./index-CjdUkE4w.js";const d=s.forwardRef(({className:e,type:r,...o},t)=>i.jsx("input",{type:r,className:n("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:t,...o}));d.displayName="Input";export{d as I}; diff --git a/assets/loader-circle-C75KLEgx.js b/assets/loader-circle-xTdSzHv_.js similarity index 85% rename from assets/loader-circle-C75KLEgx.js rename to assets/loader-circle-xTdSzHv_.js index 0476394d05ff941077bc0b41925c60f5dc1e1a60..1b1285b62c8165d07caa1fbc8f07ed7e9d458b6d 100644 --- a/assets/loader-circle-C75KLEgx.js +++ b/assets/loader-circle-xTdSzHv_.js @@ -1,4 +1,4 @@ -import{s as e}from"./index-DyXq7-Tg.js";/** +import{s as e}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/moon-DMVsctTM.js b/assets/moon-HVqBvdxs.js similarity index 85% rename from assets/moon-DMVsctTM.js rename to assets/moon-HVqBvdxs.js index 4eb4c43af23237d87cd4366ac732d8cdb924e2e4..c8e620facf8429c37fcbc8b62237b416f666a506 100644 --- a/assets/moon-DMVsctTM.js +++ b/assets/moon-HVqBvdxs.js @@ -1,4 +1,4 @@ -import{s as o}from"./index-DyXq7-Tg.js";/** +import{s as o}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/openrouter-o51Eagw8.js b/assets/openrouter-B-ghWDkd.js similarity index 82% rename from assets/openrouter-o51Eagw8.js rename to assets/openrouter-B-ghWDkd.js index 51d1d4695a46d158cd8c898ca280413900558b8f..6aaebfe4acfe8ad55d8df524dffe2b0a7f687104 100644 --- a/assets/openrouter-o51Eagw8.js +++ b/assets/openrouter-B-ghWDkd.js @@ -1 +1 @@ -import{b as r}from"./index-DyXq7-Tg.js";import{c as n}from"./chat-Ix1IrIwq.js";const o=["chat","openrouter","usage"],u=["chat","openrouter","credential"];function s(e=!0){return r({queryKey:o,queryFn:()=>n.getUsage(),enabled:e,staleTime:3e4,refetchOnWindowFocus:!0})}function c(e=!0){return r({queryKey:u,queryFn:()=>n.getOpenRouterCredential(),enabled:e,refetchOnWindowFocus:!0})}function m(e){const t=new Date(e);return{local:new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t),utc:`${t.toLocaleString("en-GB",{timeZone:"UTC",year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})} UTC`}}export{u as O,s as a,m as r,c as u}; +import{b as r}from"./index-CjdUkE4w.js";import{c as n}from"./chat-B1EBF720.js";const o=["chat","openrouter","usage"],u=["chat","openrouter","credential"];function s(e=!0){return r({queryKey:o,queryFn:()=>n.getUsage(),enabled:e,staleTime:3e4,refetchOnWindowFocus:!0})}function c(e=!0){return r({queryKey:u,queryFn:()=>n.getOpenRouterCredential(),enabled:e,refetchOnWindowFocus:!0})}function m(e){const t=new Date(e);return{local:new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t),utc:`${t.toLocaleString("en-GB",{timeZone:"UTC",year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})} UTC`}}export{u as O,s as a,m as r,c as u}; diff --git a/assets/paperEdits-CIjFYfYE.js b/assets/paperEdits-C_3nZTKz.js similarity index 84% rename from assets/paperEdits-CIjFYfYE.js rename to assets/paperEdits-C_3nZTKz.js index 4de8dc1863856d0bbc0a3407c222cc7fb98932bc..44b6c7a54f12ad99672c37ed4450673a91452e1d 100644 --- a/assets/paperEdits-CIjFYfYE.js +++ b/assets/paperEdits-C_3nZTKz.js @@ -1 +1 @@ -import{ac as p}from"./index-DyXq7-Tg.js";const a={authorization:e=>p(`/paper-edit-authorizations/${encodeURIComponent(e)}`),approve:e=>p(`/paper-edit-authorizations/${encodeURIComponent(e)}/approve`,{method:"POST"}),digest:(e,t)=>p(`/admin/paper-edit-digest?day=${e}&page=${t}`),suspend:(e,t)=>p("/admin/paper-edit-suspension",{method:"POST",body:JSON.stringify({hf_subject:e,suspended:t})})};export{a as p}; +import{ac as p}from"./index-CjdUkE4w.js";const a={authorization:e=>p(`/paper-edit-authorizations/${encodeURIComponent(e)}`),approve:e=>p(`/paper-edit-authorizations/${encodeURIComponent(e)}/approve`,{method:"POST"}),digest:(e,t)=>p(`/admin/paper-edit-digest?day=${e}&page=${t}`),suspend:(e,t)=>p("/admin/paper-edit-suspension",{method:"POST",body:JSON.stringify({hf_subject:e,suspended:t})})};export{a as p}; diff --git a/assets/paperReader-BIpQD5HO.js b/assets/paperReader-BIpQD5HO.js deleted file mode 100644 index b290ab8deb340f427acaae85de03c7ab9b101a67..0000000000000000000000000000000000000000 --- a/assets/paperReader-BIpQD5HO.js +++ /dev/null @@ -1 +0,0 @@ -import{s as o}from"./safeExternalHref-CkBrsh84.js";const a=new Set(["aclanthology.org","dl.acm.org","doi.org","dx.doi.org","eccv.ecva.net","ieeexplore.ieee.org","link.springer.com","openaccess.thecvf.com","openreview.net","sciencedirect.com","zenodo.org"]);function c(e){const r=o(e);if(!r)return!1;const n=new URL(r);return`${n.pathname}?${n.search}`.toLowerCase().includes(".pdf")||n.pathname.toLowerCase().includes("/pdf")}function t(e){return c(e.source_url)||!!o(e.conference_url_pdf)}function l(e){if(e.source!=="external"||t(e))return null;const r=o(e.source_url);if(!r)return null;const n=new URL(r);return n.hash||a.has(n.hostname.replace(/^www\./,""))?null:r}function u(e,r){if(e.source==="external")return(t(e)||!!l(e))&&e.id?`/pdf/${e.id}`:null;const n=(e.arxiv_id||r).replace(/v\d+$/i,"");return o(e.url_pdf)&&n?`/pdf/${n}`:null}function f(e){const r=e.slice(5);sessionStorage.removeItem(`pwc:reader:session:${r}`),sessionStorage.removeItem(`pwc:reader:assistant-collapsed:${r}`),sessionStorage.removeItem(`pwc:reader:page:${r}`)}const i=/^Title: [^\n]*\n\nURL Source: [^\n]*\n\nMarkdown Content:\n/;function m(e){return e.replace(i,"").trim()}export{l as e,u as p,f as r,m as w}; diff --git a/assets/paperReader-h6jqpWHI.js b/assets/paperReader-h6jqpWHI.js new file mode 100644 index 0000000000000000000000000000000000000000..027d4f44c47aa7186d297756a4e24e12c989dbc5 --- /dev/null +++ b/assets/paperReader-h6jqpWHI.js @@ -0,0 +1 @@ +import{s as o}from"./safeExternalHref-CkBrsh84.js";const a=new Set(["aclanthology.org","dl.acm.org","doi.org","dx.doi.org","eccv.ecva.net","ieeexplore.ieee.org","link.springer.com","openaccess.thecvf.com","openreview.net","sciencedirect.com","zenodo.org"]);function c(e){const r=o(e);if(!r)return!1;const n=new URL(r);return`${n.pathname}?${n.search}`.toLowerCase().includes(".pdf")||n.pathname.toLowerCase().includes("/pdf")}function s(e){return c(e.source_url)||!!o(e.conference_url_pdf)}function l(e){if(e.source!=="external"||s(e))return null;const r=o(e.source_url);if(!r)return null;const n=new URL(r);return n.hash||a.has(n.hostname.replace(/^www\./,""))?null:r}function g(e,r){if(e.source==="external")return(s(e)||!!l(e))&&e.id?`/pdf/${e.id}`:null;const n=(e.arxiv_id||r).replace(/v\d+$/i,"");return o(e.url_pdf)&&n?`/pdf/${n}`:null}const d=e=>`pwc:reader:session:${e}`,i=e=>`pwc:reader:assistant-collapsed:${e}`,u=e=>`pwc:reader:page:${e}`;function w(e){const r=e.slice(5);sessionStorage.removeItem(d(r)),sessionStorage.removeItem(i(r)),sessionStorage.removeItem(u(r))}const f=/^Title: [^\n]*\n\nURL Source: [^\n]*\n\nMarkdown Content:\n/;function h(e){return e.replace(f,"").trim()}export{d as a,i as b,u as c,l as e,g as p,w as r,h as w}; diff --git a/assets/papers-Dh3ljlL0.js b/assets/papers-DgZwjF3K.js similarity index 96% rename from assets/papers-Dh3ljlL0.js rename to assets/papers-DgZwjF3K.js index ec09ff4d50fb332d174ef99fb9b02162ae999eec..31dfc82525875b3f3a87d8200bcd156efa47d518 100644 --- a/assets/papers-Dh3ljlL0.js +++ b/assets/papers-DgZwjF3K.js @@ -1 +1 @@ -import{p as a}from"./curation-YeS7FBYf.js";import{ac as c,aV as h,aW as m}from"./index-DyXq7-Tg.js";function u(i){const e=new URLSearchParams;for(const[t,s]of Object.entries(i??{}))s!==void 0&&s!==""&&e.set(t,String(s));const r=e.toString();return r?`?${r}`:""}class d{constructor(e){this.request=e}list(e){const r=new URLSearchParams;for(const[s,o]of Object.entries(e??{}))o!==void 0&&o!==""&&r.set(s,String(o));const t=r.toString();return this.request(`/papers/${t?`?${t}`:""}`,{cache:"no-cache"})}search(e,r=1,t=10,s,o,n){const p=new URLSearchParams({q:e,page:r.toString(),page_size:t.toString()});return s&&p.set("mode",s),n!=null&&n.start_date&&p.set("start_date",n.start_date),n!=null&&n.end_date&&p.set("end_date",n.end_date),this.request(`/papers/search?${p.toString()}`,{signal:o})}searchFeed(e){return this.request(`/papers/search/feed${u(e)}`,{cache:"no-cache"})}get(e,r=!0){const t=r?"?include_resources=true":"";return this.request(`/papers/${e}${t}`)}getByArxivId(e,r=!0){const t=r?"?include_resources=true":"";return this.request(`/papers/arxiv/${e}${t}`)}lookup(e){return this.request("/papers/lookup",{method:"POST",body:JSON.stringify({references:e})})}related(e,r=4){return this.request(`/papers/${encodeURIComponent(e)}/related?limit=${r}`)}suggestedQuestions(e){return this.request(`/papers/${encodeURIComponent(e)}/suggested-questions`)}versions(e){return this.request(`/papers/arxiv/${e}/versions`)}indexFromArxiv(e){return this.request(`/papers/index/${e}`,{method:"POST"})}submit(e){return this.request("/papers/submit",{method:"POST",body:JSON.stringify(e)})}copyToBucket(e,r){return this.request(`/papers/${encodeURIComponent(e)}/copy-to-bucket`,{method:"POST",body:JSON.stringify(r)})}trending(e){const r=new URLSearchParams;for(const[s,o]of Object.entries(e??{}))o!==void 0&&r.set(s,String(o));const t=r.toString();return this.request(`/papers/trending${t?`?${t}`:""}`,{cache:"no-store"})}xTrending(e){return this.request(`/papers/x-trending${u(e)}`)}forTask(e,r){return this.request(`/tasks/${e}/papers${u(r)}`)}forMethod(e,r){return this.request(`/methods/${encodeURIComponent(e)}/papers${u(r)}`)}forConference(e,r){return this.request(`/conferences/${e}/papers${u(r)}`)}forOrganization(e,r){return this.request(`/organizations/${e}/papers${u(r)}`)}getAuthor(e){return this.request(`/authors/${e}`)}searchAuthors(e,r){return this.request(`/authors/${u({search:e,page_size:r})}`)}primeCurationState(e,r=!1){return a.primePaper(e,r)}freshAuthMutationDraft(){return a.freshAuthMutationDraft()}resumeFreshAuthMutation(){return a.resumeFreshAuthMutation()}updateTasks(e,r){const t=new URLSearchParams(r.map(s=>["task_ids",String(s)])).toString();return a.mutatePaper(e,"tasks",r,`/papers/${e}/tasks?${t}`,{method:"PUT"})}updateMethods(e,r){const t=new URLSearchParams(r.map(s=>["method_ids",String(s)])).toString();return a.mutatePaper(e,"methods",r,`/papers/${e}/methods?${t}`,{method:"PUT"})}updateOrganizations(e,r){const t=new URLSearchParams(r.map(s=>["organization_ids",String(s)])).toString();return a.mutatePaper(e,"organizations",r,`/papers/${e}/organizations?${t}`,{method:"PUT"})}updateRepositories(e,r){return a.mutatePaper(e,"repositories",r,`/papers/${e}/repositories`,{method:"PUT",body:JSON.stringify({repositories:r})})}updateProjectPages(e,r){return a.mutatePaper(e,"project_pages",r,`/papers/${e}/project-pages`,{method:"PUT",body:JSON.stringify({project_pages:r})})}updateXThreads(e,r){return a.mutatePaper(e,"x_threads",r,`/papers/${e}/x-threads`,{method:"PUT",body:JSON.stringify({x_threads:r})})}updateSourceUrl(e,r){return a.mutatePaper(e,"source_url",r,`/papers/${e}/source-url`,{method:"PUT",body:JSON.stringify({source_url:r})})}updateHfArtifacts(e,r){return a.mutatePaper(e,"hf_artifacts",r,`/papers/${e}/hf-artifacts`,{method:"PUT",body:JSON.stringify(r)})}}const g=new d(c);async function P(i){return(await h(`/papers/${encodeURIComponent(i)}/web-markdown`)).text()}function S(i){return m(`/papers/${encodeURIComponent(i)}/layout`)}export{S as a,P as g,g as p}; +import{p as a}from"./curation-CyyuHfv5.js";import{ac as c,az as h,aW as m}from"./index-CjdUkE4w.js";function u(i){const e=new URLSearchParams;for(const[t,s]of Object.entries(i??{}))s!==void 0&&s!==""&&e.set(t,String(s));const r=e.toString();return r?`?${r}`:""}class d{constructor(e){this.request=e}list(e){const r=new URLSearchParams;for(const[s,o]of Object.entries(e??{}))o!==void 0&&o!==""&&r.set(s,String(o));const t=r.toString();return this.request(`/papers/${t?`?${t}`:""}`,{cache:"no-cache"})}search(e,r=1,t=10,s,o,n){const p=new URLSearchParams({q:e,page:r.toString(),page_size:t.toString()});return s&&p.set("mode",s),n!=null&&n.start_date&&p.set("start_date",n.start_date),n!=null&&n.end_date&&p.set("end_date",n.end_date),this.request(`/papers/search?${p.toString()}`,{signal:o})}searchFeed(e){return this.request(`/papers/search/feed${u(e)}`,{cache:"no-cache"})}get(e,r=!0){const t=r?"?include_resources=true":"";return this.request(`/papers/${e}${t}`)}getByArxivId(e,r=!0){const t=r?"?include_resources=true":"";return this.request(`/papers/arxiv/${e}${t}`)}lookup(e){return this.request("/papers/lookup",{method:"POST",body:JSON.stringify({references:e})})}related(e,r=4){return this.request(`/papers/${encodeURIComponent(e)}/related?limit=${r}`)}suggestedQuestions(e){return this.request(`/papers/${encodeURIComponent(e)}/suggested-questions`)}versions(e){return this.request(`/papers/arxiv/${e}/versions`)}indexFromArxiv(e){return this.request(`/papers/index/${e}`,{method:"POST"})}submit(e){return this.request("/papers/submit",{method:"POST",body:JSON.stringify(e)})}copyToBucket(e,r){return this.request(`/papers/${encodeURIComponent(e)}/copy-to-bucket`,{method:"POST",body:JSON.stringify(r)})}trending(e){const r=new URLSearchParams;for(const[s,o]of Object.entries(e??{}))o!==void 0&&r.set(s,String(o));const t=r.toString();return this.request(`/papers/trending${t?`?${t}`:""}`,{cache:"no-store"})}xTrending(e){return this.request(`/papers/x-trending${u(e)}`)}forTask(e,r){return this.request(`/tasks/${e}/papers${u(r)}`)}forMethod(e,r){return this.request(`/methods/${encodeURIComponent(e)}/papers${u(r)}`)}forConference(e,r){return this.request(`/conferences/${e}/papers${u(r)}`)}forOrganization(e,r){return this.request(`/organizations/${e}/papers${u(r)}`)}getAuthor(e){return this.request(`/authors/${e}`)}searchAuthors(e,r){return this.request(`/authors/${u({search:e,page_size:r})}`)}primeCurationState(e,r=!1){return a.primePaper(e,r)}freshAuthMutationDraft(){return a.freshAuthMutationDraft()}resumeFreshAuthMutation(){return a.resumeFreshAuthMutation()}updateTasks(e,r){const t=new URLSearchParams(r.map(s=>["task_ids",String(s)])).toString();return a.mutatePaper(e,"tasks",r,`/papers/${e}/tasks?${t}`,{method:"PUT"})}updateMethods(e,r){const t=new URLSearchParams(r.map(s=>["method_ids",String(s)])).toString();return a.mutatePaper(e,"methods",r,`/papers/${e}/methods?${t}`,{method:"PUT"})}updateOrganizations(e,r){const t=new URLSearchParams(r.map(s=>["organization_ids",String(s)])).toString();return a.mutatePaper(e,"organizations",r,`/papers/${e}/organizations?${t}`,{method:"PUT"})}updateRepositories(e,r){return a.mutatePaper(e,"repositories",r,`/papers/${e}/repositories`,{method:"PUT",body:JSON.stringify({repositories:r})})}updateProjectPages(e,r){return a.mutatePaper(e,"project_pages",r,`/papers/${e}/project-pages`,{method:"PUT",body:JSON.stringify({project_pages:r})})}updateXThreads(e,r){return a.mutatePaper(e,"x_threads",r,`/papers/${e}/x-threads`,{method:"PUT",body:JSON.stringify({x_threads:r})})}updateSourceUrl(e,r){return a.mutatePaper(e,"source_url",r,`/papers/${e}/source-url`,{method:"PUT",body:JSON.stringify({source_url:r})})}updateHfArtifacts(e,r){return a.mutatePaper(e,"hf_artifacts",r,`/papers/${e}/hf-artifacts`,{method:"PUT",body:JSON.stringify(r)})}}const g=new d(c);async function P(i){return(await h(`/papers/${encodeURIComponent(i)}/web-markdown`)).text()}function S(i){return m(`/papers/${encodeURIComponent(i)}/layout`)}export{S as a,P as g,g as p}; diff --git a/assets/plus-Yh42pKZz.js b/assets/plus-AztI1566.js similarity index 87% rename from assets/plus-Yh42pKZz.js rename to assets/plus-AztI1566.js index 5dbba74ae7eb84a136b157c0f6feb62ee054d3c9..fd33bc1c62bfa5a069a5098c3e67774714994a66 100644 --- a/assets/plus-Yh42pKZz.js +++ b/assets/plus-AztI1566.js @@ -1,4 +1,4 @@ -import{s}from"./index-DyXq7-Tg.js";/** +import{s}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/popover-CTBEUp7Y.js b/assets/popover-Df5_dywQ.js similarity index 96% rename from assets/popover-CTBEUp7Y.js rename to assets/popover-Df5_dywQ.js index 98ffe850151dad24d75ada9ae00ef029a1dccc16..68d6a011a5d8a1ce518bbeea7f386d87e0d3da61 100644 --- a/assets/popover-CTBEUp7Y.js +++ b/assets/popover-Df5_dywQ.js @@ -1 +1 @@ -import{d as s,j as l,ak as V,A as $,ap as L,af as W,B as A,z as O,D as h,aq as E,ar as _,P as y,as as H,F as z,aX as G,aY as B,aZ as Z,a_ as K,at as q,au as U,av as X,G as Y}from"./index-DyXq7-Tg.js";function J(e){const t=Q(e),r=s.forwardRef((n,o)=>{const{children:a,...c}=n,i=s.Children.toArray(a),p=i.find(oe);if(p){const u=p.props.children,P=i.map(f=>f===p?s.Children.count(u)>1?s.Children.only(null):s.isValidElement(u)?u.props.children:null:f);return l.jsx(t,{...c,ref:o,children:s.isValidElement(u)?s.cloneElement(u,void 0,P):null})}return l.jsx(t,{...c,ref:o,children:a})});return r.displayName=`${e}.Slot`,r}function Q(e){const t=s.forwardRef((r,n)=>{const{children:o,...a}=r;if(s.isValidElement(o)){const c=re(o),i=te(a,o.props);return o.type!==s.Fragment&&(i.ref=n?V(n,c):c),s.cloneElement(o,i)}return s.Children.count(o)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ee=Symbol("radix.slottable");function oe(e){return s.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ee}function te(e,t){const r={...t};for(const n in t){const o=e[n],a=t[n];/^on[A-Z]/.test(n)?o&&a?r[n]=(...i)=>{const p=a(...i);return o(...i),p}:o&&(r[n]=o):n==="style"?r[n]={...o,...a}:n==="className"&&(r[n]=[o,a].filter(Boolean).join(" "))}return{...e,...r}}function re(e){var n,o;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var C="Popover",[b]=z(C,[_]),m=_(),[ne,d]=b(C),j=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:a,modal:c=!1}=e,i=m(t),p=s.useRef(null),[u,P]=s.useState(!1),[f,v]=$({prop:n,defaultProp:o??!1,onChange:a,caller:C});return l.jsx(L,{...i,children:l.jsx(ne,{scope:t,contentId:W(),triggerRef:p,open:f,onOpenChange:v,onOpenToggle:s.useCallback(()=>v(x=>!x),[v]),hasCustomAnchor:u,onCustomAnchorAdd:s.useCallback(()=>P(!0),[]),onCustomAnchorRemove:s.useCallback(()=>P(!1),[]),modal:c,children:r})})};j.displayName=C;var w="PopoverAnchor",ae=s.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=d(w,r),a=m(r),{onCustomAnchorAdd:c,onCustomAnchorRemove:i}=o;return s.useEffect(()=>(c(),()=>i()),[c,i]),l.jsx(E,{...a,...n,ref:t})});ae.displayName=w;var S="PopoverTrigger",N=s.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=d(S,r),a=m(r),c=A(t,o.triggerRef),i=l.jsx(O.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":M(o.open),...n,ref:c,onClick:h(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?i:l.jsx(E,{asChild:!0,...a,children:i})});N.displayName=S;var R="PopoverPortal",[se,ce]=b(R,{forceMount:void 0}),F=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,a=d(R,t);return l.jsx(se,{scope:t,forceMount:r,children:l.jsx(y,{present:r||a.open,children:l.jsx(H,{asChild:!0,container:o,children:n})})})};F.displayName=R;var g="PopoverContent",D=s.forwardRef((e,t)=>{const r=ce(g,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,a=d(g,e.__scopePopover);return l.jsx(y,{present:n||a.open,children:a.modal?l.jsx(le,{...o,ref:t}):l.jsx(pe,{...o,ref:t})})});D.displayName=g;var ie=J("PopoverContent.RemoveScroll"),le=s.forwardRef((e,t)=>{const r=d(g,e.__scopePopover),n=s.useRef(null),o=A(t,n),a=s.useRef(!1);return s.useEffect(()=>{const c=n.current;if(c)return G(c)},[]),l.jsx(B,{as:ie,allowPinchZoom:!0,children:l.jsx(I,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:h(e.onCloseAutoFocus,c=>{var i;c.preventDefault(),a.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:h(e.onPointerDownOutside,c=>{const i=c.detail.originalEvent,p=i.button===0&&i.ctrlKey===!0,u=i.button===2||p;a.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:h(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),pe=s.forwardRef((e,t)=>{const r=d(g,e.__scopePopover),n=s.useRef(!1),o=s.useRef(!1);return l.jsx(I,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var c,i;(c=e.onCloseAutoFocus)==null||c.call(e,a),a.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),a.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:a=>{var p,u;(p=e.onInteractOutside)==null||p.call(e,a),a.defaultPrevented||(n.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=a.target;((u=r.triggerRef.current)==null?void 0:u.contains(c))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),I=s.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEscapeKeyDown:i,onPointerDownOutside:p,onFocusOutside:u,onInteractOutside:P,...f}=e,v=d(g,r),x=m(r);return Z(),l.jsx(K,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:a,children:l.jsx(q,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:P,onEscapeKeyDown:i,onPointerDownOutside:p,onFocusOutside:u,onDismiss:()=>v.onOpenChange(!1),children:l.jsx(U,{"data-state":M(v.open),role:"dialog",id:v.contentId,...x,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),T="PopoverClose",ue=s.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=d(T,r);return l.jsx(O.button,{type:"button",...n,ref:t,onClick:h(e.onClick,()=>o.onOpenChange(!1))})});ue.displayName=T;var de="PopoverArrow",fe=s.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=m(r);return l.jsx(X,{...o,...n,ref:t})});fe.displayName=de;function M(e){return e?"open":"closed"}var ve=j,Pe=N,ge=F,k=D;const Ce=ve,xe=Pe,he=s.forwardRef(({className:e,align:t="center",sideOffset:r=4,...n},o)=>l.jsx(ge,{children:l.jsx(k,{ref:o,align:t,sideOffset:r,className:Y("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));he.displayName=k.displayName;export{Ce as P,xe as a,he as b}; +import{d as s,j as l,ak as V,B as $,ap as L,af as W,D as A,z as O,E as h,aq as E,ar as _,P as y,as as H,G as z,aX as G,aY as B,aZ as Z,a_ as K,at as q,au as U,av as X,I as Y}from"./index-CjdUkE4w.js";function J(e){const t=Q(e),r=s.forwardRef((n,o)=>{const{children:a,...c}=n,i=s.Children.toArray(a),p=i.find(oe);if(p){const u=p.props.children,P=i.map(f=>f===p?s.Children.count(u)>1?s.Children.only(null):s.isValidElement(u)?u.props.children:null:f);return l.jsx(t,{...c,ref:o,children:s.isValidElement(u)?s.cloneElement(u,void 0,P):null})}return l.jsx(t,{...c,ref:o,children:a})});return r.displayName=`${e}.Slot`,r}function Q(e){const t=s.forwardRef((r,n)=>{const{children:o,...a}=r;if(s.isValidElement(o)){const c=re(o),i=te(a,o.props);return o.type!==s.Fragment&&(i.ref=n?V(n,c):c),s.cloneElement(o,i)}return s.Children.count(o)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ee=Symbol("radix.slottable");function oe(e){return s.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ee}function te(e,t){const r={...t};for(const n in t){const o=e[n],a=t[n];/^on[A-Z]/.test(n)?o&&a?r[n]=(...i)=>{const p=a(...i);return o(...i),p}:o&&(r[n]=o):n==="style"?r[n]={...o,...a}:n==="className"&&(r[n]=[o,a].filter(Boolean).join(" "))}return{...e,...r}}function re(e){var n,o;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var C="Popover",[b]=z(C,[_]),m=_(),[ne,d]=b(C),j=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:a,modal:c=!1}=e,i=m(t),p=s.useRef(null),[u,P]=s.useState(!1),[f,v]=$({prop:n,defaultProp:o??!1,onChange:a,caller:C});return l.jsx(L,{...i,children:l.jsx(ne,{scope:t,contentId:W(),triggerRef:p,open:f,onOpenChange:v,onOpenToggle:s.useCallback(()=>v(x=>!x),[v]),hasCustomAnchor:u,onCustomAnchorAdd:s.useCallback(()=>P(!0),[]),onCustomAnchorRemove:s.useCallback(()=>P(!1),[]),modal:c,children:r})})};j.displayName=C;var w="PopoverAnchor",ae=s.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=d(w,r),a=m(r),{onCustomAnchorAdd:c,onCustomAnchorRemove:i}=o;return s.useEffect(()=>(c(),()=>i()),[c,i]),l.jsx(E,{...a,...n,ref:t})});ae.displayName=w;var S="PopoverTrigger",N=s.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=d(S,r),a=m(r),c=A(t,o.triggerRef),i=l.jsx(O.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":M(o.open),...n,ref:c,onClick:h(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?i:l.jsx(E,{asChild:!0,...a,children:i})});N.displayName=S;var R="PopoverPortal",[se,ce]=b(R,{forceMount:void 0}),F=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,a=d(R,t);return l.jsx(se,{scope:t,forceMount:r,children:l.jsx(y,{present:r||a.open,children:l.jsx(H,{asChild:!0,container:o,children:n})})})};F.displayName=R;var g="PopoverContent",D=s.forwardRef((e,t)=>{const r=ce(g,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,a=d(g,e.__scopePopover);return l.jsx(y,{present:n||a.open,children:a.modal?l.jsx(le,{...o,ref:t}):l.jsx(pe,{...o,ref:t})})});D.displayName=g;var ie=J("PopoverContent.RemoveScroll"),le=s.forwardRef((e,t)=>{const r=d(g,e.__scopePopover),n=s.useRef(null),o=A(t,n),a=s.useRef(!1);return s.useEffect(()=>{const c=n.current;if(c)return G(c)},[]),l.jsx(B,{as:ie,allowPinchZoom:!0,children:l.jsx(I,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:h(e.onCloseAutoFocus,c=>{var i;c.preventDefault(),a.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:h(e.onPointerDownOutside,c=>{const i=c.detail.originalEvent,p=i.button===0&&i.ctrlKey===!0,u=i.button===2||p;a.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:h(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),pe=s.forwardRef((e,t)=>{const r=d(g,e.__scopePopover),n=s.useRef(!1),o=s.useRef(!1);return l.jsx(I,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var c,i;(c=e.onCloseAutoFocus)==null||c.call(e,a),a.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),a.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:a=>{var p,u;(p=e.onInteractOutside)==null||p.call(e,a),a.defaultPrevented||(n.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=a.target;((u=r.triggerRef.current)==null?void 0:u.contains(c))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),I=s.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEscapeKeyDown:i,onPointerDownOutside:p,onFocusOutside:u,onInteractOutside:P,...f}=e,v=d(g,r),x=m(r);return Z(),l.jsx(K,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:a,children:l.jsx(q,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:P,onEscapeKeyDown:i,onPointerDownOutside:p,onFocusOutside:u,onDismiss:()=>v.onOpenChange(!1),children:l.jsx(U,{"data-state":M(v.open),role:"dialog",id:v.contentId,...x,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),T="PopoverClose",ue=s.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=d(T,r);return l.jsx(O.button,{type:"button",...n,ref:t,onClick:h(e.onClick,()=>o.onOpenChange(!1))})});ue.displayName=T;var de="PopoverArrow",fe=s.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=m(r);return l.jsx(X,{...o,...n,ref:t})});fe.displayName=de;function M(e){return e?"open":"closed"}var ve=j,Pe=N,ge=F,k=D;const Ce=ve,xe=Pe,he=s.forwardRef(({className:e,align:t="center",sideOffset:r=4,...n},o)=>l.jsx(ge,{children:l.jsx(k,{ref:o,align:t,sideOffset:r,className:Y("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));he.displayName=k.displayName;export{Ce as P,xe as a,he as b}; diff --git a/assets/preferences-COzeOLyS.js b/assets/preferences-DMhkYrri.js similarity index 74% rename from assets/preferences-COzeOLyS.js rename to assets/preferences-DMhkYrri.js index 9a42d7e8d34329ff7836edfca4ac4aa4c148ead7..c31839c337cbd134ac7868fa50be9b7a52722cca 100644 --- a/assets/preferences-COzeOLyS.js +++ b/assets/preferences-DMhkYrri.js @@ -1 +1 @@ -import{a as y,i as d,b as f,W as p}from"./index-DyXq7-Tg.js";import{u as m}from"./useMutation-UWxBeqtn.js";import{a as c}from"./account-cbblajck.js";const i={hide_closed_source_evals:!1};function v(){const{user:t}=y(),r=d(),s=p.preferences,a=f({queryKey:s,queryFn:()=>c.getPreferences(),enabled:!!t,staleTime:1/0}),o=a.data??i,l=m({mutationFn:e=>t?c.updatePreferences(e):Promise.resolve(e),onMutate:async e=>{await r.cancelQueries({queryKey:s});const u=r.getQueryData(s)??i;return r.setQueryData(s,e),{previous:u}},onError:(e,u,n)=>{n&&r.setQueryData(s,n.previous)},onSuccess:e=>r.setQueryData(s,e)});return{preferences:o,canPersist:!!t,isLoading:a.isLoading,setHideClosedSourceEvals:e=>l.mutate({...o,hide_closed_source_evals:e})}}export{v as u}; +import{a as y,i as d,b as f,W as p}from"./index-CjdUkE4w.js";import{u as m}from"./useMutation-BYtVrkc7.js";import{a as c}from"./account-DoluPGSd.js";const i={hide_closed_source_evals:!1};function v(){const{user:t}=y(),r=d(),s=p.preferences,a=f({queryKey:s,queryFn:()=>c.getPreferences(),enabled:!!t,staleTime:1/0}),o=a.data??i,l=m({mutationFn:e=>t?c.updatePreferences(e):Promise.resolve(e),onMutate:async e=>{await r.cancelQueries({queryKey:s});const u=r.getQueryData(s)??i;return r.setQueryData(s,e),{previous:u}},onError:(e,u,n)=>{n&&r.setQueryData(s,n.previous)},onSuccess:e=>r.setQueryData(s,e)});return{preferences:o,canPersist:!!t,isLoading:a.isLoading,setHideClosedSourceEvals:e=>l.mutate({...o,hide_closed_source_evals:e})}}export{v as u}; diff --git a/assets/queryInvalidation-CfHeNeUY.js b/assets/queryInvalidation-LiTu0GxY.js similarity index 93% rename from assets/queryInvalidation-CfHeNeUY.js rename to assets/queryInvalidation-LiTu0GxY.js index 681aaf3c70ceab2fb3d7a69f350e4607993c8d35..735de74d1432a2407c5d240e54efd0366199c405 100644 --- a/assets/queryInvalidation-CfHeNeUY.js +++ b/assets/queryInvalidation-LiTu0GxY.js @@ -1 +1 @@ -import{p as n,t as u}from"./index-DyXq7-Tg.js";function f(e,t,a){if(!e)return e;const i=r=>r.paper_id!==t||r.paper_title===a?r:{...r,paper_title:a};if(Array.isArray(e)){const r=e.map(i);return r.some((s,o)=>s!==e[o])?r:e}if(Array.isArray(e.results)){const r=e.results.map(i);return r.some((s,o)=>s!==e.results[o])?{...e,results:r}:e}return e}function p(e,t){const a=new Set(t.filter(i=>!!i));for(const i of a)for(const r of[n.detail(i),n.arxiv(i),n.preview(i),n.summary(i)])e.invalidateQueries({queryKey:r,exact:!0})}function y(e){for(const t of Object.values(n.feeds))e.invalidateQueries({queryKey:t,refetchType:"none"})}function h(e,t,a){new Set([...a,t.id,t.arxiv_id].filter(s=>!!s)).forEach(s=>{e.setQueryData(n.detail(s),t),e.setQueryData(n.arxiv(s),t),e.setQueriesData({queryKey:n.preview(s),exact:!0},t),e.setQueriesData({queryKey:n.summary(s),exact:!0},t)}),y(e);const r=String(t.id),c=s=>f(s,r,t.title);for(const s of[u.all,u.byDatasetAll])e.setQueriesData({queryKey:s},c),e.invalidateQueries({queryKey:s,refetchType:"none"})}export{y as a,p as i,h as r}; +import{p as n,t as u}from"./index-CjdUkE4w.js";function f(e,t,a){if(!e)return e;const i=r=>r.paper_id!==t||r.paper_title===a?r:{...r,paper_title:a};if(Array.isArray(e)){const r=e.map(i);return r.some((s,o)=>s!==e[o])?r:e}if(Array.isArray(e.results)){const r=e.results.map(i);return r.some((s,o)=>s!==e.results[o])?{...e,results:r}:e}return e}function p(e,t){const a=new Set(t.filter(i=>!!i));for(const i of a)for(const r of[n.detail(i),n.arxiv(i),n.preview(i),n.summary(i)])e.invalidateQueries({queryKey:r,exact:!0})}function y(e){for(const t of Object.values(n.feeds))e.invalidateQueries({queryKey:t,refetchType:"none"})}function h(e,t,a){new Set([...a,t.id,t.arxiv_id].filter(s=>!!s)).forEach(s=>{e.setQueryData(n.detail(s),t),e.setQueryData(n.arxiv(s),t),e.setQueriesData({queryKey:n.preview(s),exact:!0},t),e.setQueriesData({queryKey:n.summary(s),exact:!0},t)}),y(e);const r=String(t.id),c=s=>f(s,r,t.title);for(const s of[u.all,u.byDatasetAll])e.setQueriesData({queryKey:s},c),e.invalidateQueries({queryKey:s,refetchType:"none"})}export{y as a,p as i,h as r}; diff --git a/assets/refresh-cw-DYXzpRir.js b/assets/refresh-cw-BuRFYuxm.js similarity index 94% rename from assets/refresh-cw-DYXzpRir.js rename to assets/refresh-cw-BuRFYuxm.js index 6f75ee7f01d5f3b0d276294009661b7f442a4b06..bec3976df366c02d8a3c24da85861157f8447e0f 100644 --- a/assets/refresh-cw-DYXzpRir.js +++ b/assets/refresh-cw-BuRFYuxm.js @@ -1,4 +1,4 @@ -import{s as e}from"./index-DyXq7-Tg.js";/** +import{s as e}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/researchTopic-DbX0eko-.js b/assets/researchTopic-NmABF6tT.js similarity index 94% rename from assets/researchTopic-DbX0eko-.js rename to assets/researchTopic-NmABF6tT.js index e4b22947d2f62d6bc5aeeb19e46f31928f623cf5..33d0145970314368fbf459663158ee17f364e669 100644 --- a/assets/researchTopic-DbX0eko-.js +++ b/assets/researchTopic-NmABF6tT.js @@ -1 +1 @@ -import{ac as n,f as u,b as y,r,i as m}from"./index-DyXq7-Tg.js";import{u as w}from"./useMutation-UWxBeqtn.js";const _=300,c={follows:()=>n("/me/follows"),followSuggestions:()=>n("/research/follow-suggestions"),setFollow:(e,t,s)=>n(`/me/follows/${e}/${t}`,{method:s?"PUT":"DELETE"}),following:(e=0,t={})=>{const s=new URLSearchParams({offset:String(e),limit:"40"});return t.startDate&&s.set("start_date",t.startDate),t.endDate&&s.set("end_date",t.endDate),!t.startDate&&!t.endDate&&s.set("all_time","true"),t.topicOnly&&s.set("topic_only","true"),n(`/me/following?${s}`)},topic:()=>n("/me/topic"),setTopic:e=>n("/me/topic",{method:"PUT",body:JSON.stringify({text:e})}),clearTopic:()=>n("/me/topic",{method:"DELETE"}),email:()=>n("/me/research-email"),setEmail:e=>n("/me/research-email",{method:"PUT",body:JSON.stringify({enabled:e})})};function d(e,t,{follows:s}){return Promise.all([s&&e.invalidateQueries({queryKey:r.follows(t)}),e.invalidateQueries({queryKey:r.feed(t)}),e.invalidateQueries({queryKey:r.email(t)})])}function F(e=!0){var s;const t=(s=u())==null?void 0:s.user;return y({queryKey:r.follows(t==null?void 0:t.hf_subject),queryFn:c.follows,enabled:e&&!!t})}function E({onChanged:e,awaitRefresh:t=!1}={}){var i;const s=(i=u())==null?void 0:i.user,a=m();return w({mutationFn:({kind:l,entityId:o,follow:f})=>c.setFollow(l,o,f),onSuccess:async(l,o)=>{e==null||e(o);const f=d(a,s==null?void 0:s.hf_subject,{follows:!0});t&&await f}})}function D(e){var a;const t=(a=u())==null?void 0:a.user,s=m();return w({mutationFn:async i=>i===null?(await c.clearTopic(),null):c.setTopic(i),onSuccess:i=>{s.setQueryData(r.topic(t==null?void 0:t.hf_subject),i),h(),e==null||e(),d(s,t==null?void 0:t.hf_subject,{follows:!1})}})}const p="pwc:following-pending-topic";function I(e){sessionStorage.setItem(p,e)}function O(){return sessionStorage.getItem(p)}function h(){sessionStorage.removeItem(p)}function N(){var s;const e=(s=u())==null?void 0:s.user,t=m();return w({mutationFn:async a=>{const l=(await Promise.allSettled(a.map(o=>c.setFollow(o.kind,o.id,o.follow??!0)))).find(o=>o.status==="rejected");if(l)throw l.reason},onSuccess:()=>S(),onSettled:()=>void d(t,e==null?void 0:e.hf_subject,{follows:!0})})}const g="pwc:following-pending-follows";function b(e){sessionStorage.setItem(g,JSON.stringify(e))}function K(){return JSON.parse(sessionStorage.getItem(g)??"[]")}function S(){sessionStorage.removeItem(g)}export{_ as T,D as a,N as b,b as c,O as d,K as e,h as f,E as g,c as r,I as s,F as u}; +import{ac as n,f as u,b as y,r,i as m}from"./index-CjdUkE4w.js";import{u as w}from"./useMutation-BYtVrkc7.js";const _=300,c={follows:()=>n("/me/follows"),followSuggestions:()=>n("/research/follow-suggestions"),setFollow:(e,t,s)=>n(`/me/follows/${e}/${t}`,{method:s?"PUT":"DELETE"}),following:(e=0,t={})=>{const s=new URLSearchParams({offset:String(e),limit:"40"});return t.startDate&&s.set("start_date",t.startDate),t.endDate&&s.set("end_date",t.endDate),!t.startDate&&!t.endDate&&s.set("all_time","true"),t.topicOnly&&s.set("topic_only","true"),n(`/me/following?${s}`)},topic:()=>n("/me/topic"),setTopic:e=>n("/me/topic",{method:"PUT",body:JSON.stringify({text:e})}),clearTopic:()=>n("/me/topic",{method:"DELETE"}),email:()=>n("/me/research-email"),setEmail:e=>n("/me/research-email",{method:"PUT",body:JSON.stringify({enabled:e})})};function d(e,t,{follows:s}){return Promise.all([s&&e.invalidateQueries({queryKey:r.follows(t)}),e.invalidateQueries({queryKey:r.feed(t)}),e.invalidateQueries({queryKey:r.email(t)})])}function F(e=!0){var s;const t=(s=u())==null?void 0:s.user;return y({queryKey:r.follows(t==null?void 0:t.hf_subject),queryFn:c.follows,enabled:e&&!!t})}function E({onChanged:e,awaitRefresh:t=!1}={}){var i;const s=(i=u())==null?void 0:i.user,a=m();return w({mutationFn:({kind:l,entityId:o,follow:f})=>c.setFollow(l,o,f),onSuccess:async(l,o)=>{e==null||e(o);const f=d(a,s==null?void 0:s.hf_subject,{follows:!0});t&&await f}})}function D(e){var a;const t=(a=u())==null?void 0:a.user,s=m();return w({mutationFn:async i=>i===null?(await c.clearTopic(),null):c.setTopic(i),onSuccess:i=>{s.setQueryData(r.topic(t==null?void 0:t.hf_subject),i),h(),e==null||e(),d(s,t==null?void 0:t.hf_subject,{follows:!1})}})}const p="pwc:following-pending-topic";function I(e){sessionStorage.setItem(p,e)}function O(){return sessionStorage.getItem(p)}function h(){sessionStorage.removeItem(p)}function N(){var s;const e=(s=u())==null?void 0:s.user,t=m();return w({mutationFn:async a=>{const l=(await Promise.allSettled(a.map(o=>c.setFollow(o.kind,o.id,o.follow??!0)))).find(o=>o.status==="rejected");if(l)throw l.reason},onSuccess:()=>S(),onSettled:()=>void d(t,e==null?void 0:e.hf_subject,{follows:!0})})}const g="pwc:following-pending-follows";function b(e){sessionStorage.setItem(g,JSON.stringify(e))}function K(){return JSON.parse(sessionStorage.getItem(g)??"[]")}function S(){sessionStorage.removeItem(g)}export{_ as T,D as a,N as b,b as c,O as d,K as e,h as f,E as g,c as r,I as s,F as u}; diff --git a/assets/savedPapersAuth-TV7AiXOw.js b/assets/savedPapersAuth-DT83MLdi.js similarity index 75% rename from assets/savedPapersAuth-TV7AiXOw.js rename to assets/savedPapersAuth-DT83MLdi.js index d5898f4566158caeabfd069df8989abb151f0bba..9901a38606b12005fb2486d002cd38f76c91b29f 100644 --- a/assets/savedPapersAuth-TV7AiXOw.js +++ b/assets/savedPapersAuth-DT83MLdi.js @@ -1 +1 @@ -import{h as a}from"./index-DyXq7-Tg.js";const t="saved_papers_authorized";function o(r=!1){const e=new URL(window.location.href);return r&&e.searchParams.set(t,"1"),a(`${e.pathname}${e.search}${e.hash}`,{authorizeBucket:!0,bucketCreate:!0})}export{t as S,o as s}; +import{h as a}from"./index-CjdUkE4w.js";const t="saved_papers_authorized";function o(r=!1){const e=new URL(window.location.href);return r&&e.searchParams.set(t,"1"),a(`${e.pathname}${e.search}${e.hash}`,{authorizeBucket:!0,bucketCreate:!0})}export{t as S,o as s}; diff --git a/assets/search-8ssWDP68.js b/assets/search-DxMn7VKI.js similarity index 87% rename from assets/search-8ssWDP68.js rename to assets/search-DxMn7VKI.js index edae1d6caca9cbebddcc9b85fc61ba2fdb3b1fdb..42504e69564d46e856c40ba12db8d79f572e5d47 100644 --- a/assets/search-8ssWDP68.js +++ b/assets/search-DxMn7VKI.js @@ -1,4 +1,4 @@ -import{s as e}from"./index-DyXq7-Tg.js";/** +import{s as e}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/searchable-select-DiDLwvbI.js b/assets/searchable-select-EPf13F1I.js similarity index 76% rename from assets/searchable-select-DiDLwvbI.js rename to assets/searchable-select-EPf13F1I.js index 1c0e6334fb98bf9e6737c8c0a091fad80ce87b7c..8f0e38521c831d1a774f4678b21f8000859104ee 100644 --- a/assets/searchable-select-DiDLwvbI.js +++ b/assets/searchable-select-EPf13F1I.js @@ -1,6 +1,6 @@ -import{s as Ae,d as a,af as z,z as L,ag as Me,ah as De,ai as $e,aj as Le,ak as H,j as p,G as D,b as Pe,C as Fe}from"./index-DyXq7-Tg.js";import{B as Ke}from"./button-DZeAbOf2.js";import{P as qe,a as Ve,b as Be}from"./popover-CTBEUp7Y.js";import"./dialog-CfM0Uql2.js";import{S as Ue}from"./search-8ssWDP68.js";import{L as ze}from"./loader-circle-C75KLEgx.js";/** +import{s as Ae,d as a,af as z,z as L,ag as Me,ah as De,ai as $e,aj as Le,ak as H,j as p,I as D,b as Pe,C as Fe}from"./index-CjdUkE4w.js";import{B as Ke}from"./button-DetZl_ch.js";import{P as qe,a as Ve,b as Be}from"./popover-Df5_dywQ.js";import"./dialog-BzX9PD3v.js";import{S as Ue}from"./search-DxMn7VKI.js";import{L as ze}from"./loader-circle-xTdSzHv_.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Ge=Ae("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);var fe=1,Qe=.9,Te=.8,He=.17,re=.1,ne=.999,We=.9999,Je=.99,Xe=/[\\\/_+.#"@\[\(\{&]/,Ye=/[\\\/_+.#"@\[\(\{&]/g,Ze=/[\s-]/,he=/[\s-]/g;function le(e,n,t,m,u,i,d){if(i===n.length)return u===e.length?fe:Je;var c=`${u},${i}`;if(d[c]!==void 0)return d[c];for(var y=m.charAt(i),o=t.indexOf(y,u),v=0,g,C,k,I;o>=0;)g=le(e,n,t,m,o+1,i+1,d),g>v&&(o===u?g*=fe:Xe.test(e.charAt(o-1))?(g*=Te,k=e.slice(u,o-1).match(Ye),k&&u>0&&(g*=Math.pow(ne,k.length))):Ze.test(e.charAt(o-1))?(g*=Qe,I=e.slice(u,o-1).match(he),I&&u>0&&(g*=Math.pow(ne,I.length))):(g*=He,u>0&&(g*=Math.pow(ne,o-u))),e.charAt(o)!==n.charAt(i)&&(g*=We)),(gg&&(g=C*re)),g>v&&(v=g),o=t.indexOf(y,o+1);return d[c]=v,v}function pe(e){return e.toLowerCase().replace(he," ")}function _e(e,n,t){return e=t&&t.length>0?`${e+" "+t.join(" ")}`:e,le(e,n,pe(e),pe(n),0,0,{})}var T='[cmdk-group=""]',ae='[cmdk-group-items=""]',Oe='[cmdk-group-heading=""]',ge='[cmdk-item=""]',ve=`${ge}:not([aria-disabled="true"])`,ue="cmdk-item-select",B="data-value",et=(e,n,t)=>_e(e,n,t),xe=a.createContext(void 0),W=()=>a.useContext(xe),be=a.createContext(void 0),oe=()=>a.useContext(be),ye=a.createContext(void 0),we=a.forwardRef((e,n)=>{let t=U(()=>{var r,s;return{search:"",value:(s=(r=e.value)!=null?r:e.defaultValue)!=null?s:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),m=U(()=>new Set),u=U(()=>new Map),i=U(()=>new Map),d=U(()=>new Set),c=ke(e),{label:y,children:o,value:v,onValueChange:g,filter:C,shouldFilter:k,loop:I,disablePointerSelection:P=!1,vimBindings:R=!0,...F}=e,q=z(),A=z(),G=z(),M=a.useRef(null),x=dt();K(()=>{if(v!==void 0){let r=v.trim();t.current.value=r,E.emit()}},[v]),K(()=>{x(6,ie)},[]);let E=a.useMemo(()=>({subscribe:r=>(d.current.add(r),()=>d.current.delete(r)),snapshot:()=>t.current,setState:(r,s,f)=>{var l,h,b,j;if(!Object.is(t.current[r],s)){if(t.current[r]=s,r==="search")O(),Z(),x(1,_);else if(r==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let S=document.getElementById(G);S?S.focus():(l=document.getElementById(q))==null||l.focus()}if(x(7,()=>{var S;t.current.selectedItemId=(S=V())==null?void 0:S.id,E.emit()}),f||x(5,ie),((h=c.current)==null?void 0:h.value)!==void 0){let S=s??"";(j=(b=c.current).onValueChange)==null||j.call(b,S);return}}E.emit()}},emit:()=>{d.current.forEach(r=>r())}}),[]),w=a.useMemo(()=>({value:(r,s,f)=>{var l;s!==((l=i.current.get(r))==null?void 0:l.value)&&(i.current.set(r,{value:s,keywords:f}),t.current.filtered.items.set(r,J(s,f)),x(2,()=>{Z(),E.emit()}))},item:(r,s)=>(m.current.add(r),s&&(u.current.has(s)?u.current.get(s).add(r):u.current.set(s,new Set([r]))),x(3,()=>{O(),Z(),t.current.value||_(),E.emit()}),()=>{i.current.delete(r),m.current.delete(r),t.current.filtered.items.delete(r);let f=V();x(4,()=>{O(),(f==null?void 0:f.getAttribute("id"))===r&&_(),E.emit()})}),group:r=>(u.current.has(r)||u.current.set(r,new Set),()=>{i.current.delete(r),u.current.delete(r)}),filter:()=>c.current.shouldFilter,label:y||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:q,inputId:G,labelId:A,listInnerRef:M}),[]);function J(r,s){var f,l;let h=(l=(f=c.current)==null?void 0:f.filter)!=null?l:et;return r?h(r,t.current.search,s):0}function Z(){if(!t.current.search||c.current.shouldFilter===!1)return;let r=t.current.filtered.items,s=[];t.current.filtered.groups.forEach(l=>{let h=u.current.get(l),b=0;h.forEach(j=>{let S=r.get(j);b=Math.max(S,b)}),s.push([l,b])});let f=M.current;Q().sort((l,h)=>{var b,j;let S=l.getAttribute("id"),X=h.getAttribute("id");return((b=r.get(X))!=null?b:0)-((j=r.get(S))!=null?j:0)}).forEach(l=>{let h=l.closest(ae);h?h.appendChild(l.parentElement===h?l:l.closest(`${ae} > *`)):f.appendChild(l.parentElement===f?l:l.closest(`${ae} > *`))}),s.sort((l,h)=>h[1]-l[1]).forEach(l=>{var h;let b=(h=M.current)==null?void 0:h.querySelector(`${T}[${B}="${encodeURIComponent(l[0])}"]`);b==null||b.parentElement.appendChild(b)})}function _(){let r=Q().find(f=>f.getAttribute("aria-disabled")!=="true"),s=r==null?void 0:r.getAttribute(B);E.setState("value",s||void 0)}function O(){var r,s,f,l;if(!t.current.search||c.current.shouldFilter===!1){t.current.filtered.count=m.current.size;return}t.current.filtered.groups=new Set;let h=0;for(let b of m.current){let j=(s=(r=i.current.get(b))==null?void 0:r.value)!=null?s:"",S=(l=(f=i.current.get(b))==null?void 0:f.keywords)!=null?l:[],X=J(j,S);t.current.filtered.items.set(b,X),X>0&&h++}for(let[b,j]of u.current)for(let S of j)if(t.current.filtered.items.get(S)>0){t.current.filtered.groups.add(b);break}t.current.filtered.count=h}function ie(){var r,s,f;let l=V();l&&(((r=l.parentElement)==null?void 0:r.firstChild)===l&&((f=(s=l.closest(T))==null?void 0:s.querySelector(Oe))==null||f.scrollIntoView({block:"nearest"})),l.scrollIntoView({block:"nearest"}))}function V(){var r;return(r=M.current)==null?void 0:r.querySelector(`${ge}[aria-selected="true"]`)}function Q(){var r;return Array.from(((r=M.current)==null?void 0:r.querySelectorAll(ve))||[])}function ee(r){let s=Q()[r];s&&E.setState("value",s.getAttribute(B))}function te(r){var s;let f=V(),l=Q(),h=l.findIndex(j=>j===f),b=l[h+r];(s=c.current)!=null&&s.loop&&(b=h+r<0?l[l.length-1]:h+r===l.length?l[0]:l[h+r]),b&&E.setState("value",b.getAttribute(B))}function se(r){let s=V(),f=s==null?void 0:s.closest(T),l;for(;f&&!l;)f=r>0?st(f,T):ct(f,T),l=f==null?void 0:f.querySelector(ve);l?E.setState("value",l.getAttribute(B)):te(r)}let ce=()=>ee(Q().length-1),de=r=>{r.preventDefault(),r.metaKey?ce():r.altKey?se(1):te(1)},me=r=>{r.preventDefault(),r.metaKey?ee(0):r.altKey?se(-1):te(-1)};return a.createElement(L.div,{ref:n,tabIndex:-1,...F,"cmdk-root":"",onKeyDown:r=>{var s;(s=F.onKeyDown)==null||s.call(F,r);let f=r.nativeEvent.isComposing||r.keyCode===229;if(!(r.defaultPrevented||f))switch(r.key){case"n":case"j":{R&&r.ctrlKey&&de(r);break}case"ArrowDown":{de(r);break}case"p":case"k":{R&&r.ctrlKey&&me(r);break}case"ArrowUp":{me(r);break}case"Home":{r.preventDefault(),ee(0);break}case"End":{r.preventDefault(),ce();break}case"Enter":{r.preventDefault();let l=V();if(l){let h=new Event(ue);l.dispatchEvent(h)}}}}},a.createElement("label",{"cmdk-label":"",htmlFor:w.inputId,id:w.labelId,style:ft},y),Y(e,r=>a.createElement(be.Provider,{value:E},a.createElement(xe.Provider,{value:w},r))))}),tt=a.forwardRef((e,n)=>{var t,m;let u=z(),i=a.useRef(null),d=a.useContext(ye),c=W(),y=ke(e),o=(m=(t=y.current)==null?void 0:t.forceMount)!=null?m:d==null?void 0:d.forceMount;K(()=>{if(!o)return c.item(u,d==null?void 0:d.id)},[o]);let v=Ee(u,i,[e.value,e.children,i],e.keywords),g=oe(),C=$(x=>x.value&&x.value===v.current),k=$(x=>o||c.filter()===!1?!0:x.search?x.filtered.items.get(u)>0:!0);a.useEffect(()=>{let x=i.current;if(!(!x||e.disabled))return x.addEventListener(ue,I),()=>x.removeEventListener(ue,I)},[k,e.onSelect,e.disabled]);function I(){var x,E;P(),(E=(x=y.current).onSelect)==null||E.call(x,v.current)}function P(){g.setState("value",v.current,!0)}if(!k)return null;let{disabled:R,value:F,onSelect:q,forceMount:A,keywords:G,...M}=e;return a.createElement(L.div,{ref:H(i,n),...M,id:u,"cmdk-item":"",role:"option","aria-disabled":!!R,"aria-selected":!!C,"data-disabled":!!R,"data-selected":!!C,onPointerMove:R||c.getDisablePointerSelection()?void 0:P,onClick:R?void 0:I},e.children)}),rt=a.forwardRef((e,n)=>{let{heading:t,children:m,forceMount:u,...i}=e,d=z(),c=a.useRef(null),y=a.useRef(null),o=z(),v=W(),g=$(k=>u||v.filter()===!1?!0:k.search?k.filtered.groups.has(d):!0);K(()=>v.group(d),[]),Ee(d,c,[e.value,e.heading,y]);let C=a.useMemo(()=>({id:d,forceMount:u}),[u]);return a.createElement(L.div,{ref:H(c,n),...i,"cmdk-group":"",role:"presentation",hidden:g?void 0:!0},t&&a.createElement("div",{ref:y,"cmdk-group-heading":"","aria-hidden":!0,id:o},t),Y(e,k=>a.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?o:void 0},a.createElement(ye.Provider,{value:C},k))))}),nt=a.forwardRef((e,n)=>{let{alwaysRender:t,...m}=e,u=a.useRef(null),i=$(d=>!d.search);return!t&&!i?null:a.createElement(L.div,{ref:H(u,n),...m,"cmdk-separator":"",role:"separator"})}),at=a.forwardRef((e,n)=>{let{onValueChange:t,...m}=e,u=e.value!=null,i=oe(),d=$(o=>o.search),c=$(o=>o.selectedItemId),y=W();return a.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),a.createElement(L.input,{ref:n,...m,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":y.listId,"aria-labelledby":y.labelId,"aria-activedescendant":c,id:y.inputId,type:"text",value:u?e.value:d,onChange:o=>{u||i.setState("search",o.target.value),t==null||t(o.target.value)}})}),lt=a.forwardRef((e,n)=>{let{children:t,label:m="Suggestions",...u}=e,i=a.useRef(null),d=a.useRef(null),c=$(o=>o.selectedItemId),y=W();return a.useEffect(()=>{if(d.current&&i.current){let o=d.current,v=i.current,g,C=new ResizeObserver(()=>{g=requestAnimationFrame(()=>{let k=o.offsetHeight;v.style.setProperty("--cmdk-list-height",k.toFixed(1)+"px")})});return C.observe(o),()=>{cancelAnimationFrame(g),C.unobserve(o)}}},[]),a.createElement(L.div,{ref:H(i,n),...u,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":m,id:y.listId},Y(e,o=>a.createElement("div",{ref:H(d,y.listInnerRef),"cmdk-list-sizer":""},o)))}),ut=a.forwardRef((e,n)=>{let{open:t,onOpenChange:m,overlayClassName:u,contentClassName:i,container:d,...c}=e;return a.createElement(Me,{open:t,onOpenChange:m},a.createElement(De,{container:d},a.createElement($e,{"cmdk-overlay":"",className:u}),a.createElement(Le,{"aria-label":e.label,"cmdk-dialog":"",className:i},a.createElement(we,{ref:n,...c}))))}),ot=a.forwardRef((e,n)=>$(t=>t.filtered.count===0)?a.createElement(L.div,{ref:n,...e,"cmdk-empty":"",role:"presentation"}):null),it=a.forwardRef((e,n)=>{let{progress:t,children:m,label:u="Loading...",...i}=e;return a.createElement(L.div,{ref:n,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":u},Y(e,d=>a.createElement("div",{"aria-hidden":!0},d)))}),N=Object.assign(we,{List:lt,Item:tt,Input:at,Group:rt,Separator:nt,Dialog:ut,Empty:ot,Loading:it});function st(e,n){let t=e.nextElementSibling;for(;t;){if(t.matches(n))return t;t=t.nextElementSibling}}function ct(e,n){let t=e.previousElementSibling;for(;t;){if(t.matches(n))return t;t=t.previousElementSibling}}function ke(e){let n=a.useRef(e);return K(()=>{n.current=e}),n}var K=typeof window>"u"?a.useEffect:a.useLayoutEffect;function U(e){let n=a.useRef();return n.current===void 0&&(n.current=e()),n}function $(e){let n=oe(),t=()=>e(n.snapshot());return a.useSyncExternalStore(n.subscribe,t,t)}function Ee(e,n,t,m=[]){let u=a.useRef(),i=W();return K(()=>{var d;let c=(()=>{var o;for(let v of t){if(typeof v=="string")return v.trim();if(typeof v=="object"&&"current"in v)return v.current?(o=v.current.textContent)==null?void 0:o.trim():u.current}})(),y=m.map(o=>o.trim());i.value(e,c,y),(d=n.current)==null||d.setAttribute(B,c),u.current=c}),u}var dt=()=>{let[e,n]=a.useState(),t=U(()=>new Map);return K(()=>{t.current.forEach(m=>m()),t.current=new Map},[e]),(m,u)=>{t.current.set(m,u),n({})}};function mt(e){let n=e.type;return typeof n=="function"?n(e.props):"render"in n?n.render(e.props):e}function Y({asChild:e,children:n},t){return e&&a.isValidElement(n)?a.cloneElement(mt(n),{ref:n.ref},t(n.props.children)):t(n)}var ft={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Se=a.forwardRef(({className:e,...n},t)=>p.jsx(N,{ref:t,className:D("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...n}));Se.displayName=N.displayName;const Ce=a.forwardRef(({className:e,...n},t)=>p.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[p.jsx(Ue,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),p.jsx(N.Input,{ref:t,className:D("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...n})]}));Ce.displayName=N.Input.displayName;const Ne=a.forwardRef(({className:e,...n},t)=>p.jsx(N.List,{ref:t,className:D("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...n}));Ne.displayName=N.List.displayName;const je=a.forwardRef((e,n)=>p.jsx(N.Empty,{ref:n,className:"py-6 text-center text-sm",...e}));je.displayName=N.Empty.displayName;const Ie=a.forwardRef(({className:e,...n},t)=>p.jsx(N.Group,{ref:t,className:D("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...n}));Ie.displayName=N.Group.displayName;const pt=a.forwardRef(({className:e,...n},t)=>p.jsx(N.Separator,{ref:t,className:D("-mx-1 h-px bg-border",e),...n}));pt.displayName=N.Separator.displayName;const Re=a.forwardRef(({className:e,...n},t)=>p.jsx(N.Item,{ref:t,className:D("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...n}));Re.displayName=N.Item.displayName;const vt=250;function kt({value:e,onChange:n,placeholder:t="Select...",searchPlaceholder:m="Search...",emptyMessage:u="No results found.",errorMessage:i,disabled:d=!1,selectedOption:c,queryKey:y,queryFn:o,enabled:v=!0,className:g,ariaLabel:C}){const[k,I]=a.useState(!1),[P,R]=a.useState(""),[F,q]=a.useState("");a.useEffect(()=>{const w=window.setTimeout(()=>{q(P.trim())},vt);return()=>window.clearTimeout(w)},[P]),a.useEffect(()=>{k||(R(""),q(""))},[k]);const{data:A=[],isFetching:G,isError:M}=Pe({queryKey:[...y,F],queryFn:()=>o(F),enabled:v&&k}),x=a.useMemo(()=>!e||A.some(w=>w.value===e)?A:(c==null?void 0:c.value)===e?[c,...A]:A,[A,c,e]),E=a.useMemo(()=>{if(!e)return t;const w=x.find(J=>J.value===e)??((c==null?void 0:c.value)===e?c:null);return(w==null?void 0:w.label)??t},[x,t,c,e]);return p.jsxs(qe,{open:k,onOpenChange:I,modal:!0,children:[p.jsx(Ve,{asChild:!0,children:p.jsxs(Ke,{type:"button",variant:"outline",role:"combobox","aria-expanded":k,"aria-label":C,disabled:d,className:D("h-8 w-full justify-between px-2 text-sm font-normal",!e&&"text-muted-foreground",g),children:[p.jsx("span",{className:"truncate",children:E}),p.jsx(Ge,{className:"ml-1 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),p.jsx(Be,{className:"z-[60] w-[var(--radix-popover-trigger-width)] max-h-[var(--radix-popover-content-available-height)] overflow-hidden p-0",align:"start",collisionPadding:8,onWheel:w=>w.stopPropagation(),children:p.jsxs(Se,{shouldFilter:!1,className:"h-full",children:[p.jsx(Ce,{placeholder:m,value:P,onValueChange:R}),p.jsx(Ne,{className:"max-h-[min(300px,calc(var(--radix-popover-content-available-height)-2.75rem))] min-h-0 overscroll-contain",children:G?p.jsxs("div",{className:"flex items-center justify-center py-6 text-sm text-muted-foreground",children:[p.jsx(ze,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading..."]}):M&&i?p.jsx("div",{className:"px-4 py-6 text-center text-sm text-destructive",role:"alert",children:i}):x.length===0?p.jsx(je,{children:u}):p.jsx(Ie,{children:x.map(w=>p.jsxs(Re,{value:w.value,onSelect:()=>{n(w.value,w),I(!1)},children:[p.jsx(Fe,{className:D("mr-2 h-4 w-4",e===w.value?"opacity-100":"opacity-0")}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate",children:w.label}),w.description?p.jsx("div",{className:"truncate text-xs text-muted-foreground",children:w.description}):null]})]},w.value))})})]})})]})}export{kt as S}; + */const Qe=Ae("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);var fe=1,Te=.9,Ge=.8,He=.17,re=.1,ne=.999,We=.9999,Je=.99,Xe=/[\\\/_+.#"@\[\(\{&]/,Ye=/[\\\/_+.#"@\[\(\{&]/g,Ze=/[\s-]/,he=/[\s-]/g;function le(e,n,t,m,u,i,d){if(i===n.length)return u===e.length?fe:Je;var c=`${u},${i}`;if(d[c]!==void 0)return d[c];for(var y=m.charAt(i),o=t.indexOf(y,u),v=0,g,C,k,j;o>=0;)g=le(e,n,t,m,o+1,i+1,d),g>v&&(o===u?g*=fe:Xe.test(e.charAt(o-1))?(g*=Ge,k=e.slice(u,o-1).match(Ye),k&&u>0&&(g*=Math.pow(ne,k.length))):Ze.test(e.charAt(o-1))?(g*=Te,j=e.slice(u,o-1).match(he),j&&u>0&&(g*=Math.pow(ne,j.length))):(g*=He,u>0&&(g*=Math.pow(ne,o-u))),e.charAt(o)!==n.charAt(i)&&(g*=We)),(gg&&(g=C*re)),g>v&&(v=g),o=t.indexOf(y,o+1);return d[c]=v,v}function pe(e){return e.toLowerCase().replace(he," ")}function _e(e,n,t){return e=t&&t.length>0?`${e+" "+t.join(" ")}`:e,le(e,n,pe(e),pe(n),0,0,{})}var G='[cmdk-group=""]',ae='[cmdk-group-items=""]',Oe='[cmdk-group-heading=""]',ge='[cmdk-item=""]',ve=`${ge}:not([aria-disabled="true"])`,ue="cmdk-item-select",B="data-value",et=(e,n,t)=>_e(e,n,t),xe=a.createContext(void 0),W=()=>a.useContext(xe),be=a.createContext(void 0),oe=()=>a.useContext(be),ye=a.createContext(void 0),we=a.forwardRef((e,n)=>{let t=U(()=>{var r,s;return{search:"",value:(s=(r=e.value)!=null?r:e.defaultValue)!=null?s:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),m=U(()=>new Set),u=U(()=>new Map),i=U(()=>new Map),d=U(()=>new Set),c=ke(e),{label:y,children:o,value:v,onValueChange:g,filter:C,shouldFilter:k,loop:j,disablePointerSelection:P=!1,vimBindings:R=!0,...F}=e,q=z(),A=z(),Q=z(),M=a.useRef(null),x=dt();K(()=>{if(v!==void 0){let r=v.trim();t.current.value=r,E.emit()}},[v]),K(()=>{x(6,ie)},[]);let E=a.useMemo(()=>({subscribe:r=>(d.current.add(r),()=>d.current.delete(r)),snapshot:()=>t.current,setState:(r,s,f)=>{var l,h,b,N;if(!Object.is(t.current[r],s)){if(t.current[r]=s,r==="search")O(),Z(),x(1,_);else if(r==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let S=document.getElementById(Q);S?S.focus():(l=document.getElementById(q))==null||l.focus()}if(x(7,()=>{var S;t.current.selectedItemId=(S=V())==null?void 0:S.id,E.emit()}),f||x(5,ie),((h=c.current)==null?void 0:h.value)!==void 0){let S=s??"";(N=(b=c.current).onValueChange)==null||N.call(b,S);return}}E.emit()}},emit:()=>{d.current.forEach(r=>r())}}),[]),w=a.useMemo(()=>({value:(r,s,f)=>{var l;s!==((l=i.current.get(r))==null?void 0:l.value)&&(i.current.set(r,{value:s,keywords:f}),t.current.filtered.items.set(r,J(s,f)),x(2,()=>{Z(),E.emit()}))},item:(r,s)=>(m.current.add(r),s&&(u.current.has(s)?u.current.get(s).add(r):u.current.set(s,new Set([r]))),x(3,()=>{O(),Z(),t.current.value||_(),E.emit()}),()=>{i.current.delete(r),m.current.delete(r),t.current.filtered.items.delete(r);let f=V();x(4,()=>{O(),(f==null?void 0:f.getAttribute("id"))===r&&_(),E.emit()})}),group:r=>(u.current.has(r)||u.current.set(r,new Set),()=>{i.current.delete(r),u.current.delete(r)}),filter:()=>c.current.shouldFilter,label:y||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:q,inputId:Q,labelId:A,listInnerRef:M}),[]);function J(r,s){var f,l;let h=(l=(f=c.current)==null?void 0:f.filter)!=null?l:et;return r?h(r,t.current.search,s):0}function Z(){if(!t.current.search||c.current.shouldFilter===!1)return;let r=t.current.filtered.items,s=[];t.current.filtered.groups.forEach(l=>{let h=u.current.get(l),b=0;h.forEach(N=>{let S=r.get(N);b=Math.max(S,b)}),s.push([l,b])});let f=M.current;T().sort((l,h)=>{var b,N;let S=l.getAttribute("id"),X=h.getAttribute("id");return((b=r.get(X))!=null?b:0)-((N=r.get(S))!=null?N:0)}).forEach(l=>{let h=l.closest(ae);h?h.appendChild(l.parentElement===h?l:l.closest(`${ae} > *`)):f.appendChild(l.parentElement===f?l:l.closest(`${ae} > *`))}),s.sort((l,h)=>h[1]-l[1]).forEach(l=>{var h;let b=(h=M.current)==null?void 0:h.querySelector(`${G}[${B}="${encodeURIComponent(l[0])}"]`);b==null||b.parentElement.appendChild(b)})}function _(){let r=T().find(f=>f.getAttribute("aria-disabled")!=="true"),s=r==null?void 0:r.getAttribute(B);E.setState("value",s||void 0)}function O(){var r,s,f,l;if(!t.current.search||c.current.shouldFilter===!1){t.current.filtered.count=m.current.size;return}t.current.filtered.groups=new Set;let h=0;for(let b of m.current){let N=(s=(r=i.current.get(b))==null?void 0:r.value)!=null?s:"",S=(l=(f=i.current.get(b))==null?void 0:f.keywords)!=null?l:[],X=J(N,S);t.current.filtered.items.set(b,X),X>0&&h++}for(let[b,N]of u.current)for(let S of N)if(t.current.filtered.items.get(S)>0){t.current.filtered.groups.add(b);break}t.current.filtered.count=h}function ie(){var r,s,f;let l=V();l&&(((r=l.parentElement)==null?void 0:r.firstChild)===l&&((f=(s=l.closest(G))==null?void 0:s.querySelector(Oe))==null||f.scrollIntoView({block:"nearest"})),l.scrollIntoView({block:"nearest"}))}function V(){var r;return(r=M.current)==null?void 0:r.querySelector(`${ge}[aria-selected="true"]`)}function T(){var r;return Array.from(((r=M.current)==null?void 0:r.querySelectorAll(ve))||[])}function ee(r){let s=T()[r];s&&E.setState("value",s.getAttribute(B))}function te(r){var s;let f=V(),l=T(),h=l.findIndex(N=>N===f),b=l[h+r];(s=c.current)!=null&&s.loop&&(b=h+r<0?l[l.length-1]:h+r===l.length?l[0]:l[h+r]),b&&E.setState("value",b.getAttribute(B))}function se(r){let s=V(),f=s==null?void 0:s.closest(G),l;for(;f&&!l;)f=r>0?st(f,G):ct(f,G),l=f==null?void 0:f.querySelector(ve);l?E.setState("value",l.getAttribute(B)):te(r)}let ce=()=>ee(T().length-1),de=r=>{r.preventDefault(),r.metaKey?ce():r.altKey?se(1):te(1)},me=r=>{r.preventDefault(),r.metaKey?ee(0):r.altKey?se(-1):te(-1)};return a.createElement(L.div,{ref:n,tabIndex:-1,...F,"cmdk-root":"",onKeyDown:r=>{var s;(s=F.onKeyDown)==null||s.call(F,r);let f=r.nativeEvent.isComposing||r.keyCode===229;if(!(r.defaultPrevented||f))switch(r.key){case"n":case"j":{R&&r.ctrlKey&&de(r);break}case"ArrowDown":{de(r);break}case"p":case"k":{R&&r.ctrlKey&&me(r);break}case"ArrowUp":{me(r);break}case"Home":{r.preventDefault(),ee(0);break}case"End":{r.preventDefault(),ce();break}case"Enter":{r.preventDefault();let l=V();if(l){let h=new Event(ue);l.dispatchEvent(h)}}}}},a.createElement("label",{"cmdk-label":"",htmlFor:w.inputId,id:w.labelId,style:ft},y),Y(e,r=>a.createElement(be.Provider,{value:E},a.createElement(xe.Provider,{value:w},r))))}),tt=a.forwardRef((e,n)=>{var t,m;let u=z(),i=a.useRef(null),d=a.useContext(ye),c=W(),y=ke(e),o=(m=(t=y.current)==null?void 0:t.forceMount)!=null?m:d==null?void 0:d.forceMount;K(()=>{if(!o)return c.item(u,d==null?void 0:d.id)},[o]);let v=Ee(u,i,[e.value,e.children,i],e.keywords),g=oe(),C=$(x=>x.value&&x.value===v.current),k=$(x=>o||c.filter()===!1?!0:x.search?x.filtered.items.get(u)>0:!0);a.useEffect(()=>{let x=i.current;if(!(!x||e.disabled))return x.addEventListener(ue,j),()=>x.removeEventListener(ue,j)},[k,e.onSelect,e.disabled]);function j(){var x,E;P(),(E=(x=y.current).onSelect)==null||E.call(x,v.current)}function P(){g.setState("value",v.current,!0)}if(!k)return null;let{disabled:R,value:F,onSelect:q,forceMount:A,keywords:Q,...M}=e;return a.createElement(L.div,{ref:H(i,n),...M,id:u,"cmdk-item":"",role:"option","aria-disabled":!!R,"aria-selected":!!C,"data-disabled":!!R,"data-selected":!!C,onPointerMove:R||c.getDisablePointerSelection()?void 0:P,onClick:R?void 0:j},e.children)}),rt=a.forwardRef((e,n)=>{let{heading:t,children:m,forceMount:u,...i}=e,d=z(),c=a.useRef(null),y=a.useRef(null),o=z(),v=W(),g=$(k=>u||v.filter()===!1?!0:k.search?k.filtered.groups.has(d):!0);K(()=>v.group(d),[]),Ee(d,c,[e.value,e.heading,y]);let C=a.useMemo(()=>({id:d,forceMount:u}),[u]);return a.createElement(L.div,{ref:H(c,n),...i,"cmdk-group":"",role:"presentation",hidden:g?void 0:!0},t&&a.createElement("div",{ref:y,"cmdk-group-heading":"","aria-hidden":!0,id:o},t),Y(e,k=>a.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?o:void 0},a.createElement(ye.Provider,{value:C},k))))}),nt=a.forwardRef((e,n)=>{let{alwaysRender:t,...m}=e,u=a.useRef(null),i=$(d=>!d.search);return!t&&!i?null:a.createElement(L.div,{ref:H(u,n),...m,"cmdk-separator":"",role:"separator"})}),at=a.forwardRef((e,n)=>{let{onValueChange:t,...m}=e,u=e.value!=null,i=oe(),d=$(o=>o.search),c=$(o=>o.selectedItemId),y=W();return a.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),a.createElement(L.input,{ref:n,...m,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":y.listId,"aria-labelledby":y.labelId,"aria-activedescendant":c,id:y.inputId,type:"text",value:u?e.value:d,onChange:o=>{u||i.setState("search",o.target.value),t==null||t(o.target.value)}})}),lt=a.forwardRef((e,n)=>{let{children:t,label:m="Suggestions",...u}=e,i=a.useRef(null),d=a.useRef(null),c=$(o=>o.selectedItemId),y=W();return a.useEffect(()=>{if(d.current&&i.current){let o=d.current,v=i.current,g,C=new ResizeObserver(()=>{g=requestAnimationFrame(()=>{let k=o.offsetHeight;v.style.setProperty("--cmdk-list-height",k.toFixed(1)+"px")})});return C.observe(o),()=>{cancelAnimationFrame(g),C.unobserve(o)}}},[]),a.createElement(L.div,{ref:H(i,n),...u,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":m,id:y.listId},Y(e,o=>a.createElement("div",{ref:H(d,y.listInnerRef),"cmdk-list-sizer":""},o)))}),ut=a.forwardRef((e,n)=>{let{open:t,onOpenChange:m,overlayClassName:u,contentClassName:i,container:d,...c}=e;return a.createElement(Me,{open:t,onOpenChange:m},a.createElement(De,{container:d},a.createElement($e,{"cmdk-overlay":"",className:u}),a.createElement(Le,{"aria-label":e.label,"cmdk-dialog":"",className:i},a.createElement(we,{ref:n,...c}))))}),ot=a.forwardRef((e,n)=>$(t=>t.filtered.count===0)?a.createElement(L.div,{ref:n,...e,"cmdk-empty":"",role:"presentation"}):null),it=a.forwardRef((e,n)=>{let{progress:t,children:m,label:u="Loading...",...i}=e;return a.createElement(L.div,{ref:n,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":u},Y(e,d=>a.createElement("div",{"aria-hidden":!0},d)))}),I=Object.assign(we,{List:lt,Item:tt,Input:at,Group:rt,Separator:nt,Dialog:ut,Empty:ot,Loading:it});function st(e,n){let t=e.nextElementSibling;for(;t;){if(t.matches(n))return t;t=t.nextElementSibling}}function ct(e,n){let t=e.previousElementSibling;for(;t;){if(t.matches(n))return t;t=t.previousElementSibling}}function ke(e){let n=a.useRef(e);return K(()=>{n.current=e}),n}var K=typeof window>"u"?a.useEffect:a.useLayoutEffect;function U(e){let n=a.useRef();return n.current===void 0&&(n.current=e()),n}function $(e){let n=oe(),t=()=>e(n.snapshot());return a.useSyncExternalStore(n.subscribe,t,t)}function Ee(e,n,t,m=[]){let u=a.useRef(),i=W();return K(()=>{var d;let c=(()=>{var o;for(let v of t){if(typeof v=="string")return v.trim();if(typeof v=="object"&&"current"in v)return v.current?(o=v.current.textContent)==null?void 0:o.trim():u.current}})(),y=m.map(o=>o.trim());i.value(e,c,y),(d=n.current)==null||d.setAttribute(B,c),u.current=c}),u}var dt=()=>{let[e,n]=a.useState(),t=U(()=>new Map);return K(()=>{t.current.forEach(m=>m()),t.current=new Map},[e]),(m,u)=>{t.current.set(m,u),n({})}};function mt(e){let n=e.type;return typeof n=="function"?n(e.props):"render"in n?n.render(e.props):e}function Y({asChild:e,children:n},t){return e&&a.isValidElement(n)?a.cloneElement(mt(n),{ref:n.ref},t(n.props.children)):t(n)}var ft={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Se=a.forwardRef(({className:e,...n},t)=>p.jsx(I,{ref:t,className:D("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...n}));Se.displayName=I.displayName;const Ce=a.forwardRef(({className:e,...n},t)=>p.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[p.jsx(Ue,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),p.jsx(I.Input,{ref:t,className:D("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...n})]}));Ce.displayName=I.Input.displayName;const Ie=a.forwardRef(({className:e,...n},t)=>p.jsx(I.List,{ref:t,className:D("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...n}));Ie.displayName=I.List.displayName;const Ne=a.forwardRef((e,n)=>p.jsx(I.Empty,{ref:n,className:"py-6 text-center text-sm",...e}));Ne.displayName=I.Empty.displayName;const je=a.forwardRef(({className:e,...n},t)=>p.jsx(I.Group,{ref:t,className:D("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...n}));je.displayName=I.Group.displayName;const pt=a.forwardRef(({className:e,...n},t)=>p.jsx(I.Separator,{ref:t,className:D("-mx-1 h-px bg-border",e),...n}));pt.displayName=I.Separator.displayName;const Re=a.forwardRef(({className:e,...n},t)=>p.jsx(I.Item,{ref:t,className:D("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...n}));Re.displayName=I.Item.displayName;const vt=250;function kt({value:e,onChange:n,placeholder:t="Select...",searchPlaceholder:m="Search...",emptyMessage:u="No results found.",errorMessage:i,disabled:d=!1,selectedOption:c,queryKey:y,queryFn:o,enabled:v=!0,className:g,ariaLabel:C}){const[k,j]=a.useState(!1),[P,R]=a.useState(""),[F,q]=a.useState("");a.useEffect(()=>{const w=window.setTimeout(()=>{q(P.trim())},vt);return()=>window.clearTimeout(w)},[P]),a.useEffect(()=>{k||(R(""),q(""))},[k]);const{data:A=[],isFetching:Q,isError:M}=Pe({queryKey:[...y,F],queryFn:()=>o(F),enabled:v&&k}),x=a.useMemo(()=>!e||A.some(w=>w.value===e)?A:(c==null?void 0:c.value)===e?[c,...A]:A,[A,c,e]),E=a.useMemo(()=>{if(!e)return t;const w=x.find(J=>J.value===e)??((c==null?void 0:c.value)===e?c:null);return(w==null?void 0:w.label)??t},[x,t,c,e]);return p.jsxs(qe,{open:k,onOpenChange:j,modal:!0,children:[p.jsx(Ve,{asChild:!0,children:p.jsxs(Ke,{type:"button",variant:"outline",role:"combobox","aria-expanded":k,"aria-label":C,disabled:d,className:D("h-8 w-full justify-between px-2 text-sm font-normal",!e&&"text-muted-foreground",g),children:[p.jsx("span",{className:"truncate",children:E}),p.jsx(Qe,{className:"ml-1 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),p.jsx(Be,{className:"z-[60] w-[var(--radix-popover-trigger-width)] max-h-[var(--radix-popover-content-available-height)] overflow-hidden p-0",align:"start",collisionPadding:8,onWheel:w=>w.stopPropagation(),children:p.jsxs(Se,{shouldFilter:!1,className:"h-full",children:[p.jsx(Ce,{placeholder:m,value:P,onValueChange:R}),p.jsx(Ie,{className:"max-h-[min(300px,calc(var(--radix-popover-content-available-height)-2.75rem))] min-h-0 overscroll-contain",children:Q?p.jsxs("div",{className:"flex items-center justify-center py-6 text-sm text-muted-foreground",children:[p.jsx(ze,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading..."]}):M&&i?p.jsx("div",{className:"px-4 py-6 text-center text-sm text-destructive",role:"alert",children:i}):x.length===0?p.jsx(Ne,{children:u}):p.jsx(je,{children:x.map(w=>p.jsxs(Re,{value:w.value,onSelect:()=>{n(w.value,w),j(!1)},children:[p.jsx(Fe,{className:D("mr-2 h-4 w-4",e===w.value?"opacity-100":"opacity-0")}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate",children:w.label}),w.description?p.jsx("div",{className:"truncate text-xs text-muted-foreground",children:w.description}):null]})]},w.value))})})]})})]})}export{kt as S}; diff --git a/assets/share-2-fiavn5SS.js b/assets/share-2-Nvga0TP8.js similarity index 91% rename from assets/share-2-fiavn5SS.js rename to assets/share-2-Nvga0TP8.js index b138b2f1d8e23ad01c39c92a4fb2c104df3332ba..f947b1dd7c1a1de70c12af839c56a3df9e01d8ef 100644 --- a/assets/share-2-fiavn5SS.js +++ b/assets/share-2-Nvga0TP8.js @@ -1,4 +1,4 @@ -import{s as c}from"./index-DyXq7-Tg.js";/** +import{s as c}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/skeleton-C3IIzpSL.js b/assets/skeleton-DTWi7Ctg.js similarity index 62% rename from assets/skeleton-C3IIzpSL.js rename to assets/skeleton-DTWi7Ctg.js index 03f97af4bb7706616e887cf3da8124cbe9a356a4..dcbf13313b98f64f6d84564c800dbf4239428ee0 100644 --- a/assets/skeleton-C3IIzpSL.js +++ b/assets/skeleton-DTWi7Ctg.js @@ -1 +1 @@ -import{j as t,G as n}from"./index-DyXq7-Tg.js";function m({className:e,...s}){return t.jsx("div",{className:n("animate-pulse rounded-md bg-muted",e),...s})}export{m as S}; +import{j as t,I as n}from"./index-CjdUkE4w.js";function m({className:e,...s}){return t.jsx("div",{className:n("animate-pulse rounded-md bg-muted",e),...s})}export{m as S}; diff --git a/assets/sparkles-CcIiUzzc.js b/assets/sparkles-CIfeDmV2.js similarity index 93% rename from assets/sparkles-CcIiUzzc.js rename to assets/sparkles-CIfeDmV2.js index 4c28f38b101e548dbed5739a2268733bdac7a14f..917722b031ec319be9fbdf2a03a49638bdd23605 100644 --- a/assets/sparkles-CcIiUzzc.js +++ b/assets/sparkles-CIfeDmV2.js @@ -1,4 +1,4 @@ -import{s as a}from"./index-DyXq7-Tg.js";/** +import{s as a}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/submissions-Cz_J-Ha2.js b/assets/submissions-CQ6M0giV.js similarity index 99% rename from assets/submissions-Cz_J-Ha2.js rename to assets/submissions-CQ6M0giV.js index 9fd3751f285a172d5350030f0263fe98d7677bd7..2910e88f7e18f01aa462a2928741482ac0cd3605 100644 --- a/assets/submissions-Cz_J-Ha2.js +++ b/assets/submissions-CQ6M0giV.js @@ -1 +1 @@ -import{ac as Fe}from"./index-DyXq7-Tg.js";var v;(function(s){s.assertEqual=a=>{};function e(a){}s.assertIs=e;function t(a){throw new Error}s.assertNever=t,s.arrayToEnum=a=>{const n={};for(const i of a)n[i]=i;return n},s.getValidEnumValues=a=>{const n=s.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),i={};for(const o of n)i[o]=a[o];return s.objectValues(i)},s.objectValues=a=>s.objectKeys(a).map(function(n){return a[n]}),s.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const n=[];for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&n.push(i);return n},s.find=(a,n)=>{for(const i of a)if(n(i))return i},s.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function r(a,n=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(n)}s.joinValues=r,s.jsonStringifyReplacer=(a,n)=>typeof n=="bigint"?n.toString():n})(v||(v={}));var Se;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Se||(Se={}));const u=v.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$=s=>{switch(typeof s){case"undefined":return u.undefined;case"string":return u.string;case"number":return Number.isNaN(s)?u.nan:u.number;case"boolean":return u.boolean;case"function":return u.function;case"bigint":return u.bigint;case"symbol":return u.symbol;case"object":return Array.isArray(s)?u.array:s===null?u.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?u.promise:typeof Map<"u"&&s instanceof Map?u.map:typeof Set<"u"&&s instanceof Set?u.set:typeof Date<"u"&&s instanceof Date?u.date:u.object;default:return u.unknown}},d=v.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class I extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(n){return n.message},r={_errors:[]},a=n=>{for(const i of n.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,f=0;for(;ft.message){const t={},r=[];for(const a of this.issues)if(a.path.length>0){const n=a.path[0];t[n]=t[n]||[],t[n].push(e(a))}else r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}I.create=s=>new I(s);const le=(s,e)=>{let t;switch(s.code){case d.invalid_type:s.received===u.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,v.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${v.joinValues(s.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${v.joinValues(s.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${v.joinValues(s.options)}, received '${s.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:v.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case d.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case d.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,v.assertNever(s)}return{message:t}};let We=le;function Je(){return We}const Ye=s=>{const{data:e,path:t,errorMaps:r,issueData:a}=s,n=[...t,...a.path||[]],i={...a,path:n};if(a.message!==void 0)return{...a,path:n,message:a.message};let o="";const f=r.filter(p=>!!p).slice().reverse();for(const p of f)o=p(i,{data:e,defaultError:o}).message;return{...a,path:n,message:o}};function c(s,e){const t=Je(),r=Ye({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===le?void 0:le].filter(a=>!!a)});s.common.issues.push(r)}class C{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const a of t){if(a.status==="aborted")return m;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const a of t){const n=await a.key,i=await a.value;r.push({key:n,value:i})}return C.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const a of t){const{key:n,value:i}=a;if(n.status==="aborted"||i.status==="aborted")return m;n.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(r[n.value]=i.value)}return{status:e.value,value:r}}}const m=Object.freeze({status:"aborted"}),J=s=>({status:"dirty",value:s}),O=s=>({status:"valid",value:s}),Ce=s=>s.status==="aborted",Oe=s=>s.status==="dirty",B=s=>s.status==="valid",X=s=>typeof Promise<"u"&&s instanceof Promise;var h;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(h||(h={}));class E{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ne=(s,e)=>{if(B(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new I(s.common.issues);return this._error=t,this._error}}};function g(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:a}=s;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,o)=>{const{message:f}=s;return i.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:f??r??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:f??t??o.defaultError}},description:a}}class y{get description(){return this._def.description}_getType(e){return $(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new C,ctx:{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(X(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Ne(r,a)}"~validate"(e){var r,a;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return B(n)?{value:n.value}:{issues:t.common.issues}}catch(n){(a=(r=n==null?void 0:n.message)==null?void 0:r.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(n=>B(n)?{value:n.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)},a=this._parse({data:e,path:r.path,parent:r}),n=await(X(a)?a:Promise.resolve(a));return Ne(r,n)}refine(e,t){const r=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,n)=>{const i=e(a),o=()=>n.addIssue({code:d.custom,...r(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(f=>f?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof t=="function"?t(r,a):t),!1))}_refinement(e){return new L({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return j.create(this,this._def)}nullable(){return D.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return N.create(this)}promise(){return ae.create(this,this._def)}or(e){return ee.create([this,e],this._def)}and(e){return te.create(this,e,this._def)}transform(e){return new L({...g(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ne({...g(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new ze({typeName:_.ZodBranded,type:this,...g(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ie({...g(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return be.create(this,e)}readonly(){return oe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const He=/^c[^\s-]{8,}$/i,Ge=/^[0-9a-z]+$/,Qe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Xe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ke=/^[a-z0-9_-]{21}$/i,et=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,tt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,st=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ue;const at=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,nt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,it=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ot=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,dt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ct=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,$e="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ut=new RegExp(`^${$e}$`);function Pe(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);const t=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function lt(s){return new RegExp(`^${Pe(s)}$`)}function ht(s){let e=`${$e}T${Pe(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function ft(s,e){return!!((e==="v4"||!e)&&at.test(s)||(e==="v6"||!e)&&it.test(s))}function pt(s,e){if(!et.test(s))return!1;try{const[t]=s.split(".");if(!t)return!1;const r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(r));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function mt(s,e){return!!((e==="v4"||!e)&&nt.test(s)||(e==="v6"||!e)&&ot.test(s))}class R extends y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==u.string){const n=this._getOrReturnCtx(e);return c(n,{code:d.invalid_type,expected:u.string,received:n.parsedType}),m}const r=new C;let a;for(const n of this._def.checks)if(n.kind==="min")e.data.lengthn.value&&(a=this._getOrReturnCtx(e,a),c(a,{code:d.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="length"){const i=e.data.length>n.value,o=e.data.lengthe.test(a),{validation:t,code:d.invalid_string,...h.errToObj(r)})}_addCheck(e){return new R({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...h.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...h.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...h.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new R({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new R({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new R({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew R({checks:[],typeName:_.ZodString,coerce:(s==null?void 0:s.coerce)??!1,...g(s)});function _t(s,e){const t=(s.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=t>r?t:r,n=Number.parseInt(s.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return n%i/10**a}class q extends y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==u.number){const n=this._getOrReturnCtx(e);return c(n,{code:d.invalid_type,expected:u.number,received:n.parsedType}),m}let r;const a=new C;for(const n of this._def.checks)n.kind==="int"?v.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),c(r,{code:d.invalid_type,expected:"integer",received:"float",message:n.message}),a.dirty()):n.kind==="min"?(n.inclusive?e.datan.value:e.data>=n.value)&&(r=this._getOrReturnCtx(e,r),c(r,{code:d.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="multipleOf"?_t(e.data,n.value)!==0&&(r=this._getOrReturnCtx(e,r),c(r,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),c(r,{code:d.not_finite,message:n.message}),a.dirty()):v.assertNever(n);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,r,a){return new q({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:h.toString(a)}]})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.valuee.kind==="int"||e.kind==="multipleOf"&&v.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.valuenew q({checks:[],typeName:_.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...g(s)});class Y extends y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==u.bigint)return this._getInvalidInput(e);let r;const a=new C;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.datan.value:e.data>=n.value)&&(r=this._getOrReturnCtx(e,r),c(r,{code:d.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),c(r,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):v.assertNever(n);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return c(t,{code:d.invalid_type,expected:u.bigint,received:t.parsedType}),m}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,r,a){return new Y({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:h.toString(a)}]})}_addCheck(e){return new Y({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew Y({checks:[],typeName:_.ZodBigInt,coerce:(s==null?void 0:s.coerce)??!1,...g(s)});class he extends y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==u.boolean){const r=this._getOrReturnCtx(e);return c(r,{code:d.invalid_type,expected:u.boolean,received:r.parsedType}),m}return O(e.data)}}he.create=s=>new he({typeName:_.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...g(s)});class K extends y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==u.date){const n=this._getOrReturnCtx(e);return c(n,{code:d.invalid_type,expected:u.date,received:n.parsedType}),m}if(Number.isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return c(n,{code:d.invalid_date}),m}const r=new C;let a;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()n.value&&(a=this._getOrReturnCtx(e,a),c(a,{code:d.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):v.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new K({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew K({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:_.ZodDate,...g(s)});class Ae extends y{_parse(e){if(this._getType(e)!==u.symbol){const r=this._getOrReturnCtx(e);return c(r,{code:d.invalid_type,expected:u.symbol,received:r.parsedType}),m}return O(e.data)}}Ae.create=s=>new Ae({typeName:_.ZodSymbol,...g(s)});class fe extends y{_parse(e){if(this._getType(e)!==u.undefined){const r=this._getOrReturnCtx(e);return c(r,{code:d.invalid_type,expected:u.undefined,received:r.parsedType}),m}return O(e.data)}}fe.create=s=>new fe({typeName:_.ZodUndefined,...g(s)});class pe extends y{_parse(e){if(this._getType(e)!==u.null){const r=this._getOrReturnCtx(e);return c(r,{code:d.invalid_type,expected:u.null,received:r.parsedType}),m}return O(e.data)}}pe.create=s=>new pe({typeName:_.ZodNull,...g(s)});class Ee extends y{constructor(){super(...arguments),this._any=!0}_parse(e){return O(e.data)}}Ee.create=s=>new Ee({typeName:_.ZodAny,...g(s)});class me extends y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return O(e.data)}}me.create=s=>new me({typeName:_.ZodUnknown,...g(s)});class P extends y{_parse(e){const t=this._getOrReturnCtx(e);return c(t,{code:d.invalid_type,expected:u.never,received:t.parsedType}),m}}P.create=s=>new P({typeName:_.ZodNever,...g(s)});class Ze extends y{_parse(e){if(this._getType(e)!==u.undefined){const r=this._getOrReturnCtx(e);return c(r,{code:d.invalid_type,expected:u.void,received:r.parsedType}),m}return O(e.data)}}Ze.create=s=>new Ze({typeName:_.ZodVoid,...g(s)});class N extends y{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==u.array)return c(t,{code:d.invalid_type,expected:u.array,received:t.parsedType}),m;if(a.exactLength!==null){const i=t.data.length>a.exactLength.value,o=t.data.lengtha.maxLength.value&&(c(t,{code:d.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>a.type._parseAsync(new E(t,i,t.path,o)))).then(i=>C.mergeArray(r,i));const n=[...t.data].map((i,o)=>a.type._parseSync(new E(t,i,t.path,o)));return C.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new N({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new N({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new N({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}}N.create=(s,e)=>new N({type:s,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...g(e)});function U(s){if(s instanceof w){const e={};for(const t in s.shape){const r=s.shape[t];e[t]=j.create(U(r))}return new w({...s._def,shape:()=>e})}else return s instanceof N?new N({...s._def,type:U(s.element)}):s instanceof j?j.create(U(s.unwrap())):s instanceof D?D.create(U(s.unwrap())):s instanceof z?z.create(s.items.map(e=>U(e))):s}class w extends y{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=v.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==u.object){const p=this._getOrReturnCtx(e);return c(p,{code:d.invalid_type,expected:u.object,received:p.parsedType}),m}const{status:r,ctx:a}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof P&&this._def.unknownKeys==="strip"))for(const p in a.data)i.includes(p)||o.push(p);const f=[];for(const p of i){const x=n[p],W=a.data[p];f.push({key:{status:"valid",value:p},value:x._parse(new E(a,W,a.path,p)),alwaysSet:p in a.data})}if(this._def.catchall instanceof P){const p=this._def.unknownKeys;if(p==="passthrough")for(const x of o)f.push({key:{status:"valid",value:x},value:{status:"valid",value:a.data[x]}});else if(p==="strict")o.length>0&&(c(a,{code:d.unrecognized_keys,keys:o}),r.dirty());else if(p!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const p=this._def.catchall;for(const x of o){const W=a.data[x];f.push({key:{status:"valid",value:x},value:p._parse(new E(a,W,a.path,x)),alwaysSet:x in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const p=[];for(const x of f){const W=await x.key,qe=await x.value;p.push({key:W,value:qe,alwaysSet:x.alwaysSet})}return p}).then(p=>C.mergeObjectSync(r,p)):C.mergeObjectSync(r,f)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var n,i;const a=((i=(n=this._def).errorMap)==null?void 0:i.call(n,t,r).message)??r.defaultError;return t.code==="unrecognized_keys"?{message:h.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new w({...this._def,catchall:e})}pick(e){const t={};for(const r of v.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new w({...this._def,shape:()=>t})}omit(e){const t={};for(const r of v.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new w({...this._def,shape:()=>t})}deepPartial(){return U(this)}partial(e){const t={};for(const r of v.objectKeys(this.shape)){const a=this.shape[r];e&&!e[r]?t[r]=a:t[r]=a.optional()}return new w({...this._def,shape:()=>t})}required(e){const t={};for(const r of v.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let n=this.shape[r];for(;n instanceof j;)n=n._def.innerType;t[r]=n}return new w({...this._def,shape:()=>t})}keyof(){return Me(v.objectKeys(this.shape))}}w.create=(s,e)=>new w({shape:()=>s,unknownKeys:"strip",catchall:P.create(),typeName:_.ZodObject,...g(e)});w.strictCreate=(s,e)=>new w({shape:()=>s,unknownKeys:"strict",catchall:P.create(),typeName:_.ZodObject,...g(e)});w.lazycreate=(s,e)=>new w({shape:s,unknownKeys:"strip",catchall:P.create(),typeName:_.ZodObject,...g(e)});class ee extends y{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function a(n){for(const o of n)if(o.result.status==="valid")return o.result;for(const o of n)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=n.map(o=>new I(o.ctx.common.issues));return c(t,{code:d.invalid_union,unionErrors:i}),m}if(t.common.async)return Promise.all(r.map(async n=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(a);{let n;const i=[];for(const f of r){const p={...t,common:{...t.common,issues:[]},parent:null},x=f._parseSync({data:t.data,path:t.path,parent:p});if(x.status==="valid")return x;x.status==="dirty"&&!n&&(n={result:x,ctx:p}),p.common.issues.length&&i.push(p.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const o=i.map(f=>new I(f));return c(t,{code:d.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}ee.create=(s,e)=>new ee({options:s,typeName:_.ZodUnion,...g(e)});const Z=s=>s instanceof ge?Z(s.schema):s instanceof L?Z(s.innerType()):s instanceof re?[s.value]:s instanceof V?s.options:s instanceof ye?v.objectValues(s.enum):s instanceof ne?Z(s._def.innerType):s instanceof fe?[void 0]:s instanceof pe?[null]:s instanceof j?[void 0,...Z(s.unwrap())]:s instanceof D?[null,...Z(s.unwrap())]:s instanceof ze||s instanceof oe?Z(s.unwrap()):s instanceof ie?Z(s._def.innerType):[];class ke extends y{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.object)return c(t,{code:d.invalid_type,expected:u.object,received:t.parsedType}),m;const r=this.discriminator,a=t.data[r],n=this.optionsMap.get(a);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(c(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const a=new Map;for(const n of t){const i=Z(n.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(a.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);a.set(o,n)}}return new ke({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...g(r)})}}function _e(s,e){const t=$(s),r=$(e);if(s===e)return{valid:!0,data:s};if(t===u.object&&r===u.object){const a=v.objectKeys(e),n=v.objectKeys(s).filter(o=>a.indexOf(o)!==-1),i={...s,...e};for(const o of n){const f=_e(s[o],e[o]);if(!f.valid)return{valid:!1};i[o]=f.data}return{valid:!0,data:i}}else if(t===u.array&&r===u.array){if(s.length!==e.length)return{valid:!1};const a=[];for(let n=0;n{if(Ce(n)||Ce(i))return m;const o=_e(n.value,i.value);return o.valid?((Oe(n)||Oe(i))&&t.dirty(),{status:t.value,value:o.data}):(c(r,{code:d.invalid_intersection_types}),m)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([n,i])=>a(n,i)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}te.create=(s,e,t)=>new te({left:s,right:e,typeName:_.ZodIntersection,...g(t)});class z extends y{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==u.array)return c(r,{code:d.invalid_type,expected:u.array,received:r.parsedType}),m;if(r.data.lengththis._def.items.length&&(c(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...r.data].map((i,o)=>{const f=this._def.items[o]||this._def.rest;return f?f._parse(new E(r,i,r.path,o)):null}).filter(i=>!!i);return r.common.async?Promise.all(n).then(i=>C.mergeArray(t,i)):C.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new z({...this._def,rest:e})}}z.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new z({items:s,typeName:_.ZodTuple,rest:null,...g(e)})};class se extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==u.object)return c(r,{code:d.invalid_type,expected:u.object,received:r.parsedType}),m;const a=[],n=this._def.keyType,i=this._def.valueType;for(const o in r.data)a.push({key:n._parse(new E(r,o,r.path,o)),value:i._parse(new E(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?C.mergeObjectAsync(t,a):C.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof y?new se({keyType:e,valueType:t,typeName:_.ZodRecord,...g(r)}):new se({keyType:R.create(),valueType:e,typeName:_.ZodRecord,...g(t)})}}class Re extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==u.map)return c(r,{code:d.invalid_type,expected:u.map,received:r.parsedType}),m;const a=this._def.keyType,n=this._def.valueType,i=[...r.data.entries()].map(([o,f],p)=>({key:a._parse(new E(r,o,r.path,[p,"key"])),value:n._parse(new E(r,f,r.path,[p,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const f of i){const p=await f.key,x=await f.value;if(p.status==="aborted"||x.status==="aborted")return m;(p.status==="dirty"||x.status==="dirty")&&t.dirty(),o.set(p.value,x.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const f of i){const p=f.key,x=f.value;if(p.status==="aborted"||x.status==="aborted")return m;(p.status==="dirty"||x.status==="dirty")&&t.dirty(),o.set(p.value,x.value)}return{status:t.value,value:o}}}}Re.create=(s,e,t)=>new Re({valueType:e,keyType:s,typeName:_.ZodMap,...g(t)});class H extends y{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==u.set)return c(r,{code:d.invalid_type,expected:u.set,received:r.parsedType}),m;const a=this._def;a.minSize!==null&&r.data.sizea.maxSize.value&&(c(r,{code:d.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const n=this._def.valueType;function i(f){const p=new Set;for(const x of f){if(x.status==="aborted")return m;x.status==="dirty"&&t.dirty(),p.add(x.value)}return{status:t.value,value:p}}const o=[...r.data.values()].map((f,p)=>n._parse(new E(r,f,r.path,p)));return r.common.async?Promise.all(o).then(f=>i(f)):i(o)}min(e,t){return new H({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new H({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}H.create=(s,e)=>new H({valueType:s,minSize:null,maxSize:null,typeName:_.ZodSet,...g(e)});class ge extends y{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ge.create=(s,e)=>new ge({getter:s,typeName:_.ZodLazy,...g(e)});class re extends y{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return c(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}re.create=(s,e)=>new re({value:s,typeName:_.ZodLiteral,...g(e)});function Me(s,e){return new V({values:s,typeName:_.ZodEnum,...g(e)})}class V extends y{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return c(t,{expected:v.joinValues(r),received:t.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return c(t,{received:t.data,code:d.invalid_enum_value,options:r}),m}return O(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return V.create(e,{...this._def,...t})}exclude(e,t=this._def){return V.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}V.create=Me;class ye extends y{_parse(e){const t=v.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==u.string&&r.parsedType!==u.number){const a=v.objectValues(t);return c(r,{expected:v.joinValues(a),received:r.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(v.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=v.objectValues(t);return c(r,{received:r.data,code:d.invalid_enum_value,options:a}),m}return O(e.data)}get enum(){return this._def.values}}ye.create=(s,e)=>new ye({values:s,typeName:_.ZodNativeEnum,...g(e)});class ae extends y{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.promise&&t.common.async===!1)return c(t,{code:d.invalid_type,expected:u.promise,received:t.parsedType}),m;const r=t.parsedType===u.promise?t.data:Promise.resolve(t.data);return O(r.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ae.create=(s,e)=>new ae({type:s,typeName:_.ZodPromise,...g(e)});class L extends y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,n={addIssue:i=>{c(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),a.type==="preprocess"){const i=a.transform(r.data,n);if(r.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return m;const f=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return f.status==="aborted"?m:f.status==="dirty"||t.value==="dirty"?J(f.value):f});{if(t.value==="aborted")return m;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?m:o.status==="dirty"||t.value==="dirty"?J(o.value):o}}if(a.type==="refinement"){const i=o=>{const f=a.refinement(o,n);if(r.common.async)return Promise.resolve(f);if(f instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(a.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!B(i))return m;const o=a.transform(i.value,n);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>B(i)?Promise.resolve(a.transform(i.value,n)).then(o=>({status:t.value,value:o})):m);v.assertNever(a)}}L.create=(s,e,t)=>new L({schema:s,typeName:_.ZodEffects,effect:e,...g(t)});L.createWithPreprocess=(s,e,t)=>new L({schema:e,effect:{type:"preprocess",transform:s},typeName:_.ZodEffects,...g(t)});class j extends y{_parse(e){return this._getType(e)===u.undefined?O(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}j.create=(s,e)=>new j({innerType:s,typeName:_.ZodOptional,...g(e)});class D extends y{_parse(e){return this._getType(e)===u.null?O(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}D.create=(s,e)=>new D({innerType:s,typeName:_.ZodNullable,...g(e)});class ne extends y{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===u.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ne.create=(s,e)=>new ne({innerType:s,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});class ie extends y{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return X(a)?a.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ie.create=(s,e)=>new ie({innerType:s,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...g(e)});class je extends y{_parse(e){if(this._getType(e)!==u.nan){const r=this._getOrReturnCtx(e);return c(r,{code:d.invalid_type,expected:u.nan,received:r.parsedType}),m}return{status:"valid",value:e.data}}}je.create=s=>new je({typeName:_.ZodNaN,...g(s)});class ze extends y{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class be extends y{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?m:n.status==="dirty"?(t.dirty(),J(n.value)):this._def.out._parseAsync({data:n.value,path:r.path,parent:r})})();{const a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?m:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,t){return new be({in:e,out:t,typeName:_.ZodPipeline})}}class oe extends y{_parse(e){const t=this._def.innerType._parse(e),r=a=>(B(a)&&(a.value=Object.freeze(a.value)),a);return X(t)?t.then(a=>r(a)):r(t)}unwrap(){return this._def.innerType}}oe.create=(s,e)=>new oe({innerType:s,typeName:_.ZodReadonly,...g(e)});var _;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(_||(_={}));const l=R.create,b=q.create,de=he.create,gt=me.create;P.create;const T=N.create,k=w.create,Ve=ee.create,Le=ke.create;te.create;z.create;const De=se.create,Q=re.create,ve=V.create;ae.create;j.create;D.create;const A=De(gt()),we=k({id:b(),name:l(),slug:l().optional()}).passthrough(),ce=k({url:l(),is_official:de()}),xe=k({task_id:b(),dataset_id:b(),model_name:l().nullish(),harness:l().nullish(),methodology:l().nullish(),metrics:De(Ve([l(),b()])),uses_additional_data:de().optional(),is_open:de().optional(),best_rank:b().nullish(),best_metric:l().nullish(),evaluated_on:l().nullish(),external_source_url:l().nullish(),num_parameters:b().nullish(),hf_model_url:l().nullish()}).passthrough(),yt=xe.partial().extend({id:b().optional()}),vt=Le("op",[k({op:Q("create"),data:xe}),k({op:Q("update"),evaluation_id:b(),data:xe}),k({op:Q("delete"),evaluation_id:b()})]),Ie=k({hf_models:T(l()),hf_datasets:T(l()),hf_spaces:T(l())}),Te=k({file_name:l(),mime_type:l(),data_url:l().optional(),url:l().optional()}),F=k({name:l(),description:l().optional()}),xt=F.extend({image:Te.optional(),image_credit:l().optional(),parent_id:b().optional(),area_id:b().optional(),keywords:l().optional()}),kt=F.extend({image:Te.optional(),image_credit:l().optional(),source_paper_id:b().optional(),source_url:l().optional(),source_title:l().optional()}),bt=Ve([k({benchmark:l(),task:l(),description:l()}),F.extend({description:l(),task_ids:T(b()),full_name:l().optional(),url:l().optional(),hf_url:l().optional(),paper_url:l().optional(),license_name:l().optional(),license_url:l().optional()})]),wt=F.extend({description:l(),direction:ve(["higher_is_better","lower_is_better"]),full_name:l().optional(),scale:l().optional(),task_id:b(),dataset_id:b()}),Tt=F.extend({short_name:l().optional(),venue:l().optional(),location:l().optional(),url:l(),year:b(),start_date:l().optional(),end_date:l().optional()}),St=F.extend({hf_slug:l().optional(),website_url:l().optional(),image:Te.optional()}),Ct=k({id:b(),paper_id:b().nullable(),hf_username:l(),hf_subject:l().nullish(),is_author:de(),status:ve(["pending","approved","rejected"]),applied_payload:A.nullish(),conflict_payload:A.nullish(),result_entity_type:l().nullish(),result_entity_id:l().nullish(),admin_note:l().nullish(),user_review_reason:l().nullish(),reviewed_by:l().nullish(),reviewed_by_kind:ve(["human","codex","auto"]).nullish(),catalog_event_id:l().nullish(),review_evidence:A.nullish(),created_at:l(),updated_at:l(),reviewed_at:l().nullish()});function S(s,e,t){return Ct.extend({edit_type:Q(s),proposed_payload:e,current_payload:t.nullish()})}const Ot=S("tasks",k({task_ids:T(b())}),k({tasks:T(we)})),Nt=S("methods",k({method_ids:T(b())}),k({methods:T(we)})),At=S("evaluations",k({operations:T(vt)}),k({evaluations:T(yt)})),Et=S("repositories",k({repositories:T(ce)}),k({repositories:T(ce)})),Zt=S("project_pages",k({project_pages:T(ce)}),k({project_pages:T(ce)})),Rt=S("source_url",k({source_url:l()}),k({source_url:l().nullish()})),jt=S("hf_artifacts",Ie,Ie),It=S("x_threads",k({x_threads:T(l())}),k({x_threads:T(k({url:l()}))})),$t=S("organizations",k({organization_ids:T(b())}),k({organizations:T(we)})),Pt=S("new_task",xt,A),Mt=S("new_method",kt,A),zt=S("new_benchmark",bt,A),Vt=S("new_metric",wt,A),Lt=S("new_conference",Tt,A),Dt=S("new_organization",St,A),Ut=S("new_external_paper",k({title:l().optional(),source_url:l(),authors:T(l()),date_published:l().optional(),abstract:l().optional()}),A),Ue=Le("edit_type",[Ot,Nt,At,Et,Zt,Rt,jt,It,$t,Pt,Mt,zt,Vt,Lt,Dt,Ut]);function Yt(s,e,t){return{paper_id:s,edit_type:e,proposed_payload:t}}const M=(s,e)=>({directory:{title:s,subtitle:e}}),Ht={tasks:{label:"tasks",administrative:!1},methods:{label:"methods",administrative:!1},evaluations:{label:"evaluations",administrative:!1},repositories:{label:"repositories",administrative:!1},project_pages:{label:"project pages",administrative:!1},source_url:{label:"source url",administrative:!1},x_threads:{label:"x threads",administrative:!1},hf_artifacts:{label:"hf artifacts",administrative:!1},organizations:{label:"organizations",administrative:!1},new_task:{label:"new task",administrative:!0,...M("New task","Task suggestion")},new_method:{label:"new method",administrative:!0,...M("New method","Method suggestion")},new_benchmark:{label:"new benchmark",administrative:!0,...M("New benchmark","Benchmark suggestion")},new_metric:{label:"new metric",administrative:!0,...M("New metric","Metric suggestion")},new_conference:{label:"new conference",administrative:!0,...M("New conference","Conference suggestion")},new_organization:{label:"new organization",administrative:!1,...M("New organization","Organization suggestion")},new_external_paper:{label:"external paper",administrative:!1,...M("External paper","External paper submission")}},Bt=k({count:b(),results:T(Ue)});class qt extends Error{constructor(e){super(`Malformed pending-edit payload: ${e}`),this.name="PendingEditPayloadError"}}function Be(s,e){const t=s.safeParse(e);if(t.success)return t.data;const r=t.error.issues[0];throw new qt(`${(r==null?void 0:r.path.join("."))||"response"}: ${(r==null?void 0:r.message)||"invalid value"}`)}const G=s=>Be(Ue,s),Ft=s=>Be(Bt,s);class Wt{constructor(e){this.request=e}async submit(e){return G(await this.request("/me/paper-edits",{method:"POST",body:JSON.stringify(e)}))}list(e){const t=new URLSearchParams;for(const[a,n]of Object.entries(e??{}))n!==void 0&&t.set(a,String(n));const r=t.toString();return this.request(`/admin/paper-edits${r?`?${r}`:""}`).then(Ft)}revertAutoApproved(e,t={}){return this.request(`/admin/submitters/${encodeURIComponent(e)}/revert-auto-approved`,{method:"POST",body:JSON.stringify(t)})}async get(e){return G(await this.request(`/admin/paper-edits/${e}`))}async approve(e,t={}){return G(await this.request(`/admin/paper-edits/${e}/approve`,{method:"POST",body:JSON.stringify(t)}))}async reject(e,t={}){return G(await this.request(`/admin/paper-edits/${e}/reject`,{method:"POST",body:JSON.stringify(t)}))}}const Gt=new Wt(Fe);export{Ht as E,Yt as p,Gt as s}; +import{ac as Fe}from"./index-CjdUkE4w.js";var v;(function(s){s.assertEqual=a=>{};function e(a){}s.assertIs=e;function t(a){throw new Error}s.assertNever=t,s.arrayToEnum=a=>{const n={};for(const i of a)n[i]=i;return n},s.getValidEnumValues=a=>{const n=s.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),i={};for(const o of n)i[o]=a[o];return s.objectValues(i)},s.objectValues=a=>s.objectKeys(a).map(function(n){return a[n]}),s.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const n=[];for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&n.push(i);return n},s.find=(a,n)=>{for(const i of a)if(n(i))return i},s.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function r(a,n=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(n)}s.joinValues=r,s.jsonStringifyReplacer=(a,n)=>typeof n=="bigint"?n.toString():n})(v||(v={}));var Se;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Se||(Se={}));const u=v.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$=s=>{switch(typeof s){case"undefined":return u.undefined;case"string":return u.string;case"number":return Number.isNaN(s)?u.nan:u.number;case"boolean":return u.boolean;case"function":return u.function;case"bigint":return u.bigint;case"symbol":return u.symbol;case"object":return Array.isArray(s)?u.array:s===null?u.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?u.promise:typeof Map<"u"&&s instanceof Map?u.map:typeof Set<"u"&&s instanceof Set?u.set:typeof Date<"u"&&s instanceof Date?u.date:u.object;default:return u.unknown}},d=v.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class I extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(n){return n.message},r={_errors:[]},a=n=>{for(const i of n.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,f=0;for(;ft.message){const t={},r=[];for(const a of this.issues)if(a.path.length>0){const n=a.path[0];t[n]=t[n]||[],t[n].push(e(a))}else r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}I.create=s=>new I(s);const le=(s,e)=>{let t;switch(s.code){case d.invalid_type:s.received===u.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,v.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${v.joinValues(s.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${v.joinValues(s.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${v.joinValues(s.options)}, received '${s.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:v.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case d.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case d.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,v.assertNever(s)}return{message:t}};let We=le;function Je(){return We}const Ye=s=>{const{data:e,path:t,errorMaps:r,issueData:a}=s,n=[...t,...a.path||[]],i={...a,path:n};if(a.message!==void 0)return{...a,path:n,message:a.message};let o="";const f=r.filter(p=>!!p).slice().reverse();for(const p of f)o=p(i,{data:e,defaultError:o}).message;return{...a,path:n,message:o}};function c(s,e){const t=Je(),r=Ye({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===le?void 0:le].filter(a=>!!a)});s.common.issues.push(r)}class C{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const a of t){if(a.status==="aborted")return m;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const a of t){const n=await a.key,i=await a.value;r.push({key:n,value:i})}return C.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const a of t){const{key:n,value:i}=a;if(n.status==="aborted"||i.status==="aborted")return m;n.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(r[n.value]=i.value)}return{status:e.value,value:r}}}const m=Object.freeze({status:"aborted"}),J=s=>({status:"dirty",value:s}),O=s=>({status:"valid",value:s}),Ce=s=>s.status==="aborted",Oe=s=>s.status==="dirty",B=s=>s.status==="valid",X=s=>typeof Promise<"u"&&s instanceof Promise;var h;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(h||(h={}));class E{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ne=(s,e)=>{if(B(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new I(s.common.issues);return this._error=t,this._error}}};function g(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:a}=s;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,o)=>{const{message:f}=s;return i.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:f??r??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:f??t??o.defaultError}},description:a}}class y{get description(){return this._def.description}_getType(e){return $(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new C,ctx:{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(X(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Ne(r,a)}"~validate"(e){var r,a;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return B(n)?{value:n.value}:{issues:t.common.issues}}catch(n){(a=(r=n==null?void 0:n.message)==null?void 0:r.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(n=>B(n)?{value:n.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)},a=this._parse({data:e,path:r.path,parent:r}),n=await(X(a)?a:Promise.resolve(a));return Ne(r,n)}refine(e,t){const r=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,n)=>{const i=e(a),o=()=>n.addIssue({code:d.custom,...r(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(f=>f?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof t=="function"?t(r,a):t),!1))}_refinement(e){return new L({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return j.create(this,this._def)}nullable(){return D.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return N.create(this)}promise(){return ae.create(this,this._def)}or(e){return ee.create([this,e],this._def)}and(e){return te.create(this,e,this._def)}transform(e){return new L({...g(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ne({...g(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new ze({typeName:_.ZodBranded,type:this,...g(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ie({...g(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return be.create(this,e)}readonly(){return oe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const He=/^c[^\s-]{8,}$/i,Ge=/^[0-9a-z]+$/,Qe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Xe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ke=/^[a-z0-9_-]{21}$/i,et=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,tt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,st=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ue;const at=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,nt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,it=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ot=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,dt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ct=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,$e="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ut=new RegExp(`^${$e}$`);function Pe(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);const t=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function lt(s){return new RegExp(`^${Pe(s)}$`)}function ht(s){let e=`${$e}T${Pe(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function ft(s,e){return!!((e==="v4"||!e)&&at.test(s)||(e==="v6"||!e)&&it.test(s))}function pt(s,e){if(!et.test(s))return!1;try{const[t]=s.split(".");if(!t)return!1;const r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(r));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function mt(s,e){return!!((e==="v4"||!e)&&nt.test(s)||(e==="v6"||!e)&&ot.test(s))}class R extends y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==u.string){const n=this._getOrReturnCtx(e);return c(n,{code:d.invalid_type,expected:u.string,received:n.parsedType}),m}const r=new C;let a;for(const n of this._def.checks)if(n.kind==="min")e.data.lengthn.value&&(a=this._getOrReturnCtx(e,a),c(a,{code:d.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="length"){const i=e.data.length>n.value,o=e.data.lengthe.test(a),{validation:t,code:d.invalid_string,...h.errToObj(r)})}_addCheck(e){return new R({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...h.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...h.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...h.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new R({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new R({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new R({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew R({checks:[],typeName:_.ZodString,coerce:(s==null?void 0:s.coerce)??!1,...g(s)});function _t(s,e){const t=(s.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=t>r?t:r,n=Number.parseInt(s.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return n%i/10**a}class q extends y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==u.number){const n=this._getOrReturnCtx(e);return c(n,{code:d.invalid_type,expected:u.number,received:n.parsedType}),m}let r;const a=new C;for(const n of this._def.checks)n.kind==="int"?v.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),c(r,{code:d.invalid_type,expected:"integer",received:"float",message:n.message}),a.dirty()):n.kind==="min"?(n.inclusive?e.datan.value:e.data>=n.value)&&(r=this._getOrReturnCtx(e,r),c(r,{code:d.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="multipleOf"?_t(e.data,n.value)!==0&&(r=this._getOrReturnCtx(e,r),c(r,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),c(r,{code:d.not_finite,message:n.message}),a.dirty()):v.assertNever(n);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,r,a){return new q({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:h.toString(a)}]})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.valuee.kind==="int"||e.kind==="multipleOf"&&v.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.valuenew q({checks:[],typeName:_.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...g(s)});class Y extends y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==u.bigint)return this._getInvalidInput(e);let r;const a=new C;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.datan.value:e.data>=n.value)&&(r=this._getOrReturnCtx(e,r),c(r,{code:d.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),c(r,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):v.assertNever(n);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return c(t,{code:d.invalid_type,expected:u.bigint,received:t.parsedType}),m}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,r,a){return new Y({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:h.toString(a)}]})}_addCheck(e){return new Y({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew Y({checks:[],typeName:_.ZodBigInt,coerce:(s==null?void 0:s.coerce)??!1,...g(s)});class he extends y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==u.boolean){const r=this._getOrReturnCtx(e);return c(r,{code:d.invalid_type,expected:u.boolean,received:r.parsedType}),m}return O(e.data)}}he.create=s=>new he({typeName:_.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...g(s)});class K extends y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==u.date){const n=this._getOrReturnCtx(e);return c(n,{code:d.invalid_type,expected:u.date,received:n.parsedType}),m}if(Number.isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return c(n,{code:d.invalid_date}),m}const r=new C;let a;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()n.value&&(a=this._getOrReturnCtx(e,a),c(a,{code:d.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):v.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new K({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew K({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:_.ZodDate,...g(s)});class Ae extends y{_parse(e){if(this._getType(e)!==u.symbol){const r=this._getOrReturnCtx(e);return c(r,{code:d.invalid_type,expected:u.symbol,received:r.parsedType}),m}return O(e.data)}}Ae.create=s=>new Ae({typeName:_.ZodSymbol,...g(s)});class fe extends y{_parse(e){if(this._getType(e)!==u.undefined){const r=this._getOrReturnCtx(e);return c(r,{code:d.invalid_type,expected:u.undefined,received:r.parsedType}),m}return O(e.data)}}fe.create=s=>new fe({typeName:_.ZodUndefined,...g(s)});class pe extends y{_parse(e){if(this._getType(e)!==u.null){const r=this._getOrReturnCtx(e);return c(r,{code:d.invalid_type,expected:u.null,received:r.parsedType}),m}return O(e.data)}}pe.create=s=>new pe({typeName:_.ZodNull,...g(s)});class Ee extends y{constructor(){super(...arguments),this._any=!0}_parse(e){return O(e.data)}}Ee.create=s=>new Ee({typeName:_.ZodAny,...g(s)});class me extends y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return O(e.data)}}me.create=s=>new me({typeName:_.ZodUnknown,...g(s)});class P extends y{_parse(e){const t=this._getOrReturnCtx(e);return c(t,{code:d.invalid_type,expected:u.never,received:t.parsedType}),m}}P.create=s=>new P({typeName:_.ZodNever,...g(s)});class Ze extends y{_parse(e){if(this._getType(e)!==u.undefined){const r=this._getOrReturnCtx(e);return c(r,{code:d.invalid_type,expected:u.void,received:r.parsedType}),m}return O(e.data)}}Ze.create=s=>new Ze({typeName:_.ZodVoid,...g(s)});class N extends y{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==u.array)return c(t,{code:d.invalid_type,expected:u.array,received:t.parsedType}),m;if(a.exactLength!==null){const i=t.data.length>a.exactLength.value,o=t.data.lengtha.maxLength.value&&(c(t,{code:d.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>a.type._parseAsync(new E(t,i,t.path,o)))).then(i=>C.mergeArray(r,i));const n=[...t.data].map((i,o)=>a.type._parseSync(new E(t,i,t.path,o)));return C.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new N({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new N({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new N({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}}N.create=(s,e)=>new N({type:s,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...g(e)});function U(s){if(s instanceof w){const e={};for(const t in s.shape){const r=s.shape[t];e[t]=j.create(U(r))}return new w({...s._def,shape:()=>e})}else return s instanceof N?new N({...s._def,type:U(s.element)}):s instanceof j?j.create(U(s.unwrap())):s instanceof D?D.create(U(s.unwrap())):s instanceof z?z.create(s.items.map(e=>U(e))):s}class w extends y{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=v.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==u.object){const p=this._getOrReturnCtx(e);return c(p,{code:d.invalid_type,expected:u.object,received:p.parsedType}),m}const{status:r,ctx:a}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof P&&this._def.unknownKeys==="strip"))for(const p in a.data)i.includes(p)||o.push(p);const f=[];for(const p of i){const x=n[p],W=a.data[p];f.push({key:{status:"valid",value:p},value:x._parse(new E(a,W,a.path,p)),alwaysSet:p in a.data})}if(this._def.catchall instanceof P){const p=this._def.unknownKeys;if(p==="passthrough")for(const x of o)f.push({key:{status:"valid",value:x},value:{status:"valid",value:a.data[x]}});else if(p==="strict")o.length>0&&(c(a,{code:d.unrecognized_keys,keys:o}),r.dirty());else if(p!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const p=this._def.catchall;for(const x of o){const W=a.data[x];f.push({key:{status:"valid",value:x},value:p._parse(new E(a,W,a.path,x)),alwaysSet:x in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const p=[];for(const x of f){const W=await x.key,qe=await x.value;p.push({key:W,value:qe,alwaysSet:x.alwaysSet})}return p}).then(p=>C.mergeObjectSync(r,p)):C.mergeObjectSync(r,f)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var n,i;const a=((i=(n=this._def).errorMap)==null?void 0:i.call(n,t,r).message)??r.defaultError;return t.code==="unrecognized_keys"?{message:h.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new w({...this._def,catchall:e})}pick(e){const t={};for(const r of v.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new w({...this._def,shape:()=>t})}omit(e){const t={};for(const r of v.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new w({...this._def,shape:()=>t})}deepPartial(){return U(this)}partial(e){const t={};for(const r of v.objectKeys(this.shape)){const a=this.shape[r];e&&!e[r]?t[r]=a:t[r]=a.optional()}return new w({...this._def,shape:()=>t})}required(e){const t={};for(const r of v.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let n=this.shape[r];for(;n instanceof j;)n=n._def.innerType;t[r]=n}return new w({...this._def,shape:()=>t})}keyof(){return Me(v.objectKeys(this.shape))}}w.create=(s,e)=>new w({shape:()=>s,unknownKeys:"strip",catchall:P.create(),typeName:_.ZodObject,...g(e)});w.strictCreate=(s,e)=>new w({shape:()=>s,unknownKeys:"strict",catchall:P.create(),typeName:_.ZodObject,...g(e)});w.lazycreate=(s,e)=>new w({shape:s,unknownKeys:"strip",catchall:P.create(),typeName:_.ZodObject,...g(e)});class ee extends y{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function a(n){for(const o of n)if(o.result.status==="valid")return o.result;for(const o of n)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=n.map(o=>new I(o.ctx.common.issues));return c(t,{code:d.invalid_union,unionErrors:i}),m}if(t.common.async)return Promise.all(r.map(async n=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(a);{let n;const i=[];for(const f of r){const p={...t,common:{...t.common,issues:[]},parent:null},x=f._parseSync({data:t.data,path:t.path,parent:p});if(x.status==="valid")return x;x.status==="dirty"&&!n&&(n={result:x,ctx:p}),p.common.issues.length&&i.push(p.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const o=i.map(f=>new I(f));return c(t,{code:d.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}ee.create=(s,e)=>new ee({options:s,typeName:_.ZodUnion,...g(e)});const Z=s=>s instanceof ge?Z(s.schema):s instanceof L?Z(s.innerType()):s instanceof re?[s.value]:s instanceof V?s.options:s instanceof ye?v.objectValues(s.enum):s instanceof ne?Z(s._def.innerType):s instanceof fe?[void 0]:s instanceof pe?[null]:s instanceof j?[void 0,...Z(s.unwrap())]:s instanceof D?[null,...Z(s.unwrap())]:s instanceof ze||s instanceof oe?Z(s.unwrap()):s instanceof ie?Z(s._def.innerType):[];class ke extends y{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.object)return c(t,{code:d.invalid_type,expected:u.object,received:t.parsedType}),m;const r=this.discriminator,a=t.data[r],n=this.optionsMap.get(a);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(c(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const a=new Map;for(const n of t){const i=Z(n.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(a.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);a.set(o,n)}}return new ke({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...g(r)})}}function _e(s,e){const t=$(s),r=$(e);if(s===e)return{valid:!0,data:s};if(t===u.object&&r===u.object){const a=v.objectKeys(e),n=v.objectKeys(s).filter(o=>a.indexOf(o)!==-1),i={...s,...e};for(const o of n){const f=_e(s[o],e[o]);if(!f.valid)return{valid:!1};i[o]=f.data}return{valid:!0,data:i}}else if(t===u.array&&r===u.array){if(s.length!==e.length)return{valid:!1};const a=[];for(let n=0;n{if(Ce(n)||Ce(i))return m;const o=_e(n.value,i.value);return o.valid?((Oe(n)||Oe(i))&&t.dirty(),{status:t.value,value:o.data}):(c(r,{code:d.invalid_intersection_types}),m)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([n,i])=>a(n,i)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}te.create=(s,e,t)=>new te({left:s,right:e,typeName:_.ZodIntersection,...g(t)});class z extends y{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==u.array)return c(r,{code:d.invalid_type,expected:u.array,received:r.parsedType}),m;if(r.data.lengththis._def.items.length&&(c(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...r.data].map((i,o)=>{const f=this._def.items[o]||this._def.rest;return f?f._parse(new E(r,i,r.path,o)):null}).filter(i=>!!i);return r.common.async?Promise.all(n).then(i=>C.mergeArray(t,i)):C.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new z({...this._def,rest:e})}}z.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new z({items:s,typeName:_.ZodTuple,rest:null,...g(e)})};class se extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==u.object)return c(r,{code:d.invalid_type,expected:u.object,received:r.parsedType}),m;const a=[],n=this._def.keyType,i=this._def.valueType;for(const o in r.data)a.push({key:n._parse(new E(r,o,r.path,o)),value:i._parse(new E(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?C.mergeObjectAsync(t,a):C.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof y?new se({keyType:e,valueType:t,typeName:_.ZodRecord,...g(r)}):new se({keyType:R.create(),valueType:e,typeName:_.ZodRecord,...g(t)})}}class Re extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==u.map)return c(r,{code:d.invalid_type,expected:u.map,received:r.parsedType}),m;const a=this._def.keyType,n=this._def.valueType,i=[...r.data.entries()].map(([o,f],p)=>({key:a._parse(new E(r,o,r.path,[p,"key"])),value:n._parse(new E(r,f,r.path,[p,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const f of i){const p=await f.key,x=await f.value;if(p.status==="aborted"||x.status==="aborted")return m;(p.status==="dirty"||x.status==="dirty")&&t.dirty(),o.set(p.value,x.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const f of i){const p=f.key,x=f.value;if(p.status==="aborted"||x.status==="aborted")return m;(p.status==="dirty"||x.status==="dirty")&&t.dirty(),o.set(p.value,x.value)}return{status:t.value,value:o}}}}Re.create=(s,e,t)=>new Re({valueType:e,keyType:s,typeName:_.ZodMap,...g(t)});class H extends y{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==u.set)return c(r,{code:d.invalid_type,expected:u.set,received:r.parsedType}),m;const a=this._def;a.minSize!==null&&r.data.sizea.maxSize.value&&(c(r,{code:d.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const n=this._def.valueType;function i(f){const p=new Set;for(const x of f){if(x.status==="aborted")return m;x.status==="dirty"&&t.dirty(),p.add(x.value)}return{status:t.value,value:p}}const o=[...r.data.values()].map((f,p)=>n._parse(new E(r,f,r.path,p)));return r.common.async?Promise.all(o).then(f=>i(f)):i(o)}min(e,t){return new H({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new H({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}H.create=(s,e)=>new H({valueType:s,minSize:null,maxSize:null,typeName:_.ZodSet,...g(e)});class ge extends y{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ge.create=(s,e)=>new ge({getter:s,typeName:_.ZodLazy,...g(e)});class re extends y{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return c(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}re.create=(s,e)=>new re({value:s,typeName:_.ZodLiteral,...g(e)});function Me(s,e){return new V({values:s,typeName:_.ZodEnum,...g(e)})}class V extends y{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return c(t,{expected:v.joinValues(r),received:t.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return c(t,{received:t.data,code:d.invalid_enum_value,options:r}),m}return O(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return V.create(e,{...this._def,...t})}exclude(e,t=this._def){return V.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}V.create=Me;class ye extends y{_parse(e){const t=v.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==u.string&&r.parsedType!==u.number){const a=v.objectValues(t);return c(r,{expected:v.joinValues(a),received:r.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(v.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=v.objectValues(t);return c(r,{received:r.data,code:d.invalid_enum_value,options:a}),m}return O(e.data)}get enum(){return this._def.values}}ye.create=(s,e)=>new ye({values:s,typeName:_.ZodNativeEnum,...g(e)});class ae extends y{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.promise&&t.common.async===!1)return c(t,{code:d.invalid_type,expected:u.promise,received:t.parsedType}),m;const r=t.parsedType===u.promise?t.data:Promise.resolve(t.data);return O(r.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ae.create=(s,e)=>new ae({type:s,typeName:_.ZodPromise,...g(e)});class L extends y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,n={addIssue:i=>{c(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),a.type==="preprocess"){const i=a.transform(r.data,n);if(r.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return m;const f=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return f.status==="aborted"?m:f.status==="dirty"||t.value==="dirty"?J(f.value):f});{if(t.value==="aborted")return m;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?m:o.status==="dirty"||t.value==="dirty"?J(o.value):o}}if(a.type==="refinement"){const i=o=>{const f=a.refinement(o,n);if(r.common.async)return Promise.resolve(f);if(f instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(a.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!B(i))return m;const o=a.transform(i.value,n);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>B(i)?Promise.resolve(a.transform(i.value,n)).then(o=>({status:t.value,value:o})):m);v.assertNever(a)}}L.create=(s,e,t)=>new L({schema:s,typeName:_.ZodEffects,effect:e,...g(t)});L.createWithPreprocess=(s,e,t)=>new L({schema:e,effect:{type:"preprocess",transform:s},typeName:_.ZodEffects,...g(t)});class j extends y{_parse(e){return this._getType(e)===u.undefined?O(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}j.create=(s,e)=>new j({innerType:s,typeName:_.ZodOptional,...g(e)});class D extends y{_parse(e){return this._getType(e)===u.null?O(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}D.create=(s,e)=>new D({innerType:s,typeName:_.ZodNullable,...g(e)});class ne extends y{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===u.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ne.create=(s,e)=>new ne({innerType:s,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});class ie extends y{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return X(a)?a.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ie.create=(s,e)=>new ie({innerType:s,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...g(e)});class je extends y{_parse(e){if(this._getType(e)!==u.nan){const r=this._getOrReturnCtx(e);return c(r,{code:d.invalid_type,expected:u.nan,received:r.parsedType}),m}return{status:"valid",value:e.data}}}je.create=s=>new je({typeName:_.ZodNaN,...g(s)});class ze extends y{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class be extends y{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?m:n.status==="dirty"?(t.dirty(),J(n.value)):this._def.out._parseAsync({data:n.value,path:r.path,parent:r})})();{const a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?m:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,t){return new be({in:e,out:t,typeName:_.ZodPipeline})}}class oe extends y{_parse(e){const t=this._def.innerType._parse(e),r=a=>(B(a)&&(a.value=Object.freeze(a.value)),a);return X(t)?t.then(a=>r(a)):r(t)}unwrap(){return this._def.innerType}}oe.create=(s,e)=>new oe({innerType:s,typeName:_.ZodReadonly,...g(e)});var _;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(_||(_={}));const l=R.create,b=q.create,de=he.create,gt=me.create;P.create;const T=N.create,k=w.create,Ve=ee.create,Le=ke.create;te.create;z.create;const De=se.create,Q=re.create,ve=V.create;ae.create;j.create;D.create;const A=De(gt()),we=k({id:b(),name:l(),slug:l().optional()}).passthrough(),ce=k({url:l(),is_official:de()}),xe=k({task_id:b(),dataset_id:b(),model_name:l().nullish(),harness:l().nullish(),methodology:l().nullish(),metrics:De(Ve([l(),b()])),uses_additional_data:de().optional(),is_open:de().optional(),best_rank:b().nullish(),best_metric:l().nullish(),evaluated_on:l().nullish(),external_source_url:l().nullish(),num_parameters:b().nullish(),hf_model_url:l().nullish()}).passthrough(),yt=xe.partial().extend({id:b().optional()}),vt=Le("op",[k({op:Q("create"),data:xe}),k({op:Q("update"),evaluation_id:b(),data:xe}),k({op:Q("delete"),evaluation_id:b()})]),Ie=k({hf_models:T(l()),hf_datasets:T(l()),hf_spaces:T(l())}),Te=k({file_name:l(),mime_type:l(),data_url:l().optional(),url:l().optional()}),F=k({name:l(),description:l().optional()}),xt=F.extend({image:Te.optional(),image_credit:l().optional(),parent_id:b().optional(),area_id:b().optional(),keywords:l().optional()}),kt=F.extend({image:Te.optional(),image_credit:l().optional(),source_paper_id:b().optional(),source_url:l().optional(),source_title:l().optional()}),bt=Ve([k({benchmark:l(),task:l(),description:l()}),F.extend({description:l(),task_ids:T(b()),full_name:l().optional(),url:l().optional(),hf_url:l().optional(),paper_url:l().optional(),license_name:l().optional(),license_url:l().optional()})]),wt=F.extend({description:l(),direction:ve(["higher_is_better","lower_is_better"]),full_name:l().optional(),scale:l().optional(),task_id:b(),dataset_id:b()}),Tt=F.extend({short_name:l().optional(),venue:l().optional(),location:l().optional(),url:l(),year:b(),start_date:l().optional(),end_date:l().optional()}),St=F.extend({hf_slug:l().optional(),website_url:l().optional(),image:Te.optional()}),Ct=k({id:b(),paper_id:b().nullable(),hf_username:l(),hf_subject:l().nullish(),is_author:de(),status:ve(["pending","approved","rejected"]),applied_payload:A.nullish(),conflict_payload:A.nullish(),result_entity_type:l().nullish(),result_entity_id:l().nullish(),admin_note:l().nullish(),user_review_reason:l().nullish(),reviewed_by:l().nullish(),reviewed_by_kind:ve(["human","codex","auto"]).nullish(),catalog_event_id:l().nullish(),review_evidence:A.nullish(),created_at:l(),updated_at:l(),reviewed_at:l().nullish()});function S(s,e,t){return Ct.extend({edit_type:Q(s),proposed_payload:e,current_payload:t.nullish()})}const Ot=S("tasks",k({task_ids:T(b())}),k({tasks:T(we)})),Nt=S("methods",k({method_ids:T(b())}),k({methods:T(we)})),At=S("evaluations",k({operations:T(vt)}),k({evaluations:T(yt)})),Et=S("repositories",k({repositories:T(ce)}),k({repositories:T(ce)})),Zt=S("project_pages",k({project_pages:T(ce)}),k({project_pages:T(ce)})),Rt=S("source_url",k({source_url:l()}),k({source_url:l().nullish()})),jt=S("hf_artifacts",Ie,Ie),It=S("x_threads",k({x_threads:T(l())}),k({x_threads:T(k({url:l()}))})),$t=S("organizations",k({organization_ids:T(b())}),k({organizations:T(we)})),Pt=S("new_task",xt,A),Mt=S("new_method",kt,A),zt=S("new_benchmark",bt,A),Vt=S("new_metric",wt,A),Lt=S("new_conference",Tt,A),Dt=S("new_organization",St,A),Ut=S("new_external_paper",k({title:l().optional(),source_url:l(),authors:T(l()),date_published:l().optional(),abstract:l().optional()}),A),Ue=Le("edit_type",[Ot,Nt,At,Et,Zt,Rt,jt,It,$t,Pt,Mt,zt,Vt,Lt,Dt,Ut]);function Yt(s,e,t){return{paper_id:s,edit_type:e,proposed_payload:t}}const M=(s,e)=>({directory:{title:s,subtitle:e}}),Ht={tasks:{label:"tasks",administrative:!1},methods:{label:"methods",administrative:!1},evaluations:{label:"evaluations",administrative:!1},repositories:{label:"repositories",administrative:!1},project_pages:{label:"project pages",administrative:!1},source_url:{label:"source url",administrative:!1},x_threads:{label:"x threads",administrative:!1},hf_artifacts:{label:"hf artifacts",administrative:!1},organizations:{label:"organizations",administrative:!1},new_task:{label:"new task",administrative:!0,...M("New task","Task suggestion")},new_method:{label:"new method",administrative:!0,...M("New method","Method suggestion")},new_benchmark:{label:"new benchmark",administrative:!0,...M("New benchmark","Benchmark suggestion")},new_metric:{label:"new metric",administrative:!0,...M("New metric","Metric suggestion")},new_conference:{label:"new conference",administrative:!0,...M("New conference","Conference suggestion")},new_organization:{label:"new organization",administrative:!1,...M("New organization","Organization suggestion")},new_external_paper:{label:"external paper",administrative:!1,...M("External paper","External paper submission")}},Bt=k({count:b(),results:T(Ue)});class qt extends Error{constructor(e){super(`Malformed pending-edit payload: ${e}`),this.name="PendingEditPayloadError"}}function Be(s,e){const t=s.safeParse(e);if(t.success)return t.data;const r=t.error.issues[0];throw new qt(`${(r==null?void 0:r.path.join("."))||"response"}: ${(r==null?void 0:r.message)||"invalid value"}`)}const G=s=>Be(Ue,s),Ft=s=>Be(Bt,s);class Wt{constructor(e){this.request=e}async submit(e){return G(await this.request("/me/paper-edits",{method:"POST",body:JSON.stringify(e)}))}list(e){const t=new URLSearchParams;for(const[a,n]of Object.entries(e??{}))n!==void 0&&t.set(a,String(n));const r=t.toString();return this.request(`/admin/paper-edits${r?`?${r}`:""}`).then(Ft)}revertAutoApproved(e,t={}){return this.request(`/admin/submitters/${encodeURIComponent(e)}/revert-auto-approved`,{method:"POST",body:JSON.stringify(t)})}async get(e){return G(await this.request(`/admin/paper-edits/${e}`))}async approve(e,t={}){return G(await this.request(`/admin/paper-edits/${e}/approve`,{method:"POST",body:JSON.stringify(t)}))}async reject(e,t={}){return G(await this.request(`/admin/paper-edits/${e}/reject`,{method:"POST",body:JSON.stringify(t)}))}}const Gt=new Wt(Fe);export{Ht as E,Yt as p,Gt as s}; diff --git a/assets/switch-nfvTohnt.js b/assets/switch-hcLL2FH0.js similarity index 84% rename from assets/switch-nfvTohnt.js rename to assets/switch-hcLL2FH0.js index 9cc6be49e7d1858b1a0d9e9509c1ace763e1988c..af3d527f37134af267f1874db9bc8e0a8eec76d5 100644 --- a/assets/switch-nfvTohnt.js +++ b/assets/switch-hcLL2FH0.js @@ -1 +1 @@ -import{d as s,B as C,A as I,j as a,z as y,D as M,E as A,F as H,G as x}from"./index-DyXq7-Tg.js";import{u as z}from"./index-C041TDos.js";var b="Switch",[U]=H(b),[q,D]=U(b),E=s.forwardRef((t,o)=>{const{__scopeSwitch:e,name:n,checked:r,defaultChecked:m,required:d,disabled:c,value:u="on",onCheckedChange:v,form:i,...w}=t,[l,p]=s.useState(null),S=C(o,h=>p(h)),k=s.useRef(!1),g=l?i||!!l.closest("form"):!0,[f,B]=I({prop:r,defaultProp:m??!1,onChange:v,caller:b});return a.jsxs(q,{scope:e,checked:f,disabled:c,children:[a.jsx(y.button,{type:"button",role:"switch","aria-checked":f,"aria-required":d,"data-state":j(f),"data-disabled":c?"":void 0,disabled:c,value:u,...w,ref:S,onClick:M(t.onClick,h=>{B(T=>!T),g&&(k.current=h.isPropagationStopped(),k.current||h.stopPropagation())})}),g&&a.jsx(N,{control:l,bubbles:!k.current,name:n,value:u,checked:f,required:d,disabled:c,form:i,style:{transform:"translateX(-100%)"}})]})});E.displayName=b;var P="SwitchThumb",R=s.forwardRef((t,o)=>{const{__scopeSwitch:e,...n}=t,r=D(P,e);return a.jsx(y.span,{"data-state":j(r.checked),"data-disabled":r.disabled?"":void 0,...n,ref:o})});R.displayName=P;var F="SwitchBubbleInput",N=s.forwardRef(({__scopeSwitch:t,control:o,checked:e,bubbles:n=!0,...r},m)=>{const d=s.useRef(null),c=C(d,m),u=z(e),v=A(o);return s.useEffect(()=>{const i=d.current;if(!i)return;const w=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(w,"checked").set;if(u!==e&&p){const S=new Event("click",{bubbles:n});p.call(i,e),i.dispatchEvent(S)}},[u,e,n]),a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:e,...r,tabIndex:-1,ref:c,style:{...r.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});N.displayName=F;function j(t){return t?"checked":"unchecked"}var _=E,L=R;const O=s.forwardRef(({className:t,...o},e)=>a.jsx(_,{className:x("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...o,ref:e,children:a.jsx(L,{className:x("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));O.displayName=_.displayName;export{O as S}; +import{d as s,D as C,B as T,j as a,z as y,E as M,F as H,G as z,I as x}from"./index-CjdUkE4w.js";import{u as A}from"./index-BxR27SAB.js";var b="Switch",[U]=z(b),[q,D]=U(b),E=s.forwardRef((t,o)=>{const{__scopeSwitch:e,name:n,checked:r,defaultChecked:m,required:d,disabled:c,value:u="on",onCheckedChange:v,form:i,...w}=t,[l,p]=s.useState(null),S=C(o,h=>p(h)),k=s.useRef(!1),g=l?i||!!l.closest("form"):!0,[f,B]=T({prop:r,defaultProp:m??!1,onChange:v,caller:b});return a.jsxs(q,{scope:e,checked:f,disabled:c,children:[a.jsx(y.button,{type:"button",role:"switch","aria-checked":f,"aria-required":d,"data-state":j(f),"data-disabled":c?"":void 0,disabled:c,value:u,...w,ref:S,onClick:M(t.onClick,h=>{B(I=>!I),g&&(k.current=h.isPropagationStopped(),k.current||h.stopPropagation())})}),g&&a.jsx(N,{control:l,bubbles:!k.current,name:n,value:u,checked:f,required:d,disabled:c,form:i,style:{transform:"translateX(-100%)"}})]})});E.displayName=b;var P="SwitchThumb",R=s.forwardRef((t,o)=>{const{__scopeSwitch:e,...n}=t,r=D(P,e);return a.jsx(y.span,{"data-state":j(r.checked),"data-disabled":r.disabled?"":void 0,...n,ref:o})});R.displayName=P;var F="SwitchBubbleInput",N=s.forwardRef(({__scopeSwitch:t,control:o,checked:e,bubbles:n=!0,...r},m)=>{const d=s.useRef(null),c=C(d,m),u=A(e),v=H(o);return s.useEffect(()=>{const i=d.current;if(!i)return;const w=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(w,"checked").set;if(u!==e&&p){const S=new Event("click",{bubbles:n});p.call(i,e),i.dispatchEvent(S)}},[u,e,n]),a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:e,...r,tabIndex:-1,ref:c,style:{...r.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});N.displayName=F;function j(t){return t?"checked":"unchecked"}var _=E,L=R;const O=s.forwardRef(({className:t,...o},e)=>a.jsx(_,{className:x("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...o,ref:e,children:a.jsx(L,{className:x("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));O.displayName=_.displayName;export{O as S}; diff --git a/assets/textarea-DPixlM5U.js b/assets/textarea-biscLKBK.js similarity index 86% rename from assets/textarea-DPixlM5U.js rename to assets/textarea-biscLKBK.js index d475e4d9c506bc079e67f41d5e158c220724d6de..7f386a7b6ffcbc71201c7c27314c54799066f812 100644 --- a/assets/textarea-DPixlM5U.js +++ b/assets/textarea-biscLKBK.js @@ -1 +1 @@ -import{d as s,j as a,G as t}from"./index-DyXq7-Tg.js";const i=s.forwardRef(({className:e,...r},o)=>a.jsx("textarea",{className:t("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:o,...r}));i.displayName="Textarea";export{i as T}; +import{d as s,j as a,I as t}from"./index-CjdUkE4w.js";const i=s.forwardRef(({className:e,...r},o)=>a.jsx("textarea",{className:t("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:o,...r}));i.displayName="Textarea";export{i as T}; diff --git a/assets/thumbs-up-CPLlGli7.js b/assets/thumbs-up-Dn_5H93T.js similarity index 90% rename from assets/thumbs-up-CPLlGli7.js rename to assets/thumbs-up-Dn_5H93T.js index d9c459379530cc6a6fb93c3001b884260871443f..19446f1940d439cfe7b2a442fd345eaede68c12e 100644 --- a/assets/thumbs-up-CPLlGli7.js +++ b/assets/thumbs-up-Dn_5H93T.js @@ -1,4 +1,4 @@ -import{s as a}from"./index-DyXq7-Tg.js";/** +import{s as a}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/transform-D46m70Qr.js b/assets/transform-CRNzYLch.js similarity index 99% rename from assets/transform-D46m70Qr.js rename to assets/transform-CRNzYLch.js index 6e02e41b6d09604469d1c2b21ba4ff7a1ae6b824..759c1eb5a13492d7fbf67c5d485f70023ebb1b10 100644 --- a/assets/transform-D46m70Qr.js +++ b/assets/transform-CRNzYLch.js @@ -1 +1 @@ -import{a3 as _}from"./index-DyXq7-Tg.js";function w(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function D(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}const A=6048e5,z=864e5,I=6e4,R=36e5;let V={};function W(){return V}function v(t,e){var s,u,d,f;const n=W(),r=(e==null?void 0:e.weekStartsOn)??((u=(s=e==null?void 0:e.locale)==null?void 0:s.options)==null?void 0:u.weekStartsOn)??n.weekStartsOn??((f=(d=n.locale)==null?void 0:d.options)==null?void 0:f.weekStartsOn)??0,a=w(t),i=a.getDay(),o=(i=a.getTime()?n+1:e.getTime()>=o.getTime()?n:n-1}function F(t){const e=w(t);return e.setHours(0,0,0,0),e}function E(t){const e=w(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function J(t,e){const n=F(t),r=F(e),a=+n-E(n),i=+r-E(r);return Math.round((a-i)/z)}function Z(t){const e=j(t),n=D(t,0);return n.setFullYear(e,0,4),n.setHours(0,0,0,0),S(n)}function K(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function tt(t){if(!K(t)&&typeof t!="number")return!1;const e=w(t);return!isNaN(Number(e))}function et(t){const e=w(t),n=D(t,0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}const nt={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},rt=(t,e,n)=>{let r;const a=nt[t];return typeof a=="string"?r=a:e===1?r=a.one:r=a.other.replace("{{count}}",e.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function N(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const at={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},it={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},ot={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},st={date:N({formats:at,defaultWidth:"full"}),time:N({formats:it,defaultWidth:"full"}),dateTime:N({formats:ot,defaultWidth:"full"})},ut={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ct=(t,e,n,r)=>ut[t];function O(t){return(e,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&t.formattingValues){const o=t.defaultFormattingWidth||t.defaultWidth,s=n!=null&&n.width?String(n.width):o;a=t.formattingValues[s]||t.formattingValues[o]}else{const o=t.defaultWidth,s=n!=null&&n.width?String(n.width):t.defaultWidth;a=t.values[s]||t.values[o]}const i=t.argumentCallback?t.argumentCallback(e):e;return a[i]}}const dt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},lt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ft={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},ht={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},mt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},gt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},wt=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},yt={ordinalNumber:wt,era:O({values:dt,defaultWidth:"wide"}),quarter:O({values:lt,defaultWidth:"wide",argumentCallback:t=>t-1}),month:O({values:ft,defaultWidth:"wide"}),day:O({values:ht,defaultWidth:"wide"}),dayPeriod:O({values:mt,defaultWidth:"wide",formattingValues:gt,defaultFormattingWidth:"wide"})};function P(t){return(e,n={})=>{const r=n.width,a=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],i=e.match(a);if(!i)return null;const o=i[0],s=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],u=Array.isArray(s)?Dt(s,g=>g.test(o)):bt(s,g=>g.test(o));let d;d=t.valueCallback?t.valueCallback(u):u,d=n.valueCallback?n.valueCallback(d):d;const f=e.slice(o.length);return{value:d,rest:f}}}function bt(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function Dt(t,e){for(let n=0;n{const r=e.match(t.matchPattern);if(!r)return null;const a=r[0],i=e.match(t.parsePattern);if(!i)return null;let o=t.valueCallback?t.valueCallback(i[0]):i[0];o=n.valueCallback?n.valueCallback(o):o;const s=e.slice(a.length);return{value:o,rest:s}}}const kt=/^(\d+)(th|st|nd|rd)?/i,Ot=/\d+/i,Pt={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},pt={any:[/^b/i,/^(a|c)/i]},vt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},xt={any:[/1/i,/2/i,/3/i,/4/i]},Tt={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},St={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Wt={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Yt={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Nt={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Ct={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},_t={ordinalNumber:Mt({matchPattern:kt,parsePattern:Ot,valueCallback:t=>parseInt(t,10)}),era:P({matchPatterns:Pt,defaultMatchWidth:"wide",parsePatterns:pt,defaultParseWidth:"any"}),quarter:P({matchPatterns:vt,defaultMatchWidth:"wide",parsePatterns:xt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:P({matchPatterns:Tt,defaultMatchWidth:"wide",parsePatterns:St,defaultParseWidth:"any"}),day:P({matchPatterns:Wt,defaultMatchWidth:"wide",parsePatterns:Yt,defaultParseWidth:"any"}),dayPeriod:P({matchPatterns:Nt,defaultMatchWidth:"any",parsePatterns:Ct,defaultParseWidth:"any"})},Ft={code:"en-US",formatDistance:rt,formatLong:st,formatRelative:ct,localize:yt,match:_t,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Et(t){const e=w(t);return J(e,et(e))+1}function qt(t){const e=w(t),n=+S(e)-+Z(e);return Math.round(n/A)+1}function Q(t,e){var f,g,l,k;const n=w(t),r=n.getFullYear(),a=W(),i=(e==null?void 0:e.firstWeekContainsDate)??((g=(f=e==null?void 0:e.locale)==null?void 0:f.options)==null?void 0:g.firstWeekContainsDate)??a.firstWeekContainsDate??((k=(l=a.locale)==null?void 0:l.options)==null?void 0:k.firstWeekContainsDate)??1,o=D(t,0);o.setFullYear(r+1,0,i),o.setHours(0,0,0,0);const s=v(o,e),u=D(t,0);u.setFullYear(r,0,i),u.setHours(0,0,0,0);const d=v(u,e);return n.getTime()>=s.getTime()?r+1:n.getTime()>=d.getTime()?r:r-1}function Ut(t,e){var s,u,d,f;const n=W(),r=(e==null?void 0:e.firstWeekContainsDate)??((u=(s=e==null?void 0:e.locale)==null?void 0:s.options)==null?void 0:u.firstWeekContainsDate)??n.firstWeekContainsDate??((f=(d=n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??1,a=Q(t,e),i=D(t,0);return i.setFullYear(a,0,r),i.setHours(0,0,0,0),v(i,e)}function Lt(t,e){const n=w(t),r=+v(n,e)-+Ut(n,e);return Math.round(r/A)+1}function c(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const y={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return c(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):c(n+1,2)},d(t,e){return c(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return c(t.getHours()%12||12,e.length)},H(t,e){return c(t.getHours(),e.length)},m(t,e){return c(t.getMinutes(),e.length)},s(t,e){return c(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return c(a,e.length)}},M={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},q={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return y.y(t,e)},Y:function(t,e,n,r){const a=Q(t,r),i=a>0?a:1-a;if(e==="YY"){const o=i%100;return c(o,2)}return e==="Yo"?n.ordinalNumber(i,{unit:"year"}):c(i,e.length)},R:function(t,e){const n=j(t);return c(n,e.length)},u:function(t,e){const n=t.getFullYear();return c(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return c(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return c(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return y.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return c(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const a=Lt(t,r);return e==="wo"?n.ordinalNumber(a,{unit:"week"}):c(a,e.length)},I:function(t,e,n){const r=qt(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):c(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):y.d(t,e)},D:function(t,e,n){const r=Et(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):c(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const a=t.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return c(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const a=t.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return c(i,e.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),a=r===0?7:r;switch(e){case"i":return String(a);case"ii":return c(a,e.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const a=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let a;switch(r===12?a=M.noon:r===0?a=M.midnight:a=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let a;switch(r>=17?a=M.evening:r>=12?a=M.afternoon:r>=4?a=M.morning:a=M.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return y.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):y.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):c(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):c(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):y.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):y.s(t,e)},S:function(t,e){return y.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return L(r);case"XXXX":case"XX":return b(r);case"XXXXX":case"XXX":default:return b(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return L(r);case"xxxx":case"xx":return b(r);case"xxxxx":case"xxx":default:return b(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+U(r,":");case"OOOO":default:return"GMT"+b(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+U(r,":");case"zzzz":default:return"GMT"+b(r,":")}},t:function(t,e,n){const r=Math.trunc(t.getTime()/1e3);return c(r,e.length)},T:function(t,e,n){const r=t.getTime();return c(r,e.length)}};function U(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),a=Math.trunc(r/60),i=r%60;return i===0?n+String(a):n+String(a)+e+c(i,2)}function L(t,e){return t%60===0?(t>0?"-":"+")+c(Math.abs(t)/60,2):b(t,e)}function b(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),a=c(Math.trunc(r/60),2),i=c(r%60,2);return n+a+e+i}const H=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},X=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},Ht=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return H(t,e);let i;switch(r){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;case"PPPP":default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",H(r,e)).replace("{{time}}",X(a,e))},At={p:X,P:Ht},It=/^D+$/,Rt=/^Y+$/,jt=["D","DD","YY","YYYY"];function Qt(t){return It.test(t)}function Xt(t){return Rt.test(t)}function Bt(t,e,n){const r=Gt(t,e,n);if(console.warn(r),jt.includes(t))throw new RangeError(r)}function Gt(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const $t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,zt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Vt=/^'([^]*?)'?$/,Jt=/''/g,Zt=/[a-zA-Z]/;function Kt(t,e,n){var f,g,l,k;const r=W(),a=r.locale??Ft,i=r.firstWeekContainsDate??((g=(f=r.locale)==null?void 0:f.options)==null?void 0:g.firstWeekContainsDate)??1,o=r.weekStartsOn??((k=(l=r.locale)==null?void 0:l.options)==null?void 0:k.weekStartsOn)??0,s=w(t);if(!tt(s))throw new RangeError("Invalid time value");let u=e.match(zt).map(m=>{const h=m[0];if(h==="p"||h==="P"){const Y=At[h];return Y(m,a.formatLong)}return m}).join("").match($t).map(m=>{if(m==="''")return{isToken:!1,value:"'"};const h=m[0];if(h==="'")return{isToken:!1,value:te(m)};if(q[h])return{isToken:!0,value:m};if(h.match(Zt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:m}});a.localize.preprocessor&&(u=a.localize.preprocessor(s,u));const d={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return u.map(m=>{if(!m.isToken)return m.value;const h=m.value;(Xt(h)||Qt(h))&&Bt(h,e,String(t));const Y=q[h[0]];return Y(s,h,a.localize,d)}).join("")}function te(t){const e=t.match(Vt);return e?e[1].replace(Jt,"'"):t}function B(t,e){const r=ae(t);let a;if(r.date){const u=ie(r.date,2);a=oe(u.restDateString,u.year)}if(!a||isNaN(a.getTime()))return new Date(NaN);const i=a.getTime();let o=0,s;if(r.time&&(o=se(r.time),isNaN(o)))return new Date(NaN);if(r.timezone){if(s=ue(r.timezone),isNaN(s))return new Date(NaN)}else{const u=new Date(i+o),d=new Date(0);return d.setFullYear(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate()),d.setHours(u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.getUTCMilliseconds()),d}return new Date(i+o+s)}const x={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},ee=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,ne=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,re=/^([+-])(\d{2})(?::?(\d{2}))?$/;function ae(t){const e={},n=t.split(x.dateTimeDelimiter);let r;if(n.length>2)return e;if(/:/.test(n[0])?r=n[0]:(e.date=n[0],r=n[1],x.timeZoneDelimiter.test(e.date)&&(e.date=t.split(x.timeZoneDelimiter)[0],r=t.substr(e.date.length,t.length))),r){const a=x.timezone.exec(r);a?(e.time=r.replace(a[1],""),e.timezone=a[1]):e.time=r}return e}function ie(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),r=t.match(n);if(!r)return{year:NaN,restDateString:""};const a=r[1]?parseInt(r[1]):null,i=r[2]?parseInt(r[2]):null;return{year:i===null?a:i*100,restDateString:t.slice((r[1]||r[2]).length)}}function oe(t,e){if(e===null)return new Date(NaN);const n=t.match(ee);if(!n)return new Date(NaN);const r=!!n[4],a=p(n[1]),i=p(n[2])-1,o=p(n[3]),s=p(n[4]),u=p(n[5])-1;if(r)return he(e,s,u)?ce(e,s,u):new Date(NaN);{const d=new Date(0);return!le(e,i,o)||!fe(e,a)?new Date(NaN):(d.setUTCFullYear(e,i,Math.max(a,o)),d)}}function p(t){return t?parseInt(t):1}function se(t){const e=t.match(ne);if(!e)return NaN;const n=C(e[1]),r=C(e[2]),a=C(e[3]);return me(n,r,a)?n*R+r*I+a*1e3:NaN}function C(t){return t&&parseFloat(t.replace(",","."))||0}function ue(t){if(t==="Z")return 0;const e=t.match(re);if(!e)return 0;const n=e[1]==="+"?-1:1,r=parseInt(e[2]),a=e[3]&&parseInt(e[3])||0;return ge(r,a)?n*(r*R+a*I):NaN}function ce(t,e,n){const r=new Date(0);r.setUTCFullYear(t,0,4);const a=r.getUTCDay()||7,i=(e-1)*7+n+1-a;return r.setUTCDate(r.getUTCDate()+i),r}const de=[31,null,31,30,31,30,31,31,30,31,30,31];function G(t){return t%400===0||t%4===0&&t%100!==0}function le(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(de[e]||(G(t)?29:28))}function fe(t,e){return e>=1&&e<=(G(t)?366:365)}function he(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function me(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function ge(t,e){return e>=0&&e<=59}const we={model:"models",dataset:"datasets",space:"spaces"};function ye(t){const e=t.hf_artifact_summary;return!e||!e.best_kind||!e.best_url||e.best_count<=0?{hfKind:null,hfCount:0,hfUrl:null}:{hfKind:we[e.best_kind]??null,hfCount:e.best_count,hfUrl:e.best_url}}function be(t){if(!t||t.length===0)return{github:null,githubUrl:null,velocity24h:null};const e=t.filter(a=>a.is_official),r=[...e.length>0?e:t].sort((a,i)=>(i.num_stars||0)-(a.num_stars||0))[0];return{github:r&&r.num_stars>0?r.num_stars:null,githubUrl:(r==null?void 0:r.url)||null,velocity24h:(r==null?void 0:r.trending_score)??null}}function De(t){if(!t)return null;try{const e=typeof t=="string"?B(t):t;return Kt(e,"MMM d, yyyy")}catch{return null}}function Me(t){if(!t)return null;try{return B(t).getFullYear()}catch{return null}}function ke(t){return(t||[]).filter(e=>e.best_rank>=1&&e.best_rank<=3).map(e=>{let n=null;if(e.dataset_slug){const r=new URLSearchParams;e.task_slug&&r.set("task",e.task_slug),r.set("eval",e.evaluation_id),n=`/benchmark/${e.dataset_slug}?${r}`}return{name:e.dataset_name,href:n,rank:e.best_rank}})}function ve(t){var f,g;const{github:e,githubUrl:n,velocity24h:r}=be(t.repositories),{hfKind:a,hfCount:i,hfUrl:o}=ye(t),s=(t.tasks||[]).map(l=>l.slug||"").filter(Boolean),u=(t.methods||[]).map(l=>({id:l.id,name:l.name,slug:l.slug})),d=ke(t.leaderboard_ranks);return{id:t.arxiv_id||t.id,dbId:t.id,title:t.title,abstract:t.abstract||"",authors:t.authors||[],authorIds:(t.author_links||[]).map(l=>l.id??null),authorHfProfiles:(t.author_links||[]).map(l=>l.hf_username?{username:l.hf_username,avatarUrl:l.hf_avatar_url??null}:null),tags:s,methods:u,organizations:(t.organizations||[]).map(l=>({name:l.name,slug:l.slug,logoUrl:_(l.logo_url)||null})),citations:t.citation_count||0,github:e,githubUrl:n,project:((g=(f=t.project_pages)==null?void 0:f[0])==null?void 0:g.url)||null,date:De(t.published),publishedIso:t.published||null,year:Me(t.published),thumbnailUrl:_(t.thumbnail_url)||null,tldr:t.tldr||null,version:t.version||"v1",velocity24h:r,hfKind:a,hfCount:i,hfUrl:o,sotaRanks:d}}function Oe(t){const e=$.get(t.toLowerCase());if(e)return e;const n=t.toUpperCase();return T.has(n)?n:t.replace(/[-_]+/g," ").replace(/\b\w/g,r=>r.toUpperCase())}const T=new Set(["3D","AI","OCR"]),$=new Map([["3d-tracking","3D Tracking"],["point-tracking","2D Point Tracking"],["3d-generation","3D generation"],["3d-understanding","3D understanding"],["3d-semantic-segmentation","3D semantic segmentation"],["3d-instance-segmentation","3D instance segmentation"],["3d-object-detection","3D object detection"],["text-to-sql","Text-to-SQL"]]);function xe(t,e){const n=t||Oe(e||""),r=$.get((e==null?void 0:e.toLowerCase())||Pe(n));if(r)return r;const a=e==null?void 0:e.toUpperCase(),i=n.toUpperCase();return/^[A-Z0-9][A-Z0-9-]{1,}$/.test(n)||a&&T.has(a)||T.has(i)?i:n.replace(/\b[A-Za-z0-9]+\b/g,s=>/^[A-Z0-9]{2,}$/.test(s)||T.has(s.toUpperCase())?s.toUpperCase():s.charAt(0).toUpperCase()+s.slice(1).toLowerCase())}function Pe(t){return t.trim().toLowerCase().replace(/[\s_]+/g,"-")}export{ke as a,xe as d,Oe as h,be as s,ve as t}; +import{a3 as _}from"./index-CjdUkE4w.js";function w(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function D(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}const A=6048e5,z=864e5,I=6e4,R=36e5;let V={};function W(){return V}function v(t,e){var s,u,d,f;const n=W(),r=(e==null?void 0:e.weekStartsOn)??((u=(s=e==null?void 0:e.locale)==null?void 0:s.options)==null?void 0:u.weekStartsOn)??n.weekStartsOn??((f=(d=n.locale)==null?void 0:d.options)==null?void 0:f.weekStartsOn)??0,a=w(t),i=a.getDay(),o=(i=a.getTime()?n+1:e.getTime()>=o.getTime()?n:n-1}function F(t){const e=w(t);return e.setHours(0,0,0,0),e}function E(t){const e=w(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function J(t,e){const n=F(t),r=F(e),a=+n-E(n),i=+r-E(r);return Math.round((a-i)/z)}function Z(t){const e=j(t),n=D(t,0);return n.setFullYear(e,0,4),n.setHours(0,0,0,0),S(n)}function K(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function tt(t){if(!K(t)&&typeof t!="number")return!1;const e=w(t);return!isNaN(Number(e))}function et(t){const e=w(t),n=D(t,0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}const nt={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},rt=(t,e,n)=>{let r;const a=nt[t];return typeof a=="string"?r=a:e===1?r=a.one:r=a.other.replace("{{count}}",e.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function N(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const at={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},it={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},ot={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},st={date:N({formats:at,defaultWidth:"full"}),time:N({formats:it,defaultWidth:"full"}),dateTime:N({formats:ot,defaultWidth:"full"})},ut={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ct=(t,e,n,r)=>ut[t];function O(t){return(e,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&t.formattingValues){const o=t.defaultFormattingWidth||t.defaultWidth,s=n!=null&&n.width?String(n.width):o;a=t.formattingValues[s]||t.formattingValues[o]}else{const o=t.defaultWidth,s=n!=null&&n.width?String(n.width):t.defaultWidth;a=t.values[s]||t.values[o]}const i=t.argumentCallback?t.argumentCallback(e):e;return a[i]}}const dt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},lt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ft={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},ht={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},mt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},gt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},wt=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},yt={ordinalNumber:wt,era:O({values:dt,defaultWidth:"wide"}),quarter:O({values:lt,defaultWidth:"wide",argumentCallback:t=>t-1}),month:O({values:ft,defaultWidth:"wide"}),day:O({values:ht,defaultWidth:"wide"}),dayPeriod:O({values:mt,defaultWidth:"wide",formattingValues:gt,defaultFormattingWidth:"wide"})};function P(t){return(e,n={})=>{const r=n.width,a=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],i=e.match(a);if(!i)return null;const o=i[0],s=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],u=Array.isArray(s)?Dt(s,g=>g.test(o)):bt(s,g=>g.test(o));let d;d=t.valueCallback?t.valueCallback(u):u,d=n.valueCallback?n.valueCallback(d):d;const f=e.slice(o.length);return{value:d,rest:f}}}function bt(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function Dt(t,e){for(let n=0;n{const r=e.match(t.matchPattern);if(!r)return null;const a=r[0],i=e.match(t.parsePattern);if(!i)return null;let o=t.valueCallback?t.valueCallback(i[0]):i[0];o=n.valueCallback?n.valueCallback(o):o;const s=e.slice(a.length);return{value:o,rest:s}}}const kt=/^(\d+)(th|st|nd|rd)?/i,Ot=/\d+/i,Pt={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},pt={any:[/^b/i,/^(a|c)/i]},vt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},xt={any:[/1/i,/2/i,/3/i,/4/i]},Tt={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},St={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Wt={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Yt={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Nt={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Ct={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},_t={ordinalNumber:Mt({matchPattern:kt,parsePattern:Ot,valueCallback:t=>parseInt(t,10)}),era:P({matchPatterns:Pt,defaultMatchWidth:"wide",parsePatterns:pt,defaultParseWidth:"any"}),quarter:P({matchPatterns:vt,defaultMatchWidth:"wide",parsePatterns:xt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:P({matchPatterns:Tt,defaultMatchWidth:"wide",parsePatterns:St,defaultParseWidth:"any"}),day:P({matchPatterns:Wt,defaultMatchWidth:"wide",parsePatterns:Yt,defaultParseWidth:"any"}),dayPeriod:P({matchPatterns:Nt,defaultMatchWidth:"any",parsePatterns:Ct,defaultParseWidth:"any"})},Ft={code:"en-US",formatDistance:rt,formatLong:st,formatRelative:ct,localize:yt,match:_t,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Et(t){const e=w(t);return J(e,et(e))+1}function qt(t){const e=w(t),n=+S(e)-+Z(e);return Math.round(n/A)+1}function Q(t,e){var f,g,l,k;const n=w(t),r=n.getFullYear(),a=W(),i=(e==null?void 0:e.firstWeekContainsDate)??((g=(f=e==null?void 0:e.locale)==null?void 0:f.options)==null?void 0:g.firstWeekContainsDate)??a.firstWeekContainsDate??((k=(l=a.locale)==null?void 0:l.options)==null?void 0:k.firstWeekContainsDate)??1,o=D(t,0);o.setFullYear(r+1,0,i),o.setHours(0,0,0,0);const s=v(o,e),u=D(t,0);u.setFullYear(r,0,i),u.setHours(0,0,0,0);const d=v(u,e);return n.getTime()>=s.getTime()?r+1:n.getTime()>=d.getTime()?r:r-1}function Ut(t,e){var s,u,d,f;const n=W(),r=(e==null?void 0:e.firstWeekContainsDate)??((u=(s=e==null?void 0:e.locale)==null?void 0:s.options)==null?void 0:u.firstWeekContainsDate)??n.firstWeekContainsDate??((f=(d=n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??1,a=Q(t,e),i=D(t,0);return i.setFullYear(a,0,r),i.setHours(0,0,0,0),v(i,e)}function Lt(t,e){const n=w(t),r=+v(n,e)-+Ut(n,e);return Math.round(r/A)+1}function c(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const y={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return c(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):c(n+1,2)},d(t,e){return c(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return c(t.getHours()%12||12,e.length)},H(t,e){return c(t.getHours(),e.length)},m(t,e){return c(t.getMinutes(),e.length)},s(t,e){return c(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return c(a,e.length)}},M={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},q={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return y.y(t,e)},Y:function(t,e,n,r){const a=Q(t,r),i=a>0?a:1-a;if(e==="YY"){const o=i%100;return c(o,2)}return e==="Yo"?n.ordinalNumber(i,{unit:"year"}):c(i,e.length)},R:function(t,e){const n=j(t);return c(n,e.length)},u:function(t,e){const n=t.getFullYear();return c(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return c(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return c(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return y.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return c(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const a=Lt(t,r);return e==="wo"?n.ordinalNumber(a,{unit:"week"}):c(a,e.length)},I:function(t,e,n){const r=qt(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):c(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):y.d(t,e)},D:function(t,e,n){const r=Et(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):c(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const a=t.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return c(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const a=t.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return c(i,e.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),a=r===0?7:r;switch(e){case"i":return String(a);case"ii":return c(a,e.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const a=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let a;switch(r===12?a=M.noon:r===0?a=M.midnight:a=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let a;switch(r>=17?a=M.evening:r>=12?a=M.afternoon:r>=4?a=M.morning:a=M.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return y.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):y.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):c(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):c(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):y.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):y.s(t,e)},S:function(t,e){return y.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return L(r);case"XXXX":case"XX":return b(r);case"XXXXX":case"XXX":default:return b(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return L(r);case"xxxx":case"xx":return b(r);case"xxxxx":case"xxx":default:return b(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+U(r,":");case"OOOO":default:return"GMT"+b(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+U(r,":");case"zzzz":default:return"GMT"+b(r,":")}},t:function(t,e,n){const r=Math.trunc(t.getTime()/1e3);return c(r,e.length)},T:function(t,e,n){const r=t.getTime();return c(r,e.length)}};function U(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),a=Math.trunc(r/60),i=r%60;return i===0?n+String(a):n+String(a)+e+c(i,2)}function L(t,e){return t%60===0?(t>0?"-":"+")+c(Math.abs(t)/60,2):b(t,e)}function b(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),a=c(Math.trunc(r/60),2),i=c(r%60,2);return n+a+e+i}const H=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},X=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},Ht=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return H(t,e);let i;switch(r){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;case"PPPP":default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",H(r,e)).replace("{{time}}",X(a,e))},At={p:X,P:Ht},It=/^D+$/,Rt=/^Y+$/,jt=["D","DD","YY","YYYY"];function Qt(t){return It.test(t)}function Xt(t){return Rt.test(t)}function Bt(t,e,n){const r=Gt(t,e,n);if(console.warn(r),jt.includes(t))throw new RangeError(r)}function Gt(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const $t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,zt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Vt=/^'([^]*?)'?$/,Jt=/''/g,Zt=/[a-zA-Z]/;function Kt(t,e,n){var f,g,l,k;const r=W(),a=r.locale??Ft,i=r.firstWeekContainsDate??((g=(f=r.locale)==null?void 0:f.options)==null?void 0:g.firstWeekContainsDate)??1,o=r.weekStartsOn??((k=(l=r.locale)==null?void 0:l.options)==null?void 0:k.weekStartsOn)??0,s=w(t);if(!tt(s))throw new RangeError("Invalid time value");let u=e.match(zt).map(m=>{const h=m[0];if(h==="p"||h==="P"){const Y=At[h];return Y(m,a.formatLong)}return m}).join("").match($t).map(m=>{if(m==="''")return{isToken:!1,value:"'"};const h=m[0];if(h==="'")return{isToken:!1,value:te(m)};if(q[h])return{isToken:!0,value:m};if(h.match(Zt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:m}});a.localize.preprocessor&&(u=a.localize.preprocessor(s,u));const d={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return u.map(m=>{if(!m.isToken)return m.value;const h=m.value;(Xt(h)||Qt(h))&&Bt(h,e,String(t));const Y=q[h[0]];return Y(s,h,a.localize,d)}).join("")}function te(t){const e=t.match(Vt);return e?e[1].replace(Jt,"'"):t}function B(t,e){const r=ae(t);let a;if(r.date){const u=ie(r.date,2);a=oe(u.restDateString,u.year)}if(!a||isNaN(a.getTime()))return new Date(NaN);const i=a.getTime();let o=0,s;if(r.time&&(o=se(r.time),isNaN(o)))return new Date(NaN);if(r.timezone){if(s=ue(r.timezone),isNaN(s))return new Date(NaN)}else{const u=new Date(i+o),d=new Date(0);return d.setFullYear(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate()),d.setHours(u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.getUTCMilliseconds()),d}return new Date(i+o+s)}const x={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},ee=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,ne=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,re=/^([+-])(\d{2})(?::?(\d{2}))?$/;function ae(t){const e={},n=t.split(x.dateTimeDelimiter);let r;if(n.length>2)return e;if(/:/.test(n[0])?r=n[0]:(e.date=n[0],r=n[1],x.timeZoneDelimiter.test(e.date)&&(e.date=t.split(x.timeZoneDelimiter)[0],r=t.substr(e.date.length,t.length))),r){const a=x.timezone.exec(r);a?(e.time=r.replace(a[1],""),e.timezone=a[1]):e.time=r}return e}function ie(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),r=t.match(n);if(!r)return{year:NaN,restDateString:""};const a=r[1]?parseInt(r[1]):null,i=r[2]?parseInt(r[2]):null;return{year:i===null?a:i*100,restDateString:t.slice((r[1]||r[2]).length)}}function oe(t,e){if(e===null)return new Date(NaN);const n=t.match(ee);if(!n)return new Date(NaN);const r=!!n[4],a=p(n[1]),i=p(n[2])-1,o=p(n[3]),s=p(n[4]),u=p(n[5])-1;if(r)return he(e,s,u)?ce(e,s,u):new Date(NaN);{const d=new Date(0);return!le(e,i,o)||!fe(e,a)?new Date(NaN):(d.setUTCFullYear(e,i,Math.max(a,o)),d)}}function p(t){return t?parseInt(t):1}function se(t){const e=t.match(ne);if(!e)return NaN;const n=C(e[1]),r=C(e[2]),a=C(e[3]);return me(n,r,a)?n*R+r*I+a*1e3:NaN}function C(t){return t&&parseFloat(t.replace(",","."))||0}function ue(t){if(t==="Z")return 0;const e=t.match(re);if(!e)return 0;const n=e[1]==="+"?-1:1,r=parseInt(e[2]),a=e[3]&&parseInt(e[3])||0;return ge(r,a)?n*(r*R+a*I):NaN}function ce(t,e,n){const r=new Date(0);r.setUTCFullYear(t,0,4);const a=r.getUTCDay()||7,i=(e-1)*7+n+1-a;return r.setUTCDate(r.getUTCDate()+i),r}const de=[31,null,31,30,31,30,31,31,30,31,30,31];function G(t){return t%400===0||t%4===0&&t%100!==0}function le(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(de[e]||(G(t)?29:28))}function fe(t,e){return e>=1&&e<=(G(t)?366:365)}function he(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function me(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function ge(t,e){return e>=0&&e<=59}const we={model:"models",dataset:"datasets",space:"spaces"};function ye(t){const e=t.hf_artifact_summary;return!e||!e.best_kind||!e.best_url||e.best_count<=0?{hfKind:null,hfCount:0,hfUrl:null}:{hfKind:we[e.best_kind]??null,hfCount:e.best_count,hfUrl:e.best_url}}function be(t){if(!t||t.length===0)return{github:null,githubUrl:null,velocity24h:null};const e=t.filter(a=>a.is_official),r=[...e.length>0?e:t].sort((a,i)=>(i.num_stars||0)-(a.num_stars||0))[0];return{github:r&&r.num_stars>0?r.num_stars:null,githubUrl:(r==null?void 0:r.url)||null,velocity24h:(r==null?void 0:r.trending_score)??null}}function De(t){if(!t)return null;try{const e=typeof t=="string"?B(t):t;return Kt(e,"MMM d, yyyy")}catch{return null}}function Me(t){if(!t)return null;try{return B(t).getFullYear()}catch{return null}}function ke(t){return(t||[]).filter(e=>e.best_rank>=1&&e.best_rank<=3).map(e=>{let n=null;if(e.dataset_slug){const r=new URLSearchParams;e.task_slug&&r.set("task",e.task_slug),r.set("eval",e.evaluation_id),n=`/benchmark/${e.dataset_slug}?${r}`}return{name:e.dataset_name,href:n,rank:e.best_rank}})}function ve(t){var f,g;const{github:e,githubUrl:n,velocity24h:r}=be(t.repositories),{hfKind:a,hfCount:i,hfUrl:o}=ye(t),s=(t.tasks||[]).map(l=>l.slug||"").filter(Boolean),u=(t.methods||[]).map(l=>({id:l.id,name:l.name,slug:l.slug})),d=ke(t.leaderboard_ranks);return{id:t.arxiv_id||t.id,dbId:t.id,title:t.title,abstract:t.abstract||"",authors:t.authors||[],authorIds:(t.author_links||[]).map(l=>l.id??null),authorHfProfiles:(t.author_links||[]).map(l=>l.hf_username?{username:l.hf_username,avatarUrl:l.hf_avatar_url??null}:null),tags:s,methods:u,organizations:(t.organizations||[]).map(l=>({name:l.name,slug:l.slug,logoUrl:_(l.logo_url)||null})),citations:t.citation_count||0,github:e,githubUrl:n,project:((g=(f=t.project_pages)==null?void 0:f[0])==null?void 0:g.url)||null,date:De(t.published),publishedIso:t.published||null,year:Me(t.published),thumbnailUrl:_(t.thumbnail_url)||null,tldr:t.tldr||null,version:t.version||"v1",velocity24h:r,hfKind:a,hfCount:i,hfUrl:o,sotaRanks:d}}function Oe(t){const e=$.get(t.toLowerCase());if(e)return e;const n=t.toUpperCase();return T.has(n)?n:t.replace(/[-_]+/g," ").replace(/\b\w/g,r=>r.toUpperCase())}const T=new Set(["3D","AI","OCR"]),$=new Map([["3d-tracking","3D Tracking"],["point-tracking","2D Point Tracking"],["3d-generation","3D generation"],["3d-understanding","3D understanding"],["3d-semantic-segmentation","3D semantic segmentation"],["3d-instance-segmentation","3D instance segmentation"],["3d-object-detection","3D object detection"],["text-to-sql","Text-to-SQL"]]);function xe(t,e){const n=t||Oe(e||""),r=$.get((e==null?void 0:e.toLowerCase())||Pe(n));if(r)return r;const a=e==null?void 0:e.toUpperCase(),i=n.toUpperCase();return/^[A-Z0-9][A-Z0-9-]{1,}$/.test(n)||a&&T.has(a)||T.has(i)?i:n.replace(/\b[A-Za-z0-9]+\b/g,s=>/^[A-Z0-9]{2,}$/.test(s)||T.has(s.toUpperCase())?s.toUpperCase():s.charAt(0).toUpperCase()+s.slice(1).toLowerCase())}function Pe(t){return t.trim().toLowerCase().replace(/[\s_]+/g,"-")}export{ke as a,xe as d,Oe as h,be as s,ve as t}; diff --git a/assets/trending-up-OM6wBVvQ.js b/assets/trending-up-BMb-8Pi8.js similarity index 88% rename from assets/trending-up-OM6wBVvQ.js rename to assets/trending-up-BMb-8Pi8.js index 1797296b7d0d07713dcc14a153d8023b6c027b90..2469bd91d90561b4eda4a398503717bf522c5eb4 100644 --- a/assets/trending-up-OM6wBVvQ.js +++ b/assets/trending-up-BMb-8Pi8.js @@ -1,4 +1,4 @@ -import{s as e}from"./index-DyXq7-Tg.js";/** +import{s as e}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/triangle-alert-uZ3fXFkp.js b/assets/triangle-alert-DF8Mdy0J.js similarity index 94% rename from assets/triangle-alert-uZ3fXFkp.js rename to assets/triangle-alert-DF8Mdy0J.js index 26afcd91280ac3853988e32953473f811b643be0..37e2d0515d7e5e9683993ef92bc4e1115022c27a 100644 --- a/assets/triangle-alert-uZ3fXFkp.js +++ b/assets/triangle-alert-DF8Mdy0J.js @@ -1,4 +1,4 @@ -import{s as e}from"./index-DyXq7-Tg.js";/** +import{s as e}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/trophy-BtgLmZ39.js b/assets/trophy-BQy3NGXy.js similarity index 93% rename from assets/trophy-BtgLmZ39.js rename to assets/trophy-BQy3NGXy.js index c906c509aeaf1ae3104b6fd777c07532921a0974..2f29d009aef8ce3aa1bbe72d37294790aaa37b11 100644 --- a/assets/trophy-BtgLmZ39.js +++ b/assets/trophy-BQy3NGXy.js @@ -1,4 +1,4 @@ -import{s as a}from"./index-DyXq7-Tg.js";/** +import{s as a}from"./index-CjdUkE4w.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/useDebounce-B9jkN7LV.js b/assets/useDebounce-wGQ3PIQd.js similarity index 66% rename from assets/useDebounce-B9jkN7LV.js rename to assets/useDebounce-wGQ3PIQd.js index d5fdd347ca590e2a6ad483c623c105cb20a32dea..3fc6754730d303847ad181ab09f16bdfdbbe495d 100644 --- a/assets/useDebounce-B9jkN7LV.js +++ b/assets/useDebounce-wGQ3PIQd.js @@ -1 +1 @@ -import{d as o}from"./index-DyXq7-Tg.js";function s(e,t=300){const[r,u]=o.useState(e);return o.useEffect(()=>{const c=setTimeout(()=>u(e),t);return()=>clearTimeout(c)},[e,t]),r}export{s as u}; +import{d as o}from"./index-CjdUkE4w.js";function s(e,t=300){const[r,u]=o.useState(e);return o.useEffect(()=>{const c=setTimeout(()=>u(e),t);return()=>clearTimeout(c)},[e,t]),r}export{s as u}; diff --git a/assets/useDocumentTitle-DcxM2Zv_.js b/assets/useDocumentTitle-2Ho8_KfW.js similarity index 96% rename from assets/useDocumentTitle-DcxM2Zv_.js rename to assets/useDocumentTitle-2Ho8_KfW.js index 9c72dad2baf66a425d908a601974e6f6bb20146d..68f70b2605ca57007b93453f868fa8bc570e0568 100644 --- a/assets/useDocumentTitle-DcxM2Zv_.js +++ b/assets/useDocumentTitle-2Ho8_KfW.js @@ -1 +1 @@ -import{d as s}from"./index-DyXq7-Tg.js";const E={a:"á",e:"é",i:"í",o:"ó",u:"ú",y:"ý",A:"Á",E:"É",I:"Í",O:"Ó",U:"Ú",Y:"Ý"},p={a:"à",e:"è",i:"ì",o:"ò",u:"ù",A:"À",E:"È",I:"Ì",O:"Ò",U:"Ù"},u={a:"â",e:"ê",i:"î",o:"ô",u:"û",A:"Â",E:"Ê",I:"Î",O:"Ô",U:"Û"},_={a:"ä",e:"ë",i:"ï",o:"ö",u:"ü",y:"ÿ",A:"Ä",E:"Ë",I:"Ï",O:"Ö",U:"Ü",Y:"Ÿ"},T={"'":E,"`":p,"^":u,'"':_,"~":{n:"ñ",N:"Ñ"}},i={ss:"ß",ae:"æ",AE:"Æ",oe:"œ",OE:"Œ",o:"ø",O:"Ø",l:"ł",L:"Ł"},m=[["varphi","φ"],["varepsilon","ε"],["vartheta","ϑ"],["Gamma","Γ"],["Delta","Δ"],["Theta","Θ"],["Lambda","Λ"],["Sigma","Σ"],["Omega","Ω"],["alpha","α"],["beta","β"],["gamma","γ"],["delta","δ"],["epsilon","ε"],["zeta","ζ"],["eta","η"],["theta","θ"],["kappa","κ"],["lambda","λ"],["mu","μ"],["nu","ν"],["xi","ξ"],["pi","π"],["rho","ρ"],["sigma","σ"],["tau","τ"],["phi","φ"],["chi","χ"],["psi","ψ"],["omega","ω"]],L=/\\(?:textbf|mathbf|emph|textit|textsl|texttt|color|textcolor)\{([^{}]*)\}/g,f=/\\(['"`^~])([A-Za-z])/g,C=/\\c\{([cCsS])\}/g,M=new RegExp(`\\\\(${Object.keys(i).join("|")})(?![A-Za-z])`,"g"),g=/\$\$([^$]+)\$\$/g,O=/\$([^$]+)\$/g,$=/\\([A-Za-z]+)/g;function o(e,t,a){return e.split(t).join(a)}function r(e){let t=e.trim();for(const[a,n]of m)t=o(t,`\\${a}`,n);return t=t.replace($,(a,n)=>n),o(t,"$","")}function h(e){let t=e.replace(g,(a,n)=>r(n));return t=t.replace(O,(a,n)=>r(n)),o(t,"$","")}function D(e){if(!e)return e;let t=e.replace(L,"$1");return t=t.replace(C,(a,n)=>({c:"ç",C:"Ç"})[n]??a),t=t.replace(f,(a,n,A)=>{var c;return((c=T[n])==null?void 0:c[A])??a}),t=t.replace(M,(a,n)=>i[n]??a),t=h(t),o(t,"~"," ")}const l="Papers with Code";function I(e,t=l){return`${D(e.trim())||"Paper"} | ${t}`}function R(e,{restorePrevious:t=!1}={}){s.useEffect(()=>{if(!e)return;const a=document.title;return document.title=e,()=>{document.title=t?a:l}},[e,t])}export{I as f,R as u}; +import{d as s}from"./index-CjdUkE4w.js";const E={a:"á",e:"é",i:"í",o:"ó",u:"ú",y:"ý",A:"Á",E:"É",I:"Í",O:"Ó",U:"Ú",Y:"Ý"},p={a:"à",e:"è",i:"ì",o:"ò",u:"ù",A:"À",E:"È",I:"Ì",O:"Ò",U:"Ù"},u={a:"â",e:"ê",i:"î",o:"ô",u:"û",A:"Â",E:"Ê",I:"Î",O:"Ô",U:"Û"},_={a:"ä",e:"ë",i:"ï",o:"ö",u:"ü",y:"ÿ",A:"Ä",E:"Ë",I:"Ï",O:"Ö",U:"Ü",Y:"Ÿ"},T={"'":E,"`":p,"^":u,'"':_,"~":{n:"ñ",N:"Ñ"}},i={ss:"ß",ae:"æ",AE:"Æ",oe:"œ",OE:"Œ",o:"ø",O:"Ø",l:"ł",L:"Ł"},m=[["varphi","φ"],["varepsilon","ε"],["vartheta","ϑ"],["Gamma","Γ"],["Delta","Δ"],["Theta","Θ"],["Lambda","Λ"],["Sigma","Σ"],["Omega","Ω"],["alpha","α"],["beta","β"],["gamma","γ"],["delta","δ"],["epsilon","ε"],["zeta","ζ"],["eta","η"],["theta","θ"],["kappa","κ"],["lambda","λ"],["mu","μ"],["nu","ν"],["xi","ξ"],["pi","π"],["rho","ρ"],["sigma","σ"],["tau","τ"],["phi","φ"],["chi","χ"],["psi","ψ"],["omega","ω"]],L=/\\(?:textbf|mathbf|emph|textit|textsl|texttt|color|textcolor)\{([^{}]*)\}/g,f=/\\(['"`^~])([A-Za-z])/g,C=/\\c\{([cCsS])\}/g,M=new RegExp(`\\\\(${Object.keys(i).join("|")})(?![A-Za-z])`,"g"),g=/\$\$([^$]+)\$\$/g,O=/\$([^$]+)\$/g,$=/\\([A-Za-z]+)/g;function o(e,t,a){return e.split(t).join(a)}function r(e){let t=e.trim();for(const[a,n]of m)t=o(t,`\\${a}`,n);return t=t.replace($,(a,n)=>n),o(t,"$","")}function h(e){let t=e.replace(g,(a,n)=>r(n));return t=t.replace(O,(a,n)=>r(n)),o(t,"$","")}function D(e){if(!e)return e;let t=e.replace(L,"$1");return t=t.replace(C,(a,n)=>({c:"ç",C:"Ç"})[n]??a),t=t.replace(f,(a,n,A)=>{var c;return((c=T[n])==null?void 0:c[A])??a}),t=t.replace(M,(a,n)=>i[n]??a),t=h(t),o(t,"~"," ")}const l="Papers with Code";function I(e,t=l){return`${D(e.trim())||"Paper"} | ${t}`}function R(e,{restorePrevious:t=!1}={}){s.useEffect(()=>{if(!e)return;const a=document.title;return document.title=e,()=>{document.title=t?a:l}},[e,t])}export{I as f,R as u}; diff --git a/assets/useHashScrollOnReady-D5UCCQuT.js b/assets/useHashScrollOnReady-mScSLUem.js similarity index 90% rename from assets/useHashScrollOnReady-D5UCCQuT.js rename to assets/useHashScrollOnReady-mScSLUem.js index e8ad9dffa3699d60bae679d09ce5e62b9dd4a29e..6a5a8705af39f581da4ab7a293fdc4c335159a49 100644 --- a/assets/useHashScrollOnReady-D5UCCQuT.js +++ b/assets/useHashScrollOnReady-mScSLUem.js @@ -1 +1 @@ -import{j as s,L as h,d as x}from"./index-DyXq7-Tg.js";import{S as p}from"./skeleton-C3IIzpSL.js";import{A as j,a as m}from"./alert-gbJBhAVE.js";import{T as d}from"./trending-up-OM6wBVvQ.js";const y=({noun:n,items:e,recentDays:i=30,baselineDays:l=180,isLoading:o,error:t,mono:c})=>!o&&!t&&!(e!=null&&e.length)?null:s.jsxs("section",{id:"trending",className:"taxonomy-trending","aria-label":`Trending ${n}s`,children:[s.jsxs("div",{className:"taxonomy-trending-header",children:[s.jsxs("h2",{children:[s.jsx(d,{size:22,"aria-hidden":"true"}),"Trending"]}),s.jsxs("p",{className:"taxonomy-trending-note",children:[n==="task"?"Tasks":"Methods"," across all areas whose share of papers in the last ",i," days grew the most against the preceding ",l," days."]})]}),t?s.jsx(j,{variant:"destructive",children:s.jsxs(m,{children:["Failed to load trending ",n,"s."]})}):o?s.jsx("div",{className:"tag-grid",children:Array.from({length:6}).map((a,r)=>s.jsx(p,{className:"h-20"},r))}):s.jsx("div",{className:"tag-grid",children:e==null?void 0:e.map((a,r)=>s.jsxs(h,{to:a.href,className:"tag-cell",children:[s.jsxs("div",{className:"name",style:c?{fontFamily:"var(--mono)",fontSize:15}:void 0,children:[s.jsx("span",{className:"taxonomy-trending-rank",children:r+1}),a.icon&&s.jsx("span",{className:"task-icon",style:{color:a.iconColor},children:s.jsx(a.icon,{size:16,strokeWidth:2,"aria-hidden":"true"})}),a.name]}),s.jsxs("div",{className:"meta taxonomy-trending-meta",children:[a.areaName&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:a.areaName}),s.jsx("span",{children:"·"})]}),s.jsxs("span",{children:[a.recentPaperCount.toLocaleString()," papers / ",i,"d"]}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"method-trend-score taxonomy-trending-lift",title:`Share of recent papers is ${a.shareLift.toFixed(1)}× its baseline share`,children:[s.jsx(d,{size:12,"aria-hidden":"true"}),a.shareLift.toFixed(1),"×"]})]})]},a.id))})]});function v(n){x.useEffect(()=>{var e;!n||!window.location.hash||(e=document.getElementById(window.location.hash.slice(1)))==null||e.scrollIntoView({block:"start"})},[n])}export{y as T,v as u}; +import{j as s,L as h,d as x}from"./index-CjdUkE4w.js";import{S as p}from"./skeleton-DTWi7Ctg.js";import{A as j,a as m}from"./alert-BM9Xfuyy.js";import{T as d}from"./trending-up-BMb-8Pi8.js";const y=({noun:n,items:e,recentDays:i=30,baselineDays:l=180,isLoading:o,error:t,mono:c})=>!o&&!t&&!(e!=null&&e.length)?null:s.jsxs("section",{id:"trending",className:"taxonomy-trending","aria-label":`Trending ${n}s`,children:[s.jsxs("div",{className:"taxonomy-trending-header",children:[s.jsxs("h2",{children:[s.jsx(d,{size:22,"aria-hidden":"true"}),"Trending"]}),s.jsxs("p",{className:"taxonomy-trending-note",children:[n==="task"?"Tasks":"Methods"," across all areas whose share of papers in the last ",i," days grew the most against the preceding ",l," days."]})]}),t?s.jsx(j,{variant:"destructive",children:s.jsxs(m,{children:["Failed to load trending ",n,"s."]})}):o?s.jsx("div",{className:"tag-grid",children:Array.from({length:6}).map((a,r)=>s.jsx(p,{className:"h-20"},r))}):s.jsx("div",{className:"tag-grid",children:e==null?void 0:e.map((a,r)=>s.jsxs(h,{to:a.href,className:"tag-cell",children:[s.jsxs("div",{className:"name",style:c?{fontFamily:"var(--mono)",fontSize:15}:void 0,children:[s.jsx("span",{className:"taxonomy-trending-rank",children:r+1}),a.icon&&s.jsx("span",{className:"task-icon",style:{color:a.iconColor},children:s.jsx(a.icon,{size:16,strokeWidth:2,"aria-hidden":"true"})}),a.name]}),s.jsxs("div",{className:"meta taxonomy-trending-meta",children:[a.areaName&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:a.areaName}),s.jsx("span",{children:"·"})]}),s.jsxs("span",{children:[a.recentPaperCount.toLocaleString()," papers / ",i,"d"]}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"method-trend-score taxonomy-trending-lift",title:`Share of recent papers is ${a.shareLift.toFixed(1)}× its baseline share`,children:[s.jsx(d,{size:12,"aria-hidden":"true"}),a.shareLift.toFixed(1),"×"]})]})]},a.id))})]});function v(n){x.useEffect(()=>{var e;!n||!window.location.hash||(e=document.getElementById(window.location.hash.slice(1)))==null||e.scrollIntoView({block:"start"})},[n])}export{y as T,v as u}; diff --git a/assets/useInfiniteQuery-BYh2zN-T.js b/assets/useInfiniteQuery-DeZTTVbI.js similarity index 94% rename from assets/useInfiniteQuery-BYh2zN-T.js rename to assets/useInfiniteQuery-DeZTTVbI.js index 1787a2c391e4e469307bc55b925841f0c7b8e4ad..992ebd7a4a5a0a6ceae5057d7c146d0fc6e9590d 100644 --- a/assets/useInfiniteQuery-BYh2zN-T.js +++ b/assets/useInfiniteQuery-DeZTTVbI.js @@ -1 +1 @@ -import{aI as v,a$ as b,b0 as x,b1 as p}from"./index-DyXq7-Tg.js";var l=class extends v{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var f,P;const{state:s}=e,i=super.createResult(e,t),{isFetching:a,isRefetching:g,isError:c,isRefetchError:d}=i,r=(P=(f=s.fetchMeta)==null?void 0:f.fetchMore)==null?void 0:P.direction,h=c&&r==="forward",n=a&&r==="forward",o=c&&r==="backward",u=a&&r==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:x(t,s.data),hasPreviousPage:b(t,s.data),isFetchNextPageError:h,isFetchingNextPage:n,isFetchPreviousPageError:o,isFetchingPreviousPage:u,isRefetchError:d&&!h&&!o,isRefetching:g&&!n&&!u}}};function m(e,t){return p(e,l)}export{m as u}; +import{aJ as v,a$ as b,b0 as x,b1 as p}from"./index-CjdUkE4w.js";var l=class extends v{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var f,P;const{state:s}=e,i=super.createResult(e,t),{isFetching:a,isRefetching:g,isError:c,isRefetchError:d}=i,r=(P=(f=s.fetchMeta)==null?void 0:f.fetchMore)==null?void 0:P.direction,h=c&&r==="forward",n=a&&r==="forward",o=c&&r==="backward",u=a&&r==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:x(t,s.data),hasPreviousPage:b(t,s.data),isFetchNextPageError:h,isFetchingNextPage:n,isFetchPreviousPageError:o,isFetchingPreviousPage:u,isRefetchError:d&&!h&&!o,isRefetching:g&&!n&&!u}}};function m(e,t){return p(e,l)}export{m as u}; diff --git a/assets/useIntersectionObserver-D6_Iig9a.js b/assets/useIntersectionObserver-Ch6RpsSk.js similarity index 86% rename from assets/useIntersectionObserver-D6_Iig9a.js rename to assets/useIntersectionObserver-Ch6RpsSk.js index 1378b8ea6190fa9441d30c3f04052cf28d4ba13a..2027f15bf6443d218b925521e10c36f4f88ee67e 100644 --- a/assets/useIntersectionObserver-D6_Iig9a.js +++ b/assets/useIntersectionObserver-Ch6RpsSk.js @@ -1 +1 @@ -import{d as r}from"./index-DyXq7-Tg.js";function b(u={}){const{threshold:t=0,rootMargin:n="0px"}=u,[i,s]=r.useState(!1),e=r.useRef(null),f=r.useCallback(c=>{if(e.current&&(e.current.disconnect(),e.current=null),!c){s(!1);return}const o=new IntersectionObserver(([l])=>s(l.isIntersecting),{threshold:t,rootMargin:n});o.observe(c),e.current=o},[t,n]);return r.useEffect(()=>()=>{e.current&&(e.current.disconnect(),e.current=null)},[]),{targetRef:f,isIntersecting:i}}export{b as u}; +import{d as r}from"./index-CjdUkE4w.js";function b(u={}){const{threshold:t=0,rootMargin:n="0px"}=u,[i,s]=r.useState(!1),e=r.useRef(null),f=r.useCallback(c=>{if(e.current&&(e.current.disconnect(),e.current=null),!c){s(!1);return}const o=new IntersectionObserver(([l])=>s(l.isIntersecting),{threshold:t,rootMargin:n});o.observe(c),e.current=o},[t,n]);return r.useEffect(()=>()=>{e.current&&(e.current.disconnect(),e.current=null)},[]),{targetRef:f,isIntersecting:i}}export{b as u}; diff --git a/assets/useMutation-UWxBeqtn.js b/assets/useMutation-BYtVrkc7.js similarity index 80% rename from assets/useMutation-UWxBeqtn.js rename to assets/useMutation-BYtVrkc7.js index dc33eb731820291f872c87466f534a32fdb51057..932db99f14e2244f98cf7eb8c72267e0397b0b53 100644 --- a/assets/useMutation-UWxBeqtn.js +++ b/assets/useMutation-BYtVrkc7.js @@ -1 +1 @@ -var R=i=>{throw TypeError(i)};var E=(i,t,s)=>t.has(i)||R("Cannot "+s);var e=(i,t,s)=>(E(i,t,"read from private field"),s?s.call(i):t.get(i)),b=(i,t,s)=>t.has(i)?R("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),p=(i,t,s,r)=>(E(i,t,"write to private field"),r?r.call(i,s):t.set(i,s),s),y=(i,t,s)=>(E(i,t,"access private method"),s);import{aE as U,aG as k,aS as j,aT as q,aF as P,i as L,d as v,aO as T,aU as A}from"./index-DyXq7-Tg.js";var a,c,o,h,n,C,S,w,D=(w=class extends U{constructor(t,s){super();b(this,n);b(this,a);b(this,c);b(this,o);b(this,h);p(this,a,t),this.setOptions(s),this.bindMethods(),y(this,n,C).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const s=this.options;this.options=e(this,a).defaultMutationOptions(t),k(this.options,s)||e(this,a).getMutationCache().notify({type:"observerOptionsUpdated",mutation:e(this,o),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&j(s.mutationKey)!==j(this.options.mutationKey)?this.reset():((r=e(this,o))==null?void 0:r.state.status)==="pending"&&e(this,o).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=e(this,o))==null||t.removeObserver(this)}onMutationUpdate(t){y(this,n,C).call(this),y(this,n,S).call(this,t)}getCurrentResult(){return e(this,c)}reset(){var t;(t=e(this,o))==null||t.removeObserver(this),p(this,o,void 0),y(this,n,C).call(this),y(this,n,S).call(this)}mutate(t,s){var r;return p(this,h,s),(r=e(this,o))==null||r.removeObserver(this),p(this,o,e(this,a).getMutationCache().build(e(this,a),this.options)),e(this,o).addObserver(this),e(this,o).execute(t)}},a=new WeakMap,c=new WeakMap,o=new WeakMap,h=new WeakMap,n=new WeakSet,C=function(){var s;const t=((s=e(this,o))==null?void 0:s.state)??q();p(this,c,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},S=function(t){P.batch(()=>{var s,r,u,f,d,O,x,K;if(e(this,h)&&this.hasListeners()){const m=e(this,c).variables,M=e(this,c).context,g={client:e(this,a),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(r=(s=e(this,h)).onSuccess)==null||r.call(s,t.data,m,M,g)}catch(l){Promise.reject(l)}try{(f=(u=e(this,h)).onSettled)==null||f.call(u,t.data,null,m,M,g)}catch(l){Promise.reject(l)}}else if((t==null?void 0:t.type)==="error"){try{(O=(d=e(this,h)).onError)==null||O.call(d,t.error,m,M,g)}catch(l){Promise.reject(l)}try{(K=(x=e(this,h)).onSettled)==null||K.call(x,void 0,t.error,m,M,g)}catch(l){Promise.reject(l)}}}this.listeners.forEach(m=>{m(e(this,c))})})},w);function I(i,t){const s=L(),[r]=v.useState(()=>new D(s,i));v.useEffect(()=>{r.setOptions(i)},[r,i]);const u=v.useSyncExternalStore(v.useCallback(d=>r.subscribe(P.batchCalls(d)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),f=v.useCallback((d,O)=>{r.mutate(d,O).catch(T)},[r]);if(u.error&&A(r.options.throwOnError,[u.error]))throw u.error;return{...u,mutate:f,mutateAsync:u.mutate}}export{I as u}; +var P=i=>{throw TypeError(i)};var E=(i,t,s)=>t.has(i)||P("Cannot "+s);var e=(i,t,s)=>(E(i,t,"read from private field"),s?s.call(i):t.get(i)),b=(i,t,s)=>t.has(i)?P("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),p=(i,t,s,r)=>(E(i,t,"write to private field"),r?r.call(i,s):t.set(i,s),s),y=(i,t,s)=>(E(i,t,"access private method"),s);import{aF as U,aH as k,aT as R,aU as q,aG as w,i as L,d as v,aP as T,aV as A}from"./index-CjdUkE4w.js";var a,c,o,h,n,C,S,j,D=(j=class extends U{constructor(t,s){super();b(this,n);b(this,a);b(this,c);b(this,o);b(this,h);p(this,a,t),this.setOptions(s),this.bindMethods(),y(this,n,C).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const s=this.options;this.options=e(this,a).defaultMutationOptions(t),k(this.options,s)||e(this,a).getMutationCache().notify({type:"observerOptionsUpdated",mutation:e(this,o),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&R(s.mutationKey)!==R(this.options.mutationKey)?this.reset():((r=e(this,o))==null?void 0:r.state.status)==="pending"&&e(this,o).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=e(this,o))==null||t.removeObserver(this)}onMutationUpdate(t){y(this,n,C).call(this),y(this,n,S).call(this,t)}getCurrentResult(){return e(this,c)}reset(){var t;(t=e(this,o))==null||t.removeObserver(this),p(this,o,void 0),y(this,n,C).call(this),y(this,n,S).call(this)}mutate(t,s){var r;return p(this,h,s),(r=e(this,o))==null||r.removeObserver(this),p(this,o,e(this,a).getMutationCache().build(e(this,a),this.options)),e(this,o).addObserver(this),e(this,o).execute(t)}},a=new WeakMap,c=new WeakMap,o=new WeakMap,h=new WeakMap,n=new WeakSet,C=function(){var s;const t=((s=e(this,o))==null?void 0:s.state)??q();p(this,c,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},S=function(t){w.batch(()=>{var s,r,u,f,d,O,x,K;if(e(this,h)&&this.hasListeners()){const m=e(this,c).variables,M=e(this,c).context,g={client:e(this,a),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(r=(s=e(this,h)).onSuccess)==null||r.call(s,t.data,m,M,g)}catch(l){Promise.reject(l)}try{(f=(u=e(this,h)).onSettled)==null||f.call(u,t.data,null,m,M,g)}catch(l){Promise.reject(l)}}else if((t==null?void 0:t.type)==="error"){try{(O=(d=e(this,h)).onError)==null||O.call(d,t.error,m,M,g)}catch(l){Promise.reject(l)}try{(K=(x=e(this,h)).onSettled)==null||K.call(x,void 0,t.error,m,M,g)}catch(l){Promise.reject(l)}}}this.listeners.forEach(m=>{m(e(this,c))})})},j);function H(i,t){const s=L(),[r]=v.useState(()=>new D(s,i));v.useEffect(()=>{r.setOptions(i)},[r,i]);const u=v.useSyncExternalStore(v.useCallback(d=>r.subscribe(w.batchCalls(d)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),f=v.useCallback((d,O)=>{r.mutate(d,O).catch(T)},[r]);if(u.error&&A(r.options.throwOnError,[u.error]))throw u.error;return{...u,mutate:f,mutateAsync:u.mutate}}export{H as u}; diff --git a/assets/usePapers-B0s20UcU.js b/assets/usePapers-BZThqZCx.js similarity index 63% rename from assets/usePapers-B0s20UcU.js rename to assets/usePapers-BZThqZCx.js index ad635289ae7e368a4345c2f3b38d38fd684082e0..46f829de665f24e94825d2bafb4182590b822768 100644 --- a/assets/usePapers-B0s20UcU.js +++ b/assets/usePapers-BZThqZCx.js @@ -1 +1 @@ -import{b as s,T as u,p as i}from"./index-DyXq7-Tg.js";import{u as m}from"./useInfiniteQuery-BYh2zN-T.js";import{p as o}from"./papers-Dh3ljlL0.js";function g(e,t=!0){return s({queryKey:i.detail(e),queryFn:()=>o.get(e),enabled:t&&!!e,staleTime:u})}function y(e,t,{enabled:n=!0,initialPage:p=1}={}){return m({queryKey:e,queryFn:({pageParam:a})=>t(a),initialPageParam:p,getNextPageParam:a=>a.next_page??void 0,enabled:n,staleTime:5*60*1e3,placeholderData:(a,r)=>(r==null?void 0:r.queryKey[0])===e[0]?a:void 0})}export{g as a,y as u}; +import{b as s,T as u,p as i}from"./index-CjdUkE4w.js";import{u as m}from"./useInfiniteQuery-DeZTTVbI.js";import{p as o}from"./papers-DgZwjF3K.js";function g(e,t=!0){return s({queryKey:i.detail(e),queryFn:()=>o.get(e),enabled:t&&!!e,staleTime:u})}function y(e,t,{enabled:n=!0,initialPage:p=1}={}){return m({queryKey:e,queryFn:({pageParam:a})=>t(a),initialPageParam:p,getNextPageParam:a=>a.next_page??void 0,enabled:n,staleTime:5*60*1e3,placeholderData:(a,r)=>(r==null?void 0:r.queryKey[0])===e[0]?a:void 0})}export{g as a,y as u}; diff --git a/index.html b/index.html index ea400cffac6acd18ca32de0db590ae295ee8b982..4b25b7827f39e9bc621dab76e504cc95ca51ac5e 100644 --- a/index.html +++ b/index.html @@ -72,7 +72,7 @@ plausible.init(); })(); - +